query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Multiplies any two integers together that the user inputs.
def multiply(number_one, number_two) number_one * number_two end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiply(a, b)\n\treturn a.to_i * b.to_i\nend", "def multiply_two_numbers( x, y )\n x * y\nend", "def multiply(int1, int2)\n int1 * int2\nend", "def multiply(int1, int2)\r\n int1 * int2\r\nend", "def multiply(a,b)\n a.to_i * b.to_i\nend", "def multiply(first_number, second_number)\n first_number * second_number\nend", "def multiply(first_num, second_num)\n first_num * second_num\nend", "def multiply(n1, n2)\r\n n1.to_i * n2.to_i\r\nend", "def mult_numbers(a,b)\n\ta*b\nend", "def multiply(first_parameter, second_parameter)\n (first_parameter * second_parameter).to_i\n end", "def multiply(number1, number2)\n number1 * number2\n end", "def multiply(num1, num2)\n num1 * num2\n end", "def multiply(first_number, second_number)\n return first_number * second_number\nend", "def multiply(first_number, second_number)\n return first_number * second_number\nend", "def multiplication (first_number, second_number)\nfirst_number * second_number\nend", "def multiplication\n\tputs \"which numbers would you like to multiply\"\n\tmult_number_1 = gets.chomp\n\tmult_number_2 = gets.chomp\n\tputs mult_number_1.to_f * mult_number_2.to_f\nend", "def multiply(first_number , second_number)\n return first_number * second_number\nend", "def Multiplication(a,b)\n f = a.to_i * b.to_i\n puts \"Multiplication of both number is: #{f}\"\n end", "def multiply(num_one, num_two)\n num_one * num_two\nend", "def multiplies (*args)\n multi=1\n args.each do |item|\n multi *=item\n end\n multi\nend", "def multiply(num_one, num_two)\n num_one * num_two\nend", "def multiply(input_number)\n $number *= input_number\n return $number\nend", "def multiply(num1, num2)\n\tnum1 * num2\nend", "def multiply(num1, num2)\n\tnum1 * num2\nend", "def multiply(num1,num2)\n\tnum1 * num2\nend", "def multiply(num_a, num_b)\n num_a * num_b\nend", "def multiply(num_a, num_b)\n num_a * num_b\nend", "def multiplication (a,b)\n f = a.to_i * b.to_i\n puts \"Multiplication is: #{f}\"\n end", "def Multiplicacion\n print \"Ingrese El numero 1: \"\n numero1 = gets.chomp.to_f\n print \"Ingrese El numeor 2: \"\n numero2 = gets.chomp.to_f\n\n puts \"\\nMultiplicacion: #{numero1 * numero2}\"\n end", "def multiply(*numbers)\n numbers.reduce(1, :*)\n end", "def multiple(num1,num2)\n\tnum1 * num2\nend", "def multiply(first_number, second_number)\n first_number.to_f * second_number.to_f\nend", "def multiply(first_number, second_number)\n first_number.to_f * second_number.to_f\nend", "def multiply(a, b)\r\n a * b\r\n end", "def multiply(num_1, num_2)\n num_1 * num_2\nend", "def multiply(num_1, num_2)\n num_1 * num_2\nend", "def multiply(num1, num2)\n\treturn num1 * num2\nend", "def multiplier(num1, num2)\nnum1 * num2\nend", "def multiplier(num1, num2)\nnum1 * num2\nend", "def multiply(number_1, number_2)\n number_1 * number_2\nend", "def multiply(number_1, number_2)\n number_1 * number_2\nend", "def multiply(num_1, num_2)\n num_1*num_2\nend", "def multiply(num1, num2)\n\tnew_value = num1 * num2\n\tnew_value\nend", "def multiplier(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n\treturn num1*num2\nend", "def multiply(num1,num2)\n num1 * num2\nend", "def multiply(x, y)\n return x * y if x.is_a?(Numeric) && y.is_a?(Numeric)\n fail ArgumentError, 'Arguments must be a number'\nend", "def multiplication(num, xtimes)\n\tnew_num = 0\n\txtimes.times do\n\t\tnew_num += num\n\tend\n\tnew_num\nend", "def multiply(number1, number2)\n number1 * number2\nend", "def multiply(number1, number2)\n number1 * number2\nend", "def multiply(number1, number2)\n number1 * number2\nend", "def multiply(number1, number2)\n number1 * number2\nend", "def multiply(first, second)\n first * second\nend", "def multiply(n1, n2)\n n1 * n2\nend", "def multiply(*input)\n\t\tinput.flatten.inject(:*)\n\tend", "def multiply(num1,num2)\n num1 * num2 \nend", "def multiply(n1, n2)\n return n1*n2\n end", "def multiply(nums)\r\n nums.reduce(:*)\r\nend", "def multiplicationm(num_1,num_2)\n return num_1 * num_2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(nb1,nb2)\n\treturn nb1*nb2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend", "def multiply(num1, num2)\n num1 * num2\nend" ]
[ "0.74555683", "0.74377584", "0.7431135", "0.7411989", "0.7383591", "0.7351849", "0.73339695", "0.73285896", "0.73062354", "0.7274972", "0.72709954", "0.72544163", "0.7251699", "0.7251699", "0.7244787", "0.72156566", "0.7213728", "0.7189992", "0.7152127", "0.7117049", "0.7107315", "0.7107028", "0.7096835", "0.7096835", "0.70883495", "0.70878935", "0.70878935", "0.7087516", "0.70736045", "0.70589256", "0.7056204", "0.70520973", "0.7046032", "0.7042888", "0.7031668", "0.7031668", "0.70198494", "0.70079976", "0.70079976", "0.6999179", "0.6999179", "0.6978965", "0.6973278", "0.69540536", "0.69339585", "0.6919044", "0.69181496", "0.691792", "0.6916463", "0.6916463", "0.6916463", "0.6916463", "0.6915205", "0.6911833", "0.69050235", "0.68890536", "0.6885011", "0.6884826", "0.6883395", "0.6882247", "0.6881048", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104", "0.688104" ]
0.7031506
36
Divides any two integers that the user inputs.
def divide(number_one, number_two) number_one / number_two end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def divide_numbers x, y\n x.fdiv(y)\nend", "def Division\n print \"Ingrese El numero 1: \"\n numero1 = gets.chomp.to_f\n print \"Ingrese El numeor 2: \"\n numero2 = gets.chomp.to_f\n\n if numero2 == 0\n puts \"\\nNo es posible dividir entre 0\"\n else\n puts \"\\nDivision: #{numero1 / numero2}\"\n end\n end", "def division\n\tputs \"which numbers would you like to divide\"\n\tdiv_number1 = gets.chomp.to_f\n\tdiv_number2 = gets.chomp.to_f\n\tif div_number2.to_f == 0\n\t\tputs \"That is not possible, you failed fourth grade math.\"\t\t\n\telse\n\t\tputs div_number1.to_f / div_number2.to_f\n\tend\nend", "def division (first_number, second_number)\nfirst_number / second_number\nend", "def divide(first_number, second_number)\n return first_number / second_number\n end", "def divide(first_number, second_number)\n first_number / second_number\nend", "def divide (a,b)\n f = a.to_i / b.to_i\n puts \"Division of both number is: #{f}\"\n end", "def divide(first_number, second_number)\n return first_number / second_number\nend", "def divide(dividend:, divisor:)\n dividend / divisor\nend", "def divide (a,b)\n f = a.to_i / b.to_i\n puts \"Division is: #{f}\"\n end", "def divide(num1, num2)\n num2.to_f / num1.to_f;\nend", "def division num1, num2\n total = num1.to_i / num2.to_i\n puts \"--> The total is... #{total}\"\nend", "def divide(num_one, num_two)\n if num_two == 0\n until num_two != 0\n puts \"You can't divide by zero. Enter the second number again: \"\n num_two = gets.chomp.to_i\n end\n end\n return num_one / num_two\nend", "def division(input_number1, input_number2)\n\tquotient = input_number1 / input_number2\n\tputs \"The quotient of #{input_number1} and #{input_number2}th is #{quotient}.\"\n\tputs \"Thank you for using the calculator. Goodbye!\"\nend", "def divide(num1, num2)\n return num1 / num2\nend", "def divideme(first_number,second_number) # divides the numbers\r\n if second_number.to_i == 0\r\n puts \"Sorry cannot divide by zero\"\r\n else\r\n if first_number.to_i % second_number.to_i == 0\r\n puts (\"#{first_number} / #{second_number} is :\" + (first_number.to_i / second_number.to_i).to_s)\r\n else\r\n puts (\"#{first_number} / #{second_number} is :\" + (first_number.to_f / second_number.to_f).to_s)\r\n end\r\n end\r\nend", "def div(x, y)\n x / y\nend", "def divide(number_1, number_2)\n return number_1 / number_2\nend", "def divide(number_1, number_2)\n return number_1 / number_2\nend", "def divide(number_1, number_2)\n return number_1 / number_2\nend", "def divide(a,b)\n raise Exception.new(\"Undefined. Divisor is 0\") if b == 0\n sign = 1\n result = -1\n\n # Handle corner cases\n if a < 0\n a *= -1\n sign *= -1\n end\n\n if b < 0\n b *= -1\n sign *= -1\n end\n\n while a >= 0\n a -= b\n result += 1\n end\n result * sign\nend", "def accurate_division(int, int_two)\n int = int.to_f\n int_two = int_two\n q = int / int_two\n return q.round(3)\nend", "def divide(first_parameter, second_parameter)\n (first_parameter / second_parameter).to_f\n end", "def div_stringed(num1, num2)\r\n\r\nend", "def divisionm(num_1,num_2)\n return num_1 / num_2\nend", "def divide(x, y)\n if y == 0\n return \"Psst. You can't divide by zero. Please try again.\"\n elsif x.is_a?(Integer) && y.is_a?(Integer) && x % y != 0\n return x.to_f / y\n else\n return x / y\n end\nend", "def div_operation()\n print_message \"Write number and press ENTER to divide more or press 'r' to show result\"\n result = 0\n div = gets.chomp\n if div != 'r'\n result = div.to_f\n end\n begin\n begin\n div = gets.chomp\n if div != 'r'\n result /= div.to_f\n end\n rescue StandardError => e\n print_error_message \"Invalid number. Ending Division operation.\\n#{e.message}\"\n div = 'r'\n end\n end while div.downcase != 'r'\n print_message \"Result of dividing: #{result.to_s}\"\n end", "def divide(x,y)\n x / y\n end", "def divideThem(numOne, numTwo)\n numOne / numTwo\nend", "def divide(input_number)\n $number /= input_number\n return $number\nend", "def divide(n1, n2)\n divide = n1 / n2\n return divide\nend", "def divisione(a, b)\n puts \"DIVIDENDO #{a} / #{b}\"\n a / b\nend", "def dec_remainder_of_two_integers(i_dividend, i_divisor)\n # your code goes here\n dec_remainder_of_two_floats(i_dividend.to_f, i_divisor.to_f)\nend", "def divide(a, b)\n puts \"DIVIDING #{a} / #{b}\"\n a / b\nend", "def dec_remainder_of_two_integers(i_dividend, i_divisor)\r\n # your code goes here\r\n f_dividend = i_dividend.to_f\r\n f_divisor = i_divisor.to_f\r\n dec_remainder_of_two_floats(f_dividend, f_divisor)\r\nend", "def divide(number1, number2)\n number2.zero? ? 'Erro! Divisão por zero não é possível' : number1 / number2\n end", "def format_userinput_for_division(operator, valid_operators, num_1, num_2, user_input)\n if num_1 =~ /^(\\d)+$/ && num_2 =~ /^(\\d)+$/\n unless divide_by_zero(num_2.to_i)\n exit\n end\n modulo = (num_1.to_i % num_2.to_i)\n if modulo != 0\n result = (num_1.to_f / num_2.to_f)\n return result\n else\n format_userinput_not_including_division(valid_operators, num_1, num_2, user_input)\n result = division(user_input[:num_1], user_input[:num_2])\n return result\n end\n else\n format_userinput_not_including_division(valid_operators, num_1, num_2, user_input)\n result = division(user_input[:num_1], user_input[:num_2])\n return result\n end\nend", "def divide\n\n\t\t# make sure when can perform the operation\n\t\tempty?\n\n\t\t# pop the last 2 numbers and store but need to be converted to a float\n\t\tnum_1 = @calculator.pop.to_f\n\t\tnum_2 = @calculator.pop.to_f\n\n\t\t# division is performed and pushed to @calc\n\t\t@calculator << num_2 / num_1\n\n\tend", "def divide(a,b)\n a/b\nend", "def dec_remainder_of_two_integers(i_dividend, i_divisor)\n # your code goes here\n return dec_remainder_of_two_floats(i_dividend.to_f, i_divisor.to_f)\nend", "def divide(numbers)\n numbers.inject { |sum, n| sum / n }\n end", "def div_by\n begin\n puts \"Gimme a number\"\n x = gets.chomp.to_i\n puts \"and what do you want me to divide by?\"\n div = gets.chomp.to_i\n\n puts x / div\n\n rescue # catches the error!\n puts \"oops, that failed!\"\n end\nend", "def divide(num1, num2)\n p num1/num2\nend", "def divide_integers(dividend, divisor)\n return 1 if dividend == divisor\n \n quotient = 0\n counter = divisor.abs\n until dividend.abs < counter\n quotient += 1\n counter += divisor.abs\n end\n\n if dividend > 0 && divisor > 0 || dividend < 0 && divisor < 0\n quotient\n else\n quotient * -1\n end\nend", "def divide(one,two)\n\treturn \"I don't think so\" if two ==0\n\tone / two\nend", "def divide(num1, num2)\n\tresults = \"\"\n\tif num2 == 0\n\t\t\"False\"\n\telse\n\tresults = num1/num2\nend\n\n\t\t\t\n\t# if number == 0\n\t# \treturn \"Cant't divide a number by 0\"\n\t# else numbers.inject do |divedend, number|\n\t# quo = (divedend /= number).round(2)\n\n\n\t# end\n\n\t# if number.zero?\n # \treturn \"Cannot divide by 0!\"\n\t# else\n # \tquo\n\t# end\n\n\t\n\t# if number != 0 \n\t\t# \treturn quo\n\t# else \n\t\t# \treturn \"error\"\n\t# end\n\n\t# end\n\nend", "def divide(a, b)\n divide = a / b\n return divide\nend", "def Division(num1,num2)\n lowest = num1 <= num2 ? num1 : num2\n\n while lowest > 0\n return lowest if num1 % lowest == 0 && num2 % lowest == 0\n lowest -= 1\n end\nend", "def div(input_a, input_b, name: nil)\n input_a, input_b = check_data_types(input_a, input_b)\n _op(:div, input_a, input_b, name: name)\n end", "def division(value1, value2)\n result = value1 / value2\n puts \"The sum of #{ value1 } / #{ value2 } = #{ result }\"\nend", "def dec_remainder_of_two_floats(f_dividend, f_divisor)\n # your code goes here\n puts (f_divisor/f_dividend).round(1)\nend", "def divide(dividend, divisor)\n negative_sign = (dividend < 0 && divisor >= 0) || (dividend >= 0 && divisor < 0)\n\n remaining = dividend.abs\n abs_divisor = divisor.abs\n quotient = 0\n while remaining >= abs_divisor\n remaining -= abs_divisor\n quotient += 1\n end\n\n negative_sign ? \"-#{quotient.to_s}\".to_i : quotient\nend", "def divide(dividend, divisor)\n # new_dividend = dividend > 0 : -divident : dividend\n # new_divisor = divisor > 0 : -divisor : divisor\n\n new_dividend = dividend\n new_divisor = divisor\n\n quotient = 0\n while new_dividend >= new_divisor\n multiplier = 0\n while (new_divisor << multiplier + 1) < new_dividend\n multiplier += 1\n end\n\n quotient += (1 << multiplier)\n new_dividend -= new_divisor << multiplier\n end\n\n quotient\nend", "def division(first_number, second_number, third_number)\n# Conditional that removes divide by zero error\n\t\tif second_number == 0\n\tresult = \"You can't divide by zero\"\nelsif third_number == 0\n\tresult = \"You can't divide by zero\"\nelse\n\t\t\t\tif (first_number == \"\") || (second_number == \"\") || (third_number == \"\")\n\tnil\nelsif (first_number == []) || (second_number == []) || (third_number == [])\n\tnil\nelse\n\tresult = first_number / second_number / third_number\nend\nend\n\tresult\n\nend", "def divide(dividend, divisor)\n\n denom = divisor\n current = 0\n\n return 0 if denom > dividend\n return 1 if denom == dividend\n\n # 5 45\n while denom <= dividend do \n \tdenom += divisor\n \tcurrent += 1 \n end\n remainder = dividend - (denom - divisor)\n current\nend", "def Division(num1, num2)\n\t# start with the lowest number and then iterate one down from there until zero, and return the first number that\n\t# divides into both\n\n\tif num1 < num2\n\t\tgreatest_common_factor = num1\n\telse\n\t\tgreatest_common_factor = num2\n\tend\n\n\twhile greatest_common_factor > 0\n\t\tif num1 % greatest_common_factor == 0 && num2 % greatest_common_factor == 0\n\t\t\treturn greatest_common_factor\n\t\tend\n\t\tgreatest_common_factor -= 1\n\tend\nend", "def self_dividing_numbers(left, right)\n (left..right).select{|x| x.digits.all?{|y| y!=0 && x%y == 0}}\nend", "def divide\n\t\tif @operands.size>= 2\n\t\t\tnew_n = (@operands[-2].to_f / @operands[-1].to_f)\n\t\t\[email protected](2)\n\t\t\[email protected] new_n\n\t\telse\n\t\t\traise \"calculator is empty\"\n\t\tend\n\tend", "def divide_x_by_y (x, y)\nz = x/y\nend", "def divide(numerator, denominator)\n puts \"#{numerator} / #{denominator} = #{numerator / denominator}\\n\"\nend", "def div(p0) end", "def divide(a, b)\n puts \"DIVIDING #{a} / #{b}\"\n return a / b\n a + b # This is ignored as the output due to the return\nend", "def dec_remainder_of_two_floats(f_dividend, f_divisor)\r\n # your code goes here\r\n f_dividend / f_divisor - (f_dividend / f_divisor).to_i\r\nend", "def floor_div(input_a, input_b, name: nil)\n check_data_types(input_a, input_b)\n _op(:floor_div, input_a, input_b, name: name)\n end", "def div(other)\n divmod(other).first\n end", "def divide(num1, num2)\n if(num2 == 0)\n raise \"can not divide by 0 in this app\"\n end\n num1/num2\nend", "def div(arg0)\n end", "def divide(other)\n Rubinius.primitive :float_div\n redo_coerced :/, other\n end", "def divides?(a,b)\n return b%a == 0\nend", "def divide(dividend, divisor)\r\n ((dividend < 0 && divisor >= 0) || (dividend >= 0 && divisor < 0)) ? negative = true : negative = false\r\n dividend = dividend.abs\r\n divisor = divisor.abs\r\n count = 0\r\n until dividend < divisor\r\n dividend -= divisor\r\n count += 1\r\n return negative ? 0 - (2**31) : 2**31 - 1 if count > 9999999\r\n end\r\n negative ? 0 - count : count\r\nend", "def split_div(str)\n str =~ /(\\d+)\\/(\\d+)/\n if $1 and $2\n result = $1.to_f / $2.to_f\n result.to_s.gsub(/\\.(\\d)\\d*/) { |s| \".\"+$1 }\n else\n str\n end\n end", "def divide\n match '/'\n factor\n emit_ln 'MOVE (SP)+,D1'\n emit_ln 'DIVS D1,D0'\nend", "def Division(num1,num2)\n factors = []\n (1..10**3).each {|idx| factors << idx if (num1 % idx == 0 && num2 % idx == 0)}\n factors.max\nend", "def reduce\n if denominator.to_i == 0\n puts \"ERROR\"\n else\n min = [numerator,denominator].min\n min.downto(2) do |x|\n if numerator%x == 0 && denominator%x == 0\n n = numerator/x\n d = denominator/x\n puts n.to_s + \"/\" + d.to_s\n break\n end\n end\n end\n end", "def divide\n C.curry.(->(x, y) { x / y })\n end", "def div(a, b) #=> funkcja wykonujaca dzielenie\n\n\tif b == 0\n\n\t\tputs \"Nie dzielimy przez 0!\"\n\t\treturn\n\n\telse\n\n\t\tputs \"Wynik: #{a/b}\"\n\n\tend\n\n\tputs \"Dzialanie wykonane prawidlowo\" #=> ta informacja nie pojawi sie w przypadku dzielenia przez 0\n\nend", "def divide(*args, &block)\n yield if params[:divide].blank? || (params[:divide].present? && args.include?(params[:divide].to_sym))\n end", "def divide(numerator, denominator)\n $LOG.debug(\"Numerator: #{numerator}, denominator #{denominator}\")\n begin\n result = numerator / denominator\n rescue Exception => e\n $LOG.error \"Error in division!: #{e}\"\n\tresult = nil\n end\n return result\n end", "def division(n, d)\n n, d = reducir(n, d)\n \n @n *= d\n @d *= n\n \n reducir(@n, @d)\n return @n, @d\n end", "def div_by\n begin\n puts \"Gimme a number\"\n x = gets.chomp.to_i\n puts \"and what do you want me to divide by?\"\n div = gets.chomp.to_i\n\n puts x / div\n\n rescue\n puts \"oops, that didn't make sense... try again\"\n retry\n end\nend", "def pre_divide; end", "def dec_remainder_two_ints(int1, int2)\n f_dividend = int1.to_f\n f_divisor = int2.to_f\n return dec_remainder_two_floats(f_dividend, f_divisor)\nend", "def /(b)\n b = b.symdescfy\n case b\n when Number\n __div_number(b)\n when Infinity\n ZERO\n else\n super\n end\n end", "def divide(number, divisor)\n\tbegin\n\t\tanswer = number/divisor\n\trescue ZeroDivisionError => e\n\t\tputs e.message\n\tend\nend", "def DivisionStringified(num1,num2)\n result = num1.to_f / num2.to_f\n result.round.to_s.chars.map(&:to_i).size <= 3 ? result.round : result.round(3)\nend", "def Divide(val)\n self.value /= val\n end", "def divide(x, y)\n if x == 0 || y == 0\n return \"We dont do math on zeros\"\n end\n\n x / y\nend", "def rounddiv(a, b)\n c = a / b\n remainder = a - b * c\n if (remainder * 2).abs < b.abs\n c\n else\n c + 1\n end\nend", "def format_userinput_not_including_division(valid_operators, num_1, num_2, user_input)\n if num_1 =~ /^(\\d)*\\.(\\d)+$/\n num_1 = num_1.to_f\n user_input[:num_1] = num_1\n elsif num_1 =~ /^(\\d)+$/\n num_1 = num_1.to_i\n user_input[:num_1] = num_1\n else\n puts \"Whoa nelly! It looks like you entered something other than a number.\"\n exit\n end\n if num_2 =~ /^(\\d)*\\.(\\d)+$/\n num_2 = num_2.to_f\n user_input[:num_2] = num_2\n elsif num_2 =~ /^(\\d)+$/\n num_2 = num_2.to_i\n user_input[:num_2] = num_2\n else\n puts \"Whoa nelly! It looks like you entered something other than a number.\"\n exit\n end\nend", "def divides_evenly(a, b)\n\ta % b == 0 ? true : false\nend", "def gc_divisor(ints:[]) \n arr = []\n arr2 = []\n for i in ints \n arr << i \n end\n \n arr.each do |num|\n for i in (1..num)\n if (num % i == 0)\n arr2 << i\n end\n end\n end\n # positive \n #divides numbers without a remainder\n #largetst one of such number\n arr2.each\nend", "def divide(number, divisor)\n begin\n answer = number / divisor\n rescue ZeroDivisionError => e\n puts e.message\n end\nend", "def divide(number, divisor)\n begin\n answer = number / divisor\n rescue ZeroDivisionError => e\n puts e.message\n end\nend", "def divide(number, divisor)\n begin\n answer = number / divisor\n rescue ZeroDivisionError => e\n puts e.message\n end\nend", "def test_13_multiple_integers_and_floats\r\n\r\n results = divide(284.182, 3.2, 19, 0.01928, 39.2944)\r\n\r\n assert_equal(6.16958, results)\r\n\r\n end", "def /(other)\n to_i / other.to_i\n end", "def multiples num1, num2, divisor\n x = []\n (num1...num2).each do |i|\n if is_divisible i, divisor\n x << i\n end\n end\n x\n end", "def divide(interpreter)\n stack = interpreter.stack\n a = stack.pop\n b = stack.pop\n stack.push(b/a) if a && b\n end", "def self_dividing_numbers(left, right)\n result = []\n i = left\n while i <= right #while i is smaller than right bound\n str = i.to_s #converts all int to string\n j = 0\n c = 0\n while j < str.length\n if str[j].to_i == 0\n break\n elsif i % str[j].to_i == 0\n c += 1\n end\n j+= 1\n end\n if c == str.length\n result.push(i)\n end\n i += 1\n end\n return result\nend", "def secure_div(divident, divisor)\n return nil if divisor == 0\n divident.to_f/divisor\n end" ]
[ "0.7488782", "0.7452657", "0.74347067", "0.7417389", "0.74109745", "0.735583", "0.7311166", "0.7270216", "0.72184664", "0.72084063", "0.7194135", "0.7173144", "0.70332575", "0.700008", "0.6982546", "0.6971411", "0.6956797", "0.69479716", "0.69479716", "0.69479716", "0.69411945", "0.69218296", "0.6918868", "0.69050914", "0.69012225", "0.6861159", "0.68449366", "0.68297386", "0.6823795", "0.68228936", "0.67950904", "0.6722998", "0.6661109", "0.6655586", "0.6617895", "0.66071326", "0.65986", "0.6577065", "0.65635175", "0.6552278", "0.6510203", "0.6501588", "0.64978486", "0.64888453", "0.6488493", "0.6481383", "0.64646596", "0.64620405", "0.6395282", "0.6388684", "0.6332234", "0.630057", "0.6298758", "0.6277395", "0.6266363", "0.62545884", "0.6248382", "0.62445426", "0.6239384", "0.6237813", "0.62266314", "0.62226075", "0.62107", "0.62101984", "0.6184117", "0.6174665", "0.61648405", "0.6162186", "0.6145694", "0.6138143", "0.6131946", "0.6131133", "0.6130064", "0.61135674", "0.6097415", "0.60861474", "0.6081149", "0.6043437", "0.6038726", "0.6001752", "0.59877163", "0.59804523", "0.5980415", "0.5975616", "0.5968696", "0.5963259", "0.59629583", "0.59440917", "0.5940357", "0.5930299", "0.59177625", "0.58885056", "0.58885056", "0.58885056", "0.5879251", "0.5869355", "0.58689207", "0.5865415", "0.5861717", "0.5856478" ]
0.6882155
25
Writes the assembly code that is the translation of the given arithmetic command PARAMETER command(string) RETURN void
def writeArithmetic(command) assembly_builder = [] # Add if command == 'add' assembly_builder.push( '@SP',# A=0 'AM=M-1',# A=RAM[0]=M[0]-1 'D=M',# D=RAM[257] 'A=A-1',# A=257-1=256 'M=M+D'# RAM[256]=RAM[256]+D ) elsif command == 'sub' assembly_builder.push( '@SP', 'AM=M-1', 'D=M', 'A=A-1', 'M=M-D' ) # y = -y elsif command == 'neg' assembly_builder.push( '@SP', 'A=M-1', 'M=-M', ) # x == y ? -1 : 0 elsif command == 'eq' assembly_builder.push( '@SP', 'AM=M-1', # M = 257 'D=M', # D = 4 'A=A-1', # @256 'D=M-D', # D = 5 - 4 = 1 'M=-1', # M[256] = -1 '@EQEND', # if D == 0 → EQEND 'D;JEQ', # '@SP', 'A=M-1', 'M=0', '(EQEND)' ) # x > y ? -1 : 0 elsif command == 'gt' assembly_builder.push( '@SP', 'AM=M-1', # M = 257 'D=M', # D = 4 'A=A-1', # @256 'D=M-D', # D = 5 - 4 = 1 'M=-1', # M[256] = -1 '@GTEND', # if D == 0 → EQEND 'D;JGT', # '@SP', 'A=M-1', 'M=0', '(GTEND)' ) # x < y ? -1 : 0 elsif command == 'lt' assembly_builder.push( '@SP', 'AM=M-1', # M = 257 'D=M', # D = 4 'A=A-1', # @256 'D=M-D', # D = 5 - 4 = 1 'M=-1', # M[256] = -1 '@LTEND', # if D == 0 → EQEND 'D;JLT', # '@SP', 'A=M-1', 'M=0', '(LTEND)' ) # x & y elsif command == 'and' assembly_builder.push( '@SP', 'AM=M-1', # M = 257 'D=M', # D = 4 'A=A-1', # @256 'M=D&M' ) # x | y elsif command == 'or' assembly_builder.push( '@SP', 'AM=M-1', # M = 257 'D=M', # D = 4 'A=A-1', # @256 'M=D|M' ) # not y elsif command == 'not' assembly_builder.push( '@SP', 'A=M-1', # M = 257 'M=!M' ) end return assembly_builder end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def writeArithmetic(command)\n\t\tif command == \"add\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M+D\\n\")\n elsif command == \"sub\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M-D\\n\") \n elsif command == \"neg\"\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=-M\\n\")\n elsif command == \"and\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M & D\\n\")\n elsif command == \"or\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M | D\\n\")\n elsif command == \"not\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M\\n\")\n @file.write(\"M=!D\")\n elsif command == \"eq\"\n label = \"negate\" + @counter.to_s\n\t\t\t@counter += 1\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"D=M-D\\n\")\n @file.write(\"@\" + label + \"\\n\")\n @file.write(\"D;JEQ\\n\")\n @file.write(\"D=1\\n\")\n @file.write(\"(\" + label + \")\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=!D\\n\")\n elsif command == \"lt\"\n glJump(\"JLT\")\n elsif command == \"gt\"\n glJump(\"JGT\")\n\t\tend\n\tend", "def writeArithmetic(command)\n\t\tif command == \"add\"\n pop()\n\t\t\[email protected](\"//writing addition\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M+D\\n\")\n elsif command == \"sub\"\n pop()\n\t\t\[email protected](\"//writting subtraction\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M-D\\n\") \n elsif command == \"neg\"\n\t\t\[email protected](\"//negating\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=-M\\n\")\n elsif command == \"and\"\n pop()\n\t\t\[email protected](\"//writing and\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M & D\\n\")\n elsif command == \"or\"\n pop()\n\t\t\[email protected](\"//writing or\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M | D\\n\")\n elsif command == \"not\"\n\t\t\[email protected](\"//writing not\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=!M\\n\")\n elsif command == \"eq\"\n label = \"negate\" + @counter.to_s\n\t\t\t@counter += 1\n pop()\n\t\t\[email protected](\"//eq\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"D=M-D\\n\")\n @file.write(\"@\" + label + \"\\n\")\n @file.write(\"D;JEQ\\n\")\n @file.write(\"D=1\\n\")\n @file.write(\"(\" + label + \")\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=!D\\n\")\n elsif command == \"lt\"\n glJump(\"JLT\")\n elsif command == \"gt\"\n glJump(\"JGT\")\n\t\tend\n\tend", "def writeArithmetic(command)\n\n if @arith_hash.has_key?(command) then\n\n File.open(@arith_hash[command],'r') do |infile|\n\terb = ERB.new(infile.read)\n\[email protected] erb.result(binding)\n\n $label_index=$label_index+1\n end\n\n else puts \"#{command} not supported. \\n\\n\"\n end\n\n end", "def run_instruction(vm, command)\n\n # declare a symbol and save it in the next available memory\n # position. The value will be stored in the position after that\n if command[0] == 'DEC'\n vm.memory[vm.memory_counter] = command[1]\n vm.memory_counter += 2\n\n elsif command[0] == 'LDA'\n index = vm.memory.index(command[1])\n vm.register_a = @converter.to_decimal(vm.memory[index + 1])\n\n elsif command[0] == 'LDB'\n index = vm.memory.index(command[1])\n vm.register_b = @converter.to_decimal(vm.memory[index + 1])\n\n # Loads the integer value into the accumulator register. The value could be negative.\n elsif command[0] == 'LDI'\n vm.register_a = command[1].to_i\n\n # store register a value at symbol (command[1])\n # if no such symbol exists, make one\n elsif command[0] == 'STR'\n index = vm.memory.index(command[1])\n vm.memory[index + 1] = @converter.to_binary(vm.register_a)\n\n # Exchanges the content registers A and B.\n elsif command[0] == 'XCH'\n temp = vm.register_a\n vm.register_a = vm.register_b\n vm.register_b = temp\n\n # Transfers control to instruction at address number in program memory\n elsif command[0] == 'JMP'\n vm.pc = command[1].to_i - 1\n\n # Transfers control to instruction at address number if the zero-result bit is set.\n elsif command[0] == 'JZS'\n vm.pc = command[1].to_i - 1 if vm.zero_bit == 1\n\n # Transfers control to instruction at address number if the overflow bit is set.\n elsif command[0] == 'JVS'\n vm.pc = command[1].to_i - 1 if vm.overflow == 1\n\n # Adds the content of registers A and B. The sum is stored\n # in A. The overflow and zero-result bits are set or cleared as needed.\n elsif command[0] == 'ADD'\n result = vm.register_a.to_i + vm.register_b.to_i\n if result > 2_147_483_647 || result < -2_147_483_648\n vm.overflow = 1\n dif = result - 2_147_483_647\n vm.register_a = dif - 2_147_483_648\n else\n vm.register_a = result\n vm.overflow = 0\n end\n vm.zero_bit = if vm.register_a.zero?\n 1\n else\n 0\n end\n elsif command[0] == 'HLT'\n vm.done = true\n end\n vm.pc += 1\n end", "def writeArithmetic(cmd,ln)\n\tcase cmd[:c]\n\twhen 'add','sub','and','or' then l = arith(cmd[:s])\n\twhen 'neg','not' then l = neginv(cmd[:s])\n\twhen 'gt','lt','eq' then l = glte(cmd[:s],ln)\n\telse return -1 end \n\treturn l\nend", "def writePushPop(command, segment, index)\n assembly_builder = []\n # Push\n if command == 'C_PUSH'\n if segment == 'constant'\n assembly_builder.push(\n \"@#{index}\",\n 'D=A',\n '@SP',\n 'A=M',\n 'M=D',\n '@SP',\n 'M=M+1'\n )\n elsif segment == 'temp'\n assembly_builder.push(\n \"@#{5 + index.to_i}\", # A = 10\n 'D=M', # D = M[10]\n '@SP', # A = 0\n 'A=M', # A = M[0] = 258\n 'M=D', # M[258] = D\n '@SP', # A = 0\n 'M=M+1' # M[0] = 258 + 1\n )\n elsif segment == 'pointer'\n assembly_builder.push(\n \"@#{3 + index.to_i}\", # A = 10\n 'D=M', # D = M[10]\n '@SP', # A = 0\n 'A=M', # A = M[0] = 258\n 'M=D', # M[258] = D\n '@SP', # A = 0\n 'M=M+1' # M[0] = 258 + 1\n )\n elsif segment == 'static'\n assembly_builder.push(\n \"@#{file_name_without_ext}.#{index}\", # A = 10\n 'D=M', # D = M[10]\n '@SP', # A = 0\n 'A=M', # A = M[0] = 258\n 'M=D', # M[258] = D\n '@SP', # A = 0\n 'M=M+1' # M[0] = 258 + 1\n )\n else\n segment_symbol = case segment\n when 'local'\n 'LCL'\n when 'argument'\n 'ARG'\n when 'this'\n 'THIS'\n when 'that'\n 'THAT'\n end\n\n assembly_builder.push(\n \"@#{index}\",\n 'D=A',\n \"@#{segment_symbol}\", # A = THAT = 4\n 'A=M',\n 'A=A+D', # A = 3010 + 5\n 'D=M', # D = M[3015]\n '@SP', # A = 0\n 'A=M', # A = M[0] = 257\n 'M=D', # M[257] = D = M[3015]\n '@SP', # A = 0\n 'M=M+1' # M[0] = 257 + 1\n )\n end\n # Pop\n elsif command == 'C_POP'\n if segment == 'temp'\n assembly_builder.push(\n '@SP', # A = 0\n 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1\n 'D=M', # D = M[257]\n \"@#{5 + index.to_i}\", # A = 5 + index\n 'M=D'\n )\n elsif segment == 'pointer'\n assembly_builder.push(\n '@SP', # A = 0\n 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1\n 'D=M', # D = M[257]\n \"@#{3 + index.to_i}\", # A = 5 + index\n 'M=D'\n )\n elsif segment == 'static'\n assembly_builder.push(\n '@SP', # A = 0\n 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1\n 'D=M', # D = M[257]\n \"@#{file_name_without_ext}.#{index}\", # A = 6 + index\n 'M=D'\n )\n else\n segment_symbol = case segment\n when 'local'\n 'LCL'\n when 'argument'\n 'ARG'\n when 'this'\n 'THIS'\n when 'that'\n 'THAT'\n end\n\n assembly_builder.push(\n # RAM[RAM[SP]] -> RAM[RAM[segment]]\n \"@#{index}\", # A = 3\n 'D=A', # D = 3\n \"@#{segment_symbol}\", # A = 1\n 'D=M+D', # D = M[1] + 3 = 300 + 3\n 'M=D', # M[1] = 303\n '@SP', # A = 0\n 'AM=M-1', # A = M[0] - 1 = 258 -1\n 'D=M', # D = M[257]\n \"@#{segment_symbol}\", # A = 1\n 'A=M', # A = M[1] = 303\n 'M=D', # M[303] = M[257]\n \"@#{index}\", # A = 3\n 'D=A', # D = 3\n \"@#{segment_symbol}\", # A = 1\n 'M=M-D' # M[1] = M[1] - 3 = 303 - 3\n )\n end\n end\n\n return assembly_builder\n end", "def execute_current_instruction\n case read_register(REGISTER_C0)\n when SUM\n write_register(REGISTER_R0, read_register(read_register(REGISTER_D0)) + read_register(read_register(REGISTER_D1)))\n when COPY\n write_register(read_register(REGISTER_D1), read_register(read_register(REGISTER_D0)))\n when WRITE\n write_register(read_register(REGISTER_D1), read_register(REGISTER_D0))\n when JUMP\n write_register(REGISTER_M0, read_register(read_register(REGISTER_D0)))\n when JUMPX\n write_register(REGISTER_M0, read_register(read_register(REGISTER_D0))) if read_register(read_register(REGISTER_D1)) == 0\n when READ_MEM\n write_register(REGISTER_M4, Memory::READ)\n write_register(REGISTER_M5, read_register(read_register(REGISTER_D0)))\n write_register(REGISTER_M6, read_register(REGISTER_D1))\n when WRITE_MEM\n write_register(REGISTER_M4, Memory::WRITE)\n write_register(REGISTER_M5, read_register(read_register(REGISTER_D0)))\n write_register(REGISTER_M6, read_register(read_register(REGISTER_D1)))\n else\n raise UnknownInstruction.new(\"Instruction '#{read_register(REGISTER_C0)}' is undefined\")\n end\n end", "def instruction name, instruction\n end", "def ADD(d,x,y) opcode \"add\", [d,x,y] end", "def convertArithmetic(op)\n case op\n\n #basic arithmetic operations\n when \"add\"\n cmds = \"//add\"+\"\\n\" + arithmeticBinary(\"+\")\n\n when \"sub\"\n cmds = \"//subtract\"+\"\\n\" +arithmeticBinary(\"-\")\n\n when \"neg\"\n cmds = \"//negate\" +\"\\n\"+arithmeticUnary(\"-\")\n\n #basic bitwise operations\n when \"and\"\n cmds = \"//and\" +\"\\n\"+arithmeticBinary(\"&\")\n\n when \"or\"\n cmds = \"//or\" +\"\\n\"+arithmeticBinary(\"|\")\n\n when \"not\"\n cmds = \"//not\" +\"\\n\"+arithmeticUnary(\"!\")\n else\n cmds = \"//not a legal command\"\n end\n\n return cmds\nend", "def rInvocationStmt\n res = rInvocation(prob(85) ? 'void' : nil)\n return '' if res.empty?\n return tab + res + ';\\n'\nend", "def processing_instruction(data)\n end", "def compile\n cmd = self.command\n#puts ' + ' + cmd\n log.debug \"Invoking the compiler\"\n rc = Platform.execute cmd\n log.debug \"Compilation complete; rc=#{rc.to_s}\"\n rc\n end", "def arithmeticBinary(op)\n str = getTopTwoFromStack + \"M=M\"+op+\"D\"+\"\\n\"\n return str+\"\\n\"\nend", "def processing_instruction!(name, attributes = nil)\n unless attributes\n self << \"<?#{name} ?>\"\n else\n self << \"<?#{name} \"\n attributes.each do |a, v|\n self << %[#{a}=\"#{v}\" ]\n end\n self << \"?>\"\n end\n end", "def process\n if command_type == :C_COMMAND\n @c = Code.new([comp, dest, jump])\n \"#{@c.translate_c}\\n\"\n else\n @c = Code.new(@current[1..-1])\n \"#{@c.translate_a}\\n\"\n end\n end", "def execute_expression\n valid_input\n to_roman(to_num(@operand_one).send(@operator, to_num(@operand_two)))\n end", "def to_bytecode\n bytecode = []\n case @op\n when 'println'\n comp_arg(@args[0], bytecode)\n bytecode.push(PRINT_OP)\n when '+'\n comp_arg(@args[0], bytecode)\n comp_arg(@args[1], bytecode)\n bytecode.push(ADD_OP)\n if @args.length > 2\n @args[[email protected]].each do |arg|\n comp_arg(arg, bytecode)\n bytecode.push(ADD_OP)\n end\n end\n when '-'\n comp_arg(@args[0], bytecode)\n comp_arg(@args[1], bytecode)\n bytecode.push(SUB_OP)\n if @args.length > 2\n @args[[email protected]].each do |arg|\n comp_arg(arg, bytecode)\n bytecode.push(SUB_OP)\n end\n end\n when '*'\n comp_arg(@args[0], bytecode)\n comp_arg(@args[1], bytecode)\n bytecode.push(MUL_OP)\n if @args.length > 2\n @args[[email protected]].each do |arg|\n comp_arg(arg, bytecode)\n bytecode.push(MUL_OP)\n end\n end\n else\n raise \"Unrecognized op '#{@op}'\"\n end\n bytecode # Returning bytecode\n end", "def run_intcode(input, output, *program)\n index = 0\n sda_base = 0\n while (program[index] % 100) != 99\n instruction = program[index]\n opcode = instruction % 100\n param1_mode = (instruction / 100) % 10\n param2_mode = (instruction / 1_000) % 10\n param3_mode = (instruction / 10_000) % 10\n\n # p [index, opcode, param1_mode, param2_mode, param3_mode, sda_base]\n\n case opcode\n when 1 # +\n sum = read_param(1, program, index, param1_mode, sda_base) + read_param(2, program, index, param2_mode, sda_base)\n write_param(3, program, index, param3_mode, sda_base, sum)\n index += 4\n when 2 # *\n prod = read_param(1, program, index, param1_mode, sda_base) * read_param(2, program, index, param2_mode, sda_base)\n write_param(3, program, index, param3_mode, sda_base, prod)\n index += 4\n when 3 # Store input\n value = input.shift\n write_param(1, program, index, param1_mode, sda_base, value)\n index += 2\n when 4 # output first parameter\n value = read_param(1, program, index, param1_mode, sda_base)\n output << value\n index += 2\n when 5 # is jump-if-true\n # if the first parameter is non-zero, it sets the instruction pointer to the value from the second parameter. Otherwise, it does nothing.\n value = read_param(1, program, index, param1_mode, sda_base)\n if value.zero?\n index += 3\n else\n index = read_param(2, program, index, param2_mode, sda_base)\n end\n when 6 # is jump-if-false\n # if the first parameter is zero, it sets the instruction pointer to the value from the second parameter. Otherwise, it does nothing.\n value = read_param(1, program, index, param1_mode, sda_base)\n if value.zero?\n index = read_param(2, program, index, param2_mode, sda_base)\n else\n index += 3\n end\n when 7 # less than\n # if the first parameter is less than the second parameter, it stores 1 in the position given by the third parameter. Otherwise, it stores 0.\n value = if read_param(1, program, index, param1_mode, sda_base) < read_param(2, program, index, param2_mode, sda_base)\n 1\n else\n 0\n end\n write_param(3, program, index, param3_mode, sda_base, value)\n index += 4\n when 8 # equals\n # if the first parameter is equal to the second parameter, it stores 1 in the position given by the third parameter. Otherwise, it stores 0.\n value = if read_param(1, program, index, param1_mode, sda_base) == read_param(2, program, index, param2_mode, sda_base)\n 1\n else\n 0\n end\n write_param(3, program, index, param3_mode, sda_base, value)\n index += 4\n when 9 # adjusts the relative base\n value = read_param(1, program, index, param1_mode, sda_base)\n sda_base += value\n index += 2\n else\n puts\n puts \"Invalid OP #{program[index]} at #{index}\"\n exit(1)\n end\n end\n # p [index, opcode, param1_mode, param2_mode, param3_mode, sda_base]\n\n program\nend", "def opcode(op,cond,args) \"#{op}#{cond} #{args.join ','}\" end", "def asmcmd( command, parameters = {})\n Puppet.debug \"Executing asmcmd command: #{command}\"\n os_user = parameters.fetch(:os_user) { ENV['GRID_OS_USER'] || 'grid'}\n full_command = \"export ORACLE_SID='+ASM1';export ORAENV_ASK=NO;. oraenv; asmcmd #{command}\"\n options = {:uid => os_user, :failonfail => true}\n Puppet::Util::Execution.execute(full_command, options)\n end", "def asm\n endian = Const::Endian::ENDIAN[arch]\n [code, jt, jf, k].pack(\"S#{endian}CCL#{endian}\")\n end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def command(binary, action, service, param = nil, sub_param = nil)\n [\n prepare_parameter(binary),\n action, # simple keyword does not need transformation\n prepare_parameter(service),\n prepare_parameter(param),\n prepare_parameter(sub_param, false) # last param does no need quoting\n ].reject(&:empty?).join ' '\n end", "def add_expression_result(code)\n with_buffer{@src << ' << (' << code << ').to_s'}\n end", "def exec_opcode(bytecode, parameters)\n @cpu.exec_opcode(bytecode, parameters)\n end", "def convertCommand(arr, i, fileName)\n op = arr[0] # the operation is the first word in the vm command\n opType = getOpType(op) # the type of operation each will have there own function\n\n case opType\n when \"arithmeticOp\"\n cmds = convertArithmetic(op)\n\n when \"compareOp\"\n #creating new jump locations for each conditional command\n jumpLocation = \"jumpLocation\"+i.to_s\n locationEnd = \"locationEnd\"+i.to_s\n cmds = convertCompare(op, jumpLocation, locationEnd)\n\n when \"pushPop\"\n segment = arr[1] #the segment is the second word in the vm command\n value = arr[2] #the value is the third word in the vm command\n cmds = convertPushPop(op, segment, value, fileName)\n\n when \"programFlowOp\"\n label = arr[1]\n cmds = convertProgramFlow(op, label)\n\n when \"functionOp\"\n label = arr[1]\n n = arr[2].to_i\n returnLocation = fileName+\"$ret.\"+i.to_s\n\n cmds = convertFunction(op, label, n, returnLocation)\n\n else\n cmds = error\n end\n\n return cmds\nend", "def run(instruction)\n case instruction\n\n # add\n when /add (#{REG}) (#{INT})/\n @registers[$1] += $2.to_i\n when /add (#{REG}) (#{REG})/\n @registers[$1] += @registers[$2]\n\n # jgz\n when /jgz (#{REG}) (#{INT})/\n @ic += $2.to_i - 1 unless @registers[$1] <= 0\n when /jgz (#{INT}) (#{INT})/\n @ic += $2.to_i - 1 unless $1.to_i <= 0\n when /jgz (#{REG}) (#{REG})/\n @ic += @registers[$2] - 1 unless @registers[$1] <= 0\n\n # mod\n when /mod (#{REG}) (#{INT})/\n @registers[$1] %= $2.to_i\n when /mod (#{REG}) (#{REG})/\n @registers[$1] %= @registers[$2]\n\n # mul\n when /mul (#{REG}) (#{INT})/\n @registers[$1] *= $2.to_i\n when /mul (#{REG}) (#{REG})/\n @registers[$1] *= @registers[$2]\n\n # set\n when /set (#{REG}) (#{INT})/\n @registers[$1] = $2.to_i\n when /set (#{REG}) (#{REG})/\n @registers[$1] = @registers[$2]\n\n # snd\n when /snd (#{INT})/\n @parent.send(@target, $1.to_i)\n when /snd (#{REG})/\n @parent.send(@target, @registers[$1])\n\n # rcv\n when /rcv (#{REG})/\n @waiting = true\n @receiver = $1\n when /rcv (#{INT})/\n @waiting = true\n @receiver = $1\n end\n end", "def build_script\n Bitcoin::Script.from_string(\"OP_RETURN #{to_payload}\")\n end", "def processing_instruction(name, content); end", "def processing_instruction(name, content); end", "def initialize(out_file, bootstrap)\n @current_line = \"\"\n @code_writer = CodeWriter.new(out_file)\n @in_file = nil\n if bootstrap\n @code_writer.write_bootstrap()\n end\n @command_type_table ={\"push\" => \"C_PUSH\",\n \"pop\" => \"C_POP\",\n \"add\" => \"C_ARITHMETIC\",\n \"sub\" => \"C_ARITHMETIC\",\n \"neg\" => \"C_ARITHMETIC\",\n \"eq\" => \"C_ARITHMETIC\",\n \"lt\" => \"C_ARITHMETIC\",\n \"gt\" => \"C_ARITHMETIC\",\n \"or\" => \"C_ARITHMETIC\",\n \"not\" => \"C_ARITHMETIC\",\n \"and\" => \"C_ARITHMETIC\",\n \"if-goto\" => \"C_IF\",\n \"label\" => \"C_LABEL\",\n \"goto\" => \"C_GOTO\",\n \"function\" => \"C_FUNCTION\",\n \"return\" => \"C_RETURN\",\n \"call\" => \"C_CALL\"}\n\n @function_call_table = {\"C_PUSH\" => \"write_push_pop\",\n \"C_POP\" => \"write_push_pop\",\n \"C_ARITHMETIC\" => \"write_arithmetic\",\n \"C_LABEL\" => \"write_label\",\n \"C_IF\" => \"write_if\",\n \"C_GOTO\" => \"write_goto\",\n \"C_RETURN\" => \"write_return\",\n \"C_CALL\" => \"write_call\",\n \"C_FUNCTION\" => \"write_function\"} \n \n @arg1_table = {\"C_PUSH\" => 1,\n \"C_POP\" => 1,\n \"C_IF\" => 1,\n \"C_LABEL\" => 1,\n \"C_GOTO\" => 1,\n \"C_FUNCTION\" => 1,\n \"C_CALL\" => 1,\n \"C_ARITHMETIC\" => 0,\n \"C_RETURN\" => 0}\n end", "def build_end\n @code << <<-CODE\n\t \t\t\treturn result\n\t\t\tend\t\n\t\tCODE\n end", "def code\n str = Indentation.get\n str << \"var #{name} = function(#{@parameters.join(', ')}) {\\n\"\n Indentation.indent { str << \"#{block}\\n\" }\n str << \"#{Indentation.get}};\\n\"\n str\n end", "def execution\n # read number base, determine how many zeros to put in front\n # read start, find relevant equivalent\n # loop: assembles each line command from start to end number. add escape characters.\n # concat each iteration to... string? string. then write string at end.\n # call file writer at end\n end", "def execute_RET(operand=nil)\n\t\[email protected]_value = pop_stack_word\n\t\[email protected] += operand.value if operand\n\tend", "def minilang(program_str)\n register = 0\n stack = []\n commands = program_str.split(' ')\n\n commands.each do |command|\n case command\n when 'PUSH' then stack << register\n when 'ADD' then register += (stack.pop).to_i\n when 'SUB' then register -= (stack.pop).to_i\n when 'MULT' then register *= (stack.pop).to_i\n when 'DIV' then register /= (stack.pop).to_i\n when 'MOD' then register %= (stack.pop).to_i\n when 'POP' then register = (stack.pop).to_i\n when 'PRINT' then puts register\n else register = command.to_i\n end\n end\nend", "def write_in_register(instruction)\n op_code, f = extract_op_code_and_modifier(instruction)\n register = select_register_from_op_code(op_code, Instructions::OP_ENTA)\n modified_address = calculate_modified_address(instruction)\n\n if f == Instructions::F_INCA or f == Instructions::F_DECA\n operation = 'increment_value'\n else\n operation = 'store_long'\n end\n if f == Instructions::F_DECA or f == Instructions::F_ENNA\n modified_address = 0 - modified_address\n end\n @logger.debug('Applying operation %s to %s ' % [operation, register]) if @logger.debug?\n register.send(operation, modified_address)\n end", "def compile_to_c\n operator_c_string + \"(\" + @expression.compile_to_c + \")\"\n end", "def assembler(name, signature, code)\n @assembler_declarations << signature\n assembler_code = <<-CODE\n .file \"#{name}.S\"\n .arch #{Makefile.hardware_params['mcu']}\n .global __do_copy_data\n .global __do_clear_bss\n .text\n .global #{name}\n .type #{name}, @function\n #{code}\n CODE\n \n File.open(File.expand_path(\"#{RAD_ROOT}\") + \"/#{PROJECT_DIR_NAME}/#{name}.S\", \"w\"){|f| f << assembler_code}\n end", "def pyper_mm symbol, command_string, **opts\n code = PostfixMachine.new( command_string ).compile( symbol, opts )\n code.gsub! /^alpha = alpha\\n/, \"alpha\\n\" # workaround\n code.gsub! /^alpha\\nalpha\\n/, \"alpha\\n\" # workaround\n code.gsub! /^alpha\\nalpha =/, \"alpha =\" # workaround\n code.gsub! /^alpha = alpha =/, 'alpha =' # workaround\n puts code if Pyper::DEBUG > 0\n self.class.module_eval( code )\n end", "def execute_instruction(instruction)\n if m = /rect (\\d+)x(\\d+)/.match(instruction)\n rect(m[1].to_i, m[2].to_i)\n elsif m = /rotate row y=(\\d+) by (\\d+)/.match(instruction)\n rotate_row(m[1].to_i, m[2].to_i)\n elsif m = /rotate column x=(\\d+) by (\\d+)/.match(instruction)\n rotate_column(m[1].to_i, m[2].to_i)\n else\n raise\n end\n end", "def add_expression_result_escaped(code)\n with_buffer{@src << ' << ' << @escapefunc << '((' << code << '))'}\n end", "def emit_assembly(fname = \"output\")\n out_arr = Array.new\n pack_str = String.new\n \n @instr.each{|i|\n if i.instr_type == InstrBase::OPCODE\n out_arr.push(i.opcode.to_i(16))\n pack_str = pack_str + \"C\"\n next if i.args_len == 0\n \n if i.args_len == 1\n out_arr.push(i.args) \n pack_str = pack_str + \"C\"\n elsif i.args_len == 2\n #gotta remember to put it in correct order, i guess\n #ex: $31F6 -> F6,31, low-order byte is in lower memory, high-order byte in high memory\n out_arr.push(i.args) if \n pack_str = pack_str +\"S\"\n else\n raise \"Invalid opcode args found #{i}\"\n end\n\n elsif i.instr_type == InstrBase::MACRO\n raise \"Unknown macro found #{i.to_s}\" if i.sym_name != \"dcb\" \n #currently we only recognize dcb macro\n \n #simply emit a series of bytes as specified in @args of dcb macro\n i.args.each{ |i|\n out_arr.push(i)\n pack_str = pack_str + \"C\"\n }\n end # if i.instr_type == InstrBase::OPCODE\n }\n \n p \"#{pack_str}\"\n p \"#{out_arr}\"\n \n pack_str = out_arr.pack(pack_str)\n \n file = File.new(fname+\".assl\", \"wb\")\n file.puts(pack_str)\n file.close \n \n out_arr\n end", "def execute\n instruction = @emulator.instruction_register\n\n source = instruction.operand(2)\n @emulator.register_write(@destination, @emulator.register_read(@source))\n end", "def do_instruction(opcode)\n sym_op = get_opcode(opcode)\n\n # Byte components\n b1 = (opcode & 0xf000) >> 12\n b2 = (opcode & 0x0f00) >> 8\n b3 = (opcode & 0x00f0) >> 4\n b4 = (opcode & 0x000f)\n\n # print \"Op: \", sym_op, \" | \"\n # print \"Desc: \", get_opcode_desc(opcode), \"\\n\"\n\n # Massive opcode conditional incoming.\n case sym_op\n\n when \"00E0\"\n # Clear the screen.\n @display.each do |row|\n row.each do |col|\n col = 0\n end\n end\n\n when \"00EE\"\n # Return from a subroutine.\n @instruction_ptr = @stack[@stack_ptr]\n @stack_ptr -= 1;\n\n when \"0NNN\"\n # This one isn't actually used by games. Skip it.\n\n when \"1NNN\"\n # Jump to address NNN.\n @instruction_ptr = opcode & 0x0fff\n\n when \"2NNN\"\n # Call subroutine at NNN.\n @stack_ptr += 1\n @stack[@stack_ptr] = @instruction_ptr\n @instruction_ptr = opcode & 0x0fff\n\n when \"3XNN\"\n # Skips next instruction if VX == NN.\n if @registers[b2] == opcode & 0x00ff\n @instruction_ptr += 2\n end\n\n when \"4XNN\"\n # Skips next instruction if VX != NN.\n if @registers[b2] != opcode & 0x00ff\n @instruction_ptr += 2\n end\n\n when \"5XY0\"\n # Skips next instruction if VX == VY.\n if @registers[b2] == @registers[b3]\n @instruction_ptr += 2\n end\n\n when \"6XNN\"\n # Sets VX to NN.\n @registers[b2] = opcode & 0x00ff\n\n when \"7XNN\"\n # Adds NN to VX.\n @registers[b2] += opcode & 0x00ff\n\n when \"8XY0\"\n # Sets VX to VY.\n @registers[b2] += @registers[b3]\n\n when \"8XY1\"\n # Sets VX to (VX or VY).\n @registers[b2] |= @registers[b3]\n\n when \"8XY2\"\n # Sets VX to (VX and VY).\n @registers[b2] &= @registers[b3]\n\n when \"8XY3\"\n # Sets VX to (VX xor VY).\n @registers[b2] ^= @registers[b3]\n\n when \"8XY4\"\n # Adds VY to VX. Sets VF to 1 when carry, 0 otherwise.\n # Only keep lowest 8 bits.\n @registers[b2] += @registers[b3]\n if @registers[b2] > 0xff\n @registers[0xf] = 1\n else\n @registers[0xf] = 0\n end\n @registers[b2] &= 0xff\n\n when \"8XY5\"\n # Subtracts VY from VX. Sets VF to 0 when borrow, 1 otherwise.\n # Only keep lowest 8 bits.\n @registers[b2] -= @registers[b3]\n if @registers[b2] < 0\n @registers[0xf] = 0\n else\n @registers[0xf] = 1\n end\n @registers[b2] &= 0xff\n\n when \"8XY6\"\n # Shifts VX right by one. Sets VF to the LSB of VX before the shift.\n @registers[0xf] = @registers[b2] % 2\n @registers[b2] >>= 1\n\n when \"8XY7\"\n # Sets VX to (VY - VX). Sets VF to 0 when borrow, otherwise 1.\n # Only keep lowest 8 bits.\n @registers[b2] = @registers[b3] - @registers[b2]\n if @registers[b2] < 0\n @registers[0xf] = 0\n else\n @registers[0xf] = 1\n end\n @registers[b2] &= 0xff\n\n when \"8XYE\"\n # Shifts VX left by one. Sets VF to the MSB of VX before the shift.\n @registers[0xf] = (@registers[b2] / 0b1000 > 0 ? 1 : 0)\n @registers[b2] = @registers[b2] << 1 & 0b0111\n\n when \"9XY0\"\n # Skips next instruction if VX == VY.\n if @registers[b2] != @registers[b3]\n @instruction_ptr += 2\n end\n\n when \"ANNN\"\n # Set address register to NNN.\n @addr_register = opcode & 0x0fff\n\n when \"BNNN\"\n # Set instruction pointer to address NNN + V0\n @instruction_ptr = (opcode & 0x0fff) + @registers[0]\n\n when \"CXNN\"\n # Set VX to a random number and NN.\n @registers[b2] = [*0..(opcode & 0x00ff)].sample\n\n when \"DXYN\"\n # TODO this should draw sprites, not just memory bits.\n # Draw N bytes of sprites starting from address register I,\n # at coordinates VX, VY. XORd onto screen. If any sprites overwritten,\n # set VF to 1, otherwise, 0. Wrap sprites if they go outside coordinates.\n overwritten = 0\n for i in 0..b4\n col_offset = (b2 + i) / 0x40\n new_row = (b3 + col_offset) % 0x20\n new_col = b2 % 0x40\n old_pixel = @display[new_row][new_col]\n new_pixel = @memory[@addr_register+i]\n result = old_pixel ^ new_pixel\n\n @display[new_row][new_col] = result\n if old_pixel == 1 and new_pixel == 0\n overwritten = 1\n end\n end\n\n @registers[0xf] = overwritten\n\n when \"EX9E\"\n # Skip the next instruction if the key stored in VX is pressed.\n if keypad[b2] == 1\n @instruction_ptr += 2\n end\n\n when \"EXA1\"\n # Skip the next instruction if the key stored in VX isn't pressed.\n if keypad[b2] == 0\n @instruction_ptr += 2\n end\n\n when \"FX07\"\n # Set VX to the value of the delay timer.\n @registers[b2] = @timers[:delay]\n\n # TODO\n when \"FX0A\"\n # A key press is awaited, and then stored in VX.\n\n when \"FX15\"\n # Sets the delay timer to VX.\n @timers[:delay] = b2\n\n when \"FX18\"\n # Sets the sound timer to VX.\n @timers[:sound] = b2\n\n when \"FX1E\"\n # Adds VX to I\n @instruction_ptr += b2\n\n # TODO\n when \"FX29\"\n # Set I to the location of the sprite for the character in VX. Characters\n # 0-F (in hexadecimal) are represented by a 4x5 font.\n\n # TODO\n when \"FX33\"\n # Store the BCD representation of Vx in memory locations I, I+1, and I+2.\n # The interpreter takes the decimal value of Vx, and places the hundreds\n # digit in memory at location in I, the tens digit at location I+1, and\n # the ones digit at location I+2.\n\n when \"FX55\"\n # Store V0 to VX in memory starting at address I.\n for i in 0..b2\n @memory[@instruction_ptr + i] = @registers[i]\n end\n\n when \"FX65\"\n # Fill V0 to VX with values from memory starting at address I.\n for i in 0..b2\n @registers[i] = @memory[@instruction_ptr + i]\n end\n end\n end", "def add_end()\n @asm_file << \"(END)\\n@END\\n0;JMP\\n\" \n end", "def processing_instruction!(name, attributes = nil)\n unless attributes\n @buffer << \"<?#{name} ?>\"\n else\n @buffer << \"<?#{name} \"\n attributes.each do |a, v|\n @buffer << %[#{a}=\"#{v}\" ]\n end\n @buffer << \"?>\"\n end\n\n return self\n end", "def execute\n\t\t\tres = instance_exec(@node, &Glyph::MACROS[@name]).to_s\n\t\t\tres.gsub(/\\\\*([\\[\\]\\|])/){\"\\\\#$1\"}# : res\n\t\tend", "def process_command\n result = f(@number, @value)\n print result\n result\n end", "def arithmeticUnary(op)\n str = getTopOfStack + \"M=\"+op+\"M\"+\"\\n\"\n return str+\"\\n\"\nend", "def arthamatic_operation(number)\n\tnumber + 3\nend", "def to_php\n \"#{function}(#{arguments.join(', ')})\"\n end", "def exec(opcode, arg)\n case opcode\n when 0\n self.acc = self.acc + ram.read(arg)\n when 1\n self.acc = self.acc - ram.read(arg)\n when 2\n self.acc = self.io.ask(\"> \", Integer)\n when 3\n self.io.say(\"--> #{self.acc}\")\n when 4\n ram.store(arg) { self.acc }\n when 5\n self.acc = ram.read(arg)\n when 6\n self.pc = arg\n when 7\n self.pc = arg if self.acc == 0\n when 8\n @running = false\n else\n raise \"Unknown instruction code #{opcode}\"\n end\n end", "def translate(ast = nil)\n # Ensure that ast is a valid Abstract Syntax Tree\n if ast == nil or !ast.respond_to?(\"root\") or ast.root == nil\n raise @err_class, \"The Abstract Syntax Tree is either invalid or empty!\"\n else\n @ast = ast\n @code = []\n end\n\n # Get root node\n curr_node = ast.root\n if curr_node.name == \"QUIT\"\n @code.push(\"HALT\")\n elsif curr_node.name == \"HOWMANY\" or curr_node.name == \"HOWMUCH\"\n translate_query(curr_node)\n elsif curr_node.name == \"ASSIGN\"\n translate_assign(curr_node)\n end\n\n # Add common initialization code used in all statements\n @code.push(\"CLR $ar\") # Clear general purpose register #1\n @code.push(\"CLR $br\") # Clear general purpose register #2\n @code.push(\"CLR $nr\") # Clear numeral register\n @code.push(\"CLR $rr\") # Clear return register\n @code.push(\"CLR $sr\") # Clear stack register\n\n # Return virtual machine code\n return @code\n end", "def asm buf = StringIO.new(''.b), metadata: {}, &block\n instance_eval(&block)\n write_to buf, metadata: metadata\n buf\n end", "def translate_query(curr_node = nil)\n # First handle errors\n if curr_node == nil\n raise @err_class, \"Malformed Query Statement!\"\n end\n\n # Add code to return result of query\n @code.push(\"RET\")\n\n # Next initialize output string\n out_str = \"\"\n\n # Generate code for a valid HOWMANY query\n if curr_node.name == \"HOWMANY\"\n if curr_node.children.length != 2\n raise @err_class, \"HOWMANY statement requires two child nodes!\"\n elsif curr_node.children[0].name != \"GALNUMBER\"\n raise @err_class, \"Left node must be a GALNUMBER!\"\n elsif curr_node.children[1].name != \"COMMODITY\"\n raise @err_class, \"Right node must be a COMMODITY!\"\n else\n @code.push(\"MOV $ar $rr\") # Move contents of gp register #1 into return register\n @code.push(\"MUL $br $ar\") # Multiply gp register #1 by gp register #2\n # Move contents of memory location into gp register #1\n @code.push(\"MOV %#{curr_node.children[1].value} $ar\")\n @code.push(\"POP $br\") # Pop value of stack register into $br \n curr_node.children[0].children.each do |num|\n out_str = out_str + num.value + \" \"\n @code.push(\"PUSH\") # Push numeral register onto stack register\n @code.push(\"MOV %#{num.value} $nr\")\n end\n out_str = out_str + curr_node.children[1].value + \" is $rr Credits\"\n @code.push(\"LOAD '#{out_str}'\") # Load out_str into string register\n #else\n # raise @err_class, \"Malformed HOWMANY statement!\"\n end\n # Generate code for a valid HOWMUCH query\n elsif curr_node.name == \"HOWMUCH\"\n if curr_node.children.length != 1\n raise @err_class, \"HOWMUCH requires one child node!\"\n elsif curr_node.children[0].name != \"GALNUMBER\"\n raise @err_class, \"Child node must be a GALNUMBER!\"\n else\n @code.push(\"MOV $br $rr\")\n @code.push(\"POP $br\")\n curr_node.children[0].children.each do |num|\n out_str = out_str + num.value + \" \"\n @code.push(\"PUSH\")\n @code.push(\"MOV %#{num.value} $nr\")\n end\n out_str = out_str + \"is $rr\"\n @code.push(\"LOAD '#{out_str}'\")\n #else\n # raise @err_class, \"Malformed HOWMUCH statement!\"\n end\n end\n end", "def minilang(program)\n stack = []\n register = 0\n commands = program.split\n commands.each do |command|\n case command\n when 'PUSH' then stack << register\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register = register * stack.pop\n when 'DIV' then register = register / stack.pop\n when 'MOD' then register = register % stack.pop\n when 'POP' then register = stack.pop\n when 'PRINT' then puts register\n else register = command.to_i\n end\n end\n nil\nend", "def operation_to_message(operation)\n word = case operation\n when '1'\n 'Adding'\n when '2'\n 'Subtracting'\n when '3'\n 'Multiplying'\n when '4'\n 'Dividing'\n end\n\n x = \"A random line of code\"\n\n word\nend", "def instructions\n \n end", "def route(command)\n if command.count(\" \") == 2\n @code_writer.send(command.split(' ')[1], command.split(' '))\n else\n @code_writer.send(command)\n end\n end", "def expression\n if is_addop @look\n emit_ln 'CLR D0'\n else\n term\n end\n while is_addop @look\n emit_ln 'MOVE D0, -(SP)' \n case @look\n when '+': add\n when '-': subtract\n else expected('Addop')\n end\n end\nend", "def encode\n @code = \"\"\n add_check_digit_and_ensure_even_digit_size\n 0.step(@encodable.size - 1, 2) do |i|\n first = SYMBOLOGY[@encodable[i]]\n second = SYMBOLOGY[@encodable[i+1]]\n @code += 0.upto(4).map { |j| first[j] + second[j] }.join\n end \n @code = SYMBOLOGY[:start] + @code + SYMBOLOGY[:stop]\n self\n end", "def assemble\n @code.join\n end", "def add\n match '+'\n term\n emit_ln 'ADD (SP)+, D1'\nend", "def method_source(mnemonic, flags, sample, prefix)\n\t\"\"\"// Mnemonic: #{sample}\n// Sets Flags: #{flags}\nfunc (p *GBProcessor) #{prefix}#{mnemonic}(opcode byte, params ...byte) {\n\n}\"\"\"\nend", "def add_instruction(*parts)\n @program.add Verneuil::Instruction.new(*parts)\n end", "def commands_for_vm\n [{:write_file => {:filename => @filename, :content => @code}},\n {:execute => {:command => \"#{VM_PYTHON} -c \\\"compile(open('#{@filename}').read(), '', 'exec')\\\" && echo success\",\n :stdout => 'syntaxchecksuccess',\n :stderr => 'syntaxcheckfail'}}]\n # in this case execution only triggers the initial syntax check, the rest is handled\n # in postprocess_print\n end", "def plus(number)\n @operation = '+' \n @number = number\nend", "def sign(cmd)\n \t\t\t\tiv = rand(0xffffffff).to_i.to_s(16).upcase.rjust(8,\"0\")\n \t\t\t\tdigest = Digest::MD5.hexdigest(cmd+iv).upcase\n \t\t\t\tsb = [@signature_block + digest].pack(\"h*\")\n \t\t\t\tsig = @signingkey_priv.private_encrypt(sb).unpack(\"h*\")[0].upcase\n \t\t\t\t# i haven't a clue what those numbers are on the front, 10|3|22\n \t\t\t\t\"10|3|22|#{cmd}|#{sig}|#{iv}\"\n \t\t\tend", "def generate_opcode\n\tputs \"[*]\".green + \"\\tGenerating reverse_https opcode for sce using \" + DEF_INT_IP.green + \" as LHOST and port \" + $port.green\n\t$def_opcode = `msfvenom -p windows/meterpreter/reverse_https EXITFUNC=thread LPORT=#{$port} LHOST=#{DEF_INT_IP} -f raw -a x86 -e x86/alpha_mixed --platform windows BufferRegister=EAX`\n\tp $def_opcode\nend", "def emit_code value\n statement :code, value\n end", "def oper(n, p)\n @socket << \"OPER #{n} #{p}\"\n end", "def command_type\n if arithmetic?\n \"C_ARITHMETIC\"\n else\n \"C_#{arg_0.upcase}\"\n end\n end", "def add_code instruction\n unless instruction.is_a?(Register::Instruction)\n raise instruction.to_s\n end\n @current.insert(instruction) #insert after current\n @current = instruction\n self\n end", "def transpile\n code = String.new(\" \")\n code << \"$#{body['name']} = \" if body['name']\n code << function_call(function, format_args(body))\n code << \"\\n\"\n end", "def compile(*args)\nputs \"barf\"\n -1 \n end", "def ADD(cond,d,a,b) opcode(\"ADD\",cond, [d,a,b]) end", "def operation_to_message(op)\n case op\n when '1'\n '+'\n when '2'\n '-'\n when '3'\n '/'\n when '4'\n '*'\n end\nend", "def putc(*line)\n raise unless @state == :asm\n @outp.puts(formatDump(\" \" + line.join(''), lastComment))\n end", "def write_command(cmd, data='', synth=SYNTH_A)\n # Make sure cmd is valid\n raise \"unknown command #{cmd}\" unless LENGTH.has_key?(cmd)\n # Verify length of data to write\n if data.length != LENGTH[cmd]\n raise \"invalid data length for command #{cmd} \" +\n \"(expected #{LENGTH[cmd]}, got #{data.length})\"\n end\n # Make sure synth has no stray bits set\n synth &= (SYNTH_A|SYNTH_B)\n\n serialport do |sp|\n cmd = WR|synth|cmd unless cmd == CMD_WRITE_FLASH\n csum = Valon.generate_checksum(cmd.chr, data)\n cmd_data_csum = [cmd, data, csum].pack('CA*A')\n sp.write(cmd_data_csum)\n ack = sp.read(1).ord\n raise \"nak error (#{ack == NAK ? 'NAK' : ack.inspect})\" if ack != ACK\n end\n nil\n end", "def execute\n case @method\n when \"0001\"\n print decode_twos_complement(@value)\n when \"0010\"\n print decode_floating_point(@value)\n else\n print @value.binary_to_decimal.chr\n end\n end", "def operation_to_message(op)\nword = case op\n when '1'\n 'Adding'\n when '2'\n 'Subtracting'\n when '3'\n 'Multiplying'\n when '4'\n 'Dividing'\n end\n\nx = \"A random line of code\"\nword\n\nend", "def compile_to_ruby\n operator_ruby_string + \"(\" + @expression.compile_to_ruby + \")\"\n end", "def evalWrite(expr)\n\tsymbol = evalExpression(expr)\n\tputs symbol[1]\nend", "def write_bytecode_to(value,target) \n target << Byte.new(value)\n @current_byte += 1 # pricti k celkove delce\n end", "def buildCommand(akeyword, para1,para2,para3,para4,para5,para6,para7,para8,para9,para10)\n\n\n\tkeyword = akeyword\n\tcommandString = \"\" \n \n\tresult = Pgw.where(command: keyword).first\n\t\tif !(result.blank?) # the command exists in the database\n\t\t\tcommandString = commandString + result.command_actual\n\t\t\tif (result.parameters == 1) # the command only has one argument\n\t\t\t\tcommandString = commandString + result.para_1 + \"\\\"\"+ para1 + \"\\\"\"\n\t\t\tend\n\n\t\t\tif (result.parameters == 2) # the command two argument\n\t\t\t\tcommandString = commandString + result.para_1 + \"\\\"\"+ para1 + \"\\\"\" + \",\" + result.para_2 + para2\n\t\t\tend\n\n\t\t\tif (result.parameters == 3) # the command only has 3 arguments\n\t\t\t\tcommandString = commandString + result.para_1 + \"\\\"\"+ para1 + \"\\\"\" + \",\" + result.para_2 + para2 + \",\" + result.para_3 + para3\n\t\t\tend\n\n\t\t\tif (result.parameters == 4) # the command only has 3 arguments\n\t\t\t\tcommandString = commandString + result.para_1 + para1 + \",\" + result.para_2 + \"\\\"\"+ para2 + \"\\\"\" + \",\" + result.para_3 + \"\\\"\" + para3 + \"\\\"\" + \",\" + result.para_4 + para4\n\t\t\tend\n\n\t\t\tif (result.parameters == 6) # the command only has 6 arguments\n\t\t\t\tcommandString = commandString + result.para_1 + para1 + \",\" + result.para_2 + para2 + \",\" + result.para_3 + para3 + \",\" + result.para_4 + \"\\\"\"+ para4 + \"\\\"\" + \",\" + result.para_5 + \"\\\"\"+ para5 + \"\\\"\" + \",\" + result.para_6 + para6\n\t\t\tend\n\n\t\t\tif (result.parameters == 11) # this is an exceptinal parameter\n\t\t\t\tcommandString = commandString + result.para_1 + para1 + \",\" + result.para_2 + \"\\\"\"+ para2 + \"\\\"\" + \",\" + result.para_3 + para3 + \",\" + result.para_4 + para4\n\t\t\tend\n commandString = commandString + \";\"\n end\n\n\t\treturn commandString\n\n\nend", "def operations\n puts \"(a) - addition (+)\"\n puts \"(s) - subtraction (-)\"\n puts \"(m) - multiplication (*)\"\n puts \"(d) - division (/)\"\nend", "def asmcmd( command, options = {})\n check_options( options )\n Puppet.debug \"Executing asmcmd command: #{command}\"\n os_user = options.fetch(:os_user) { default_asm_user}\n sid = options.fetch(:sid) { raise ArgumentError, \"you need to specify a sid for asm access\"}\n full_command = \"export ORACLE_SID=#{sid};export ORAENV_ASK=NO;. oraenv; asmcmd #{command}\"\n options = {:uid => os_user, :failonfail => true}\n Puppet::Util::Execution.execute(full_command, options)\n end", "def processingInstruction(target, data)\n\t finishStartTag() if @inStartTag\n\t @io << \"<?#{target}\"\n\t @io << \" #{data}\" unless !data || data.empty?\n\t @io << \"?>\"\n\t @io << \"\\n\" if @prettify\n\tend", "def to_s; \"<Operand: #{to_source}>\"; end", "def minilang(command_string)\n stack = []\n register = 0\n command_string.split(' ').each do |command|\n case command\n when 'PUSH' then stack << register\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register *= stack.pop\n when 'DIV' then register /= stack.pop\n when 'MOD' then register %= stack.pop\n when 'POP' then register = stack.pop\n when 'PRINT' then puts register\n else register = command.to_i\n end\n end\n register\nend", "def write\n @ruby_name = Inflector.underscore(code.name)\n\n self.prefix ||= \"#{self.parent.rice_variable}.\"\n self.suffix ||= \"\"\n\n if self.code.arguments.size == 1 && (fp = self.code.arguments[0].cpp_type.base_type).is_a?(RbGCCXML::FunctionType)\n wrap_with_function_pointer(fp)\n else\n wrap_normal_method\n end\n end", "def emit_instr(base_addr = 0x0600)\n #by convention, stack is 0x0100-0x01FF\n #so we try tolay out our program starting from 0x0200\n #\n #errr.... turns out 6502asm.com starts userspace addrs at 0x0600\n \n #2-pass compilation:\n #first pass, we lay out all the instr except for goto-labels\n addr = base_addr\n \n @instr.each { |i|\n case i.instr_type\n when InstrBase::OPCODE\n #p \"opcode #{i}\"\n i.addr = addr\n \n #increment by number of instructions used: 1 for opcode + 1-2 for args\n addr = addr + 1 + i.args_len\n when InstrBase::LABEL_HOME\n #p \"label #{i}\"\n i.addr = addr\n i.label_addr = addr\n \n #also, need to update @def_labels structure for lookups later\n @def_labels[i.label_name][1] = addr \n when InstrBase::MACRO\n #p \"macro #{i.to_s}\" \n # set addr of macro to starting addr\n i.addr = addr\n \n # increment addr by length of macro's args\n addr = addr + i.args.length\n \n #actual opcode is captured in @args of macro, get it later\n else\n #p \"else #{i.instr_type}\"\n end\n }\n \n #second pass, we link in all the goto-labels\n @instr.each { |i|\n case i.instr_type\n when InstrBase::OPCODE\n if i.args.respond_to?(:instr_type)\n if i.args.instr_type == InstrBase::LABEL_GOTO\n \n #if we have a relative addr, args_len = 1\n #add signed 1byte disp to instr. counter\n if i.args_len == 1\n disp =@def_labels[i.args.label_addr][1] - (i.addr + 2)\n i.args = disp\n else #replace label goto with mapped addr to it\n i.args = @def_labels[i.args.label_addr][1]\n end\n \n else\n #raise exception here\n raise \"Unknown opcode arg-type \\\"#{i.args}\\\" found\"\n end\n end\n else\n #p \"else #{i.instr_type}\" \n end\n }\n \n \n \n end", "def solve(a=nil, b=nil)\n program = @program.dup\n pointer = 0\n opcode = 0\n program[1] = a if a\n program[2] = b if b\n\n while (opcode != @STOP && pointer < program.length) do \n puts \"pointer: #{pointer}\" if @DEBUG\n opcode = program[pointer]\n a = 0\n b = 0\n c = 0\n\n # Check Immeidate Mode\n if(opcode.to_s.length > 2)\n opcode = opcode.to_s\n # need to parse that fancy code\n instruction = opcode[-2..-1].to_i\n puts \"instruction: #{instruction}\\nopcode: #{opcode}\" if @DEBUG\n \n if (opcode.length == 3)\n puts \"length: 3\" if @DEBUG\n c = opcode[0].to_i\n elsif (opcode.length == 4)\n puts \"length: 4\" if @DEBUG\n b = opcode[0].to_i\n c = opcode[1].to_i\n elsif (opcode.length == 5)\n puts \"length: 5\" if @DEBUG\n a = opcode[0].to_i\n b = opcode[1].to_i\n c = opcode[2].to_i\n end\n else\n puts \"opcode only: #{opcode}\" if @DEBUG\n instruction = opcode.to_i\n end\n\n if(instruction == @STOP)\n puts \"STOP\"\n break\n end\n\n puts \"a: #{a}\\nb: #{b}\\nc: #{c}\\n\" if @DEBUG\n \n if(instruction == @ADD || instruction == @MULTIPLY)\n position_a = program[pointer + 1].to_i\n position_a = program[position_a].to_i if c == 0\n\n position_b = program[pointer + 2].to_i\n position_b = program[position_b].to_i if b == 0\n\n position_c = program[pointer + 3].to_i #if a == 0\n #position_c = program[pointer + 3].to_i if a == 1\n \n if(instruction == @ADD)\n program[position_c] = position_a + position_b\n elsif(instruction == @MULTIPLY)\n program[position_c] = position_a * position_b\n end\n pointer += 4\n puts \"incrementing pointer by 4\" if @DEBUG\n end\n\n if(instruction == @READ)\n if (c == 0)\n puts \"\\nSTATUS: #{program[program[pointer + 1].to_i]}\\n\"\n else\n puts \"\\nSTATUS: #{program[pointer + 1]}\\n\"\n end\n pointer += 2\n puts \"incrementing pointer by 2\" if @DEBUG\n end\n\n if(instruction == @STORE)\n print \"input: \"\n number = gets.strip\n target = program[pointer + 1].to_i\n program[target] = number.to_i\n pointer += 2\n puts \"incrementing pointer by 2\" if @DEBUG\n end\n\n # only two params\n if(instruction == @JUMP_IF_TRUE)\n puts \"Jump if true\" if @DEBUG\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n if @DEBUG\n puts \"first: #{first}\\nsecond: #{second}\"\n puts \"first_value: #{program[first]}\\nsecond_value: #{program[second]}\"\n end\n\n unless program[first].to_i == 0\n pointer = program[second].to_i\n puts \"assigning pointer to #{pointer}\" if @DEBUG\n else\n pointer += 3\n puts \"incrementing pointer by 3\" if @DEBUG\n end\n end\n\n # only two params\n if(instruction == @JUMP_IF_FALSE)\n puts \"Jump if false\" if @DEBUG\n\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n \n if @DEBUG\n puts \"first: #{first}\\nsecond: #{second}\"\n puts \"first_value: #{program[first]}\\nsecond_value: #{program[second]}\"\n end\n\n if program[first].to_i == 0\n pointer = program[second].to_i\n puts \"assigning pointer to #{pointer}\" if @DEBUG\n else\n pointer += 3\n puts \"incrementing pointer by 3\" if @DEBUG\n end\n end\n\n # four parameters\n if(instruction == @LESS)\n puts \"Less\" if @DEBUG\n\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n third = pointer + 3\n third = program[third].to_i if a == 0\n\n if(program[first].to_i < program[second].to_i)\n program[third] = 1\n else\n program[third] = 0\n end\n\n pointer += 4\n end\n\n if(instruction == @EQUALS)\n puts \"Equals\" if @DEBUG\n\n first = pointer + 1\n first = program[pointer + 1].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n third = pointer + 3\n third = program[third].to_i if a == 0\n\n puts \"first: #{program[first]}, second: #{program[second]}\" if @DEBUG\n\n if(program[first].to_i == program[second].to_i)\n puts \"Setting #{third} to 1\" if @DEBUG\n program[third] = 1\n else\n puts \"Setting #{third} to 0\" if @DEBUG\n program[third] = 0\n end\n\n pointer += 4\n end\n gets if @DEBUG\n end\n return program[0]\n end", "def exec_opcode(opcode, params)\n #puts \"executing instruction #{self.class.instspec_table[opcode]} with (#{params.join(\", \")})\"\n __send__(\"inst_#{opcode}\", *params)\n end", "def run_program(input, intcodes)\n relative_base = 0\n pointer = 0\n instruction = intcodes[pointer]\n opcode = instruction % 100\n modes = (instruction / 100).digits\n\n while opcode != 99\n mode1 = modes[0] || 0\n mode2 = modes[1] || 0\n mode3 = modes[2] || 0\n input_param1 = intcodes[pointer + 1]\n input_param2 = intcodes[pointer + 2]\n input_param3 = intcodes[pointer + 3]\n\n case mode1\n when 0\n # position mode\n param1 = intcodes[input_param1]\n when 1\n # immediate mode\n param1 = input_param1\n when 2\n # relative mode\n param1 = intcodes[relative_base + input_param1]\n end\n\n case mode2\n when 0\n # position mode\n param2 = intcodes[input_param2]\n when 1\n # immediate mode\n param2 = input_param2\n when 2\n # relative mode\n param2 = intcodes[input_param2 + relative_base]\n end\n\n case mode3\n when 0, 1\n param3 = input_param3\n when 2\n param3 = input_param3 + relative_base\n end\n\n param1 = 0 if param1.nil?\n\n param2 = 0 if param2.nil?\n\n param3 = 0 if param3.nil?\n\n case opcode\n when 1\n intcodes[param3] = param1 + param2\n pointer += 4\n when 2\n intcodes[param3] = param1 * param2\n pointer += 4\n when 3\n if mode1 == 2\n intcodes[relative_base + input_param1] = input\n else\n intcodes[input_param1] = input\n end\n\n pointer += 2\n when 4\n puts \"OUTPUT: #{param1}\"\n\n pointer += 2\n when 5\n if param1.zero?\n pointer += 3\n else\n pointer = param2\n end\n when 6\n if param1.zero?\n pointer = param2\n else\n pointer += 3\n end\n when 7\n intcodes[param3] = if param1 < param2\n 1\n else\n 0\n end\n\n pointer += 4\n when 8\n intcodes[param3] = if param1 == param2\n 1\n else\n 0\n end\n\n pointer += 4\n when 9\n # adjusts the relative base by the value of its only parameter\n relative_base += param1\n\n pointer += 2\n else\n break\n end\n\n instruction = intcodes[pointer]\n opcode = instruction % 100\n modes = (instruction / 100).digits\n end\nend" ]
[ "0.6683082", "0.64509684", "0.6297073", "0.59178704", "0.5915949", "0.5609868", "0.5574378", "0.5536589", "0.55115277", "0.5479584", "0.546897", "0.54474735", "0.5420301", "0.5385527", "0.53832805", "0.5365469", "0.5320509", "0.5291893", "0.5290042", "0.52880615", "0.5264032", "0.525191", "0.5244276", "0.5244276", "0.5244276", "0.5244276", "0.52297026", "0.52237076", "0.520932", "0.51998925", "0.5190607", "0.5186813", "0.5186311", "0.5186311", "0.5158275", "0.51475143", "0.51441514", "0.5132287", "0.51254153", "0.5112034", "0.5103028", "0.50961316", "0.50905323", "0.5087914", "0.5079406", "0.50739884", "0.507375", "0.5063482", "0.50612164", "0.50374335", "0.50317377", "0.50286394", "0.50235486", "0.50219333", "0.50201005", "0.50150764", "0.50032914", "0.4994514", "0.49878484", "0.49805582", "0.4977007", "0.497653", "0.49762753", "0.49520472", "0.49501085", "0.49492085", "0.49381748", "0.49368736", "0.49285814", "0.4921987", "0.49168897", "0.49123418", "0.49074528", "0.4904901", "0.49037355", "0.48998034", "0.48947632", "0.48903975", "0.48899063", "0.48870197", "0.48842624", "0.48803124", "0.4873043", "0.4852402", "0.48507175", "0.48472238", "0.4847039", "0.48456103", "0.48427373", "0.4840635", "0.48399684", "0.48389715", "0.4838234", "0.48216164", "0.4814826", "0.48069417", "0.4797983", "0.47932425", "0.47874022", "0.47858438" ]
0.73196083
0
Writes the assembly code that is the translation of the given command , where command is either C_PUSH or C_POP PARAMETER command(C_PUSH or C_POP), segment(string), index(int) RETURN void
def writePushPop(command, segment, index) assembly_builder = [] # Push if command == 'C_PUSH' if segment == 'constant' assembly_builder.push( "@#{index}", 'D=A', '@SP', 'A=M', 'M=D', '@SP', 'M=M+1' ) elsif segment == 'temp' assembly_builder.push( "@#{5 + index.to_i}", # A = 10 'D=M', # D = M[10] '@SP', # A = 0 'A=M', # A = M[0] = 258 'M=D', # M[258] = D '@SP', # A = 0 'M=M+1' # M[0] = 258 + 1 ) elsif segment == 'pointer' assembly_builder.push( "@#{3 + index.to_i}", # A = 10 'D=M', # D = M[10] '@SP', # A = 0 'A=M', # A = M[0] = 258 'M=D', # M[258] = D '@SP', # A = 0 'M=M+1' # M[0] = 258 + 1 ) elsif segment == 'static' assembly_builder.push( "@#{file_name_without_ext}.#{index}", # A = 10 'D=M', # D = M[10] '@SP', # A = 0 'A=M', # A = M[0] = 258 'M=D', # M[258] = D '@SP', # A = 0 'M=M+1' # M[0] = 258 + 1 ) else segment_symbol = case segment when 'local' 'LCL' when 'argument' 'ARG' when 'this' 'THIS' when 'that' 'THAT' end assembly_builder.push( "@#{index}", 'D=A', "@#{segment_symbol}", # A = THAT = 4 'A=M', 'A=A+D', # A = 3010 + 5 'D=M', # D = M[3015] '@SP', # A = 0 'A=M', # A = M[0] = 257 'M=D', # M[257] = D = M[3015] '@SP', # A = 0 'M=M+1' # M[0] = 257 + 1 ) end # Pop elsif command == 'C_POP' if segment == 'temp' assembly_builder.push( '@SP', # A = 0 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1 'D=M', # D = M[257] "@#{5 + index.to_i}", # A = 5 + index 'M=D' ) elsif segment == 'pointer' assembly_builder.push( '@SP', # A = 0 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1 'D=M', # D = M[257] "@#{3 + index.to_i}", # A = 5 + index 'M=D' ) elsif segment == 'static' assembly_builder.push( '@SP', # A = 0 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1 'D=M', # D = M[257] "@#{file_name_without_ext}.#{index}", # A = 6 + index 'M=D' ) else segment_symbol = case segment when 'local' 'LCL' when 'argument' 'ARG' when 'this' 'THIS' when 'that' 'THAT' end assembly_builder.push( # RAM[RAM[SP]] -> RAM[RAM[segment]] "@#{index}", # A = 3 'D=A', # D = 3 "@#{segment_symbol}", # A = 1 'D=M+D', # D = M[1] + 3 = 300 + 3 'M=D', # M[1] = 303 '@SP', # A = 0 'AM=M-1', # A = M[0] - 1 = 258 -1 'D=M', # D = M[257] "@#{segment_symbol}", # A = 1 'A=M', # A = M[1] = 303 'M=D', # M[303] = M[257] "@#{index}", # A = 3 'D=A', # D = 3 "@#{segment_symbol}", # A = 1 'M=M-D' # M[1] = M[1] - 3 = 303 - 3 ) end end return assembly_builder end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process\n if command_type == :C_COMMAND\n @c = Code.new([comp, dest, jump])\n \"#{@c.translate_c}\\n\"\n else\n @c = Code.new(@current[1..-1])\n \"#{@c.translate_a}\\n\"\n end\n end", "def writePushPop(command,segment,index)\n\n key = command + \" \" + segment\n if @segment_hash.has_key?(key)\n\n File.open(@segment_hash[key], 'r') do |infile|\n erb = ERB.new(infile.read)\n @output.write erb.result(binding)\n end\n\n else puts \"#{command} #{segment} not supported\\n\\n\"\n end\n\n end", "def writePushPop(command, seg, index)\n\t\tseg.rstrip!\n\t\tif command == $PUSH\n if seg == \"constant\" \n @file.write(\"@\" + index.to_s + \"\\n\")\n @file.write(\"D=A\\n\")\n push()\n elsif seg == \"argument\"\n locInMem(\"ARG\")\n pfRAM(index)\n elsif seg == \"local\"\n locInMem(\"LCL\")\n pfRAM(index)\n elsif seg == \"this\"\n locInMem(\"THIS\")\n pfRAM(index)\n elsif seg == \"that\"\n locInMem(\"THAT\")\n pfRAM(index)\n elsif seg == \"temp\"\n plMemory(\"5\")\n pfRAM(index)\n elsif seg == \"pointer\"\n plMemory(\"3\")\n pfRAM(index)\n elsif seg == \"static\"\n @file.write(\"@\" + @currentName + \".\" + index.to_s + \"\\n\")\n @file.write(\"D=M\\n\")\n push()\n else\n print(\"ERROR: seg undefined, seg given - \" + seg)\n\t\t\tend\n elsif command == $POP\n if seg == \"argument\"\n locInMem(\"ARG\")\n storeRAM(index)\n elsif seg == \"local\"\n locInMem(\"LCL\")\n storeRAM(index)\n elsif seg == \"this\"\n locInMem(\"THIS\")\n storeRAM(index)\n elsif seg == \"that\"\n locInMem(\"THAT\")\n storeRAM(index)\n elsif seg == \"temp\"\n plMemory(\"5\")\n storeRAM(index)\n elsif seg == \"pointer\"\n plMemory(\"3\")\n storeRAM(index)\n elsif seg == \"static\"\n pop()\n @file.write(\"@\" + @currentName + \".\" + index.to_s + \"\\n\")\n @file.write(\"M=D\\n\")\n else\n print(\"ERROR: seg undefined, seg given - \" + seg)\n\t\t\tend\n\t\tend\n\tend", "def writePushPop(command, seg, index)\n\t\tseg.rstrip!\n\t\tseg.gsub!(/\\d/, '')\n\t\tif command == $PUSH\n if seg == \"constant\" \n @file.write(\"@\" + index.to_s + \"\\n\")\n @file.write(\"D=A\\n\")\n push()\n elsif seg == \"argument\"\n locInMem(\"ARG\")\n pfRAM(index)\n elsif seg == \"local\"\n locInMem(\"LCL\")\n pfRAM(index)\n elsif seg == \"this\"\n locInMem(\"THIS\")\n pfRAM(index)\n elsif seg == \"that\"\n locInMem(\"THAT\")\n pfRAM(index)\n elsif seg == \"temp\"\n plMemory(\"5\")\n pfRAM(index)\n elsif seg == \"pointer\"\n plMemory(\"3\")\n pfRAM(index)\n elsif seg == \"static\"\n\t\t\t\[email protected](\"//push static\\n\")\n @file.write(\"@\" + @currentName + \".\" + index.to_s + \"\\n\")\n\t\t\t\tputs @currentName + \".\" + index.to_s\n @file.write(\"D=M\\n\")\n push()\n else\n puts(\"ERROR: seg undefined, seg given - \" + seg)\n\t\t\tend\n elsif command == $POP\n if seg == \"argument\"\n locInMem(\"ARG\")\n storeRAM(index)\n elsif seg == \"local\"\n locInMem(\"LCL\")\n storeRAM(index)\n elsif seg == \"this\"\n locInMem(\"THIS\")\n storeRAM(index)\n elsif seg == \"that\"\n locInMem(\"THAT\")\n storeRAM(index)\n elsif seg == \"temp\"\n plMemory(\"5\")\n storeRAM(index)\n elsif seg == \"pointer\"\n plMemory(\"3\")\n storeRAM(index)\n elsif seg == \"static\"\n pop()\n\t\t\t\[email protected](\"//pop static\\n\")\n @file.write(\"@\" + @currentName + \".\" + index.to_s + \"\\n\")\n\t\t\t\tputs @currentName + \".\" + index.to_s\n @file.write(\"M=D\\n\")\n else\n puts(\"ERROR: seg undefined, seg given - \" + seg)\n\t\t\tend\n\t\tend\n\tend", "def writeArithmetic(command)\n assembly_builder = []\n # Add\n if command == 'add'\n assembly_builder.push(\n '@SP',# A=0\n 'AM=M-1',# A=RAM[0]=M[0]-1\n 'D=M',# D=RAM[257]\n 'A=A-1',# A=257-1=256\n 'M=M+D'# RAM[256]=RAM[256]+D\n )\n\n elsif command == 'sub'\n assembly_builder.push(\n '@SP',\n 'AM=M-1',\n 'D=M',\n 'A=A-1',\n 'M=M-D'\n )\n\n # y = -y\n elsif command == 'neg'\n assembly_builder.push(\n '@SP',\n 'A=M-1',\n 'M=-M',\n )\n\n # x == y ? -1 : 0\n elsif command == 'eq'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@EQEND', # if D == 0 → EQEND\n 'D;JEQ', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(EQEND)'\n )\n\n # x > y ? -1 : 0\n elsif command == 'gt'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@GTEND', # if D == 0 → EQEND\n 'D;JGT', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(GTEND)'\n )\n # x < y ? -1 : 0\n elsif command == 'lt'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@LTEND', # if D == 0 → EQEND\n 'D;JLT', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(LTEND)'\n )\n # x & y\n elsif command == 'and'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'M=D&M'\n )\n # x | y\n elsif command == 'or'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'M=D|M'\n )\n # not y\n elsif command == 'not'\n assembly_builder.push(\n '@SP',\n 'A=M-1', # M = 257\n 'M=!M'\n )\n end\n return assembly_builder\n end", "def route(command)\n if command.count(\" \") == 2\n @code_writer.send(command.split(' ')[1], command.split(' '))\n else\n @code_writer.send(command)\n end\n end", "def writeArithmetic(command)\n\t\tif command == \"add\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M+D\\n\")\n elsif command == \"sub\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M-D\\n\") \n elsif command == \"neg\"\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=-M\\n\")\n elsif command == \"and\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M & D\\n\")\n elsif command == \"or\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M | D\\n\")\n elsif command == \"not\"\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M\\n\")\n @file.write(\"M=!D\")\n elsif command == \"eq\"\n label = \"negate\" + @counter.to_s\n\t\t\t@counter += 1\n pop()\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"D=M-D\\n\")\n @file.write(\"@\" + label + \"\\n\")\n @file.write(\"D;JEQ\\n\")\n @file.write(\"D=1\\n\")\n @file.write(\"(\" + label + \")\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=!D\\n\")\n elsif command == \"lt\"\n glJump(\"JLT\")\n elsif command == \"gt\"\n glJump(\"JGT\")\n\t\tend\n\tend", "def initialize(out_file, bootstrap)\n @current_line = \"\"\n @code_writer = CodeWriter.new(out_file)\n @in_file = nil\n if bootstrap\n @code_writer.write_bootstrap()\n end\n @command_type_table ={\"push\" => \"C_PUSH\",\n \"pop\" => \"C_POP\",\n \"add\" => \"C_ARITHMETIC\",\n \"sub\" => \"C_ARITHMETIC\",\n \"neg\" => \"C_ARITHMETIC\",\n \"eq\" => \"C_ARITHMETIC\",\n \"lt\" => \"C_ARITHMETIC\",\n \"gt\" => \"C_ARITHMETIC\",\n \"or\" => \"C_ARITHMETIC\",\n \"not\" => \"C_ARITHMETIC\",\n \"and\" => \"C_ARITHMETIC\",\n \"if-goto\" => \"C_IF\",\n \"label\" => \"C_LABEL\",\n \"goto\" => \"C_GOTO\",\n \"function\" => \"C_FUNCTION\",\n \"return\" => \"C_RETURN\",\n \"call\" => \"C_CALL\"}\n\n @function_call_table = {\"C_PUSH\" => \"write_push_pop\",\n \"C_POP\" => \"write_push_pop\",\n \"C_ARITHMETIC\" => \"write_arithmetic\",\n \"C_LABEL\" => \"write_label\",\n \"C_IF\" => \"write_if\",\n \"C_GOTO\" => \"write_goto\",\n \"C_RETURN\" => \"write_return\",\n \"C_CALL\" => \"write_call\",\n \"C_FUNCTION\" => \"write_function\"} \n \n @arg1_table = {\"C_PUSH\" => 1,\n \"C_POP\" => 1,\n \"C_IF\" => 1,\n \"C_LABEL\" => 1,\n \"C_GOTO\" => 1,\n \"C_FUNCTION\" => 1,\n \"C_CALL\" => 1,\n \"C_ARITHMETIC\" => 0,\n \"C_RETURN\" => 0}\n end", "def write(command)\n if @currently_executing_block\n output \"write text '#{command}'\"\n else\n execute_block { write command }\n end\n end", "def emit_instr(base_addr = 0x0600)\n #by convention, stack is 0x0100-0x01FF\n #so we try tolay out our program starting from 0x0200\n #\n #errr.... turns out 6502asm.com starts userspace addrs at 0x0600\n \n #2-pass compilation:\n #first pass, we lay out all the instr except for goto-labels\n addr = base_addr\n \n @instr.each { |i|\n case i.instr_type\n when InstrBase::OPCODE\n #p \"opcode #{i}\"\n i.addr = addr\n \n #increment by number of instructions used: 1 for opcode + 1-2 for args\n addr = addr + 1 + i.args_len\n when InstrBase::LABEL_HOME\n #p \"label #{i}\"\n i.addr = addr\n i.label_addr = addr\n \n #also, need to update @def_labels structure for lookups later\n @def_labels[i.label_name][1] = addr \n when InstrBase::MACRO\n #p \"macro #{i.to_s}\" \n # set addr of macro to starting addr\n i.addr = addr\n \n # increment addr by length of macro's args\n addr = addr + i.args.length\n \n #actual opcode is captured in @args of macro, get it later\n else\n #p \"else #{i.instr_type}\"\n end\n }\n \n #second pass, we link in all the goto-labels\n @instr.each { |i|\n case i.instr_type\n when InstrBase::OPCODE\n if i.args.respond_to?(:instr_type)\n if i.args.instr_type == InstrBase::LABEL_GOTO\n \n #if we have a relative addr, args_len = 1\n #add signed 1byte disp to instr. counter\n if i.args_len == 1\n disp =@def_labels[i.args.label_addr][1] - (i.addr + 2)\n i.args = disp\n else #replace label goto with mapped addr to it\n i.args = @def_labels[i.args.label_addr][1]\n end\n \n else\n #raise exception here\n raise \"Unknown opcode arg-type \\\"#{i.args}\\\" found\"\n end\n end\n else\n #p \"else #{i.instr_type}\" \n end\n }\n \n \n \n end", "def push0(segment, index)\n\n @fw.puts \"// push #{segment} #{index}\"\n @fw.puts \"@#{segment}\"\n @fw.puts \"A=M\"\n index.times do\n @fw.puts \"A=A+1\"\n end\n\n @fw.puts \"D=M\"\n\n @fw.print <<EOF\n@SP\nA=M\nM=D\n\n@SP\nM=M+1\nEOF\n\n end", "def to_assembly\n case segment.to_sym\n when :pointer, :temp\n base_segment_code\n when :static\n static_code\n else\n generic_code\n end\n end", "def run_instruction(vm, command)\n\n # declare a symbol and save it in the next available memory\n # position. The value will be stored in the position after that\n if command[0] == 'DEC'\n vm.memory[vm.memory_counter] = command[1]\n vm.memory_counter += 2\n\n elsif command[0] == 'LDA'\n index = vm.memory.index(command[1])\n vm.register_a = @converter.to_decimal(vm.memory[index + 1])\n\n elsif command[0] == 'LDB'\n index = vm.memory.index(command[1])\n vm.register_b = @converter.to_decimal(vm.memory[index + 1])\n\n # Loads the integer value into the accumulator register. The value could be negative.\n elsif command[0] == 'LDI'\n vm.register_a = command[1].to_i\n\n # store register a value at symbol (command[1])\n # if no such symbol exists, make one\n elsif command[0] == 'STR'\n index = vm.memory.index(command[1])\n vm.memory[index + 1] = @converter.to_binary(vm.register_a)\n\n # Exchanges the content registers A and B.\n elsif command[0] == 'XCH'\n temp = vm.register_a\n vm.register_a = vm.register_b\n vm.register_b = temp\n\n # Transfers control to instruction at address number in program memory\n elsif command[0] == 'JMP'\n vm.pc = command[1].to_i - 1\n\n # Transfers control to instruction at address number if the zero-result bit is set.\n elsif command[0] == 'JZS'\n vm.pc = command[1].to_i - 1 if vm.zero_bit == 1\n\n # Transfers control to instruction at address number if the overflow bit is set.\n elsif command[0] == 'JVS'\n vm.pc = command[1].to_i - 1 if vm.overflow == 1\n\n # Adds the content of registers A and B. The sum is stored\n # in A. The overflow and zero-result bits are set or cleared as needed.\n elsif command[0] == 'ADD'\n result = vm.register_a.to_i + vm.register_b.to_i\n if result > 2_147_483_647 || result < -2_147_483_648\n vm.overflow = 1\n dif = result - 2_147_483_647\n vm.register_a = dif - 2_147_483_648\n else\n vm.register_a = result\n vm.overflow = 0\n end\n vm.zero_bit = if vm.register_a.zero?\n 1\n else\n 0\n end\n elsif command[0] == 'HLT'\n vm.done = true\n end\n vm.pc += 1\n end", "def putc(*line)\n raise unless @state == :asm\n @outp.puts(formatDump(\" \" + line.join(''), lastComment))\n end", "def exec(command)\n @commands << %{write text \"#{command}\"}\n end", "def convertSegmentPush(segment, value, fileName)\n case segment\n when \"local\"\n cmds = \"//push from local segment\"+\"\\n\"+\n pushFromSegment(\"LCL\", value, \"M\")\n\n when \"argument\"\n cmds = \"//push from argument segment\"+\"\\n\"+\n pushFromSegment(\"ARG\", value, \"M\")\n\n when \"static\"\n cmds = \"//push from static segment\"+\"\\n\"+\n \"@\"+fileName+value+\"\\n\"+\"D=M\"+\"\\n\"+pushToStack\n\n when \"constant\"\n cmds = \"//push constant to stack\"+\"\\n\"+\n \"@\"+value+\"\\n\"+\"D=A\"+\"\\n\" + pushToStack\n\n when \"temp\"\n cmds = \"//push from temp segment\"+\"\\n\"+\n pushFromSegment(\"5\", value, \"A\")\n\n when \"this\"\n cmds = \"//push from this segment\"+\"\\n\"+\n pushFromSegment(\"THIS\", value, \"M\")\n\n when \"that\"\n cmds = \"//push from that segment\"+\"\\n\"+\n pushFromSegment(\"THAT\", value, \"M\")\n\n when \"pointer\"\n cmds = pushFromSegment(\"3\", value, \"A\")\n else\n cmds = error\n end\n\n return cmds\nend", "def perform_write(command)\n @tcp_socket.send(command.to_bytes.pack('C*'), 0)\n end", "def emit_assembly(fname = \"output\")\n out_arr = Array.new\n pack_str = String.new\n \n @instr.each{|i|\n if i.instr_type == InstrBase::OPCODE\n out_arr.push(i.opcode.to_i(16))\n pack_str = pack_str + \"C\"\n next if i.args_len == 0\n \n if i.args_len == 1\n out_arr.push(i.args) \n pack_str = pack_str + \"C\"\n elsif i.args_len == 2\n #gotta remember to put it in correct order, i guess\n #ex: $31F6 -> F6,31, low-order byte is in lower memory, high-order byte in high memory\n out_arr.push(i.args) if \n pack_str = pack_str +\"S\"\n else\n raise \"Invalid opcode args found #{i}\"\n end\n\n elsif i.instr_type == InstrBase::MACRO\n raise \"Unknown macro found #{i.to_s}\" if i.sym_name != \"dcb\" \n #currently we only recognize dcb macro\n \n #simply emit a series of bytes as specified in @args of dcb macro\n i.args.each{ |i|\n out_arr.push(i)\n pack_str = pack_str + \"C\"\n }\n end # if i.instr_type == InstrBase::OPCODE\n }\n \n p \"#{pack_str}\"\n p \"#{out_arr}\"\n \n pack_str = out_arr.pack(pack_str)\n \n file = File.new(fname+\".assl\", \"wb\")\n file.puts(pack_str)\n file.close \n \n out_arr\n end", "def writeArithmetic(command)\n\t\tif command == \"add\"\n pop()\n\t\t\[email protected](\"//writing addition\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M+D\\n\")\n elsif command == \"sub\"\n pop()\n\t\t\[email protected](\"//writting subtraction\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M-D\\n\") \n elsif command == \"neg\"\n\t\t\[email protected](\"//negating\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=-M\\n\")\n elsif command == \"and\"\n pop()\n\t\t\[email protected](\"//writing and\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M & D\\n\")\n elsif command == \"or\"\n pop()\n\t\t\[email protected](\"//writing or\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=M | D\\n\")\n elsif command == \"not\"\n\t\t\[email protected](\"//writing not\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=!M\\n\")\n elsif command == \"eq\"\n label = \"negate\" + @counter.to_s\n\t\t\t@counter += 1\n pop()\n\t\t\[email protected](\"//eq\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"D=M-D\\n\")\n @file.write(\"@\" + label + \"\\n\")\n @file.write(\"D;JEQ\\n\")\n @file.write(\"D=1\\n\")\n @file.write(\"(\" + label + \")\\n\")\n @file.write(\"@SP\\n\")\n @file.write(\"A=M-1\\n\")\n @file.write(\"M=!D\\n\")\n elsif command == \"lt\"\n glJump(\"JLT\")\n elsif command == \"gt\"\n glJump(\"JGT\")\n\t\tend\n\tend", "def compile\n cmd = self.command\n#puts ' + ' + cmd\n log.debug \"Invoking the compiler\"\n rc = Platform.execute cmd\n log.debug \"Compilation complete; rc=#{rc.to_s}\"\n rc\n end", "def convertCommand(arr, i, fileName)\n op = arr[0] # the operation is the first word in the vm command\n opType = getOpType(op) # the type of operation each will have there own function\n\n case opType\n when \"arithmeticOp\"\n cmds = convertArithmetic(op)\n\n when \"compareOp\"\n #creating new jump locations for each conditional command\n jumpLocation = \"jumpLocation\"+i.to_s\n locationEnd = \"locationEnd\"+i.to_s\n cmds = convertCompare(op, jumpLocation, locationEnd)\n\n when \"pushPop\"\n segment = arr[1] #the segment is the second word in the vm command\n value = arr[2] #the value is the third word in the vm command\n cmds = convertPushPop(op, segment, value, fileName)\n\n when \"programFlowOp\"\n label = arr[1]\n cmds = convertProgramFlow(op, label)\n\n when \"functionOp\"\n label = arr[1]\n n = arr[2].to_i\n returnLocation = fileName+\"$ret.\"+i.to_s\n\n cmds = convertFunction(op, label, n, returnLocation)\n\n else\n cmds = error\n end\n\n return cmds\nend", "def writeArithmetic(command)\n\n if @arith_hash.has_key?(command) then\n\n File.open(@arith_hash[command],'r') do |infile|\n\terb = ERB.new(infile.read)\n\[email protected] erb.result(binding)\n\n $label_index=$label_index+1\n end\n\n else puts \"#{command} not supported. \\n\\n\"\n end\n\n end", "def do_instruction(opcode)\n sym_op = get_opcode(opcode)\n\n # Byte components\n b1 = (opcode & 0xf000) >> 12\n b2 = (opcode & 0x0f00) >> 8\n b3 = (opcode & 0x00f0) >> 4\n b4 = (opcode & 0x000f)\n\n # print \"Op: \", sym_op, \" | \"\n # print \"Desc: \", get_opcode_desc(opcode), \"\\n\"\n\n # Massive opcode conditional incoming.\n case sym_op\n\n when \"00E0\"\n # Clear the screen.\n @display.each do |row|\n row.each do |col|\n col = 0\n end\n end\n\n when \"00EE\"\n # Return from a subroutine.\n @instruction_ptr = @stack[@stack_ptr]\n @stack_ptr -= 1;\n\n when \"0NNN\"\n # This one isn't actually used by games. Skip it.\n\n when \"1NNN\"\n # Jump to address NNN.\n @instruction_ptr = opcode & 0x0fff\n\n when \"2NNN\"\n # Call subroutine at NNN.\n @stack_ptr += 1\n @stack[@stack_ptr] = @instruction_ptr\n @instruction_ptr = opcode & 0x0fff\n\n when \"3XNN\"\n # Skips next instruction if VX == NN.\n if @registers[b2] == opcode & 0x00ff\n @instruction_ptr += 2\n end\n\n when \"4XNN\"\n # Skips next instruction if VX != NN.\n if @registers[b2] != opcode & 0x00ff\n @instruction_ptr += 2\n end\n\n when \"5XY0\"\n # Skips next instruction if VX == VY.\n if @registers[b2] == @registers[b3]\n @instruction_ptr += 2\n end\n\n when \"6XNN\"\n # Sets VX to NN.\n @registers[b2] = opcode & 0x00ff\n\n when \"7XNN\"\n # Adds NN to VX.\n @registers[b2] += opcode & 0x00ff\n\n when \"8XY0\"\n # Sets VX to VY.\n @registers[b2] += @registers[b3]\n\n when \"8XY1\"\n # Sets VX to (VX or VY).\n @registers[b2] |= @registers[b3]\n\n when \"8XY2\"\n # Sets VX to (VX and VY).\n @registers[b2] &= @registers[b3]\n\n when \"8XY3\"\n # Sets VX to (VX xor VY).\n @registers[b2] ^= @registers[b3]\n\n when \"8XY4\"\n # Adds VY to VX. Sets VF to 1 when carry, 0 otherwise.\n # Only keep lowest 8 bits.\n @registers[b2] += @registers[b3]\n if @registers[b2] > 0xff\n @registers[0xf] = 1\n else\n @registers[0xf] = 0\n end\n @registers[b2] &= 0xff\n\n when \"8XY5\"\n # Subtracts VY from VX. Sets VF to 0 when borrow, 1 otherwise.\n # Only keep lowest 8 bits.\n @registers[b2] -= @registers[b3]\n if @registers[b2] < 0\n @registers[0xf] = 0\n else\n @registers[0xf] = 1\n end\n @registers[b2] &= 0xff\n\n when \"8XY6\"\n # Shifts VX right by one. Sets VF to the LSB of VX before the shift.\n @registers[0xf] = @registers[b2] % 2\n @registers[b2] >>= 1\n\n when \"8XY7\"\n # Sets VX to (VY - VX). Sets VF to 0 when borrow, otherwise 1.\n # Only keep lowest 8 bits.\n @registers[b2] = @registers[b3] - @registers[b2]\n if @registers[b2] < 0\n @registers[0xf] = 0\n else\n @registers[0xf] = 1\n end\n @registers[b2] &= 0xff\n\n when \"8XYE\"\n # Shifts VX left by one. Sets VF to the MSB of VX before the shift.\n @registers[0xf] = (@registers[b2] / 0b1000 > 0 ? 1 : 0)\n @registers[b2] = @registers[b2] << 1 & 0b0111\n\n when \"9XY0\"\n # Skips next instruction if VX == VY.\n if @registers[b2] != @registers[b3]\n @instruction_ptr += 2\n end\n\n when \"ANNN\"\n # Set address register to NNN.\n @addr_register = opcode & 0x0fff\n\n when \"BNNN\"\n # Set instruction pointer to address NNN + V0\n @instruction_ptr = (opcode & 0x0fff) + @registers[0]\n\n when \"CXNN\"\n # Set VX to a random number and NN.\n @registers[b2] = [*0..(opcode & 0x00ff)].sample\n\n when \"DXYN\"\n # TODO this should draw sprites, not just memory bits.\n # Draw N bytes of sprites starting from address register I,\n # at coordinates VX, VY. XORd onto screen. If any sprites overwritten,\n # set VF to 1, otherwise, 0. Wrap sprites if they go outside coordinates.\n overwritten = 0\n for i in 0..b4\n col_offset = (b2 + i) / 0x40\n new_row = (b3 + col_offset) % 0x20\n new_col = b2 % 0x40\n old_pixel = @display[new_row][new_col]\n new_pixel = @memory[@addr_register+i]\n result = old_pixel ^ new_pixel\n\n @display[new_row][new_col] = result\n if old_pixel == 1 and new_pixel == 0\n overwritten = 1\n end\n end\n\n @registers[0xf] = overwritten\n\n when \"EX9E\"\n # Skip the next instruction if the key stored in VX is pressed.\n if keypad[b2] == 1\n @instruction_ptr += 2\n end\n\n when \"EXA1\"\n # Skip the next instruction if the key stored in VX isn't pressed.\n if keypad[b2] == 0\n @instruction_ptr += 2\n end\n\n when \"FX07\"\n # Set VX to the value of the delay timer.\n @registers[b2] = @timers[:delay]\n\n # TODO\n when \"FX0A\"\n # A key press is awaited, and then stored in VX.\n\n when \"FX15\"\n # Sets the delay timer to VX.\n @timers[:delay] = b2\n\n when \"FX18\"\n # Sets the sound timer to VX.\n @timers[:sound] = b2\n\n when \"FX1E\"\n # Adds VX to I\n @instruction_ptr += b2\n\n # TODO\n when \"FX29\"\n # Set I to the location of the sprite for the character in VX. Characters\n # 0-F (in hexadecimal) are represented by a 4x5 font.\n\n # TODO\n when \"FX33\"\n # Store the BCD representation of Vx in memory locations I, I+1, and I+2.\n # The interpreter takes the decimal value of Vx, and places the hundreds\n # digit in memory at location in I, the tens digit at location I+1, and\n # the ones digit at location I+2.\n\n when \"FX55\"\n # Store V0 to VX in memory starting at address I.\n for i in 0..b2\n @memory[@instruction_ptr + i] = @registers[i]\n end\n\n when \"FX65\"\n # Fill V0 to VX with values from memory starting at address I.\n for i in 0..b2\n @registers[i] = @memory[@instruction_ptr + i]\n end\n end\n end", "def asm\n endian = Const::Endian::ENDIAN[arch]\n [code, jt, jf, k].pack(\"S#{endian}CCL#{endian}\")\n end", "def write_command(cmd, data='', synth=SYNTH_A)\n # Make sure cmd is valid\n raise \"unknown command #{cmd}\" unless LENGTH.has_key?(cmd)\n # Verify length of data to write\n if data.length != LENGTH[cmd]\n raise \"invalid data length for command #{cmd} \" +\n \"(expected #{LENGTH[cmd]}, got #{data.length})\"\n end\n # Make sure synth has no stray bits set\n synth &= (SYNTH_A|SYNTH_B)\n\n serialport do |sp|\n cmd = WR|synth|cmd unless cmd == CMD_WRITE_FLASH\n csum = Valon.generate_checksum(cmd.chr, data)\n cmd_data_csum = [cmd, data, csum].pack('CA*A')\n sp.write(cmd_data_csum)\n ack = sp.read(1).ord\n raise \"nak error (#{ack == NAK ? 'NAK' : ack.inspect})\" if ack != ACK\n end\n nil\n end", "def execute_current_instruction\n case read_register(REGISTER_C0)\n when SUM\n write_register(REGISTER_R0, read_register(read_register(REGISTER_D0)) + read_register(read_register(REGISTER_D1)))\n when COPY\n write_register(read_register(REGISTER_D1), read_register(read_register(REGISTER_D0)))\n when WRITE\n write_register(read_register(REGISTER_D1), read_register(REGISTER_D0))\n when JUMP\n write_register(REGISTER_M0, read_register(read_register(REGISTER_D0)))\n when JUMPX\n write_register(REGISTER_M0, read_register(read_register(REGISTER_D0))) if read_register(read_register(REGISTER_D1)) == 0\n when READ_MEM\n write_register(REGISTER_M4, Memory::READ)\n write_register(REGISTER_M5, read_register(read_register(REGISTER_D0)))\n write_register(REGISTER_M6, read_register(REGISTER_D1))\n when WRITE_MEM\n write_register(REGISTER_M4, Memory::WRITE)\n write_register(REGISTER_M5, read_register(read_register(REGISTER_D0)))\n write_register(REGISTER_M6, read_register(read_register(REGISTER_D1)))\n else\n raise UnknownInstruction.new(\"Instruction '#{read_register(REGISTER_C0)}' is undefined\")\n end\n end", "def proccess_command(command)\n # branch based on command type\n case command[0]\n when COMScript # script [code]\n # evaluate script\n result = eval(command[1])\n when COMWait # wait [int]\n # decrease wait counter by 1\n command[1] -= 1\n # proceed if wait time is up\n return command[1] <= 0\n when COMMove # move [int, int]\n # add to move commands\n @moves.push(command)\n when COMTurn # turn [int]\n # add to move commands\n @moves.push(command)\n when COMJump # jump [int, int]\n # add to move commands\n @moves.push(command)\n when COMAttack # attack\n # use attack\n @ch.use_attack\n when COMSkill # skill [int]\n # use skill\n @ch.use_skill($data_skills[command[1]])\n when COMItem # item [int]\n # use item\n @ch.use_item($data_items[command[1]])\n when COMDefend # defend [int]\n # decrease time\n time = command[1] - 1\n # use defend\n @ch.use_defend\n # set penalty\n @ch.set_action(1)\n # if not done with command\n if time > 0\n # update the command counter\n command[1] = time\n # do not proceed\n return false\n end\n when COMCharacter # character [CH, value]\n # handle based on sub-command\n case command[1]\n when CHSpeed # move speed\n # set movement speed\n @ch.move_speed = command[2]\n when CHFrequency # move frequency\n # set movement frequency\n @ch.move_frequency = command[2]\n when CHSprite # change sprite\n # set sprite\n @ch.character_name = command[2]\n when CHAnimation # play animation\n # set animation\n @ch.animation_id = command[2]\n when CHFix # direction fix\n # set direction fix flag\n @ch.direction_fix = command[2]\n when CHThrough # through\n # set through flag\n @ch.through = command[2]\n when CHOnTop # always on top\n # set always on top flag\n @ch.always_on_top = command[2]\n when CHOpacity # opacity\n # set opacity\n @ch.opacity = command[2] \n end\n when COMInput # create input window [int, [keys], IN, int]\n # create new input window\n @inputs[command[1]] = [command[2], command[3], command[4], false]\n when COMVariable # variable [VAR, value1, '=', VAR, value2]\n val1 = get_variable(command[1], command[2])\n val2 = get_variable(command[4], command[5])\n # branch handling based on operator type\n case command[3]\n when '+=' then val2 = val1 + val2 # add\n when '-=' then val2 = val1 - val2 # subtract\n when '*=' then val2 = val1 * val2 # multiply\n when '/=' then val2 = val1 / val2 # divide\n when '%=' then val2 = val1 % val2 # modulo\n end\n # set the variable\n set_variable(command[1], command[2], val2)\n when COMCondition # condition [VAR, value1, '==', VAR, value2]\n # initialize result\n result = false\n # initialize values\n val1 = get_variable(command[1], command[2])\n val2 = get_variable(command[4], command[5])\n # branch handling based on operator type\n case command[3]\n when '==' # equal to\n # result is value 1 equal to value 2\n result = val1 == val2\n when '!=' # not equal to\n # result is value 1 not equal to value 2\n result = val1 != val2\n when '>' # greater than\n # result is value 1 equal to value 2\n result = val1 > val2\n when '>=' # greater than or equal to\n # result is value 1 not equal to value 2\n result = val1 >= val2\n when '<=' # less than\n # result is value 1 equal to value 2\n result = val1 < val2\n when '<=' # less than or equal to\n # result is value 1 not equal to value 2\n result = val1 <= val2\n end \n # if input or script\n if command[1] == VARInput || command[1] == VARScript\n # value 1 contains the result\n result = val1\n # do not proceed if waiting on an input window\n if command[1] == VARInput && @inputs[command[2]][2] > 0 && !result\n return false\n end\n end\n # skip next command if exists and condition not met\n @commands.delete_at(1) if !result && @commands.size > 1\n when COMFreeze # freeze input [bool]\n # set freeze input flag\n @freeze_character = command[1]\n when COMCompletion # wait for move completion\n # proceed if no more moves and character no longer moving\n return @moves.size == 0 && [email protected]?\n when COMGoTo # go to action [int]\n raise 'ERROR: Invalid action' if !is_valid_action?(command[1])\n # setup the action\n setup_action(command[1])\n # do not proceed - new set of commands\n return false\n when COMAbort # abort\n # set ended flag\n @ended = true\n end\n return true\n end", "def translate(ast = nil)\n # Ensure that ast is a valid Abstract Syntax Tree\n if ast == nil or !ast.respond_to?(\"root\") or ast.root == nil\n raise @err_class, \"The Abstract Syntax Tree is either invalid or empty!\"\n else\n @ast = ast\n @code = []\n end\n\n # Get root node\n curr_node = ast.root\n if curr_node.name == \"QUIT\"\n @code.push(\"HALT\")\n elsif curr_node.name == \"HOWMANY\" or curr_node.name == \"HOWMUCH\"\n translate_query(curr_node)\n elsif curr_node.name == \"ASSIGN\"\n translate_assign(curr_node)\n end\n\n # Add common initialization code used in all statements\n @code.push(\"CLR $ar\") # Clear general purpose register #1\n @code.push(\"CLR $br\") # Clear general purpose register #2\n @code.push(\"CLR $nr\") # Clear numeral register\n @code.push(\"CLR $rr\") # Clear return register\n @code.push(\"CLR $sr\") # Clear stack register\n\n # Return virtual machine code\n return @code\n end", "def on_processing_instruction(target, data)\n STDOUT << \"on_characters\" << \"\\n\"\n \" target: \" << target << \"\\n\" <<\n \" data: \" << data << \"\\n\"\n STDOUT.flush\n end", "def commands_for_vm\n [{:write_file => {:filename => @filename, :content => @code}},\n {:execute => {:command => \"#{VM_PYTHON} -c \\\"compile(open('#{@filename}').read(), '', 'exec')\\\" && echo success\",\n :stdout => 'syntaxchecksuccess',\n :stderr => 'syntaxcheckfail'}}]\n # in this case execution only triggers the initial syntax check, the rest is handled\n # in postprocess_print\n end", "def program \n\t\n\t$cst.add_branch(\"Program\")\n\t\n\tblock\n\tmatch_token(\"T_EOFSIGN\", $tokens[$index])\n\nend", "def pushFromSegment(segment, value, location)\n str = \"//push from segment\"+\"\\n\"+\n getSegmentPosition(segment, value, location) + \"A=D\"+\"\\n\"+\"D=M\"+\"\\n\" + pushToStack\n return str\nend", "def opcode(op,cond,args) \"#{op}#{cond} #{args.join ','}\" end", "def execute(command)\n case command\n when 'M'\n move_forward\n when 'R'\n # rotate 90 right\n change_direction(DIRECTION_MAPPING[@direction] + 90)\n when 'L'\n # rotate 90 left\n change_direction(DIRECTION_MAPPING[@direction] - 90)\n end\n end", "def write_in_register(instruction)\n op_code, f = extract_op_code_and_modifier(instruction)\n register = select_register_from_op_code(op_code, Instructions::OP_ENTA)\n modified_address = calculate_modified_address(instruction)\n\n if f == Instructions::F_INCA or f == Instructions::F_DECA\n operation = 'increment_value'\n else\n operation = 'store_long'\n end\n if f == Instructions::F_DECA or f == Instructions::F_ENNA\n modified_address = 0 - modified_address\n end\n @logger.debug('Applying operation %s to %s ' % [operation, register]) if @logger.debug?\n register.send(operation, modified_address)\n end", "def command_type(instruction)\n instruction = instruction.strip\n if instruction[0] == \"@\"\n translate_a_instruction(instruction)\n else\n translate_c_instruction(instruction)\n end\n end", "def output(command)\n @buffer << command.gsub(/'/, '\"')\n end", "def asm buf = StringIO.new(''.b), metadata: {}, &block\n instance_eval(&block)\n write_to buf, metadata: metadata\n buf\n end", "def to_code(cc, out)\n\t\t\traise InternalError.new(\"#{self.class.name}: to_code not implemented\")\n\t\tend", "def emit_code value\n statement :code, value\n end", "def execute_DynamicJump\n method = get_register(@instruction.register)\n log.debug \"Register at: #{@instruction.register} , has #{method.class}\"\n pos = Position.get(method.binary)\n log.debug \"Jump to binary at: #{pos} #{method.name}:#{method.binary.class}\"\n raise \"Invalid position for #{method.name}\" unless pos.valid?\n pos = pos + Parfait::BinaryCode.byte_offset\n set_pc( pos )\n false\n end", "def emit(code)\n @code << code\n end", "def emit(code)\n @code << code\n end", "def emit(code)\n @code << code\n end", "def on(instruction, arguments, &bloc)\n @instructions[instruction] = [arguments, bloc]\n end", "def pipe_command(command)\n case command\n when :exit\n \"\\x00\"\n when :execute\n \"\\x01\"\n end\n end", "def send_command(command) \n command_str = command.to_encoded_str\n if @out_command_hasher\n send_frame command_str + @out_command_hasher.hash(command_str)\n else\n send_frame command_str\n end\n end", "def compile_to_c\n \"if (\" + @condition.compile_to_c + \") {\\n\" +\n indent_c(@then_part.compile_to_c) +\n \"\\n} else {\\n\" +\n indent_c(@else_part.compile_to_c) +\n \"\\n}\"\n end", "def resolveJZS(command)\r\n splitString = command.split(' ')\r\n currSymbol = splitString[1]\r\n intVal = Integer(currSymbol)\r\n if(@ZRBit == true)\r\n @PC = intVal\r\n puts \"Changing control to instruction at \" + @PC.to_s\r\n else\r\n puts \"Zero bit has not been set. Continuing to next instruction.\"\r\n end\r\n end", "def send_command_to_control(command, arg = \"\")\n Control.functions[__method__] ||= AU3_Function.new(\"ControlCommand\", 'SSSSSPI')\n buffer = \" \" * BUFFER_SIZE\n buffer.wide!\n Control.functions[__method__].call(@title.wide, @text.wide, @c_id.wide, command.wide, arg.to_s.wide, buffer, BUFFER_SIZE - 1)\n raise_unfound if AutoItX3.last_error == 1\n buffer.normal.strip\n end", "def call(jmp_addr, no_params, level) \n base << [level, sp-no_params+1]\n s[base.last[1]-1] = ni + 4\n self.ni = jmp_addr\n @jump = true\n end", "def processingInstruction(target, data)\n\t finishStartTag() if @inStartTag\n\t @io << \"<?#{target}\"\n\t @io << \" #{data}\" unless !data || data.empty?\n\t @io << \"?>\"\n\t @io << \"\\n\" if @prettify\n\tend", "def instruction name, instruction\n end", "def exec(opcode, arg)\n case opcode\n when 0\n self.acc = self.acc + ram.read(arg)\n when 1\n self.acc = self.acc - ram.read(arg)\n when 2\n self.acc = self.io.ask(\"> \", Integer)\n when 3\n self.io.say(\"--> #{self.acc}\")\n when 4\n ram.store(arg) { self.acc }\n when 5\n self.acc = ram.read(arg)\n when 6\n self.pc = arg\n when 7\n self.pc = arg if self.acc == 0\n when 8\n @running = false\n else\n raise \"Unknown instruction code #{opcode}\"\n end\n end", "def command(commands, zone = nil)\n params = {}\n\n if zone\n params[:ZoneName] = zone\n end\n\n Array(commands).flatten.each_with_index do |cmd, idx|\n params[\"cmd#{idx}\"] = cmd\n end\n\n request(\"/MainZone/index.put.asp\", params)\n end", "def write_cmd(buf)\n\tend", "def compilecmd(cmd)\n @compilator.compile(@resource[:runasdomain], @resource[:profile], cmd)\n end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def write_bytecode_to(value,target) \n target << Byte.new(value)\n @current_byte += 1 # pricti k celkove delce\n end", "def asmcmd( command, options = {})\n check_options( options )\n Puppet.debug \"Executing asmcmd command: #{command}\"\n os_user = options.fetch(:os_user) { default_asm_user}\n sid = options.fetch(:sid) { raise ArgumentError, \"you need to specify a sid for asm access\"}\n full_command = \"export ORACLE_SID=#{sid};export ORAENV_ASK=NO;. oraenv; asmcmd #{command}\"\n options = {:uid => os_user, :failonfail => true}\n Puppet::Util::Execution.execute(full_command, options)\n end", "def assembler(name, signature, code)\n @assembler_declarations << signature\n assembler_code = <<-CODE\n .file \"#{name}.S\"\n .arch #{Makefile.hardware_params['mcu']}\n .global __do_copy_data\n .global __do_clear_bss\n .text\n .global #{name}\n .type #{name}, @function\n #{code}\n CODE\n \n File.open(File.expand_path(\"#{RAD_ROOT}\") + \"/#{PROJECT_DIR_NAME}/#{name}.S\", \"w\"){|f| f << assembler_code}\n end", "def compile_statement\n # write_tag '<statement>'\n return compile_let_statement if check?(TokenType::LET)\n return compile_while_statement if check?(TokenType::WHILE)\n return compile_do_statement if check?(TokenType::DO)\n return compile_return_statement if check?(TokenType::RETURN)\n return compile_if_statement if check?(TokenType::IF)\n # write_tag '</statement>'\n end", "def command(binary, action, service, param = nil, sub_param = nil)\n [\n prepare_parameter(binary),\n action, # simple keyword does not need transformation\n prepare_parameter(service),\n prepare_parameter(param),\n prepare_parameter(sub_param, false) # last param does no need quoting\n ].reject(&:empty?).join ' '\n end", "def push(cmd); end", "def emit(code, options={})\n tab = options.has_key?(:tab) ? options[:tab] : \"\\t\"\n @code << \"#{tab}#{code}\\n\"\n end", "def send_command(house_and_unit, command)\n house_code, unit_code = select_code(house_and_unit)\n @marshaller.send(X10_PREFIX + house_code + unit_code + ADDRESS_SUFFIX)\n @marshaller.send(X10_PREFIX + house_code + COMMAND_CODE_TABLE[command] +\n COMMAND_SUFFIX)\n end", "def processing_instruction(data)\n end", "def queue(code)\n commands\n commands(@to) << unindent(code)\n end", "def handle(command)\n puts \"Doing #{command}...\"\n method = command\n case command\n when :north then method = :move\n when :south then method = :move\n when :east then method = :move\n when :west then method = :move\n when :up then method = :move\n when :down then method = :move\n end\n\n output = \"\"\n if method == :move\n output << self.send(method, command)\n else\n output << self.send(method)\n end\n\n output << \"\\n\"\n output << self.status\n\n output\n end", "def process_cmd(command, input_tokens)\n send command, input_tokens\n end", "def assemble\n @code.join\n end", "def set_jump_for(position)\n at = position.at\n code = position.object\n return unless code.next_code #dont jump beyond and\n jump = Branch.new(\"BinaryCode #{at.to_s(16)}\" , code.next_code)\n translator = @platform.translator\n cpu_jump = translator.translate(jump)\n pos = at + code.padded_length - cpu_jump.byte_length\n Position.create(cpu_jump).set(pos)\n cpu_jump.assemble(JumpWriter.new(code))\n end", "def rInvocationStmt\n res = rInvocation(prob(85) ? 'void' : nil)\n return '' if res.empty?\n return tab + res + ';\\n'\nend", "def send_command(command)\n # Enable the chip, set the DC line to COMMAND\n RPi::GPIO.set_low @cs\n RPi::GPIO.set_low @dc\n # Now send the command over the SPI line\n @spi.xfer(txdata: [command])\n # We're done, turn off CS\n RPi::GPIO.set_high @cs\n end", "def exec_opcode(bytecode, parameters)\n @cpu.exec_opcode(bytecode, parameters)\n end", "def method_append_stream\n case @opcode.arguments.size\n when 0\n @file.puts \" @stream << #{@opcode.bytecode}\"\n when 1\n @file.puts \" @stream << #{@opcode.bytecode} << arg1\"\n when 2\n @file.puts \" @stream << #{@opcode.bytecode} << arg1 << arg2\"\n end\n @file.puts \" @ip += #{@opcode.arguments.size + 1}\"\n end", "def write( &block )\n compile!( :write!, &block )\n end", "def print_instruction(instruction, idx)\n puts bold { \"[\" } + blue { idx.to_s } + bold { \"]\" } + \": \" + green { instruction.first } + \" \" + bold { instruction[1..-1].map(&:inspect) }\n end", "def command(index, &block)\n if index.is_a? Command\n cmd = index\n else\n cmd = Command.new\n cmd.index= index\n cmd.instance_eval(&block)\n end\n @commands = {} unless @commands\n @flags = [] unless @flags\n if cmd.flags?\n @flags << cmd.flags.short if cmd.flags.short?\n @flags << cmd.flags.long if cmd.flags.long?\n elsif cmd.index # just use index\n @flags << cmd.index.to_s\n else\n raise \"No index or flags were given to use this command.\"\n end\n if cmd.options?\n cmd.options.each do |_, option|\n if option.flags?\n @flags << option.flags.short if option.flags.short?\n @flags << option.flags.long if option.flags.long?\n else # just use index\n @flags << option.index.to_s\n end\n @commands[option.index] = option\n end\n end\n @commands[cmd.index] = cmd\n cmd\n end", "def write(cmd)\n\t \t @log.debug \"Tx: \"+cmd\n\t\t @sp.write cmd\n\t\t sleep 0.25 \n\t end", "def send_command(cmd)\n write cmd.chr\n end", "def generate\n tree = generate_syntax_tree\n source = []\n\n tree.butfirst.each do |production|\n non_terminal = production.first\n\n if non_terminal == :statement\n terminals = production.butfirst\n procedure = terminals.first\n arguments = terminals.butfirst\n\n # If we encounter an unknown procedure, we have to consider\n # it a fatal error.\n if mnemonic_exists?(procedure)\n source << eval_procedure(procedure, arguments)\n else\n raise Bolverk::ASM::SemanticError, \"Unknown procedure: '#{procedure.value}' at line #{procedure.line}.\"\n end\n end\n end\n\n source.join(\"\\n\")\n end", "def resolveJVS(command)\r\n splitString = command.split(' ')\r\n currSymbol = splitString[1]\r\n intVal = Integer(currSymbol)\r\n if(@OFBit == true)\r\n @PC = intVal\r\n puts \"Changing control to instruction at \" + @PC.to_s\r\n else\r\n puts \"Overflow has not been set. Continuing to next instruction.\"\r\n end\r\n end", "def call(*command); end", "def asmcmd( command, parameters = {})\n Puppet.debug \"Executing asmcmd command: #{command}\"\n os_user = parameters.fetch(:os_user) { ENV['GRID_OS_USER'] || 'grid'}\n full_command = \"export ORACLE_SID='+ASM1';export ORAENV_ASK=NO;. oraenv; asmcmd #{command}\"\n options = {:uid => os_user, :failonfail => true}\n Puppet::Util::Execution.execute(full_command, options)\n end", "def run_on_change(commands)\n \n project_name, target_name, config_name = commands.first.split(\"//\")\n builder = Xcode.project(project_name).target(target_name).config(config_name).builder\n\n UI.info \"[Guard::Xcoder] Performing [ #{@options[:actions].join(\", \")} ] for #{project_name} > #{target_name} > #{config_name}\"\n\n Array(@options[:actions]).each do |operation|\n builder.send(operation)\n end\n \n end", "def minilang(program)\n stack = []\n register = 0\n commands = program.split\n commands.each do |command|\n case command\n when 'PUSH' then stack << register\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register = register * stack.pop\n when 'DIV' then register = register / stack.pop\n when 'MOD' then register = register % stack.pop\n when 'POP' then register = stack.pop\n when 'PRINT' then puts register\n else register = command.to_i\n end\n end\n nil\nend", "def syscall_write\n buffer = \"\"\n addr = vm.read_mem(vm.read_reg(:sp) + 1)\n vm.read_mem(vm.read_reg(:sp) + 2).times do |i|\n buffer << vm.read_mem(addr + i).chr\n end\n print buffer\n end", "def statement \n\n\t$cst.add_branch(\"Statement\")\n\n\tcase scout_token\n\twhen \"T_PRINT\"\n\t\tprint_stmt\n\twhen \"T_ID\"\n\t\tassignment_stmt\n\twhen \"T_TYPE\"\n\t\tvardecl\n\twhen \"T_WHILE\"\n\t\twhile_stmt\n\twhen \"T_IF\"\n\t\tif_stmt\n\twhen \"T_LBRACE\"\n\t\tblock\n\telse\n\t\traise FaultyTokenError.new(\"T_PRINT, T_ID, T_TYPE, T_WHILE, T_IF, or T_LBRACE\", $tokens[$index])\n\tend\n\t\n\t$cst.ascend\n\t\nend", "def compile(filename)\n # First pass - define labels\n elements.each do |codeline|\n codeline.register_labels\n @@position += codeline.size\n end\n\n # Second pass - write to binary file\n File.open(filename, 'wb') do |f|\n elements.each do |codeline|\n f.write codeline.to_bin\n end\n end\n end", "def command_translate\n command :translate do |c|\n c.syntax = 'budik translate [options]'\n c.summary = @str_translate.summary\n c.description = @str_translate.description\n c.action { |args, _opts| Command.new(:translate, args) }\n end\n end", "def method_stack_effect\n read = @opcode.static_read_effect\n write = @opcode.static_write_effect\n\n if @opcode.extra\n if read > 0\n read = \"arg#{@opcode.extra+1}+#{read}\"\n else\n read = \"arg#{@opcode.extra+1}\"\n end\n end\n\n if @opcode.produced_extra\n if write > 0\n write = \"(arg#{@opcode.produced_extra+1} * #{@opcode.produced_times})+#{write}\"\n else\n write = \"(arg#{@opcode.produced_extra+1} * #{@opcode.produced_times})\"\n end\n end\n\n @file.puts \" @current_block.add_stack(#{read}, #{write})\"\n end", "def compile( method_name, op: 1, ret: 1 )\n @opts = { op: op, ret: ret }.tap do |oo|\n oo.define_singleton_method :op do self[:op] end\n oo.define_singleton_method :ret do self[:ret] end\n end\n\n # Set up compile-time argument sourcing.\n @argsrc = ArgumentSource.new\n\n # Write the method skeleton.\n initialize_writer_state\n write_method_head_skeleton( method_name )\n write_initial_pipeline\n write_method_tail_skeleton\n\n # Now that we have the skeleton, let's write the meat.\n write_method_meat\n\n puts \"head is #@head\\npipe is #@pipe\\ntail is #@tail\" if Pyper::DEBUG > 1\n\n # Finally, close any blocks and return\n autoclose_open_blocks_and_return\n end", "def command\n return nil unless commands\n\n # Map commands to template & chain\n commands.map(&method(:template_command_with_output_cleaned)).join(' && ')\n end", "def execute( command, timeout=6 )\n send_question( { type: 'code', message: command }, timeout)\n end", "def to_bytecode\n bytecode = []\n case @op\n when 'println'\n comp_arg(@args[0], bytecode)\n bytecode.push(PRINT_OP)\n when '+'\n comp_arg(@args[0], bytecode)\n comp_arg(@args[1], bytecode)\n bytecode.push(ADD_OP)\n if @args.length > 2\n @args[[email protected]].each do |arg|\n comp_arg(arg, bytecode)\n bytecode.push(ADD_OP)\n end\n end\n when '-'\n comp_arg(@args[0], bytecode)\n comp_arg(@args[1], bytecode)\n bytecode.push(SUB_OP)\n if @args.length > 2\n @args[[email protected]].each do |arg|\n comp_arg(arg, bytecode)\n bytecode.push(SUB_OP)\n end\n end\n when '*'\n comp_arg(@args[0], bytecode)\n comp_arg(@args[1], bytecode)\n bytecode.push(MUL_OP)\n if @args.length > 2\n @args[[email protected]].each do |arg|\n comp_arg(arg, bytecode)\n bytecode.push(MUL_OP)\n end\n end\n else\n raise \"Unrecognized op '#{@op}'\"\n end\n bytecode # Returning bytecode\n end", "def putAnnotation(text)\n raise unless @state == :asm\n if $enableInstrAnnotations\n @outp.puts text\n @annotation = nil\n end\n end" ]
[ "0.67036366", "0.6270412", "0.6198958", "0.60747766", "0.6072834", "0.58584106", "0.5668081", "0.5628354", "0.5605948", "0.5588802", "0.55512863", "0.5542404", "0.55178785", "0.5511275", "0.5497258", "0.5452286", "0.5390342", "0.5356419", "0.535463", "0.53124267", "0.5308719", "0.5290152", "0.52791685", "0.5246901", "0.51725715", "0.51585215", "0.5144748", "0.5137613", "0.511876", "0.5104814", "0.510234", "0.5096409", "0.5072414", "0.50333565", "0.50214386", "0.49938184", "0.49881637", "0.49787602", "0.49722943", "0.49613044", "0.49603602", "0.4953606", "0.4953606", "0.4953606", "0.49528363", "0.49524385", "0.4933725", "0.49189252", "0.4903813", "0.4896968", "0.4892501", "0.4887332", "0.4882318", "0.48806393", "0.48605824", "0.4856388", "0.4855032", "0.48514435", "0.48514435", "0.48514435", "0.48514435", "0.48441127", "0.48279837", "0.48277816", "0.48186716", "0.4813633", "0.48077452", "0.48050174", "0.48006657", "0.47985077", "0.47979033", "0.4790391", "0.47872972", "0.4779128", "0.47726622", "0.47707668", "0.4768341", "0.4765391", "0.47623146", "0.47593668", "0.47564158", "0.4749593", "0.4744854", "0.47370714", "0.47361138", "0.4729805", "0.47277552", "0.47207376", "0.47172168", "0.47137895", "0.47124818", "0.47060367", "0.46983162", "0.46954834", "0.4693775", "0.46924207", "0.4691637", "0.469102", "0.46873903", "0.46830487" ]
0.7189954
0
Closes the output file PARAMETER void RETURN void
def Close end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close_file\r\n end", "def close(filename); end", "def close()\n @file.close\n end", "def close\n @file.close\n end", "def close\n CoreServices::asl_close_output_file(@context, @dest.to_i) if @dest\n CoreServices::asl_finalize_context(@context)\n @context = nil\n end", "def close\n out.close\n end", "def close\n @fh.close\n end", "def close\n\t\[email protected]\n\tend", "def close_write\n if @output.respond_to?(:close)\n @output&.close\n end\n\n @output = nil\n end", "def close\n @output.write('', :reloaded)\n @output.close\n end", "def close\n close_data_file\n end", "def file_end(file, output)\n end", "def close\n\t\t@file_handle.close\n\tend", "def close\n\t\t@file_handle.close\n\tend", "def close\n\t io.each { |file| file.close }\n\tend", "def finish\n\t\tclose\n\tend", "def close_files\n @input_file.close if @input_file\n @output_file.close if @output_file\n @error_file.close if @error_file\n end", "def close_write; end", "def close_write() end", "def close_write() end", "def close_write() end", "def close\n\t @file_desc.close\n\tend", "def finish\n\t\t\tclose\n\t\tend", "def close\n @prime_file.close\n end", "def closing; end", "def closing; end", "def close\n @handle.closeFile\n @handle = nil\n end", "def close!\n finish!\n @fd.close\n end", "def close\n $file.close\t\t\t\t# Closes the log file\n puts \"Files flushed properly\"\t\t# Basically means that file has been closed properly instead of force quitting which MAY/COULD result in \t\t\t\t\t\t#memory leaks\n abort(\"Exiting\")\t\t\t# Actually exits the game but not before outputting 'Exiting'\nend", "def close_write(*) end", "def close; @tempfile.close; end", "def close() end", "def close() end", "def close() end", "def close() end", "def close() end", "def close\n writer.close\n end", "def close\n\t\t@file_handle << \"</tbody></table></div></body></html>\"\n\t\t@file_handle.close\n\tend", "def close_buffer\n return @output_stream if @closed\n\n finalize_current_entry\n update_local_headers\n @cdir.write_to_stream(@output_stream)\n @closed = true\n @output_stream.flush\n @output_stream\n end", "def close\n flush\n f.close\n end", "def close\n @log_file.close\n end", "def do_close; end", "def close_file\n if is_file_open?\n @file_handle.close\n \n # reset 'flags' variables and position\n @file_handle = nil\n @position = 0\n end\n end", "def close_file\n if is_file_open?\n @file_handle.close\n \n # reset 'flags' variables and position\n @file_handle = nil\n @position = 0\n end\n end", "def close\n io = finish()\n io.close if io.respond_to? :close\n io\n end", "def close\n\n # nothing to do here.\n end", "def close()\n unless fh.nil?\n # redirected.each { |rd| rd.close }\n\n fh.close if fhmustclose\n\n self.fh = nil\n self.fhmustclose = nil\n # self.redirected = []\n end\n end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def output(filename)\r\n outs = File.new(filename , \"w\")\r\n outs.puts self.to_s\r\n outs.close\r\n end", "def close_data_file\n @data_file.close unless @data_file.closed?\n end", "def close!\n end", "def close\n return if @closed\n\n finalize_current_entry\n update_local_headers\n @cdir.write_to_stream(@output_stream)\n @output_stream.close\n @closed = true\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def ending\n @io.close\n end", "def close_write\n\t\t\t\n\t\tend", "def close\n @io.close\n @tar.close\n end", "def _close\n end", "def close\n @input.close unless !@input || @input.closed?\n @output.close unless !@output || @output.closed?\n end", "def close\n Nvmkv.kv_close(@kv_id)\n f= IO.open(@file_fd).close\n end" ]
[ "0.7832121", "0.75325537", "0.74706846", "0.7426678", "0.74094415", "0.7264086", "0.72565323", "0.724619", "0.7234656", "0.7212737", "0.7063339", "0.70421314", "0.7026591", "0.7026591", "0.69607055", "0.6918237", "0.69101614", "0.6895036", "0.68911344", "0.68911344", "0.68911344", "0.6864131", "0.6848437", "0.6834249", "0.681678", "0.681678", "0.6801919", "0.6799096", "0.67983717", "0.67424166", "0.66853213", "0.66812396", "0.66812396", "0.66812396", "0.66812396", "0.66790676", "0.6658512", "0.66274434", "0.66241574", "0.6579539", "0.65737855", "0.65714395", "0.6543041", "0.65422785", "0.65334475", "0.65243876", "0.6512719", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6512672", "0.6448711", "0.6448711", "0.6448711", "0.6448711", "0.6448711", "0.6448711", "0.6448711", "0.6448711", "0.6448711", "0.64092964", "0.64067966", "0.63952047", "0.6395094", "0.6389021", "0.6389021", "0.6389021", "0.6389021", "0.6389021", "0.6389021", "0.6389021", "0.6389021", "0.6389021", "0.6379055", "0.6366937", "0.6359861", "0.63584834", "0.6349625", "0.6342784" ]
0.0
-1
TODO: Add 'add' method to add a substring of a String.
def <<(other) if other.respond_to?(:to_int) return self << ('' << other) end @chain << SubString.new(@size, other) @size += other.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def substring(str, substr)\n\nend", "def substrings(string)\r\n \r\nend", "def substrings(string)\n\nend", "def substrings_at_start(string)\n array_of_strings = []\n split_string = string.split('')\n substring = ''\n split_string.each_index do |position|\n substring += split_string[position]\n array_of_strings << substring\n end\n array_of_strings\nend", "def custom_start(str, sub_str)\n str_plc, sub_len = str, sub_str.length\n #str_plc.slice(0, sub_len) == sub_str\n str_plc[0, sub_len] == sub_str\nend", "def substrings_at_start(str)\n results = []\n substring = ''\n \n str.chars.each do |char|\n substring += char\n results << substring\n end\n \n results\nend", "def full_text_after_substring\n if include_substring?\n self.split( @substring )[1] || \"\"\n else\n self.unpack( \"U*\" )[ self.unpack( \"U*\" ).size/2+1..-1 ].pack( \"U*\" )\n end\n end", "def custom_start_with(string, substring)\n string[0, substring.length] == substring\nend", "def substring(string, beg_idx, end_idx = beg_idx)\n string[beg_idx..end_idx]\nend", "def add_rutabaga_to_string(str)\n str << \"rutabaga\"\nend", "def full_text_before_substring\n if include_substring?\n self.split( @substring )[0] || \"\"\n else\n self.unpack( \"U*\" )[ 0..self.unpack( \"U*\" ).size/2 ].pack( \"U*\" )\n end\n end", "def substrings_at_start(string)\n sub_strings = []\n 1.upto(string.size) do |count|\n sub_strings << string[0, count]\n end\n\n sub_strings\nend", "def substrings_at_start(string)\n substrings = []\n 1.upto(string.length) do |index|\n substrings << string.slice(0, index)\n end\n substrings\nend", "def substrings_at_start(string)\n susbtrings = []\n string.size.times do |count|\n susbtrings << string.slice(0, count + 1)\n end\n susbtrings\nend", "def substrings_at_start(str)\r\n chars = str.chars\r\n chars.each_with_object([]).with_index { |(el,memo), idx| memo << chars.take(idx+1).join('').to_s }\r\nend", "def substrings_at_start(str)\n new_arr = []\n 1.upto(str.size) do |count| \n substring = ''\n substring += str.slice(0, count)\n new_arr << substring\n end\n new_arr\nend", "def substrings_at_start(string)\n length = 0\n substrings = []\n while length < string.size\n substrings << string[0..length]\n length += 1\n end\n substrings\nend", "def concat(str)\n @string << str\n self\n end", "def custom_includee(string, substring)\n string.split(substring).length != 1\nend", "def substrings(string)\n results = []\n (0...string.size).each do |start_index|\n this_substring = string[start_index..-1]\n results.concat(substrings_at_start(this_substring))\n end\n results\nend", "def substring(str)\n subs = []\n start_idx = 0\n 0.upto(str.length - 2) do |i1|\n 1.upto(str.length - 1) do |i2|\n subs << str[i1..i2] if i2 > i1\n end\n end\n subs\nend", "def substrings_at_start(string)\n sum_total = []\n arr = string.split(\"\")\n 1.upto(arr.size) do |count|\n sum_total << arr.slice(0, count).reduce(:+)\n end\n sum_total\nend", "def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |index|\n result << string[0..index]\n end\n result\nend", "def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |index|\n result << string[0..index]\n end\n result\nend", "def assert_contains(expected_substring, string, *args)\r\n assert(string.include? expected_substring)\r\n end", "def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |idx|\n result << string[0..idx]\n end\n p result\nend", "def is_substring?(s1, s2) \n return s1.include?(s2)\nend", "def substrings_at_start(string)\n # Create a new array to store our substring in\n new_array = []\n\n # We call the upto method to go from 0 up until the size of the string - 1\n # to know when to stop iterating.\n 0.upto(string.size - 1) do |index|\n\n # We will append the substring that starts at the beginning, in this case 'a'\n # and since it's index is 0, we're only going to return 'a' on the first iteration.\n # However, on the second iteration we will be returning the substring 'ab'\n # since we're returng in the string starting at index 0 to index 1 # => 'ab' and so on.\n new_array << string[0..index]\n end\n\n # Return our array with substrings\n new_array\nend", "def add_string(string)\n @strings << string\n end", "def substrings_at_start(string)\n results = []\n\n string.chars.each_with_index do |char, index|\n results << string.chars[0..index].inject(:+)\n end\n results\nend", "def substrings_at_start(string)\n substrings = []\n counter = 1\n\n until counter > string.size\n substrings << string[0, counter]\n counter += 1\n end\n\n substrings\nend", "def substrings_at_start(string)\n substrings = []\n counter = 1\n\n until counter > string.size\n substrings << string[0, counter]\n counter += 1\n end\n\n substrings\nend", "def find_substring(string, substring)\n\n sub_len = substring.length\n # 3\n str_len = string.length\n # 5\n i = 0\n\n\n (str_len - sub_len).times do\n # 2\n if string[i] == substring[0]\n if string[i..(i+sub_len-1)] == substring\n # sublen -1 because starting on first letter\n return true\n end\n end\n i += 1\n end\n\n false\nend", "def substrings_at_start(string)\n substrings = []\n string.length.times do |i|\n substrings.push(string[0..i])\n end\n\n substrings\nend", "def substrings_at_start(str)\n\n results = []\n\n str.chars.each_with_index do |ss, idx|\n results << str.slice(0..idx)\n end\n\n results\n\nend", "def customStartWith(string, substring)\n result = false\n substrLen = substring.length\n target = string[0, substrLen]\n result = true if substring == target\n result\nend", "def substrings_at_start(str)\n subs = []\n str.size.times { |i| subs << str[0..i] }\n subs\nend", "def function(str,start_position, end_position) #the method of return substring\n\tstr1=str.split(\"\")\n\tstr2=[]\n\tj=0\n\tfor i in start_position-1...end_position\n\t\tstr2[j]=str1[i]\n\t\tj+=1\n\tend\n\treturn str2\nend", "def substrings(string)\n 0.upto(string.chop.size).with_object([]) do |idx, arr|\n arr.concat(subsubstrings(string[idx..-1]))\n end\nend", "def substring?(long_string, short_string)\n\nend", "def substrings_at_start(string)\n substrings = []\n string.chars.each_with_index do | _, idx |\n substrings << string.slice(0..idx)\n end\n substrings\nend", "def substrings(string)\n result = []\n 0.upto(string.length - 1) do |index|\n 1.upto(string.length - index) do |length|\n result << string[index,length]\n end\n end\n result\nend", "def substrings(string)\n substrs = []\n string.size.times do |idx|\n string.size.times do |idx2|\n substrs << string[idx..idx2]\n end\n end\n substrs.delete('')\n substrs\nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |substring|\n result << string.slice(0, substring)\n end\n result\nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |substring|\n result << string.slice(0, substring)\n end\n result\nend", "def substrings_at_start(string)\n result = []\n index = 0\n while index < string.size\n result << string[0..index]\n index += 1\n end\n result\nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |index|\n result << string.slice(0, index)\n end\n result\nend", "def substrings(string)\n result = []\n 0.upto(string.size-1) do |index1|\n index1.upto(string.size-1) do |index2|\n result << string[index1..index2]\n end \n end\n result\nend", "def substrings(str)\r\n result = []\r\n starting_index = 0\r\n num_chars = 2\r\nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.length) { |n| result << string.slice(0, n) }\n result\nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.length) { |n| result << string.slice(0, n) }\n result\nend", "def substrings(str)\n subs = []\n\n (0...str.length).each do |start_idx|\n (start_idx...str.length).each do |end_idx|\n subs << str[start_idx..end_idx]\n end\n end\n\n subs\nend", "def insert_string(str)\n bytes = str.codepoints << 0\n # To keep the alignment we need to pad the new string we're inserting.\n # In total, we're adding the string bytes + 2 bytes string length + 4 bytes string index.\n padding = (4 - (bytes.size * 2 + 2 + 4) % 4) % 4\n padding_bytes = [0] * padding\n next_string_offset = new_string_offset\n\n string_bytes = ResStringPool.utf16_str_len(str.codepoints) + bytes.pack('v*') + padding_bytes.pack('C*')\n\n # Write string data into the string data section.\n @data.insert(next_string_offset, string_bytes)\n # Insert new string index entry. The offset needs to be relative to the start of the string data section.\n @data.insert(last_string_index_offset + 4, [next_string_offset - (@offset + @string_start)].pack('V'))\n\n # We added the bytes of the string itself + a new string index entry\n string_bytes.size + 4\n end", "def is_substring?(s1, s2)\n s1.include?(s2) #disregarding efficiency, method is assumed to be given\nend", "def string_with_rutabaga(str)\n str += \"rutabaga\"\nend", "def concat(str)\n @string.concat str\n end", "def substrings(str)\r\n result = []\r\n starting_index = 0;\r\n \r\n while (starting_index <= str.length - 2)\r\n num_chars = 2\r\n while (num_chars <= str.length - starting_index)\r\n substring = str.slice(starting_index, num_chars)\r\n result << substring\r\n num_chars += 1\r\n end\r\n starting_index += 1\r\n end\r\n result\r\nend", "def substrings(str)\r\n result = []\r\n starting_index = 0;\r\n \r\n while (starting_index <= str.length - 2)\r\n num_chars = 2\r\n while (num_chars <= str.length - starting_index)\r\n substring = str.slice(starting_index, num_chars)\r\n result << substring\r\n num_chars += 1\r\n end\r\n starting_index += 1\r\n end\r\n result\r\nend", "def substrings_at_start(str)\n index = 0\n length = 1\n arry = []\n\n while length <= str.size\n arry << str[index, length]\n length += 1\n end\n arry\nend", "def substrings_at_start(str)\n index = 0\n length = 1\n arry = []\n\n while length <= str.size\n arry << str[index, length]\n length += 1\n end\n arry\nend", "def substrings_at_start(str)\n index = 0\n length = 1\n arry = []\n\n while length <= str.size\n arry << str[index, length]\n length += 1\n end\n arry\nend", "def substrings_at_start(string)\n result = []\n string.length.times { |idx| result << string[0..idx] }\n result\nend", "def substrings_at_start(string, initial_index)\n result = []\n 0.upto(string.size-1) do |i|\n result << string[initial_index..i]\n end\n result\nend", "def substrings(string)\n arr = []\n string.each_char.with_index do |char1, idx1|\n arr << char1\n \n idx2 = idx1 + 1\n while idx2 < string.length\n arr << string[idx1..idx2]\n \n idx2 += 1\n end\n \n end\n\n arr\nend", "def substrings_at_start(string)\n string.size <= 1 ? [string] : [*substrings_at_start(string.chop), string] \nend", "def add_string str\n code = @string_table[str]\n return code if code\n data = Vm::StringConstant.new(str)\n @string_table[str] = data\n end", "def substrings_at_start(string)\n substring = string\n results = []\n n = -1\n \n string.length.times do\n results << substring\n substring = substring.chop\n end\n \n results.reverse\nend", "def substrings_at_start(string)\n results = []\n\n string.length.times do |count|\n results << string.slice(0, count +1)\n end\n results\nend", "def <<(string)\n @string << string\n self\n end", "def substrings_at_start(string)\n count = 0\n new_array = []\n while count < string.length\n new_array << string[0..count]\n count += 1\n end\n new_array\nend", "def substrings_at_start(string)\n count = 0\n new_array = []\n while count < string.length\n new_array << string[0..count]\n count += 1\n end\n new_array\nend", "def substrings_at_start(str)\n result = []\n index = 0\n while index < str.size\n result << str[0..index]\n index += 1\n end\n result\nend", "def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |index| # iterates from 0 to the string size.\n result << string[0..index] # iterates each index from 0..0 to 0..index, which is string size.\n end\n result\nend", "def substrings(str)\n result = []\n start_substring_idx = 0\n end_substring_idx = start_substring_idx + 1\n\n loop do \n break if start_substring_idx == (str.size - 1)\n\n loop do \n break if end_substring_idx == str.size\n result << str[start_substring_idx..end_substring_idx]\n end_substring_idx += 1\n end\n\n start_substring_idx += 1\n end_substring_idx = start_substring_idx + 1\n end\n\n result\nend", "def substrings_at_start(string)\n leading_substrings = []\n 0.upto(string.size - 1) do |index|\n leading_substrings << string.slice(0..index)\n end\n \n leading_substrings\nend", "def substrings_at_start(string)\n array = []\n for i in (0..string.length - 1)\n array << string[0..i]\n end\n array\nend", "def substrings_at_start(string)\n string.size.times.with_object([]) { |idx, arr| arr << string[0..idx] }\nend", "def substrings_at_start(string)\n string_array = string.chars\n array_final = []\n\n 1.upto(string.size) do |count|\n array_final << string_array.slice(0, count).join\n end\n array_final\nend", "def custom_index(string, substring)\n return nil unless string.include?(substring)\n length = substring.length\n string.chars.each_with_index do |char, index|\n sequence = string[index, length]\n return index if sequence == substring\n end\nend", "def substrings(string)\n results = []\n (0...string.size).each do |start_index|\n this_substring = string[start_index..-1]\n results.concat(leading_substrings(this_substring))\n end\n results\nend", "def substrings(string)\n results = []\n (0...string.size).each do |start_index|\n this_substring = string[start_index..-1]\n results.concat(leading_substrings(this_substring))\n end\n results\nend", "def substrings(string)\n results = []\n (0...string.size).each do |start_index|\n this_substring = string[start_index..-1]\n results.concat(leading_substrings(this_substring))\n end\n results\nend", "def substring_of_string(string, substring)\n sub_i = 0\n\n string.each_char.with_index do |char, i|\n if substring[sub_i] == char\n return true if sub_i == substring.length - 1\n sub_i += 1\n else\n if substring[0] == char\n sub_i = 1\n else\n sub_i = 0\n end\n end\n end\n\n false\nend", "def substrings_at_start(string)\n \n new_array = []\n string.size.times do |idx|\n new_array << string[0..idx]\n end\n new_array\nend", "def substrings_at_start(string)\n string.size.times.with_object([]) { |idx, arr| arr << string.chars.take(idx + 1).join}\nend", "def substrings_at_start(str)\n str.chars.map.with_index { |_, idx| str[0, idx + 1] }\nend", "def substrings_at_start2(str)\n result = []\n (0..str.size - 1).each { |idx| result << str[0..idx] }\n result\nend", "def custom_index(string,substring)\n return nil unless string.include?(substring)\n length = substring.length\n string.chars.each_with_index do |char, index|\n sequence = string[index, length]\n return index if sequence == substring\n end\nend", "def substrings(string)\n result = []\n string.size.times do |index|\n result << substrings_at_start(string[index..-1])\n end\n result.flatten\nend", "def substrings_at_start(str)\n results = []\n count = 1\n \n str.size.times do\n results << str.slice(0, count)\n count += 1\n end\n results\nend", "def add_string(string) \n unless @strings.include? string\n @strings[string] = self.strtab.num_bytes\n self.strtab << BinData::Stringz(string)\n end\n @strings[string]\n end", "def substrings_at_start(string)\n string.chars.map.with_index { |_, index| string[0..index] }\nend", "def substrings_at_start(string)\n string.split(\"\").map.with_index do |_, index|\n string[0..index]\n end\nend", "def concat(string); end", "def substrings(string)\n array = []\n\n string.length.times do |index|\n this_substring = string[index..-1]\n array << substrings_at_start(this_substring)\n end\n array.flatten\nend", "def substrings_at_index(string, index)\n substrings_at_index = []\n index.upto(string.size - 1) do |num|\n substrings_at_index << string[index..num]\n end\n substrings_at_index\nend", "def substrings_at_start(string)\n results = []\n\n string.length.times do\n results << string\n string = string.chop\n end\n\n results.reverse\nend", "def substrings(str)\n str_arr = []\n 0.upto(str.length - 2) do |index|\n index.upto(str.length - 1) do |sub_endpoint|\n str_arr << substring(str, index, sub_endpoint ) unless index == sub_endpoint\n end\n end\n str_arr\nend", "def substrings_starting_at(string, index)\n substrings_at = []\n string = string[index...string.size]\n (0...string.size).each do |index|\n substrings_at << string[0..index]\n end\n substrings_at\nend", "def substrings(str)\n chars = str.chars\n substrings = []\n loop do\n break if chars.empty?\n chars.size.times do |idx|\n substrings << chars[0..idx].join\n end\n chars.shift\n end\n substrings\nend", "def substrings_at_start(string)\n (0...string.size).map do |length|\n string[0..length]\n end\nend" ]
[ "0.7156744", "0.71398467", "0.7124913", "0.6411755", "0.63850194", "0.6384808", "0.63287574", "0.63226795", "0.6221136", "0.6129629", "0.6093209", "0.6089252", "0.60675454", "0.6066548", "0.60664225", "0.6064077", "0.60554165", "0.6047874", "0.6043105", "0.602087", "0.60111535", "0.600802", "0.5998681", "0.5998681", "0.5996664", "0.5994544", "0.5990929", "0.59887636", "0.59866893", "0.5982351", "0.5957962", "0.5957962", "0.59567314", "0.59554505", "0.59537405", "0.5948528", "0.5948411", "0.5946157", "0.59448624", "0.5941589", "0.5940398", "0.5939841", "0.59379077", "0.5937214", "0.5937214", "0.59294677", "0.5924246", "0.5907634", "0.5905661", "0.59037024", "0.59037024", "0.5894384", "0.5894239", "0.58896106", "0.5886806", "0.58790135", "0.5875823", "0.5875823", "0.58664274", "0.58664274", "0.58664274", "0.5864015", "0.5854894", "0.5853598", "0.5852544", "0.5851436", "0.5845827", "0.5844152", "0.5841638", "0.58414584", "0.58414584", "0.583413", "0.5826023", "0.5825888", "0.5825871", "0.5825627", "0.5822055", "0.58114624", "0.5803948", "0.58028823", "0.58028823", "0.58028823", "0.579913", "0.57877517", "0.576954", "0.57684726", "0.5766208", "0.5760612", "0.5758143", "0.57546103", "0.57497084", "0.5749193", "0.57335067", "0.57328796", "0.5730798", "0.5730676", "0.5729013", "0.57274514", "0.5726142", "0.5724721", "0.57232827" ]
0.0
-1
State transition tables end reduce 0 omitted
def _reduce_1(val, _values, result) result = val[0] result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transitions; end", "def closure! \n cstart = new_state\n cend = new_state\n\n add_transition(cstart, cend, \"\")\n add_transition(cend, cstart, \"\")\n\n add_transition(cstart, @start, \"\")\n @final.keys.each { |key| add_transition(key, cend, \"\")}\n\n set_start(cstart)\n @final.keys.each { |key| set_final(key, false)}\n set_final(cend, true)\n\n\n end", "def closure! \n\t\ttemp = new_state\n\t\tadd_transition(temp, @start, \"\")\n\t\t@start = temp\n\t\ttemp = new_state\n\t\[email protected] { |x| \n\t\tadd_transition(x, temp, \"\") \n\t\tset_final(x, false) }\n\t\t\n\t\t@final = {temp=>true}\n\t\tadd_transition(@start, temp, \"\")\n\t\tadd_transition(temp, @start, \"\")\n\t\[email protected](nil)\n\t\[email protected](nil)\n end", "def finished_states\n states - transitive_states\n end", "def end_transition\n nil\n end", "def transition_at; end", "def transition_at; end", "def rest\n @state -= 1 if @state > 2\n @state += 1 if @state < 2\n end", "def closure!\ns0 = new_state\ns1 = new_state\nadd_transition(s0, @start, \"\")\n# reset the final states of the current object\nkeys = @final.keys\ni = 0\nwhile i < keys.size\nadd_transition(keys[i], s1, \"\")\nset_final(keys[i], false)\ni = i + 1\nend\nadd_transition(s0, s1, \"\")\nadd_transition(s1, s0, \"\")\nset_start(s0)\nset_final(s1, true)\nend", "def up\n @state -= 1 unless @state == 0\n @y -= 1 * @boost\n end", "def up\n @state -= 1 unless @state == 0\n @y -= 1 * @boost\n end", "def compute_unreachable_states\n queue = [starting_state].to_set\n transitions = self.each_transition.to_a.dup\n\n done_something = true\n while done_something\n done_something = false\n transitions.delete_if do |from, _, to|\n if queue.include?(from)\n queue << to\n done_something = true\n end\n end\n end\n\n transitions.map(&:first).to_set\n end", "def final_state(state)\n final_states(state)\n end", "def states; end", "def rest\n if @state > 2\n @state -= 1\n elsif @state < 2\n @state += 1\n end\n end", "def state_on_table_game_end\n @log.debug(\"Net_state: change to state state_on_table_game_end\")\n @network_state = :state_on_table_game_end\n make_state_change_ntfy(:ntfy_state_on_table_game_end)\n end", "def times_walked_to(state); end", "def finish\n transition_to(:successful) unless transition_to(:waiting_funds)\n end", "def count_next_index()\n if @operation == :pour\n if @second_index + 1 >= @original_state.size\n @second_index = 0\n @first_index += 1\n else\n @second_index += @second_index + 1 == @first_index ? 2 : 1\n end\n if @first_index + 1 == @original_state.size && @second_index + 1 >= @original_state.size\n @operation = :nop\n end\n else\n if @first_index + 1 < @original_state.size\n @first_index += 1\n else\n @first_index = 0\n @operation = @operation == :fill ? :empty : :pour\n end\n end\n end", "def get_lambda_transitions(state)\n transitions = []\n @lambda_table[state].each.with_index do |value, index|\n if value == 1\n transitions << index\n end\n end\n return transitions\n end", "def exit!\n map = @transition_map\n map.each do |type, events_to_transition_arrays|\n events_to_transition_arrays.each do |event, transitions|\n transitions.each(&:unarm)\n end\n end\n\n @exit_actions.each do |exit_action|\n exit_action.call(@state_machine)\n end\n @state_machine.current_state = nil\n end", "def state_anim\n states.each do |state|\n return state.state_anim if state.state_anim > 0\n end\n return 0\n end", "def completeTable(mach)\n\t\tfiltered = {}\n\t\ttable = mach.to_table\n\n\t\t# for each state in the machine\n\t\tmach.states.each_with_index do |s, index|\n\t\t\t# for each rule at a given state\n\t\t\ts.state.each do |lhs, rules|\n\t\t\t\trules.each_with_index do |rule, offset|\n\t\t\t\t\t# tryRuleInState\n\t\t\t\t\tnext unless rule.last == @marker\n\n\t\t\t\t\tfollow_set(lhs).each do |sym|\n\t\t\t\t\t\t# assertEntry\n\t\t\t\t\t\traise ShiftReductConflictError unless table[index][sym].nil?\n\t\t\t\t\t\ttable[index][sym] = \"#{lhs},#{offset}\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\t# AssertEntry[StartState, Goalsymbol, accept_symbol]\n\t\traise ShiftReductConflictError unless table[0][@goal].nil?\n\t\ttable[0][@goal] = \"accept\"\n\n\t\treturn table\n\tend", "def setup_rem_state\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n c = @acts[2] || 100\n c = c/100.0 if c.integer?\n if area_flag\n target_array.each do |t|\n if chance(c)\n t.remove_state(@acts[1])\n get_scene.tsbs_redraw_status(t)\n end\n end\n return\n end\n return unless target\n if chance(c)\n target.remove_state(@acts[1])\n get_scene.tsbs_redraw_status(target)\n end\n end", "def union!(f1)\n\t\ttemp = new_state\n\t\tadd_transition(temp, @start, \"\")\n\t\t@start = temp\n\t\tadd_transition(temp, f1.start, \"\")\n\t\ttemp = new_state\n\t\[email protected] { |x| set_final(x, false) \n\t\tadd_transition(x, temp, \"\") }\n\t\tset_final(temp)\n\t\tf1.final.keys.sort.each { |x| add_transition(x, temp, \"\") }\n\t\tf1.transition.keys.each { |v1| \n f1.transition[v1].keys.each { |v2| \n add_transition(v1, v2, f1.get_transition(v1,v2))\n }\n }\n\t\[email protected](nil)\n\t\[email protected](nil)\n end", "def failed_states\n states - success_states - transitive_states\n end", "def finished!\n Mua::State::Transition.new(state: self.terminal_states[0])\n end", "def reward(state, _action, _next_state)\n state == :stop ? 0 : grid[state[0]][state[1]]\n end", "def after_transition(*args, &block); end", "def states\n is = (0...grid.size).to_a\n js = (0...grid.first.size).to_a\n is.product(js).select { |i, j| grid[i][j] } + [:stop]\n end", "def execute\n mark_states\n @nfa = {\n :initial => 0,\n :final => @final_states,\n :symbols => @symbols,\n :states => (0..@last_state),\n :transitions => @transitions\n }\n end", "def update_state_effects\n @state_poptimer[0] += 1 unless primary_state_ani.nil?\n if @state_poptimer[0] == 30\n @animation_id = primary_state_ani\n @animation_id = 0 if @animation_id.nil?\n elsif @state_poptimer[0] == 180\n @state_poptimer[0] = 0\n end\n update_state_action_steps \n end", "def union! newFA\ns0 = new_state\ns1 = new_state\nadd_transition(s0, @start, \"\")\nadd_transition(s0, newFA.get_start, \"\")\n# reset the final states of the current object\nkeys = @final.keys\ni = 0\nwhile i < keys.size\nadd_transition(keys[i], s1, \"\")\nset_final(keys[i], false)\ni = i + 1\nend\n# set the final states of the other object\nkeys = newFA.get_final\ni = 0\nwhile i < keys.size\nadd_transition(keys[i], s1, \"\")\ni = i + 1\nend\n# copy over the states\nkeys = newFA.get_state\ni = 0\nwhile i < keys.size\nadd_state(keys[i])\ni = i + 1\nend\n# copy over the transitions\nnewFA.get_trans_hash.keys.sort.each { |v1|\nnewFA.get_trans_hash[v1].keys.sort.each { |x|\nv2 = newFA.get_transition(v1,x)\ni = 0\nwhile i < v2.size\nadd_transition(v1, v2[i], x)\ni = i + 1\nend\n}\n}\nset_start(s0)\nset_final(s1, true)\n# copy over the alphabets\nnewFA.get_alpha.each{|a|\nif @alphabet.include?(a) == false\[email protected](a)\nend\n}\nend", "def total\n @state[0]*VALUES[0] + @state[1]*VALUES[1] + @state[2]*VALUES[2] + @state[3]*VALUES[3] + @state[4]*VALUES[4]\n end", "def done?(state)\n state[:position][0][0] == 0\n end", "def start_transition\n nil\n end", "def transition_probability(state, action, next_state)\n if state == :stop || terminii.member?(state)\n action == :stop && next_state == :stop ? 1 : 0\n else\n # agent usually succeeds in moving forward, but sometimes it ends up\n # moving left or right\n move = case action\n when '^' then [['^', 0.8], ['<', 0.1], ['>', 0.1]]\n when '>' then [['>', 0.8], ['^', 0.1], ['v', 0.1]]\n when 'v' then [['v', 0.8], ['<', 0.1], ['>', 0.1]]\n when '<' then [['<', 0.8], ['^', 0.1], ['v', 0.1]]\n end\n move.map do |m, pr|\n m_state = [state[0] + MOVES[m][0], state[1] + MOVES[m][1]]\n m_state = state unless states.member?(m_state) # stay in bounds\n pr if m_state == next_state\n end.compact.inject(:+) || 0\n end\n end", "def transitions\n [\n {:parked => :idling, :on => :ignite},\n {:idling => :first_gear, :first_gear => :second_gear, :on => :shift_up}\n # ...\n ]\n end", "def extract_valid_transitions\r\n transitions_in_model=Array.new\r\n \t\tself.adjacency_matrix.each_key do |a_state|\r\n\t\t\t if self.adjacency_matrix[a_state].length == 0\r\n\t\t\t \t\t\t # Ignore if no actions, as this is not a transition, just a dead end\r\n else\r\n \t self.adjacency_matrix[a_state].each do |a_transition|\r\n \t transitions_in_model.push a_transition\r\n \tend # end each \t\r\n end # end else\r\n end # end each key\r\n\r\n return transitions_in_model\r\n end", "def transition\n new_state = fetch_sensor_state\n return if new_state == @state\n puts \"Transitioned from #{@state} to #{new_state}\"\n if valid_transition?(new_state)\n @state = new_state\n # Do nothing\n else\n puts \"Invalid transition!\"\n @beam_broken = 0\n # TODO: toss up the correct error light\n end\n end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def phase; end", "def transitions(curr_state = nil, **)\n curr_state = state_value(curr_state)\n next_states = state_table.dig(curr_state, :next)\n Array.wrap(next_states).compact_blank\n end", "def transitions\n @transitions ||= {}\n end", "def final_states(*states)\n @subject.final_states = states\n end", "def states\n\t[:shelf,:in_use,:borrowed,:misplaced,:lost]\nend", "def get_transition(v1,x)\nif has_state?(v1)\n@transition[v1][x]\nelse\nnil\nend\nend", "def converge(state) ; end", "def unflag_row_deltas\n tables.each(&:unflag_row_deltas)\n end", "def free\n @state.sum do |row|\n row.count { |square| square == FREE }\n end\n end", "def states\n states = Set.new([@initial_state])\n @transitions.each { |k,v| states += v.values }\n states\n end", "def main_end\r\n super\r\n # Execute transition\r\n Graphics.transition(40)\r\n # Prepare for transition\r\n Graphics.freeze\r\n # If battle test\r\n if $BTEST\r\n $scene = nil\r\n end\r\n end", "def transitions(year); end", "def transitions(year); end", "def state\n active = 0\n my_nodes.each do |n|\n # any node that's error or unknown will cause the whole state to be in the other state\n if n.state < 0 \n return ERROR\n elsif n.state > 0 \n active+=1\n elsif n.state == nil\n return UNKNOWN\n end\n end\n # if all the nodes fall through the tests above then the snapshot is ready or active\n return (active == 0 ? ACTIVE : TRANSITION)\n end", "def flag_row_deltas\n tables.each(&:flag_row_deltas)\n end", "def transition_time\n end", "def state\n super\n table :cs_rep, ['ident'], ['payload']\n table :cs_meter, ['ident'], ['payload']\n scratch :rmg_can_store, ['ident'], ['payload']\n end", "def succ() end", "def succ() end", "def succ() end", "def state_transitions\n StateTransition.where(record_id: id, record_type: self.class.to_s).order(id: :desc)\n end", "def execState\n findNextState\n current_state = @state_list[@state][@transition]\n\n @transition = eval \"#{@state}\"\n @history.push @state\n\n @finished = @state == :finish\n end", "def transitions\n @transitions ||= []\n end", "def update_transitions\n from_states.each do |from|\n if (value = machine.transitions[name][from])\n machine.transitions[name][from] = [value, map[from]].flatten\n else\n machine.transitions[name][from] = map[from] || ANY_STATE\n end\n end\n end", "def transition(offset_id, timestamp_value); end", "def start_level\n # clear transition layer\n clear_temporary\n end", "def expand_transition_table(row)\n (row - @transition_table.size + 1).times do |r|\n @transition_table << {}\n end\n end", "def rollback\n each {|transition| transition.rollback}\n end", "def transitions\n @transitions ||= @internal_struct[:transitions] || {}\n end", "def state_removed! statemachine\n transitions_changed!\n end", "def generate_state_transiton(state_transtion={})\n if state_transtion == {}\n # default setting is like EC\n states = [\n {state_id: 0, state_name: 'top_page_view', item_type: :no_item, request: '/'},\n {state_id: 1, state_name: 'list_page_view', item_type: :many, request: '/list'},\n {state_id: 2, state_name: 'detail_page_view', item_type: :one, request: '/item'},\n {state_id: 3, state_name: 'item_purchase', item_type: :one, request: '/purchace'}\n ]\n \n start_state = [0]\n\n taranstion = [\n # probability is 0.6 if user transit from top(id:0) to list(id:1) page.\n # transition restrict by item is none.\n {from: 0, to: 1, probability: 0.6, dependent_item: false},\n\n # probability is 0.4 if user transit from list(id:1) to detail(id:2) page\n # \"to state\" item should be choosed \"from state\" items.\n {from: 1, to: 2, probability: 0.4, dependent_item: true},\n \n # probability is 0.2 if user transit from detatil(id:2) to purchase(id:3) page\n # \"to state\" item should be choosed \"from state\" items.\n # after transition to state '3', automatically transition to state \"0\"\n {from: 2, to: 3, probability: 0.2, dependent_item: true, auto_transiton: 0}\n ]\n @start_state, @transitions = start_state, taranstion\n else\n @start_state = state_transtion[:start_state]\n @transitions = state_transtion[:transitions]\n states = state_transtion[:states]\n end\n # convert states\n states_hash = {}\n states.each do |state|\n states_hash[state[:state_id]] = state\n end\n @states = states_hash\n\n # generate auto transiton\n @transitions.each do |transition|\n if transition[:auto_transiton]\n @auto_transiton[transition[:to]] = transition[:auto_transiton]\n end\n end\n end", "def main_transition\r\n # Execute transition\r\n if $data_system.battle_transition == \"\"\r\n Graphics.transition(20)\r\n else\r\n Graphics.transition(40, \"Graphics/Transitions/\" +\r\n $data_system.battle_transition)\r\n end\r\n # Start pre-battle phase\r\n start_phase1\r\n end", "def go_sub(num)\n @state = @states[num]\n end", "def reducer; end", "def setup_rem_state\n return unless PONY::ERRNO::check_sequence(current_act)\n current_action_targets.each do |target|\n state_id = @acts[1]\n chance = @acts[2] || 100\n chance = chance / 100.0 if c.integer?\n target.remove_state(state_id) if rand < chance\n end\n end", "def states\n no_set_states + set_bonuses\n end", "def exit_state\n end", "def rollback\n each { |transition| transition.rollback }\n end", "def reduziere_lebendige_transitionen(lebendig)\n # Prüfe alle Transitionen\n lebendig.transitionen.each do |t|\n # Überspringe t, sofern Übergänge zu t laufen\n next if lebendig.fluss.values.join(', ').include?(t)\n\n # t kommt im Vorbereich mindestens einer Stelle vor\n next unless lebendig.fluss.key?(t)\n\n # Da wir vorher alle Transitionen übersprungen haben, die keinen leeren Vorbereich haben,\n # sind ab hier alle Transitionen lebendig.\n\n # Entferne jede Stelle im Nachbereich von t, mitsamt Übergängen\n lebendig.fluss[t].each do |s|\n lebendig.reduziere_knoten(s)\n end\n\n # Entferne die lebendige Transition t\n lebendig.reduziere_knoten(t)\n\n # Fürs Protokoll\n puts(\"Lebendige Transitionen reduziert!\")\n end\nend", "def derive_offsets(transitions, offsets); end", "def derive_offsets(transitions, offsets); end", "def force_final_state\r\n @final_state = true\r\n end", "def update_sm_with_actions\r\n puts_debug \"Update StateMachine with actions:\"\r\n puts_debug @state_machine.adjacency_matrix\r\n @state_machine.adjacency_matrix.values.each do |trans_array|\r\n trans_array.each do |transition|\r\n puts_debug transition.action\r\n \r\n define_action transition.action\r\n end # each transition\r\n end # each trans array \r\n end", "def dump_table(type = :state, indent_width = 2, indent_level = 2)\r\n # edge_labels = friendly_edge_labels << \" Other\" # I suspect this line is ruining the code.\r\n edge_labels = get_edge_labels << \" Other\"\r\n node_names = get_node_names\r\n \r\n s = \"#{ind(indent_level)}@#{type}_table = \" +\r\n ((type == :action) ? \"\\n#{ind(indent_level+1)}\\# ERROR = 0; MACHINE_ACCEPT = 1; HALT_RETURN = 2\" : \"\") +\r\n \"\\n#{ind(indent_level+1)}#\"\r\n edge_labels.each do |label|\r\n s += sprintf(\"%#{WIDTH+1}s\", label_friendly(label))\r\n end\r\n s += \"\\n#{ind(indent_level+1)}\"\r\n \r\n node_names.each_with_index do |node,ii|\r\n on_last_node = (ii == node_names.size-1)\r\n is_accept = !@accept_states[node].nil?\r\n s += ((ii==0) ? \"[\" : \" \") + \"[\"\r\n \r\n edge_labels.each_with_index do |edge,jj|\r\n on_last_edge = (jj == edge_labels.size-1)\r\n if(@graph_hash[node].nil?||\r\n @graph_hash[node][edge].nil?||@graph_hash[node][edge][0].nil?)\r\n sdest = \"-1\"\r\n adest = ((is_accept) ? HALT_RETURN.to_s : ERROR.to_s)\r\n if(!accept_states[node].nil?)\r\n ldest = ((is_accept) ? (lookup_codes.find_index(accept_states[node]).to_i).to_s : \"0\")\r\n else\r\n ldest = \"0\"\r\n end\r\n else\r\n sdest = graph_hash[node][edge].to_s\r\n adest = MACHINE_ACCEPT.to_s # MA if NON-ACCEPT state\r\n ldest = \"0\"\r\n end\r\n case type\r\n when :state\r\n s += sprintf(\"%#{WIDTH}s\", sdest) + \r\n ((!on_last_edge) ? \",\" \\\r\n : \"]\" + ((!on_last_node) ? \",\" \\\r\n : \"]\" ) + \" \\# #{node}#{(is_accept ? \" ACCEPT\":\"\")}\\n#{ind(indent_level+1)}\")\r\n when :action\r\n s += sprintf(\"%#{WIDTH}s\", adest) + \r\n (!on_last_edge ? \",\" \\\r\n : \"]\" + (!on_last_node ? \",\" \\\r\n : \"]\" ) + \" \\# #{node}#{(is_accept ? \" ACCEPT\" : \"\")}\\n#{ind(indent_level+1)}\")\r\n when :lookup\r\n s += sprintf(\"%#{WIDTH}s\", ldest) + \r\n (!on_last_edge ? \",\" \\\r\n : \"]\" + (!on_last_node ? \",\" \\\r\n : \"]\" ) + \" \\# #{node}#{(is_accept ? \" #{@accept_states[node]}\" : \"\")}\\n#{ind(indent_level+1)}\")\r\n end\r\n end\r\n end\r\n s.rstrip\r\n end", "def next states\n raise \"Must be implemented by subclass\"\n end", "def transition\n newMap = []\n for x in [email protected] do\n for y in 0...@map[x].length do\n if !newMap[x]\n newMap[x] = []\n end\n if !newMap[x][y]\n newMap[x][y] = @map[x][y]\n end\n numAlive = neighbors(x, y).reduce(0) { |a, c| c == 1 ? a + 1 : a }\n if numAlive < 2\n newMap[x][y] = 0 # death by under population\n elsif numAlive > 3\n newMap[x][y] = 0 # death by over population\n elsif @map[x][y] == 0 and numAlive == 3\n newMap[x][y] = 1 # alive by reproduction\n end\n end\n end\n @map = newMap\n end", "def next_state\n newstate = state_transition_out\n newiteration = @iteration\n if [:day, :signup].include?(@state)\n newiteration = @iteration + 1\n end\n @state = newstate\n @iteration = newiteration\n #state_transition_in\n @state\n end", "def emit_finish_mutations\n finish = node.finish\n #emit_self(negative_infinity, finish)\n emit_self(nan, finish)\n end", "def generate_initial_state\n @state.each_with_index do |row, row_index|\n end\n end", "def final?\n @transitions.empty?\n end", "def steps_before_repeat_state_naive\n\t\t# state = {}\n\t\tsteps = 0\n\t\torig = @moons_pos.to_s\n\t\tzero_vel = [0, 0, 0]\n\t\tstarting_time = Time.now\n\t\tp @moons_pos\n\t\twhile (42)\n\t\t\tsleep(1)\n\t\t\t# state.has_key?(@moons_pos.to_s) ? break : state[@moons_pos.to_s] = true\n\n\t\t\tapply_gravity_to_velocity\n\t\t\tapply_velocity_to_position\n\t\t\tsteps += 1\n\t\t\tp @moons_pos\n\t\t\tbreak if velocity(:io) == zero_vel && @moons_pos.to_s == orig\n\t\tend\n\t\tsteps\n\tend", "def resetStates()\r\n @players.each do |player|\r\n if(player.money > 0)\r\n player.state = \"fine\"\r\n else\r\n player.state = \"broke\"\r\n end\r\n end\r\n end", "def actions(state)\n if state == :stop || terminii.member?(state)\n [:stop]\n else\n MOVES.keys\n end\n end" ]
[ "0.64042956", "0.6064393", "0.60386634", "0.6007729", "0.5946686", "0.59351325", "0.59351325", "0.5909589", "0.58873314", "0.58676314", "0.58676314", "0.57807076", "0.5779571", "0.5710219", "0.56961817", "0.5655912", "0.55736065", "0.55026084", "0.54936284", "0.5481873", "0.5438249", "0.5409715", "0.5403657", "0.5375035", "0.5353606", "0.5353463", "0.5348177", "0.5342463", "0.5341549", "0.5316064", "0.5311208", "0.53055745", "0.53051555", "0.52858603", "0.527972", "0.52724856", "0.5271459", "0.5267875", "0.5256976", "0.52524394", "0.52235377", "0.52235377", "0.52235377", "0.52235377", "0.52235377", "0.52235377", "0.52235377", "0.52235377", "0.52161413", "0.52023757", "0.5194032", "0.51610833", "0.515993", "0.5158976", "0.51530755", "0.51404214", "0.51395154", "0.51342064", "0.51177794", "0.510656", "0.510656", "0.51036125", "0.50729126", "0.50688297", "0.50653076", "0.506288", "0.506288", "0.506288", "0.50624055", "0.5061938", "0.505782", "0.5055675", "0.50532365", "0.5044276", "0.50338036", "0.5032605", "0.502155", "0.5016229", "0.5014718", "0.50023186", "0.49948356", "0.49934676", "0.49767", "0.49704567", "0.4968285", "0.49624747", "0.4961586", "0.49610332", "0.49610332", "0.4958078", "0.49576372", "0.494714", "0.49357703", "0.4929767", "0.4925796", "0.492318", "0.4921991", "0.49218357", "0.4919685", "0.49154374", "0.49153164" ]
0.0
-1
reduce 32 omitted reduce 33 omitted
def _reduce_34(val, _values, result) result = @builder.logical_op(:and, val[0], val[1], val[2]) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_32(val, _values, result); end", "def _reduce_32(val, _values, result); end", "def _reduce_512(val, _values, result); end", "def _reduce_512(val, _values, result); end", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_34(val, _values, result); end", "def _reduce_363(val, _values, result); end", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_28(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_375(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_314(val, _values, result); end", "def _reduce_23(val, _values, result); end", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_334(val, _values, result); end", "def _reduce_18(val, _values, result); end", "def _reduce_18(val, _values, result); end", "def _reduce_512(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_17(val, _values, result); end", "def _reduce_299(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_37(val, _values, result); end", "def _reduce_37(val, _values, result); end", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_53(val, _values, result); end", "def _reduce_53(val, _values, result); end", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_378(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_634(val, _values, result); end", "def _reduce_565(val, _values, result); end", "def _reduce_565(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_411(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_686(val, _values, result); end", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_21(val, _values, result); end", "def _reduce_63(val, _values, result); end", "def _reduce_63(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_464(val, _values, result); end", "def _reduce_704(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_262(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_63(val, _values, result)\n blk, _, msg, args = val\n result = new_call(blk, msg.to_sym, args).line blk.line\n\n result\nend", "def _reduce_63(val, _values, result)\n blk, _, msg, args = val\n result = new_call(blk, msg.to_sym, args).line blk.line\n\n result\nend", "def _reduce_63(val, _values, result)\n blk, _, msg, args = val\n result = new_call(blk, msg.to_sym, args).line blk.line\n\n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_480(val, _values, result); end", "def _reduce_377(val, _values, result); end", "def _reduce_476(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end" ]
[ "0.7081952", "0.7081952", "0.70456636", "0.70456636", "0.6919567", "0.68905395", "0.68790436", "0.6871143", "0.6871143", "0.68538505", "0.6841522", "0.6831543", "0.6830546", "0.6827009", "0.68181384", "0.68181384", "0.6812494", "0.6799789", "0.6799789", "0.6793734", "0.67859346", "0.67772746", "0.6768487", "0.6765351", "0.67624086", "0.676086", "0.676086", "0.674624", "0.674624", "0.67314696", "0.67314696", "0.67273235", "0.6726259", "0.6719438", "0.6719438", "0.6714929", "0.67120814", "0.6708593", "0.6708593", "0.67064774", "0.6699664", "0.6696099", "0.6693356", "0.66919506", "0.66909504", "0.6686148", "0.66814643", "0.6680718", "0.6673819", "0.66711384", "0.66711384", "0.6666252", "0.6649181", "0.6643821", "0.6637824", "0.66355145", "0.66355145", "0.6624515", "0.6624515", "0.6618993", "0.6612173", "0.6610062", "0.6604495", "0.6604495", "0.66035", "0.660144", "0.6600703", "0.659183", "0.6589788", "0.6589788", "0.6588141", "0.6586404", "0.65853447", "0.657395", "0.65737814", "0.65702176", "0.65657264", "0.65657264", "0.65640426", "0.6563818", "0.65626544", "0.65626544", "0.65559894", "0.65518564", "0.65477955", "0.65477955", "0.6547708", "0.65445375", "0.6540283", "0.6540283", "0.6539942", "0.6537915", "0.6537292", "0.6537292", "0.6537292", "0.6533698", "0.653169", "0.6525763", "0.65187484", "0.6518537", "0.6518537" ]
0.0
-1
reduce 38 omitted reduce 39 omitted reduce 40 omitted reduce 41 omitted
def _reduce_42(val, _values, result) result = @builder.keyword_cmd(:return, val[0], nil, val[1], nil) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_47(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_37(val, _values, result); end", "def _reduce_37(val, _values, result); end", "def _reduce_385(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_34(val, _values, result); end", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_23(val, _values, result); end", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_411(val, _values, result); end", "def _reduce_28(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_704(val, _values, result); end", "def _reduce_17(val, _values, result); end", "def _reduce_312(val, _values, result); end", "def _reduce_21(val, _values, result); end", "def _reduce_18(val, _values, result); end", "def _reduce_18(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_9(val, _values, result); end", "def _reduce_9(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_710(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_359(val, _values, result); end", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_357(val, _values, result); end", "def _reduce_699(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_686(val, _values, result); end", "def _reduce_374(val, _values, result); end", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_45(val, _values, result); end", "def _reduce_684(val, _values, result); end", "def _reduce_470(val, _values, result); end", "def _reduce_50(val, _values, result); end", "def _reduce_50(val, _values, result); end", "def _reduce_402(val, _values, result); end", "def _reduce_705(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_476(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end" ]
[ "0.69768417", "0.69421995", "0.6920187", "0.69026196", "0.69007856", "0.68858093", "0.68820137", "0.68820137", "0.68664795", "0.68664795", "0.6864441", "0.68634504", "0.6862654", "0.6862654", "0.686087", "0.68546283", "0.68546283", "0.6846927", "0.6845093", "0.68427217", "0.6831223", "0.68266433", "0.6820345", "0.6820345", "0.6818985", "0.6817112", "0.6817112", "0.68164617", "0.68145764", "0.68138164", "0.68138164", "0.6806203", "0.68042374", "0.6801099", "0.6796958", "0.67960155", "0.67899716", "0.67787015", "0.6770766", "0.6768167", "0.67482007", "0.6744293", "0.67442507", "0.67418957", "0.67418957", "0.6739738", "0.6736941", "0.6736406", "0.67334735", "0.67304695", "0.67264533", "0.6724089", "0.67222065", "0.671898", "0.67169094", "0.6713986", "0.6713533", "0.67126685", "0.67126685", "0.6705754", "0.6705754", "0.6700621", "0.66997373", "0.66991574", "0.66991574", "0.66938835", "0.66938835", "0.6692662", "0.66880625", "0.66859734", "0.66854805", "0.66829765", "0.6681757", "0.6676362", "0.6675019", "0.6675019", "0.66746795", "0.6672113", "0.6668212", "0.66667813", "0.6662632", "0.66623926", "0.66623926", "0.6662054", "0.6662054", "0.6659382", "0.66544914", "0.6650062", "0.66491973", "0.6648389", "0.66467613", "0.66449773", "0.6644053", "0.66368574", "0.66368574", "0.6635589", "0.66312575", "0.6631064", "0.6618765", "0.661366", "0.661366" ]
0.0
-1
reduce 93 omitted reduce 94 omitted reduce 95 omitted reduce 96 omitted reduce 97 omitted
def _reduce_98(val, _values, result) result = @builder.symbol_internal(val[0]) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_13(val, _values, result); end", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_492(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_711(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_526(val, _values, result); end", "def _reduce_705(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_92(val, _values, result); end", "def _reduce_92(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_699(val, _values, result); end", "def _reduce_710(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_704(val, _values, result); end", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def test_reduce\n assert_equal('12Assign4BuzzAssign78AssignBuzz11Assign1314AssignBuzz',\n @ab.reduce { |acc, res| acc + res })\n end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_728(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_599(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_646(val, _values, result)\n yyerrok\n result\nend", "def _reduce_646(val, _values, result)\n yyerrok\n result\nend", "def _reduce_646(val, _values, result)\n yyerrok\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_494(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_684(val, _values, result); end" ]
[ "0.7076238", "0.70726484", "0.70458", "0.7022318", "0.69966483", "0.69799197", "0.69772357", "0.69772357", "0.6971455", "0.6965433", "0.69625586", "0.6953761", "0.6942905", "0.69428843", "0.69411147", "0.69353664", "0.69353664", "0.692743", "0.6910827", "0.6900043", "0.6870402", "0.6869539", "0.68685454", "0.68615544", "0.6860795", "0.68577117", "0.6853481", "0.6844191", "0.68432105", "0.683309", "0.6830154", "0.6816956", "0.6816956", "0.68072116", "0.679741", "0.6794552", "0.6794552", "0.6792977", "0.679121", "0.67875373", "0.6779228", "0.6775742", "0.67708796", "0.67627746", "0.67626256", "0.6761909", "0.6761909", "0.6759821", "0.6757969", "0.6737252", "0.6737252", "0.6727663", "0.67190516", "0.67190516", "0.6718616", "0.6714225", "0.67033315", "0.67021793", "0.66960704", "0.6694691", "0.6694691", "0.66945875", "0.6685715", "0.66852576", "0.6685194", "0.6685194", "0.66839284", "0.66839284", "0.66759664", "0.6673021", "0.6669892", "0.66633314", "0.66633314", "0.6661196", "0.6661196", "0.6661196", "0.66519624", "0.6650223", "0.6650058", "0.6649691", "0.6649691", "0.6649691", "0.6649691", "0.6648314", "0.66474795", "0.6646352", "0.6646352", "0.66429186", "0.66402495", "0.6639644", "0.6639644", "0.6639644", "0.6634143", "0.6634143", "0.6630132", "0.6629176", "0.6629176", "0.6629176", "0.6629176", "0.6629176", "0.66279674" ]
0.0
-1
reduce 99 omitted reduce 100 omitted reduce 101 omitted
def _reduce_102(val, _values, result) result = [ val[0] ] result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_102(val, _values, result); end", "def _reduce_102(val, _values, result); end", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_47(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_299(val, _values, result); end", "def _reduce_312(val, _values, result); end", "def _reduce_50(val, _values, result); end", "def _reduce_50(val, _values, result); end", "def _reduce_699(val, _values, result); end", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_704(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_9(val, _values, result); end", "def _reduce_9(val, _values, result); end", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_23(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_501(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_501(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_501(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_501(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_524(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n\n result\nend", "def _reduce_21(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_710(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_669(val, _values, result); end", "def _reduce_34(val, _values, result); end", "def _reduce_135(val, _values, result); end", "def _reduce_135(val, _values, result); end", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_359(val, _values, result); end", "def _reduce_476(val, _values, result); end", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_411(val, _values, result); end", "def _reduce_600(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_695(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_314(val, _values, result); end", "def _reduce_599(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_684(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_127(val, _values, result); end", "def _reduce_127(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_280(val, _values, result); end", "def _reduce_280(val, _values, result); end", "def _reduce_402(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end" ]
[ "0.7185758", "0.7144268", "0.7131739", "0.71315444", "0.71315444", "0.7130166", "0.7128689", "0.71236426", "0.71224", "0.71081793", "0.70643544", "0.7057693", "0.70132846", "0.70132846", "0.70128626", "0.70128626", "0.69915897", "0.69914603", "0.69914603", "0.697216", "0.697216", "0.69721246", "0.69678164", "0.69673306", "0.69642234", "0.6962132", "0.6957681", "0.6955248", "0.6955248", "0.6948909", "0.69450563", "0.69408107", "0.694075", "0.694075", "0.69242954", "0.69083685", "0.69082576", "0.69017625", "0.6896923", "0.6893407", "0.68853694", "0.68836695", "0.6877947", "0.68746454", "0.68746454", "0.6871772", "0.68669325", "0.6865729", "0.6859765", "0.68511397", "0.68511397", "0.6847698", "0.6847698", "0.6832265", "0.68261474", "0.68261474", "0.6818441", "0.681469", "0.681469", "0.681469", "0.681469", "0.68145335", "0.68121976", "0.6807996", "0.6795709", "0.67913467", "0.67860824", "0.67860824", "0.67829114", "0.67809355", "0.67809355", "0.67798734", "0.67791575", "0.676428", "0.676428", "0.67634344", "0.67571825", "0.6755329", "0.6754701", "0.67542565", "0.67441833", "0.6743681", "0.6742397", "0.6736481", "0.67333525", "0.6725882", "0.67240036", "0.6723421", "0.67225903", "0.67200595", "0.67151093", "0.67151093", "0.67117095", "0.67117095", "0.6709485", "0.6709485", "0.67060244", "0.67060244", "0.67035955", "0.6693262", "0.6693262" ]
0.0
-1
reduce 105 omitted reduce 106 omitted reduce 107 omitted reduce 108 omitted reduce 109 omitted reduce 110 omitted reduce 111 omitted reduce 112 omitted reduce 113 omitted reduce 114 omitted reduce 115 omitted reduce 116 omitted reduce 117 omitted reduce 118 omitted reduce 119 omitted reduce 120 omitted reduce 121 omitted reduce 122 omitted reduce 123 omitted reduce 124 omitted reduce 125 omitted reduce 126 omitted reduce 127 omitted reduce 128 omitted reduce 129 omitted reduce 130 omitted reduce 131 omitted reduce 132 omitted reduce 133 omitted reduce 134 omitted reduce 135 omitted reduce 136 omitted reduce 137 omitted reduce 138 omitted reduce 139 omitted reduce 140 omitted reduce 141 omitted reduce 142 omitted reduce 143 omitted reduce 144 omitted reduce 145 omitted reduce 146 omitted reduce 147 omitted reduce 148 omitted reduce 149 omitted reduce 150 omitted reduce 151 omitted reduce 152 omitted reduce 153 omitted reduce 154 omitted reduce 155 omitted reduce 156 omitted reduce 157 omitted reduce 158 omitted reduce 159 omitted reduce 160 omitted reduce 161 omitted reduce 162 omitted reduce 163 omitted reduce 164 omitted reduce 165 omitted reduce 166 omitted reduce 167 omitted reduce 168 omitted reduce 169 omitted reduce 170 omitted
def _reduce_171(val, _values, result) result = @builder.assign(val[0], val[1], val[2]) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_599(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_648(val, _values, result)\n yyerrok\n result\nend", "def _reduce_648(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_646(val, _values, result)\n yyerrok\n result\nend", "def _reduce_646(val, _values, result)\n yyerrok\n result\nend", "def _reduce_646(val, _values, result)\n yyerrok\n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_492(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_705(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_641(val, _values, result)\n yyerrok\n result\nend", "def _reduce_516(val, _values, result)\n yyerrok \n result\nend", "def _reduce_516(val, _values, result)\n yyerrok \n result\nend", "def _reduce_711(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_623(val, _values, result)\n yyerrok \n result\nend", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_781(val, _values, result)\n yyerrok\n result\nend", "def _reduce_619(val, _values, result)\n yyerrok \n result\nend", "def _reduce_619(val, _values, result)\n yyerrok \n result\nend", "def _reduce_619(val, _values, result)\n yyerrok \n result\nend", "def _reduce_619(val, _values, result)\n yyerrok \n result\nend", "def _reduce_619(val, _values, result)\n yyerrok \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_635(val, _values, result)\n yyerrok\n result\nend", "def _reduce_642(val, _values, result)\n yyerrok\n result\nend", "def _reduce_642(val, _values, result)\n yyerrok\n result\nend", "def _reduce_601(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_652(val, _values, result)\n yyerrok\n result\nend", "def _reduce_494(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_617(val, _values, result)\n yyerrok \n result\nend", "def _reduce_617(val, _values, result)\n yyerrok \n result\nend", "def _reduce_574(val, _values, result)\n yyerrok \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_643(val, _values, result)\n yyerrok\n result\nend", "def _reduce_643(val, _values, result)\n yyerrok\n result\nend", "def _reduce_643(val, _values, result)\n yyerrok\n result\nend", "def test_reduce\n assert_equal('12Assign4BuzzAssign78AssignBuzz11Assign1314AssignBuzz',\n @ab.reduce { |acc, res| acc + res })\n end", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_602(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_262(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_216(val, _values, result)\n result = []\n\n result\nend", "def _reduce_618(val, _values, result)\n yyerrok \n result\nend", "def _reduce_618(val, _values, result)\n yyerrok \n result\nend", "def _reduce_618(val, _values, result)\n yyerrok \n result\nend", "def _reduce_577(val, _values, result)\n yyerrok \n result\nend", "def _reduce_515(val, _values, result)\n yyerrok \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_604(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_711(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_752(val, _values, result)\n yyerrok\n result\nend", "def _reduce_518(val, _values, result)\n yyerrok \n result\nend", "def _reduce_625(val, _values, result)\n yyerrok \n result\nend" ]
[ "0.66875666", "0.66635364", "0.65839714", "0.6581318", "0.6577947", "0.6573952", "0.65137327", "0.64919853", "0.646608", "0.646608", "0.6465813", "0.64648384", "0.6464662", "0.645838", "0.64508516", "0.64346683", "0.6425549", "0.64075226", "0.64031893", "0.63875574", "0.63875574", "0.63856953", "0.63856953", "0.63856953", "0.63856953", "0.6384683", "0.63811654", "0.63811654", "0.63811654", "0.6378918", "0.6375436", "0.63746536", "0.63746536", "0.63746536", "0.63669795", "0.63669795", "0.6356441", "0.6356441", "0.63539296", "0.6350804", "0.6341988", "0.6339101", "0.6334981", "0.6326204", "0.63256496", "0.63212883", "0.63102394", "0.63102394", "0.63076586", "0.6300749", "0.6300749", "0.629768", "0.6293183", "0.62930936", "0.62892574", "0.6288282", "0.62844855", "0.62749916", "0.62645584", "0.6257826", "0.6257826", "0.6257826", "0.6257826", "0.6257826", "0.6257548", "0.625728", "0.6256471", "0.6256471", "0.62559974", "0.62542486", "0.6251055", "0.6241837", "0.6241837", "0.6241293", "0.62405044", "0.6239358", "0.62326485", "0.62326485", "0.6226872", "0.6226872", "0.6226872", "0.62198114", "0.6217804", "0.62163234", "0.62153375", "0.6212608", "0.620448", "0.620448", "0.62014955", "0.6197329", "0.6197329", "0.6197329", "0.61967367", "0.61943996", "0.6189864", "0.61894536", "0.6187218", "0.61866915", "0.61811864", "0.6179283", "0.61782587" ]
0.0
-1
reduce 214 omitted reduce 215 omitted
def _reduce_216(val, _values, result) result = [] result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_704(val, _values, result); end", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_492(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_526(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_47(val, _values, result); end", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_705(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_684(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_634(val, _values, result); end", "def _reduce_411(val, _values, result); end", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_686(val, _values, result); end", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_602(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_711(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_642(val, _values, result)\n yyerrok\n result\nend", "def _reduce_642(val, _values, result)\n yyerrok\n result\nend", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_470(val, _values, result); end", "def _reduce_23(val, _values, result); end", "def _reduce_494(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_601(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_604(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_648(val, _values, result)\n yyerrok\n result\nend", "def _reduce_648(val, _values, result)\n yyerrok\n result\nend", "def _reduce_455(val, _values, result); end", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_516(val, _values, result)\n yyerrok \n result\nend", "def _reduce_516(val, _values, result)\n yyerrok \n result\nend", "def _reduce_21(val, _values, result); end" ]
[ "0.745499", "0.7445086", "0.7434346", "0.74305993", "0.7419498", "0.74124014", "0.74124014", "0.7406467", "0.74024224", "0.74006593", "0.74006593", "0.7399456", "0.73989046", "0.7383564", "0.73473316", "0.73461574", "0.7344167", "0.7342995", "0.73418367", "0.7339777", "0.7329323", "0.73219234", "0.73147756", "0.73104453", "0.73025626", "0.7301386", "0.7297626", "0.72967464", "0.72959095", "0.7295056", "0.7292307", "0.7292307", "0.72779137", "0.72770244", "0.72713274", "0.72699994", "0.7269944", "0.72664136", "0.7266359", "0.72427857", "0.7237602", "0.7236121", "0.7236121", "0.72295344", "0.7228458", "0.7225972", "0.7225972", "0.7225821", "0.72255903", "0.72255903", "0.7222686", "0.7222686", "0.72168237", "0.72147775", "0.7214445", "0.72141075", "0.720853", "0.7203001", "0.7200769", "0.7196791", "0.7196791", "0.7194201", "0.7189202", "0.7185745", "0.7185603", "0.718236", "0.718236", "0.7177798", "0.7176394", "0.717356", "0.7171309", "0.71712023", "0.71706814", "0.71706814", "0.7159408", "0.7155626", "0.71541643", "0.7148084", "0.7148084", "0.7145008", "0.7145008", "0.7144684", "0.7141981", "0.71398956", "0.713855", "0.7138516", "0.7138516", "0.7135082", "0.7131039", "0.71305966", "0.7129558", "0.7124654", "0.7124654", "0.7121767", "0.71196264", "0.7119142", "0.7119142", "0.7119142", "0.7119023", "0.7119023", "0.7118602" ]
0.0
-1
reduce 264 omitted reduce 265 omitted reduce 266 omitted reduce 267 omitted reduce 268 omitted reduce 269 omitted reduce 270 omitted reduce 271 omitted
def _reduce_272(val, _values, result) result = @builder.call_method(nil, nil, val[0]) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_728(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_604(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_374(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_697(val, _values, result); end", "def _reduce_699(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_464(val, _values, result); end", "def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_669(val, _values, result); end", "def _reduce_466(val, _values, result); end", "def _reduce_736(val, _values, result); end", "def _reduce_216(val, _values, result)\n result = []\n\n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_263(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_667(val, _values, result); end", "def _reduce_312(val, _values, result); end", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_476(val, _values, result); end", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_705(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_314(val, _values, result); end", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_262(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_634(val, _values, result); end" ]
[ "0.73286724", "0.7215517", "0.72106093", "0.72106093", "0.7192138", "0.7169282", "0.7167932", "0.71558297", "0.7151675", "0.7149889", "0.71381", "0.71381", "0.7121299", "0.71077764", "0.7105575", "0.70913285", "0.7091209", "0.7083746", "0.70664257", "0.70641434", "0.70625556", "0.7053897", "0.70503", "0.70494545", "0.7048118", "0.7040483", "0.7033802", "0.7033802", "0.7033103", "0.7029769", "0.70154005", "0.7013141", "0.69958186", "0.6982822", "0.697532", "0.69635534", "0.69635534", "0.6960678", "0.6947652", "0.6915252", "0.69005", "0.69005", "0.6899722", "0.6898712", "0.6897932", "0.6891505", "0.68857336", "0.6868354", "0.6851752", "0.68491226", "0.6844946", "0.6844946", "0.6840611", "0.6840198", "0.68373185", "0.6836218", "0.6836218", "0.6835387", "0.6833874", "0.6833874", "0.683267", "0.68283904", "0.6825182", "0.68204844", "0.68203735", "0.6818964", "0.6808807", "0.6808807", "0.6800956", "0.6793921", "0.6793838", "0.679228", "0.6789071", "0.67837393", "0.67808914", "0.67808914", "0.67808914", "0.67808914", "0.67808914", "0.6776786", "0.67758816", "0.6775342", "0.6775342", "0.67736644", "0.67736644", "0.6773117", "0.6772199", "0.6770759", "0.6767743", "0.6767743", "0.6761091", "0.6760573", "0.6753562", "0.6753562", "0.6753562", "0.6753562", "0.67534506", "0.6748134", "0.67462224", "0.6741408", "0.673978" ]
0.0
-1
reduce 322 omitted reduce 323 omitted reduce 324 omitted
def _reduce_325(val, _values, result) result = val[1] result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_512(val, _values, result); end", "def _reduce_512(val, _values, result); end", "def _reduce_32(val, _values, result); end", "def _reduce_32(val, _values, result); end", "def _reduce_512(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_375(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_464(val, _values, result); end", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_34(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_565(val, _values, result); end", "def _reduce_565(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_411(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_634(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_127(val, _values, result); end", "def _reduce_127(val, _values, result); end", "def _reduce_334(val, _values, result); end", "def _reduce_476(val, _values, result); end", "def _reduce_384(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_314(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_684(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_686(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_704(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_480(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_257(val, _values, result)\n result = val[0] << @builder.associate(nil, val[2], nil)\n \n result\nend", "def _reduce_28(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_728(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_53(val, _values, result); end", "def _reduce_53(val, _values, result); end", "def _reduce_455(val, _values, result); end", "def _reduce_378(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_327(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_63(val, _values, result); end", "def _reduce_63(val, _values, result); end", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_216(val, _values, result)\n result = []\n\n result\nend", "def _reduce_637(val, _values, result); end", "def _reduce_265(val, _values, result)\n result = val[0] << @builder.associate(nil, val[2], nil)\n \n result\nend", "def _reduce_265(val, _values, result)\n result = val[0] << @builder.associate(nil, val[2], nil)\n \n result\nend", "def _reduce_736(val, _values, result); end", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_23(val, _values, result); end", "def _reduce_526(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_69(val, _values, result); end", "def _reduce_367(val, _values, result); end", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_268(val, _values, result); end" ]
[ "0.7298738", "0.7298738", "0.71108943", "0.71108943", "0.7094781", "0.7037549", "0.70278347", "0.69799536", "0.69799536", "0.6973357", "0.69192064", "0.68922144", "0.6886068", "0.6873236", "0.68691456", "0.68463314", "0.6842173", "0.6832834", "0.68321365", "0.68321365", "0.6824548", "0.6803908", "0.6799265", "0.679405", "0.679352", "0.679352", "0.6789847", "0.6783031", "0.6771383", "0.6770118", "0.6764537", "0.67613906", "0.67613906", "0.6759417", "0.6759417", "0.67589843", "0.6754313", "0.6749145", "0.67483234", "0.6743437", "0.6731233", "0.672739", "0.6714406", "0.6714304", "0.6711772", "0.6711772", "0.6710864", "0.6710864", "0.67088586", "0.67072994", "0.67044395", "0.67043614", "0.6697956", "0.66923726", "0.66923726", "0.669038", "0.669038", "0.6688127", "0.6678324", "0.6677671", "0.66651046", "0.6664263", "0.666287", "0.666287", "0.6653478", "0.66509235", "0.6641278", "0.66386074", "0.66386074", "0.66321737", "0.6631889", "0.662872", "0.66257507", "0.66257507", "0.66246945", "0.6620739", "0.6615239", "0.66120446", "0.6611426", "0.6600452", "0.6600452", "0.6597101", "0.6594578", "0.6587853", "0.65844285", "0.65844285", "0.6578195", "0.6576972", "0.65763927", "0.6574741", "0.6574741", "0.65674525", "0.65671724", "0.6565649", "0.6562031", "0.6557498", "0.6557498", "0.65529484", "0.65525895", "0.65474164", "0.65463316" ]
0.0
-1
reduce 326 omitted reduce 327 omitted reduce 328 omitted reduce 329 omitted
def _reduce_330(val, _values, result) else_t, else_ = val[4] result = [ val[0], @builder.condition(val[0], val[1], val[2], val[3], else_t, else_, nil), ] result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_512(val, _values, result); end", "def _reduce_512(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_512(val, _values, result)\n result = s(:nil) \n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_686(val, _values, result); end", "def _reduce_697(val, _values, result); end", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_728(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_262(val, _values, result)\n result = args val\n\n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_411(val, _values, result); end", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_736(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_526(val, _values, result); end", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_565(val, _values, result); end", "def _reduce_565(val, _values, result); end", "def _reduce_634(val, _values, result); end", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_699(val, _values, result); end", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_476(val, _values, result); end", "def _reduce_710(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_697(val, _values, result)\n result = :\"**nil\"\n\n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_704(val, _values, result); end", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_528(val, _values, result)\n result = s(:nil).line lexer.lineno\n result\nend", "def _reduce_528(val, _values, result)\n result = s(:nil).line lexer.lineno\n result\nend", "def _reduce_528(val, _values, result)\n result = s(:nil).line lexer.lineno\n result\nend", "def _reduce_528(val, _values, result)\n result = s(:nil).line lexer.lineno\n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_533(val, _values, result)\n result = s(:nil).line lexer.lineno\n result\nend", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_314(val, _values, result); end", "def _reduce_526(val, _values, result)\n result = s(:nil).line lexer.lineno\n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_127(val, _values, result); end", "def _reduce_127(val, _values, result); end", "def _reduce_648(val, _values, result)\n yyerrok\n result\nend", "def _reduce_648(val, _values, result)\n yyerrok\n result\nend", "def _reduce_334(val, _values, result); end", "def _reduce_637(val, _values, result); end", "def _reduce_367(val, _values, result); end" ]
[ "0.708324", "0.7047274", "0.70444155", "0.6992853", "0.6992853", "0.6923864", "0.6912876", "0.6912876", "0.69066507", "0.6882379", "0.6876222", "0.6834679", "0.68214226", "0.681597", "0.68158495", "0.68158495", "0.67952055", "0.6785401", "0.67789483", "0.67626715", "0.6761833", "0.6761833", "0.6749541", "0.6749541", "0.67396146", "0.67363226", "0.6731379", "0.6728479", "0.67250484", "0.6717078", "0.6714126", "0.6713757", "0.6713629", "0.6713629", "0.6706091", "0.6706091", "0.6697523", "0.6692687", "0.6681866", "0.6672175", "0.6665329", "0.66641235", "0.6660734", "0.66580826", "0.66570425", "0.66540444", "0.664885", "0.66447985", "0.663471", "0.66229784", "0.66229784", "0.66195524", "0.66187197", "0.6613983", "0.6613504", "0.6610882", "0.6602243", "0.6602243", "0.6601184", "0.6597348", "0.65973115", "0.65934044", "0.65880513", "0.65880513", "0.65867704", "0.658194", "0.65812165", "0.65645283", "0.65632075", "0.6562291", "0.6562291", "0.6559137", "0.65580523", "0.6556052", "0.654672", "0.6543249", "0.65404326", "0.65361583", "0.6534924", "0.65347946", "0.65347946", "0.65347946", "0.65347946", "0.65317744", "0.6529259", "0.65287364", "0.65281284", "0.65281284", "0.6523232", "0.6521508", "0.65191966", "0.65172005", "0.6512645", "0.6512645", "0.6510726", "0.6510726", "0.6509428", "0.6509428", "0.6503521", "0.65016925", "0.6501541" ]
0.0
-1
reduce 333 omitted reduce 334 omitted
def _reduce_335(val, _values, result) result = [ @builder.arg_expr(val[0]) ] result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_704(val, _values, result); end", "def _reduce_23(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_334(val, _values, result); end", "def _reduce_363(val, _values, result); end", "def _reduce_34(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_464(val, _values, result); end", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_634(val, _values, result); end", "def _reduce_411(val, _values, result); end", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_47(val, _values, result); end", "def _reduce_526(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_21(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_455(val, _values, result); end", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_601(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_314(val, _values, result); end", "def _reduce_492(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_711(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_372(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_604(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_645(val, _values, result)\n yyerrok\n result\nend", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_602(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_642(val, _values, result)\n yyerrok\n result\nend", "def _reduce_642(val, _values, result)\n yyerrok\n result\nend", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_277(val, _values, result); end", "def _reduce_277(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end" ]
[ "0.75453967", "0.7485832", "0.74738675", "0.7467229", "0.7464228", "0.746281", "0.74530923", "0.7440326", "0.74233043", "0.7416796", "0.7416674", "0.7416674", "0.740446", "0.74044484", "0.7397121", "0.73910797", "0.73834455", "0.73797184", "0.73699766", "0.7363254", "0.7350874", "0.7350111", "0.7347986", "0.73392904", "0.7335253", "0.7335167", "0.7333677", "0.7332711", "0.7327178", "0.7316611", "0.73136145", "0.7310818", "0.7310323", "0.7310323", "0.7307417", "0.73063827", "0.7299579", "0.7287844", "0.7283896", "0.72796077", "0.7279023", "0.7278411", "0.7278411", "0.72765195", "0.72765195", "0.7275105", "0.72727287", "0.72685254", "0.7268171", "0.7264512", "0.72620285", "0.7252064", "0.72492963", "0.7240829", "0.7239303", "0.7238015", "0.7238015", "0.72291", "0.7225637", "0.7224633", "0.7224633", "0.72230226", "0.72230226", "0.72160256", "0.72121376", "0.72121376", "0.7198507", "0.71957064", "0.71957064", "0.719398", "0.7191", "0.71890056", "0.7188047", "0.7188047", "0.71868134", "0.7174135", "0.71722156", "0.71721786", "0.71691483", "0.7168966", "0.7165782", "0.7165008", "0.71631265", "0.71631265", "0.7159678", "0.7159488", "0.7159488", "0.7159488", "0.7151888", "0.7151888", "0.71503717", "0.71498823", "0.71492565", "0.71492565", "0.71468717", "0.71468717", "0.714415", "0.714415", "0.71429396", "0.7142517", "0.7142517" ]
0.0
-1
reduce 337 omitted reduce 338 omitted
def _reduce_339(val, _values, result) result = val[0]. push(@builder.blockarg_expr(val[2], val[3])) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_363(val, _values, result); end", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_375(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_385(val, _values, result); end", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_634(val, _values, result); end", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_314(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_34(val, _values, result); end", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_637(val, _values, result); end", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_47(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_37(val, _values, result); end", "def _reduce_37(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_704(val, _values, result); end", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_378(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_526(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_53(val, _values, result); end", "def _reduce_53(val, _values, result); end", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_28(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_357(val, _values, result); end", "def _reduce_476(val, _values, result); end", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_699(val, _values, result); end", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_17(val, _values, result); end", "def _reduce_334(val, _values, result); end", "def _reduce_216(val, _values, result)\n result = []\n\n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_736(val, _values, result); end", "def _reduce_23(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_374(val, _values, result); end", "def _reduce_384(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_391(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_391(val, _values, result)\n result = val[1]\n \n result\nend" ]
[ "0.73445296", "0.73445296", "0.7298085", "0.725644", "0.72161674", "0.71827036", "0.7175643", "0.7175643", "0.7167267", "0.716692", "0.7162977", "0.71522", "0.71508366", "0.71362835", "0.7131755", "0.71300244", "0.71300244", "0.71241695", "0.7121963", "0.71207523", "0.71183604", "0.71129155", "0.71124685", "0.7105331", "0.71033317", "0.71013016", "0.7091936", "0.70769864", "0.7073002", "0.70726395", "0.7069816", "0.7069816", "0.7064888", "0.7060474", "0.7060474", "0.70588964", "0.7058823", "0.7056374", "0.7051896", "0.7051762", "0.7051762", "0.7043056", "0.7043056", "0.70360214", "0.70239854", "0.70118463", "0.70089424", "0.70089424", "0.70063204", "0.70023507", "0.70023507", "0.7000889", "0.6999896", "0.6995104", "0.6994284", "0.69916546", "0.6990197", "0.69882303", "0.698677", "0.6982973", "0.6981765", "0.6981746", "0.6981746", "0.6976633", "0.697564", "0.697564", "0.69669545", "0.69637406", "0.69637406", "0.6962114", "0.6961349", "0.6961349", "0.69576937", "0.69572234", "0.69572234", "0.69564414", "0.6950483", "0.6950483", "0.6948263", "0.69471943", "0.6946401", "0.69428444", "0.6940239", "0.69364727", "0.6934762", "0.6934762", "0.6932677", "0.69314235", "0.6926282", "0.6922221", "0.69179356", "0.69158435", "0.69139916", "0.6913764", "0.69109297", "0.6906862", "0.6903766", "0.6903147", "0.6901124", "0.68977934", "0.68977934" ]
0.0
-1
reduce 377 omitted reduce 378 omitted
def _reduce_379(val, _values, result) result = [ val[0], val[1] ] result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_375(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_47(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_34(val, _values, result); end", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_476(val, _values, result); end", "def _reduce_634(val, _values, result); end", "def _reduce_704(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_378(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_314(val, _values, result); end", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_526(val, _values, result); end", "def _reduce_23(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_455(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_604(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_216(val, _values, result)\n result = []\n\n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_699(val, _values, result); end", "def _reduce_669(val, _values, result); end", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_367(val, _values, result); end", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_470(val, _values, result); end", "def _reduce_637(val, _values, result); end", "def _reduce_710(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_411(val, _values, result); end", "def _reduce_466(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_334(val, _values, result); end" ]
[ "0.7387706", "0.73733467", "0.7367915", "0.7349766", "0.7331728", "0.7326862", "0.7297008", "0.7293756", "0.7278939", "0.7275278", "0.7275278", "0.7274133", "0.7274133", "0.72619647", "0.72598344", "0.72579694", "0.72558755", "0.7245392", "0.72447026", "0.7238811", "0.723409", "0.72239023", "0.7222772", "0.7213238", "0.7210983", "0.7209929", "0.7206388", "0.7203874", "0.7200733", "0.7200733", "0.7194152", "0.7194152", "0.7191905", "0.7191905", "0.7191823", "0.71792865", "0.717888", "0.7178773", "0.7177522", "0.7164653", "0.71581066", "0.7152268", "0.7151066", "0.71437037", "0.7140164", "0.7132712", "0.71309954", "0.711897", "0.71146536", "0.71146536", "0.71090436", "0.71025723", "0.7098945", "0.7098848", "0.7098848", "0.7097658", "0.709764", "0.709764", "0.70964766", "0.70954496", "0.7095022", "0.7094053", "0.7086066", "0.7086066", "0.7085445", "0.7085126", "0.7084501", "0.7073545", "0.707251", "0.70710886", "0.7070211", "0.7061837", "0.7060743", "0.7060743", "0.7056322", "0.70518255", "0.70506835", "0.70506835", "0.7049672", "0.7041236", "0.703844", "0.70374596", "0.7036886", "0.70346296", "0.7030392", "0.70283157", "0.70221156", "0.70221156", "0.7021994", "0.7021994", "0.701691", "0.7016847", "0.70161116", "0.70096934", "0.70054805", "0.7002778", "0.7000555", "0.6996889", "0.6994729", "0.6994729", "0.6985231" ]
0.0
-1
reduce 382 omitted reduce 383 omitted reduce 384 omitted reduce 385 omitted
def _reduce_386(val, _values, result) result = @builder.string_compose(nil, val[0], nil) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_512(val, _values, result); end", "def _reduce_512(val, _values, result); end", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_384(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_492(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_697(val, _values, result); end", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_69(val, _values, result); end", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_494(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_367(val, _values, result); end", "def _reduce_634(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_704(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_699(val, _values, result); end", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_736(val, _values, result); end", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_649(val, _values, result)\n yyerrok\n result\nend", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_669(val, _values, result); end", "def _reduce_411(val, _values, result); end", "def _reduce_314(val, _values, result); end", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_637(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_599(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_711(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_526(val, _values, result); end", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_638(val, _values, result)\n yyerrok\n result\nend", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end" ]
[ "0.7317671", "0.73003757", "0.72820497", "0.7247289", "0.7234892", "0.7230869", "0.71958476", "0.71958476", "0.71760094", "0.71636474", "0.7147073", "0.71392006", "0.713243", "0.7128843", "0.7128843", "0.71251804", "0.7116366", "0.7113735", "0.7113735", "0.71099013", "0.7105883", "0.71027637", "0.7093743", "0.70868653", "0.7078566", "0.7071441", "0.7070051", "0.7063631", "0.7063631", "0.70522153", "0.70458156", "0.70456827", "0.70414686", "0.70414686", "0.7034734", "0.7034734", "0.70328695", "0.70320225", "0.7031904", "0.7029736", "0.7010959", "0.70074946", "0.70071805", "0.69987327", "0.69987327", "0.6993534", "0.6991315", "0.69909984", "0.69781595", "0.69781387", "0.6974913", "0.6974159", "0.6966262", "0.6966262", "0.6963728", "0.6963703", "0.6962232", "0.69620955", "0.6959668", "0.69466513", "0.69439185", "0.69426006", "0.6942142", "0.6942142", "0.6939059", "0.6938427", "0.6936461", "0.6928226", "0.69281757", "0.69203407", "0.69131935", "0.6912215", "0.6910321", "0.6910321", "0.6903483", "0.69017124", "0.68992805", "0.6880413", "0.6879158", "0.68791354", "0.6874786", "0.6874786", "0.6874786", "0.6874786", "0.6873589", "0.6873589", "0.6871663", "0.68696", "0.6866925", "0.6866034", "0.6864673", "0.68606186", "0.6857747", "0.6857747", "0.6855476", "0.6852705", "0.68483794", "0.6845272", "0.6845272", "0.684527", "0.684527" ]
0.0
-1
reduce 458 omitted reduce 459 omitted
def _reduce_460(val, _values, result) @static_env.declare val[1][0] result = [ @builder.restarg(val[0], val[1]) ] result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_476(val, _values, result); end", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_455(val, _values, result); end", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_604(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_457(val, _values, result); end", "def _reduce_599(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_216(val, _values, result)\n result = []\n\n result\nend", "def _reduce_494(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_47(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_385(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_684(val, _values, result); end", "def _reduce_460(val, _values, result); end", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_565(val, _values, result); end", "def _reduce_565(val, _values, result); end", "def _reduce_526(val, _values, result); end", "def _reduce_69(val, _values, result); end", "def _reduce_13(val, _values, result); end", "def _reduce_470(val, _values, result); end", "def _reduce_637(val, _values, result); end", "def _reduce_634(val, _values, result); end", "def _reduce_704(val, _values, result); end", "def _reduce_728(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_545(val, _values, result); end", "def _reduce_545(val, _values, result); end", "def _reduce_53(val, _values, result); end", "def _reduce_53(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_34(val, _values, result); end", "def _reduce_367(val, _values, result); end", "def _reduce_480(val, _values, result); end", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_135(val, _values, result); end", "def _reduce_135(val, _values, result); end", "def _reduce_604(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_512(val, _values, result); end", "def _reduce_512(val, _values, result); end", "def _reduce_744(val, _values, result); end", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_314(val, _values, result); end", "def _reduce_363(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_600(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_686(val, _values, result); end", "def _reduce_466(val, _values, result); end", "def _reduce_137(val, _values, result); end" ]
[ "0.73140836", "0.7241976", "0.7208349", "0.7190746", "0.71732765", "0.7164137", "0.71501476", "0.71440053", "0.7135463", "0.7133203", "0.71269894", "0.7124448", "0.7123086", "0.71215135", "0.71127737", "0.71127737", "0.7108824", "0.71026945", "0.71026945", "0.7098696", "0.7089504", "0.7086867", "0.7086619", "0.707492", "0.7051491", "0.70463294", "0.70435435", "0.7033682", "0.703335", "0.703335", "0.702638", "0.7023762", "0.7017697", "0.7009646", "0.7002304", "0.69985956", "0.69918984", "0.698547", "0.698502", "0.698502", "0.698463", "0.69784176", "0.69784176", "0.69736546", "0.69694823", "0.69658595", "0.6965743", "0.6961202", "0.6960617", "0.69555604", "0.69526386", "0.69410163", "0.6933356", "0.6927342", "0.6927342", "0.6927055", "0.6924794", "0.69243133", "0.6918505", "0.69161105", "0.69155943", "0.691459", "0.69105315", "0.6908641", "0.69060695", "0.69060695", "0.69055545", "0.6900619", "0.6892084", "0.6886976", "0.6884535", "0.6880288", "0.6878875", "0.68686", "0.68659145", "0.68659145", "0.68591803", "0.68591803", "0.6859017", "0.6859017", "0.68570435", "0.68570435", "0.68557835", "0.68557835", "0.68540263", "0.6851919", "0.68479675", "0.6845443", "0.6841206", "0.6841206", "0.68408906", "0.6840496", "0.6840496", "0.68403673", "0.6839444", "0.6836954", "0.683678", "0.68355894", "0.6832466", "0.683014", "0.682458" ]
0.0
-1
reduce 462 omitted reduce 463 omitted
def _reduce_464(val, _values, result) @static_env.declare val[1][0] result = @builder.blockarg(val[0], val[1]) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_363(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_476(val, _values, result); end", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_526(val, _values, result); end", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_634(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_684(val, _values, result); end", "def _reduce_704(val, _values, result); end", "def _reduce_604(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_637(val, _values, result); end", "def _reduce_13(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_363(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_411(val, _values, result); end", "def _reduce_385(val, _values, result); end", "def _reduce_494(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_466(val, _values, result); end", "def _reduce_455(val, _values, result); end", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_312(val, _values, result); end", "def _reduce_470(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_744(val, _values, result); end", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_334(val, _values, result); end", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_512(val, _values, result); end", "def _reduce_512(val, _values, result); end", "def _reduce_736(val, _values, result); end", "def _reduce_669(val, _values, result); end", "def _reduce_699(val, _values, result); end", "def _reduce_53(val, _values, result); end", "def _reduce_53(val, _values, result); end", "def _reduce_314(val, _values, result); end", "def _reduce_457(val, _values, result); end", "def _reduce_34(val, _values, result); end", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_394(val, _values, result); end", "def _reduce_462(val, _values, result); end", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_492(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_137(val, _values, result); end", "def _reduce_137(val, _values, result); end" ]
[ "0.7505988", "0.7428923", "0.74218297", "0.7421626", "0.7388083", "0.7376065", "0.73724425", "0.73724425", "0.7353877", "0.73303175", "0.732211", "0.732211", "0.73181117", "0.730277", "0.73017347", "0.72995216", "0.72995216", "0.7289194", "0.72807974", "0.72795606", "0.7269947", "0.7266329", "0.7262179", "0.7244154", "0.7239034", "0.72353196", "0.7231657", "0.7222503", "0.7216381", "0.7215201", "0.7214543", "0.7214218", "0.7211182", "0.72055376", "0.71860576", "0.71843946", "0.71843946", "0.7179664", "0.71700555", "0.71578497", "0.7157162", "0.715652", "0.7155741", "0.7150038", "0.7144077", "0.71387494", "0.71387494", "0.7138663", "0.7138663", "0.71357185", "0.71357185", "0.71333665", "0.71222955", "0.711943", "0.7117548", "0.7117548", "0.71156484", "0.7115048", "0.7115048", "0.7114627", "0.71135354", "0.7113122", "0.7113122", "0.71118647", "0.71072483", "0.71042365", "0.71001446", "0.7099922", "0.7098412", "0.70979613", "0.70962465", "0.70938784", "0.70874876", "0.7087469", "0.70836973", "0.7083523", "0.7083284", "0.7076109", "0.706923", "0.70676184", "0.7065636", "0.7065636", "0.7062926", "0.7062044", "0.70607394", "0.70511115", "0.70511115", "0.7048703", "0.70474154", "0.70458835", "0.704347", "0.7041451", "0.7038479", "0.7028999", "0.702862", "0.702862", "0.7028558", "0.702726", "0.70202327", "0.7019162", "0.7019162" ]
0.0
-1
reduce 475 omitted reduce 476 omitted reduce 477 omitted reduce 478 omitted reduce 479 omitted reduce 480 omitted reduce 481 omitted reduce 482 omitted reduce 483 omitted reduce 484 omitted reduce 485 omitted reduce 486 omitted reduce 487 omitted reduce 488 omitted reduce 489 omitted reduce 490 omitted reduce 491 omitted reduce 492 omitted reduce 493 omitted
def _reduce_494(val, _values, result) yyerrok result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_498(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_709(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_600(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_363(val, _values, result); end", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_512(val, _values, result); end", "def _reduce_512(val, _values, result); end", "def _reduce_697(val, _values, result); end", "def _reduce_216(val, _values, result)\n result = []\n\n result\nend", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_13(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_684(val, _values, result); end", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_240(val, _values, result); end", "def _reduce_240(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_50(val, _values, result); end", "def _reduce_50(val, _values, result); end", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_728(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_367(val, _values, result); end", "def _reduce_552(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_699(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_695(val, _values, result); end", "def _reduce_476(val, _values, result); end", "def _reduce_466(val, _values, result); end", "def _reduce_669(val, _values, result); end", "def _reduce_9(val, _values, result); end", "def _reduce_9(val, _values, result); end", "def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_634(val, _values, result); end", "def _reduce_599(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_667(val, _values, result); end", "def _reduce_470(val, _values, result); end", "def _reduce_704(val, _values, result); end", "def _reduce_637(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_604(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_736(val, _values, result); end", "def _reduce_526(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_237(val, _values, result)\n result = []\n \n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_710(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend" ]
[ "0.74167854", "0.73850244", "0.7354644", "0.7334862", "0.73247856", "0.73204184", "0.73155296", "0.7294253", "0.72786516", "0.72577024", "0.72577024", "0.72555196", "0.7252882", "0.72350633", "0.7234671", "0.7232565", "0.72266793", "0.72169805", "0.72169805", "0.7212306", "0.72113186", "0.72105956", "0.7202485", "0.7202485", "0.72008204", "0.7198014", "0.7198014", "0.71934986", "0.71883994", "0.71883994", "0.7172844", "0.71680146", "0.7166073", "0.7163243", "0.7161257", "0.7161062", "0.7159248", "0.71504354", "0.71504354", "0.71373624", "0.71362454", "0.71310645", "0.7128186", "0.7127619", "0.7127619", "0.71159583", "0.71130806", "0.71015483", "0.7098404", "0.70973784", "0.70973784", "0.70971435", "0.70957124", "0.7094443", "0.7094114", "0.70899755", "0.7086554", "0.7085612", "0.7085574", "0.7075962", "0.7075962", "0.70729524", "0.7072364", "0.7072364", "0.707078", "0.70676965", "0.7067121", "0.70609087", "0.70605516", "0.7057792", "0.70567805", "0.70466155", "0.70466155", "0.7043495", "0.70420307", "0.7038337", "0.7031799", "0.7025247", "0.7019664", "0.70151216", "0.70116675", "0.70116675", "0.7004063", "0.699624", "0.69879776", "0.69873047", "0.69868267", "0.69839597", "0.6981318", "0.69806296", "0.69800925", "0.69800925", "0.6971609", "0.6971315", "0.6966491", "0.6966201", "0.6966201", "0.6957182", "0.69516605", "0.69516605", "0.69506025" ]
0.0
-1
reduce 495 omitted reduce 496 omitted reduce 497 omitted
def _reduce_498(val, _values, result) result = nil result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_496(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_263(val, _values, result); end", "def _reduce_263(val, _values, result); end", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_464(val, _values, result); end", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_605(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_528(val, _values, result); end", "def _reduce_528(val, _values, result); end", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_697(val, _values, result); end", "def _reduce_47(val, _values, result); end", "def _reduce_363(val, _values, result); end", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_228(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_526(val, _values, result); end", "def _reduce_686(val, _values, result); end", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_683(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_576(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_271(val, _values, result); end", "def _reduce_271(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_476(val, _values, result); end", "def _reduce_684(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_363(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_385(val, _values, result); end", "def _reduce_544(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_634(val, _values, result); end", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_704(val, _values, result); end", "def _reduce_466(val, _values, result); end", "def _reduce_606(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_411(val, _values, result); end", "def _reduce_13(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_268(val, _values, result); end", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_699(val, _values, result); end", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_470(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_603(val, _values, result); end", "def _reduce_554(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_579(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_637(val, _values, result); end", "def _reduce_363(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_492(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_218(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_736(val, _values, result); end", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_312(val, _values, result); end", "def _reduce_707(val, _values, result); end", "def _reduce_744(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_455(val, _values, result); end", "def _reduce_669(val, _values, result); end", "def _reduce_710(val, _values, result)\n _, margs, _ = val\n\n result = margs\n\n result\nend", "def _reduce_494(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_277(val, _values, result); end", "def _reduce_277(val, _values, result); end", "def _reduce_367(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_211(val, _values, result); end", "def _reduce_596(val, _values, result)\n yyerrok\n\n result\nend", "def _reduce_602(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_336(val, _values, result); end", "def _reduce_336(val, _values, result); end", "def _reduce_394(val, _values, result); end", "def _reduce_34(val, _values, result); end", "def _reduce_334(val, _values, result); end" ]
[ "0.749545", "0.74520427", "0.74520427", "0.7431019", "0.74008954", "0.7396472", "0.73883563", "0.738511", "0.7370563", "0.73573446", "0.73573446", "0.73220867", "0.7316749", "0.73133725", "0.7308586", "0.730313", "0.730313", "0.72983825", "0.7290327", "0.7290001", "0.72892326", "0.72889566", "0.7288934", "0.72839445", "0.7278271", "0.72777635", "0.72770464", "0.7273202", "0.7273202", "0.7267007", "0.7265051", "0.7265051", "0.7259186", "0.72562903", "0.7255151", "0.7255151", "0.7254827", "0.7254487", "0.7241343", "0.72328097", "0.7230517", "0.7230517", "0.7229894", "0.7217367", "0.7217325", "0.72143257", "0.7210668", "0.7209768", "0.72063166", "0.7201583", "0.7199778", "0.71993166", "0.7193456", "0.71826375", "0.71826375", "0.71794826", "0.7178951", "0.717846", "0.71769977", "0.7175809", "0.7166917", "0.71661794", "0.71661794", "0.7162624", "0.7161233", "0.715531", "0.715531", "0.71551675", "0.715516", "0.715516", "0.71494067", "0.71485", "0.7147306", "0.71436524", "0.71403587", "0.71375734", "0.71339905", "0.7132847", "0.7132847", "0.71281683", "0.71267384", "0.71202344", "0.7117729", "0.7113521", "0.7112031", "0.71118647", "0.7106502", "0.7106502", "0.71029687", "0.7101306", "0.7101306", "0.70983624", "0.70900714", "0.7086187", "0.7082972", "0.70816755", "0.70816755", "0.708006", "0.7079757", "0.7078366" ]
0.7299128
17
Adding new contact in an array
def add_new_contact # Getting information from user puts "Enter your firstname" firstName = gets puts"Enter your Lastname" lastName = gets puts"Enter Email" email = gets puts "Enter notes" notes = gets # Making a contact object contact = Contact.new(firstName, lastName, email, notes) @contacts << contact # Putting newly created object in array. end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_contact(contact)\n\t\tcontact.id = @@ids\n\t\t@contacts << contact \n\t\t@@ids += 1\n\t\tcontact\n\tend", "def addContact(fname,lname,email)\n\t\[email protected](Struct::ContactEntry.new(fname,lname,email))\n\tend", "def create_contact(name, telephone, email)\n\tcontact_list = {\n\t\tname: name,\n\t\ttelephone: telephone,\n\t\temail: email\n\t}\n\tcontacts = []\n\tcontacts << contact_list\nend", "def modify_existing_contact\n self.to_contact.modify_existing_contact.to_contact\n end", "def add_contact\n puts \"What is the contact name?\"\n @one_contact[:contact_name] = gets.strip\n puts \"What is the contact's email?\"\n @one_contact[:contact_email] = gets.strip\n puts \"\\nThe following contact has been added:\"\n one_contact\n @contact_arr << @one_contact\n @one_contact = {}\n puts\nend", "def initialize\n @contacts = []\n end", "def initialize\n @contacts = []\n end", "def action_new( contacts )\n\n #calls the create new method to create a new contact\n contact = create_new\n\n #puts the newly created contact in the contacts array\n contacts << contact\n\n write_contacts( contacts )\n\n puts\n puts \"New contact created:\"\n puts\n\n #Shows the newly created user\n show( contact )\n puts\nend", "def initialize#(contacts)\n\t\t@contacts = [] #if we have different contacts with the same name we need to add another value to give each contact a unique identifier to differentiate between them\n\tend", "def add_contact\n\t\tprint \"First Name: \".pink\n\t\tfirst_name = gets.chomp\n\t\tprint \"Last Name: \".pink\n\t\tlast_name = gets.chomp\n\t\tprint \"Email :\".pink\n\t\temail = gets.chomp\n\t\tprint \"Note :\".pink\n\t\tnote = gets.chomp #could use a hash but it is not ideal - if you need a cutstom piece of data to be repeated you need to create a new class for that method to call on\n\n\t\tcontact = Contact.new(first_name, last_name, email, note)\n\t\[email protected]_contact(contact)\n\n\tend", "def create_contact()\n Contact.new(id: rand(2000)).tap do |c|\n contacts << c\n end\n end", "def add_friends(friends_array,name)\n friends_array << name\nend", "def save!(additions = [])\n additions.each do |contact|\n @ab.addRecord(contact.person)\n end\n\n @ab.save\n end", "def create(name, email)\n id = 1\n CSV.foreach(\"contact_data.csv\") { |line| id += 1}\n contact_list = CSV.open(\"contact_data.csv\", 'a')\n new_contact = [id,name,email]\n contact_list << new_contact\n id\n end", "def add_contacts\n \tap \"adding contacts\"\n # asking whether we are already authorized\n AddressBook.request_authorization unless AddressBook.authorized?\n\n \n if AddressBook.authorized?\n 25.times do\n person = AddressBook::Person.create(\n :first_name => Forgery::Name.first_name, \n :last_name => Forgery::Name.last_name, \n :email => [{ :value => Forgery(:internet).email_address , :label => 'Home'}], :phones => [{ :value => rand(10 ** 10).to_s, :label => 'Mobile'}])\n end\n else\n #ap \"This app is not authorized to access the address book.\"\n end\n #enVd\n end", "def add_contacts \n params[:contact_ids] = params[:contact_ids][0].split(', ')\n contacts = current_user.contacts.find(params[:contact_ids]) \n @notification = current_user.notifications.find(params[:id])\n \n contacts = contacts.collect{|el| @notification.contacts.include?(el) ? nil : el}.compact\n contacts.each do |el|\n @notification.receipients.create( :contact_id => el.id, :status => 'active' )\n end\n \n render :update do |page| \n page.redirect_to(@notification)\n end \n end", "def add_a_contact\r\n print 'Enter a name: '\r\n name = gets.chomp\r\n phone_numbers = []\r\n email = []\r\n\r\n print 'Enter the phone number: '\r\n phone_num = gets.chomp\r\n phone_numbers.push phone_num\r\n while phone_num != 'x'\r\n print 'Enter additional phone number or type \"x\" to stop: '\r\n phone_num = gets.chomp\r\n end\r\n\r\n print 'Enter the email address: '\r\n email = gets.chomp\r\n while email != 'x'\r\n emails.push email\r\n print 'Enter additional email address or type \"x\" to stop: '\r\n email = gets.chomp\r\n end\r\n\r\n @contact_book.add_contact(name, phone_numbers, emails)\r\n end", "def initialize\n\t\t@contacts = [] #empty arrary to hold entire contact list.\n\tend", "def add_contact(params={})\n @obj.put('add-contact', @auth.merge(params))\n end", "def add_new_contact\n print \"First Name:\"\n first_name = gets.chomp\n print \"last name:\"\n last_name = gets.chomp\n print \"Email:\"\n email = gets.chomp\n print \"Note:\"\n note = gets.chomp\n contact = Contact.new(first_name, last_name, email, note)\n add_contact(contact)\n end", "def add_contact\n\t\tcheck_if_myself(params[:user_id])\n\t\tuser = User.find(params[:user_id])\n\t\tto_add = User.find(params[:to_add_id])\n\t\tif to_add && user != to_add && !Contact.where(from_user: user.id).map {|c| c.to_user.id}.include?(to_add.id)\n\t\t\tuser.contacts.push(to_add)\n\t\t\tuser.save\n\t\t\tredirect_to contacts_page_path(id: params[:user_id])\n\t\telse\n\t\t\traise ActionController::RoutingError, 'Not Found'\n\t\tend\n\tend", "def add_contact(ownnick, person)\n return ret_fail('can not add yourself') if person == ownnick #you cant add yourself !\n\n usr = User.first(:nickname=>person)\n return ret_fail('no such user') if usr == nil #user does not exist !\n\n ownusr = User.first(:nickname => ownnick) #get own record to get the contact list\n return ret_fail('already in list') if ownusr.contacts.first(:userid => usr.id) != nil\n\n c = ownusr.contacts.new\n c.userid = usr.id\n puts usr.id\n puts c.userid\n c.authgiven = 'f'\n c.save\n\n return ret_success\nend", "def create\n @searcheds = Searched.all\n @searched = Searched.new(searched_params)\n contact_id = ''\n if !params['contact_ids'].nil? && params['contact_ids'].first.to_i > 0\n id_array = []\n contact_id_array = params['contact_ids'].to_a\n\n contact_id_array.each do |id |\n if id.to_i > 0\n id_array << id\n contact_id = id.to_s\n end\n end\n\n if contact_id_array[0].to_i > 0\n @searched.contact_ids = id_array\n end\n @searched.update_attributes(:name => @searched.contacts.first.name, :contact_id => contact_id, :number => @searched.contacts.first.phone, :email => @searched.contacts.first.email, :cell => @searched.contacts.first.cell, :fulladdress => @searched.contacts.first.Fulladdress)\n\n end\n\n\n respond_to do |format|\n if @searched.save\n format.html { redirect_to @searched, notice: 'Searched was successfully created.' }\n format.json { render :show, status: :created, location: @searched }\n else\n format.html { render :new }\n format.json { render json: @searched.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def post_contact\n\t\tcontact = Contact.new\n\t\tcontact.first_name = params[:first_name]\n\t\tcontact.last_name = params[:last_name]\n\t\tcontact.phone_number = params[:phone_number]\n\t\tcontact.email = params[:email]\n\t\tcontact.save\n\t\tcurrent_agendify_user.contacts.push(contact)\n\t\tcurrent_agendify_user.save\n\t\tredirect_to root_path\n\tend", "def create_contact(name, phonenumber)\n contact = {\n name: \"#{name}\",\n phone: \"#{phonenumber}\",\n }\n @contact_book << contact\n #p @contact_book #print confirmation of adding to the hash \nend", "def initialize\n\t\t@contacts = []\n\t\t#@index = 1000 #1003 for 2 rolodexes with 3 contacts.\n\tend", "def prime \n first_name = [\"James\", \"Mark\", \"Angela\", \"Theodore\", \"Sarah\"]\n last_name = [\"Bond\", \"Sheffield\", \"La Roche\", \"Michaels\", \"Robertson\"]\n email = [\"[email protected]\", \"[email protected]\", \"[email protected]\", \"[email protected]\", \"[email protected]\"]\n note = [\"This guys is badass!\", \"He's ok.\", \"Super annoying\", \"Great customer!\", \"Not much to say\"]\n\n first_name.each_index do |i|\n contact = Contact.new(first_name[i], last_name[i], email[i], note[i])\n Rolodex.add_contact(contact)\n Rolodex.contacts \n end\nend", "def create(name, email, numbers = [])\n exists = Contact.search_by_email(email)\n return ['exist', Contact.search_by_email(email)] if exists\n contact = Contact.new(name, email, (self.all.count + 1))\n numbers.each do |number|\n contact.add_number(number)\n end\n CSV.open('contacts.csv', 'a') do |csv_file|\n nums = []\n contact.numbers.each do |number|\n nums << \"#{number.to_s}\"\n end\n csv_file.puts [contact.id, contact.name, contact.email] + nums\n end\n contact\n end", "def contacts\n @contacts ||= @ab.people.map {|abperson| Macabee::Contact.new(abperson, :macabee => self)}\n end", "def add(contact)\n raise StandardError, \"Must connect to device first\" if @sp.nil?\n\n name_hex = to_hex(contact.name)\n home_hex = to_hex(contact.phone_numbers[\"home\"])\n mobile_hex = to_hex(contact.phone_numbers[\"mobile\"])\n work_hex = to_hex(contact.phone_numbers[\"work\"])\n\n # https://satphoneshop.com/downloads/AT_Commands.pdf\n # +CAPBW=<name>,[<home_number>],[<work_number>],[<mobile_number>],[<other_number>],[<email>],[<notes>] \n cmd = \"AT+CAPBW=#{name_hex},#{home_hex},#{work_hex},#{mobile_hex},,,\\r\"\n\n write(cmd)\n end", "def add_data_com_contacts(datacom_contacts)\n datacom_contacts.each do |contact|\n contacts << Contact.new(contact.to_sugar_data.merge(contacts_defaults))\n end\n end", "def view_contacts(contacts) # run this function to view the contacts int he array\n contacts = contacts\n puts \"--- View Contacts ---\"\n count = 0\n # While count is less than the length of the elements in the contacts array\n # keep looping this while loop\n count = 0\n if contacts.empty?\n puts \"Contact list is empty\\n\\n\"\n else\n while count < contacts.length\n #puts contacts[count] # Display the current element in position (count) of the contacts array - Debugging\n # Set the first object in the array, which is a hash from create_contact,\n # as the value of theHash\n theHash = contacts[count]\n # puts \"The hash is: #{theHash}\"\n puts \"\\n\\tContact #{count + 1}\"\n # Select the Hash pair using the method getHash targeting the \"Name\" pair\n theName = theHash[\"Name\"]\n puts \"Name: #{theName}\"\n \n # Select the Hash pair using the method getHash targeting the \"Phone\" pair\n theNumber = theHash[\"Phone\"]\n puts \"Phone: #{theNumber}\"\n \n # Select the Hash pair using the method getHash targeting the \"Email\" pair\n theEmail = theHash[\"Email\"]\n puts \"Email: #{theEmail}\"\n \n # Select the Hash pair using the method getHash targeting the \"Address\"\n theAddress = theHash[\"Address\"]\n puts \"Address: #{theAddress}\"\n \n count += 1 # Add one to the count\n end\n end\nend", "def add_all_to\n if params[:contact_type] && [1, 2, 3].include?(params[:contact_type].to_i)\n contacts = Contact.find_all_by_contact_type_id(params[:contact_type])\n for contact in contacts\n Subscriber.find_or_create_by_subscriber_list_id_and_contact_id(@subscriber_list.id, contact.id)\n end\n\n flash[:notice] = \"Todos los #{Contact::SUBSCRIBER_TYPES.select{|x| x.idx == params[:contact_type].to_i}.first.name} han sido añadidos.\"\n end\n\n redirect_to :back\n end", "def add_mailout_contact( role_contactinfo, user_id )\n \n person = role_contactinfo.role.person\n organisation = role_contactinfo.role.organisation\n \n # get details relevant only to person contact\n if !person.blank?\n contact_name = person.full_name\n salutation = person.salutation\n nomen = person.nomen.nomen unless person.nomen.blank?\n role_title = role_contactinfo.role.role_title unless role_contactinfo.role.organisation.blank? || role_contactinfo.role.role_title.blank?\n #else\n # contact_name = organisation.organisation_name unless organisation.blank?\n end\n \n # raise exception if an exact duplicate found (the same role_contactinfo_id)\n for contact in mailout_contacts\n if !role_contactinfo.blank? && contact.role_contactinfo_id == role_contactinfo.role_contactinfo_id\n errors.add \"The contact #{ contact_name } already exists in the mailout\"\n raise CampaignMailoutException.new(\"The contact #{ contact_name } already exists in the mailout\")\n end\n end\n \n #puts \"***** Adding contact #{role_contactinfo.role_contactinfo_id} \"\n \n mailout_contact = MailoutContact.new\n mailout_contact.name = contact_name\n mailout_contact.nomen = nomen\n mailout_contact.role_title = role_title\n mailout_contact.organisation_name = organisation.organisation_name unless organisation.blank?\n \n # FIXME do we need salutation?\n mailout_contact.salutation = salutation\n \n mailout_contact.role_contactinfo_id = role_contactinfo.role_contactinfo_id\n mailout_contact.campaign_mailout_id = campaign_mailout_id\n mailout_contact.updated_by = user_id\n \n #puts \"=======\"\n #puts mailout_contact.to_yaml\n \n mailout_contact = copy_address_details(mailout_contact, role_contactinfo.contactinfo)\n \n mailout_contacts << mailout_contact\n \n\t# WR#53662 - system performance issues:\n\t# solr re-indexing of role contactinfos takes a lot of time\n\t# for large lists, as per Scilla's note dated 12:44 23-05-2008\n\t# commented out solr re-indexing\n\t\t\n #if mailout_contact.save\n # # for solr update\n # mailout_contact.role_contactinfo.save\n #end\n \n #puts errors.to_yaml\n \n end", "def add_new_contact \t\n\t print \"Enter First Name: \"\n\t first_name = gets.chomp\n\t print \"Enter Last Name: \"\n\t last_name = gets.chomp\n\t print \"Enter Email Address: \"\n\t email = gets.chomp\n\t print \"Enter a Note: \"\n\t note = gets.chomp\n\n\t contact = Contact.new(first_name, last_name, email, note)\n\t @rolodex.add_contact(contact)\n\tend", "def add_tag_to_contact\n\t\t\t\t# add a tag to this contact\n\t\t\t\t# collect and clean the params\n\t\t\t\ttag_text = params[:tag_text].match(/[A-Za-z0-9-]+/)[0]\n\t\t\t\tcontact_id = params[:contact_id].match(/[A-Fa-f0-9]+/)[0]\n\t\t\t\t# let's see if this tag exists. if so, set tag to equal its corresponding object \n\t\t\t\ttag = Tag.where(:tag => tag_text).first\n\t\t\t\t# see if we got one\n\t\t\t\tif !tag\n\t\t\t\t\t# if we don't find the tag, make one\n\t\t\t\t\ttag = Tag.new\n\t\t\t\t\ttag.tag = tag_text\n\t\t\t\t\ttag.save\n\t\t\t\tend\n\t\t\t\t# after we have a tag, let's add it to the contact\n\t\t\t\t# find the parent contact\n\t\t\t\tcontact = Contact.where(:id => contact_id).first\n\t\t\t\tif !contact\n\t\t\t\t\t# something way fucked happened\n\t\t\t\tend\n\t\t\t\t# append tag to tags list\n\t\t\t\tcontact.tags << tag\n\t\t\t\t# save it\n\t\t\t\tcontact.save\n\t\t\t\t\n\t\t\t\t# send it back to the client\n\t\t\t\trender json: {:status => \"success\", :contact => contact}\n\t\t\tend", "def contacts\r\n\r\n end", "def get_contact(contacts)\n puts contacts\n puts 'Name: '\n name = gets.chomp\n puts 'Phone: '\n phone = gets.chomp\n contacts[name] = phone\n contacts\nend", "def initialize #what attritubes\n\t\t@contacts = []\n\tend", "def edit_contact\nputs \"Which Contact Would You Like to Edit?\"\n @contacts.delete(gets)\n puts \"What are the new details?\"\n @contacts << gets\n puts \"Your contact has been Edited\"\n #edited_contacts = @contacts.map {|contact| }\nend", "def add_new_contacts(emails)\n\t\t@list_email = []\n\t\temails.each {|email|\n\t\t\t@list_email << email if !already_exits?(email)\n\t\t}\n\t\treturn @list_email\n\tend", "def append_contact_person!(params)\r\n contact_person = ERP::ContactPerson.new params\r\n return contact_person unless contact_person.valid?\r\n \r\n self.class.transaction(self) do\r\n contact_person = self.contact_people.create! params\r\n contact_person.bind_store_user!\r\n return contact_person\r\n end\r\n end", "def getContact(contacts)\n puts contacts\n puts 'Name: '\n name = gets.chomp\n puts 'Phone: '\n phone = gets.chomp\n contacts[name] = phone\n contacts\nend", "def create(name, email, *phone)\n check_duplicate_email!(email)\n new_contact = self.new(name, email) \n new_contact.save\n \n phone.flatten!\n if phone.length > 0\n (0...phone.length).step(2) do |item|\n new_number = PhoneNumbers.create(phone[item], phone[item+1], new_contact.id.to_i)\n p new_number\n end\n end\n end", "def modify_contact\n\n end", "def add_contacts_to_selection\n logger.debug \"**** ADD CONTACTS to SELN ****\"\n show_params(params) #debug params and put them in logs\n @role_contactinfos_ids = params[:role_contactinfos][:ids]\n \n previous_contacts = session[SELECTED_CONTACTS]\n saved_list_contacts = session[:list_contacts]\n mailout_list_contacts = session[:mailout_contacts]\n existent_contacts = previous_contacts\n \n # add saved list contacts or mailout contacts if any\n # so they are not added again to the list\n if saved_list_contacts != nil\n existent_contacts = existent_contacts + saved_list_contacts\n end\n \n if mailout_list_contacts != nil\n existent_contacts = existent_contacts + mailout_list_contacts\n end\n \n new_contacts = []\n for new_contact_id in @role_contactinfos_ids\n #new_contact = get_person_or_organisation(new_contact_id)\n # get the contact to add\n new_contact_id = new_contact_id.gsub('role_contactinfo_', '')\n new_contact = RoleContactinfo.find( new_contact_id )\n new_contacts = new_contacts + [new_contact] unless existent_contacts.include?new_contact\n end\n \n \n session[SELECTED_CONTACTS] = previous_contacts + new_contacts\n \n @contacts = session[SELECTED_CONTACTS] \n \n @already_selected = session[SELECTED_CONTACTS]\n \n # processing for existent contacts from mailout or saved contact lists\n if saved_list_contacts != nil\n @already_selected = @already_selected + saved_list_contacts\n end\n \n if mailout_list_contacts != nil\n @already_selected = @already_selected + mailout_list_contacts\n end\n \n render :layout => false\n end", "def create_contact\n @contact = Spree::Address.new(contact_params)\n # Currently for demo, I will leave the country id to be 1, later update will be noticed!\n hard_code_contact(contact_params)\n respond_to do |format|\n if @contact.save\n @seller.spree_addresses << @contact\n format.html { redirect_to contacts_admin_seller_path, notice: \"Contacts #{@contact.firstname} #{@contact.lastname} is successfully created!\" }\n else\n flash[:error] = @contact.errors.full_messages\n format.html { render :new_contact }\n format.json { render :new_contact, status: :unprocessable_entity }\n end\n end\n end", "def add_phone(p)\n phone_numbers << p \n end", "def contacts!(params = {})\n # contacts in this group\n @contacts = nil\n contacts\n end", "def contacts\n collection = CapsuleCRM::ContactCollection.new(self,CapsuleCRM::Contact, [])\n collection.concat emails\n collection.concat phone_numbers\n collection.concat websites\n collection.concat addresses\n collection\n end", "def contacts\r\n @contact = @customer.contact_people.find_by_id params[:id]\r\n \r\n # Delete contact\r\n if @contact && params[:method] == \"delete\"\r\n @store_user.my_account_log(@contact,\"Delete Contact #{@contact.name}\")\r\n @contact.destroy\r\n @customer.update_ax( :contacts => [@contact] )\r\n redirect_to :id => nil\r\n end\r\n \r\n # Add or update contact\r\n if request.post? && params[:contact]\r\n @contact ||= @customer.contact_people.build\r\n @contact.attributes = params[:contact]\r\n if @contact.save\r\n redirect_to :id => nil\r\n else\r\n @customer.contact_people.delete @contact\r\n render\r\n end\r\n \r\n # Synchronize customer\r\n @customer.update_ax( :contacts => [@contact] ) if @contact.errors.empty?\r\n @store_user.my_account_log(@contact,\"Add or Update Contact #{@contact.name}\")\r\n end\r\n end", "def create\n @contact = Contact.new\n @contact.first_name=params[:first_name]\n @contact.last_name=params[:last_name]\n @contact.email=params[:email]\n @contact.org=params[:org]\n @contact.events=params[:events]\n @contact.interests=params[:interests]\n @contact.save\n\n contacts_list\n end", "def add_contact(contact_info)\n self.refresh_access_token!\n\n contact = OpenStruct.new({\n first_name: contact_info[:first_name],\n last_name: contact_info[:last_name],\n phone: contact_info[:phone]\n })\n\n haml_template = File.read(File.join(TEMPLATES_DIR, 'contact.xml.haml'))\n request_body = Haml::Engine.new(haml_template, remove_whitespace: true).render(Object.new, {\n contact: contact,\n user: self\n })\n\n @response = @oauth_access_token.post(\n 'https://www.google.com/m8/feeds/contacts/default/full',\n {\n body: request_body,\n headers: {\n 'Content-type' => 'application/atom+xml',\n 'GData-Version' => '3.0'\n }\n }\n )\n\n @response.status == 201\n end", "def modify_existing_contact \n\t\t contact = display_one_contact\t\n\t\t print \"Change First Name: \"\n\t\t first_name = gets.chomp\n\t\t print \"Change Last Name: \"\n\t\t last_name = gets.chomp\n\t\t print \"Change Email Address: \"\n\t\t email = gets.chomp\n\t\t print \"Change your Note: \"\n\t\t note = gets.chomp\n\t\t contact = Contact.new(first_name, last_name, email, note)\n\tend", "def contacts(params = {})\n # contacts in this group\n @contacts = nil\n contacts!\n end", "def write(arr)\n starting_id = read.length\n CSV.open('contacts.csv', 'a') do |csv|\n csv << arr.unshift(starting_id)\n end\n end", "def add_entry(name, phone_number, email)\n # try to place entries in order by alphabet\n index = 0\n entries.each do |entry|\n if name < entry.name\n break\n end\n index += 1\n end\n # insert entry into array\n entries.insert(index, Entry.new(name, phone_number, email))\n end", "def addPerson(person)\n @person.push(person)\n end", "def contacts\n first_set = self.initiated_contacts\n second_set = self.received_contacts\n return first_set + second_set\n end", "def add_phone(phone)\n @phone_numbers.push (phone)\n end", "def add_party(new_party)\n# add the new party to the array\n @list << new_party\n# make the new party the last entry in the array\n @list.last\n end", "def add_multiple\n @group = Group.find(params[:group_id])\n contacts = current_user.contacts.where(id: params[:contact_ids])\n contacts.each do |contact|\n contact.connections.create(group_id: params[:group_id])\n end\n @members_count = @group.reload.connections.size\n end", "def add (p)\n @people << p \n end", "def add_person\n coord = get_empty_coords()\n x_coord = coord[0]\n y_coord = coord[1]\n\n new_person = Person.new(x_coord, y_coord, @x_size, @y_size)\n @all_persons.push(new_person)\n end", "def create(contact, organization_id)\n path = get_path(organization_id)\n result = handle_response(@client.push(path, contact.attributes))\n return if result.blank?\n\n set_contact_data(contact.attributes, result['name'])\n end", "def upsert(list_id, contact)\n post @endpoint, params = {:list_id => list_id, :contacts => [contact]}\n end", "def add_contacts_query(contact_ids)\n # add_contacts_query gets a query string to add contacts to a group.\n # We're using the alternative \"/foo?_method=PUT&key=value\" format to send\n # the contact IDs as GET params. Sending these in the request body would\n # require a painful workaround, as the client sends request bodies as\n # JSON by default. See also:\n # https://developers.messagebird.com/docs/alternatives.\n\n contact_ids.map { |id| \"ids[]=#{id}\" }.join('&').prepend('_method=PUT&')\n end", "def create(name, email, *phones)\n new_id = nil\n CSV.open(\"contacts.csv\", \"ab+\") do |csv|\n csv << [name,email,phones[0],phones[1]]\n new_id = Contact.all.length\n end\n new_id\n end", "def add_new_gift(gifts_array, new_gift)\r\n gifts_array << new_gift\r\nend", "def contact_to!(actor)\n contact_to(actor) || sent_contacts.create!(receiver: actor)\n end", "def add_new_student_to_schools_student_array(new_student_name, new_student_grade, school)\n new_student = {name: new_student_name, grade: new_student_grade}\n #school[:students].push(new_student)\n school[:students][school[:students].size] = new_student\n school\nend", "def added(array)\nend", "def createContact(k = 0)\n puts $testCaseID = \"VT229-0003\"\n contacts = []\n for i in 0..k\n createRandContacts\n contacts << {\"first_name\" =>$conFirstName, \"last_name\" =>$conLastName, \"mobile_number\" =>$conMobNum, \"business_number\" =>$conBusNum, \"email_address\" =>$conEmail, \"company_name\" =>$conComp}\n end\n puts \"Value of local variable is #{contacts}\" \n \n contacts.each do |contact|\n Rho::RhoContact.create! contact\n end\n redirect :action => :index \n end", "def add_contact\n print \"First name:\"\n first_name = gets.chomp\n\n print \"Last Name:\"\n last_name = gets.chomp\n\n print \"Email:\"\n email = gets.chomp\n\n print \"Notes:\"\n notes = gets.chomp\n\n Contact.create(first_name, last_name, { email: email, notes: notes })\n end", "def create_list\n # First delete all current contacts for this user (no overlapping contacts)\n Contact.delete_all(\"user_id = #{current_user.id}\")\n \n # Parse the list (json encoded) and create individual contact entries\n if params[:contacts].nil? || params[:contacts].empty?\n return render :status => 170, :json => {:message => 'Contacts are missing.'}\n end\n contacts = ActiveSupport::JSON.decode(CGI::unescape(params[:contacts]))\n \n total_saved = 0\n contacts.each do |contact|\n # Verify this contact has all required params\n next if (!contact.key?('name') || !contact.key?('email') || !contact.key?('source'))\n\n # Create new contact entry\n Contact.create({\n :user_id => current_user.id,\n :name => contact['name'],\n :email => contact['email'],\n :source => contact['source']\n })\n\n total_saved += 1\n end\n\n render :status => 200, :json => {:message => \"Contacts saved successfully (#{total_saved} of #{contacts.size}).\"}\n end", "def update_contacts(contacts)\n b = Builder::XmlMarkup.new\n request_xml = b.Contacts {\n contacts.each do | contact |\n contact.to_xml(b)\n end\n }\n\n response_xml = http_post(@client, \"#{@xero_url}/Contacts\", request_xml, {})\n\n response = parse_response(response_xml, {:request_xml => request_xml}, {:request_signature => 'POST/contacts'})\n response.contacts.each_with_index do | response_contact, index |\n contacts[index].contact_id = response_contact.contact_id if response_contact && response_contact.contact_id\n end\n response\n end", "def new_contact\n @contact = Spree::Address.new\n end", "def update_if_necessary(new_contact_record)\n matched = []\n updated_details = []\n self.first_name = new_contact_record.first_name\n self.last_name = new_contact_record.last_name\n \n new_contact_record.details.each do |ncd|\n details.each do |ocd|\n matched << [ocd,ncd] and break if ocd.matches?(ncd)\n end\n end\n # Update the matched records if necessary\n matched.each do |ocd,ncd|\n if not ocd.update_if_necessary(ncd).empty?\n updated_details << ocd\n end\n end\n # Also add the new contact details that we are adding\n # We need to dup to make sure we don't overwrite the original\n \n (new_contact_record.details - matched.column(1)).each do |ncd| \n self.details << ncd.dup\n updated_details << self.details.last\n end \n updated_details\n end", "def new_contact\n @contact=Contact.new()\n end", "def add(email)\n eval_response = @mailing_list.add_contacts(email, force: true)\n end", "def new\n\t\t\t\t# we are going to make a new contact yall\n\t\t\t\t# comes in like post\n\t\t\t\t# {'api_token': ..., 'contact': {}}\n\t\t\t\tcontact_params = params[:contact] # be sure to clean all the values\n\t\t\t\t# clean them up\n\t\t\t\tcontact_params = sanitize_obj(contact_params);\n\t\t\t\t# lets allow rails to build this for us automagically\n\t\t\t\tc = Contact.new\n\t\t\t\tc.from_json(contact_params.to_json) # generate from our cleaned params\n\t\t\t\t# should be it for that, as long as the keys match, rails should set it\n\t\t\t\t\n\t\t\t\t# now we can save the contact\n\t\t\t\tc.save\n\t\t\t\[email protected] << c\n\t\t\t\[email protected]\n\t\t\t\t\n\t\t\t\t# now let's this new contact to the client\n\t\t\t\trender json: {:status => \"success\", :contact => c}\n\t\t\tend", "def create(name, email)\n id = CSV.read('contacts.csv').last[0].to_i + 1\n new_contact = Contact.new(id, name, email)\n CSV.open('contacts.csv', 'a') do |file|\n file << [new_contact.id, new_contact.name, new_contact.email]\n end\n new_contact\n end", "def create\n @group = Group.new(params[:group])\n \n if params[:hello]\n @contact = Contact.find_all_by_id(params[:group]['contact_ids'])\n @contact.each do |s|\n s.status = !s.status?\n s.save!\n end\n redirect_to contacts_path\n \n else\n \n if !params[:contact_groups][:group_id].blank? \n @a = params[:contact_groups][:group_id]\n @b = params[:group]['contact_ids']\n \n recipients_array = params[:group]['contact_ids']\n recipients_array.each do |r|\n ContactGroup.create(:contact_id => r,:group_id => @a)\n end\n \n redirect_to contacts_path \n \n else\n if @group.save \n flash[:notice] = \"created and added in that group\"\n redirect_to contacts_path \n else \n flash[:notice] = \"Present already in that group\"\n redirect_to contacts_path \n end\n end\n end\n end", "def save\n # can put other business rules here to notify other users etc or start background processes\n # to handle new contact saves\n contact.addresses = self.addresses\n # can get rid of bang, depends on how we want to bubble up exceptions\n contact.save!\n contact\n end", "def new_service_contact(service, contact_data)\n contact = service.contacts.find_by(email: contact_data['contact_email']&.strip)\n if contact\n puts \" 👉 NB: contact for this service already exists so not creating them. \\\"#{contact_data['contact_email']}\\\".\"\n return contact.id\n else \n new_contact = service.contacts.new(\n name: contact_data['contact_name']&.strip,\n title: contact_data['contact_title']&.strip,\n visible: contact_data['contact_visible'].present? ? contact_data['contact_visible'] : false,\n email: contact_data['contact_email']&.strip,\n phone: contact_data['contact_phone']&.strip,\n )\n if new_contact.save\n puts \"🟢 Contact: \\\"#{new_contact.name}\\\" created (id: #{new_contact.id}).\"\n return new_contact.id\n else \n abort(\"🔴 Contact: \\\"#{new_contact.name}\\\" was not created. Exiting. #{new_contact.errors.messages}\")\n end\n end \n end", "def link(contact)\n contact.accounts << self\n contact.owner = self if contact.owner.nil?\n contact.save\n end", "def save\n MoxiworksPlatform::Contact.update(self.to_hash)\n end", "def modify_contact(attribute_to_modify,contact_to_modify,new_value)\n\t\tif attribute_to_modify == \"id\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].id = new_value\n\t\telsif attribute_to_modify == \"first name\" \n\t\t \t@database_array[@database_array.index {|x| \n\t\t \t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t \t\tcontact_to_modify==x.email}].first_name = new_value\n\t\telsif attribute_to_modify == \"last name\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].last_name = new_value\t\t\t\t\n\t\telsif attribute_to_modify == \"email\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].email = new_value\n\t\telse\n\t\t\tputs \"Wrong input. Please try again!\\n\" rescue nil\n\t\tend\n\t\n\tend", "def add chromosome\n\t\t@arrayChromosomes << chromosome\n\tend", "def create_contact(options = {})\n post(:contacts, contacts: [options]).pop\n end", "def add_to_customers\n \t\t@@customers.each do |customer|\n \t\traise DuplicateCustomerError, \"#{@name} already exists.\" if customer.name == @name\n \tend\n \t\t@@customers << self\n \tend", "def add_friend(person, friend)\nperson[:friends].push(friend)\nend", "def add_friend(person, friend)\nperson[:friends].push(friend)\nend", "def get_contact(contacts)\n\tputs \"What is your name?\"\n\tname = gets.chomp\n\tputs \"What is your phone number?\"\n\tphone = gets.chomp.to_i\n\tif not contacts[name]\n\t\tcontacts[name] = phone\n\tend\n\tcontacts\nend", "def update(rec)\n if ( !rec.fields[\"phone\"].nil? && @phone.index(rec.fields[\"phone\"]).nil? )\n @phone << rec.fields[\"phone\"]\n end\n \n if ( !rec.fields[\"fax\"].nil? && @fax.index(rec.fields[\"fax\"]).nil? )\n @fax << rec.fields[\"fax\"] \n end\n \n if ( !rec.fields[\"email\"].nil? && @email.index(rec.fields[\"email\"]).nil? )\n @email << rec.fields[\"email\"] \n end\n end", "def insert(number, counter, who)\r\n # Printed Array\r\n @nha[number-1][counter] = act_player[who]\r\n # Search through Array\r\n @nha2[number-1][counter] = act_player[who]\r\n \r\n end", "def contact_to!(subject)\n contact_to(subject) ||\n sent_contacts.create!(:receiver => Actor.normalize(subject))\n end", "def contact; end", "def show_contact(id)\r\n contacts_in_array = load_contacts\r\n contacts = {}\r\n contacts_in_array.each do |contact|\r\n id_from_array = contact.shift\r\n data_from_array = contact\r\n contacts[id_from_array] = data_from_array\r\n end\r\n if contacts[id.to_s] != nil \r\n puts contacts[id.to_s]\r\n else\r\n puts \"not found\"\r\n end\r\n end", "def add_contact\n puts \"What contact would you like to add?\"\n input = gets.strip\n @contacts.push(input)\n # \"Would you like to see the new contact list? yes/no\"\n # yn = gets.strip\n # if yn == yes\n # view_contacts\n # elsif yn == no\n main_menu\nend" ]
[ "0.7606978", "0.73178595", "0.690067", "0.67124504", "0.6464356", "0.64344054", "0.64344054", "0.6364738", "0.6364475", "0.6325117", "0.63154167", "0.6278344", "0.6262329", "0.62103415", "0.6209401", "0.6169682", "0.6153025", "0.6117727", "0.61088103", "0.6104208", "0.6102624", "0.6096783", "0.6073725", "0.60661674", "0.60452026", "0.6019321", "0.5993841", "0.59869933", "0.596671", "0.5947192", "0.5943377", "0.593538", "0.59350204", "0.59121174", "0.59095174", "0.5908003", "0.5873103", "0.5860463", "0.58570665", "0.5838497", "0.58255154", "0.5812848", "0.58010995", "0.5784687", "0.5768843", "0.57563746", "0.5743155", "0.57254606", "0.57092", "0.57050204", "0.56939745", "0.5692313", "0.5683658", "0.568203", "0.5672538", "0.5668034", "0.5657242", "0.564881", "0.5643143", "0.5642412", "0.5638173", "0.56209254", "0.56173426", "0.5611524", "0.5607699", "0.5602571", "0.55848515", "0.558117", "0.55785644", "0.5566635", "0.5566025", "0.555861", "0.5556872", "0.55567443", "0.5555977", "0.5549533", "0.5547983", "0.5535679", "0.55339265", "0.5525974", "0.5524549", "0.5522474", "0.55142665", "0.55135727", "0.55064416", "0.5502195", "0.54987305", "0.54932165", "0.5492999", "0.548158", "0.5477105", "0.5476934", "0.5476934", "0.5475826", "0.54756975", "0.545886", "0.5441911", "0.5439694", "0.5437997", "0.54331285" ]
0.65596074
4
p bsearch([1, 2, 3], 1) => 0 p bsearch([2, 3, 4, 5], 3) => 1 p bsearch([2, 4, 6, 8, 10], 6) => 2 p bsearch([1, 3, 4, 5, 9], 5) => 3 p bsearch([1, 2, 3, 4, 5, 6], 6) => 5 p bsearch([1, 2, 3, 4, 5, 6], 0) => nil
def merged_sort(arr) return arr if arr.length <= 1 left_arr = arr[0...arr.length/2] right_arr = arr[arr.length/2..-1] combine(merged_sort(left_arr), merged_sort(right_arr)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bsearch(array, value)\n return nil if array.empty?\n # return nil if !array.include?(value)\n\n # debugger\n indeces = array.dup.freeze #[1, 2, 3]\n \n middle = (array.length) / 2\n left = array[(0...middle)]\n right = array[(middle..-1)]\n\n # debugger\n if array[middle] == value\n return indeces.index(value) \n elsif value < array[middle]\n bsearch(left, value)\n else\n middle + bsearch(right, value)\n end\n #somewhere bsearch(array[(0..-2)]\nend", "def bsearch(nums, target)\n return nil if nums.empty?\n\n probe_index = nums.length / 2\n case target <=> nums[probe_index]\n when -1\n bsearch(nums.take(probe_index), target)\n when 0\n probe_index\n when 1\n\n sub_answer = bsearch(nums.drop(probe_index + 1), target)\n (sub_answer.nil?) ? nil : (probe_index + 1) + sub_answer\n end\n\nend", "def bsearch(arr, target)\n return -1 if arr.empty?\n left = 0\n right = arr.length - 1\n bsearch_helper(arr, target, left, right)\nend", "def bsearch(array, target)\n return nil if array.empty?\n\n mid_idx = array.length / 2\n mid_ele = array[mid_idx]\n\n return mid_idx if target == mid_ele\n\n if target < mid_ele\n sub_arr = array[0...mid_idx]\n return bsearch(sub_arr, target)\n else\n sub_arr = array[mid_idx + 1..-1]\n next_search = bsearch(sub_arr, target)\n return nil if next_search == nil\n return mid_idx + 1 + next_search\n end\nend", "def bsearch(arr, item)\n middle = arr.count / 2\n return true if arr[middle] == item\n return false if arr.count < 2\n\n (item < arr[middle]) ? bsearch(arr[0...middle], item) : bsearch(arr[middle..-1], item)\nend", "def bsearch(arr, target)\n return nil if arr.length < 1\n\n middle_idx = arr.length / 2\n return_idx = 0\n\n return middle_idx if arr[middle_idx] == target\n\n if target < arr[middle_idx]\n index = bsearch(arr[0...middle_idx], target)\n index.nil? ? (return nil) : return_idx += index\n else\n index = bsearch(arr[middle_idx + 1..-1], target)\n index.nil? ? (return nil) : (return_idx = (middle_idx + index + 1))\n end\n\n return_idx\nend", "def bsearch(arr, target)\n return nil if arr.length < 1\n # return nil if target > arr.max || target < arr.min\n compare_index = arr.length / 2\n match = target <=> arr[compare_index]\n case match\n when -1\n bsearch(arr.take(compare_index), target)\n when 0\n compare_index\n else\n result = bsearch(arr.drop(compare_index+1), target)\n return nil if result.nil?\n result + compare_index + 1\n end\nend", "def bsearch(array, target)\nend", "def bsearch(array, target)\n middle_idx = array.length / 2\n middle = array[middle_idx]\n\n return middle_idx if target == middle\n return nil if array.length == 1\n if target < middle\n return bsearch(array[0...middle_idx], target)\n elsif target > middle\n b_searched = bsearch(array[middle_idx..-1], target)\n if b_searched == nil\n return nil\n else\n return middle_idx + b_searched\n end\n end\nend", "def bsearch(array, target)\n return nil if array.empty?\n\n middle_idx = array.length / 2\n if array[middle_idx] == target\n return middle_idx\n elsif array[middle_idx] > target\n bsearch(array[0...middle_idx], target)\n else\n result = bsearch(array[(middle_idx+1)..-1], target)\n if result.is_a?(Fixnum)\n result + middle_idx + 1\n else\n nil\n end\n end\nend", "def bsearch(array, target)\n return nil if !array.include?(target)\n arr = array.sort\n\n mid = arr.length / 2\n\n\n if arr[mid] == target\n return mid\n elsif arr[mid] < target\n mid + bsearch(arr[mid..-1], target)\n else\n bsearch(arr[0..mid-1], target)\n end\nend", "def bsearch arr, target \n return nil if arr.length == 1 && !arr.include?(target)\n\n mid_idx = arr.length / 2\n\n return mid_idx if arr[mid_idx] == target \n \n left = arr.take(mid_idx)\n right = arr.drop(mid_idx)\n\n if arr[mid_idx] > target \n bsearch(left, target)\n else \n result = bsearch(right,target)\n if result.nil? \n return nil \n else \n result + mid_idx\n end\n end\nend", "def bsearch(arr, target)\n i = 0\n j = arr.length - 1\n while i <= j\n m = (i + j) / 2\n if target < arr[m]\n j = m - 1\n elsif target > arr[m]\n i = m + 1\n elsif target == arr[m]\n return m\n end\n end\n -1\nend", "def bsearch(array, target)\n return nil if array.empty?\n\n n = array.size / 2\n bottom = array[0...n]\n mid = array[n]\n top = array[n + 1..-1]\n\n if target < mid\n bsearch(bottom, target)\n elsif target > mid\n top_search = bsearch(top, target)\n top_search.nil? ? nil : top_search + bottom.size + 1\n else\n mid == target ? n : nil\n end\nend", "def bsearch(arr, target)\n return nil if arr.empty?\n mid = arr.length / 2\n return mid if arr[mid] == target\n\n if target < arr[mid]\n bsearch(arr[0...mid], target)\n else\n result = bsearch(arr[mid + 1..-1], target)\n result.nil? ? nil : mid + 1 + result\n end\nend", "def bsearch(array, target)\n\n return nil unless array.include?(target)\n\n middle = (array.length - 1) / 2\n return middle if target == array[middle]\n\n if target < array[middle]\n bsearch(array[0...middle], target)\n elsif target > array[middle]\n middle + 1 + bsearch(array[(middle + 1)..-1], target)\n end\nend", "def bsearch(arr, target)\n return nil if arr.length == 1 && arr[0] != target\n mid_i = arr.length / 2\n return mid_i if arr[mid_i] == target\n\n low_arr = arr[0...mid_i]\n high_arr = arr[mid_i+1..-1]\n\n if arr[mid_i] > target\n bsearch(low_arr, target) \n elsif bsearch(high_arr, target) != nil\n low_arr.length + 1 + bsearch(high_arr, target)\n end\n\nend", "def bsearch(array, target)\n bsearch_subs(array, target, 0, array.length - 1)\nend", "def bsearch(array, target)\n # compare target value to middle element\n #if target value is == to middle elements value\n #return the position and end\n # if target value is less than middle value seach lower half of array\n # same goes for greater than (search upper half)\n # when it searches lower or upper half it keeps the same logic as the beginning\n # nil if not found; can't find anything in an empty array\n return nil if array.empty?\n\n index = array.length / 2\n # spaceship operator magic!\n case target <=> array[index]\n when -1 #search left side\n bsearch(array.take(index), target)\n when 0\n index\n when 1 #search right side\n answer = bsearch(array.drop(index + 1), target)\n answer.nil? ? nil : index + 1 + answer\n end\nend", "def bsearch(array, target)\n return nil if array.length <= 1 && array[0] != target\n\n mid_idx = (array.length - 1) / 2\n if array[mid_idx] == target\n mid_idx\n elsif array[mid_idx] < target\n response = bsearch(array[(mid_idx + 1)..-1], target)\n response.nil? ? nil : response + mid_idx + 1\n else\n bsearch(array[0...mid_idx], target)\n end\nend", "def bsearch(array, target)\n return nil if array.length == 1 && target != array[0]\n idx = array.length / 2\n mid_ele = array[idx]\n\n if target == mid_ele\n return idx\n elsif target < mid_ele\n return bsearch(array[0...idx], target)\n else\n if bsearch(array[idx+1..-1], target).nil?\n return nil\n else\n return idx + 1 + bsearch(array[idx+1..-1], target)\n end\n end\nend", "def bsearch(arr, target)\n if arr.length < 1 # empty array, returns nil\n return nil\n end\n \n # multiple elements, grab middle and compare\n middle_index = arr.length / 2\n middle_element = arr[middle_index]\n case target <=> middle_element\n when -1 # target smaller, check left half\n new_arr = arr[0...middle_index]\n bsearch(new_arr, target)\n when 1\n new_arr = arr[middle_index+1..-1]\n answer = bsearch(new_arr, target)\n return nil if answer.nil?\n answer + middle_index + 1\n when 0\n return middle_index\n end\nend", "def bsearch(array, target)\n return nil if array == []\n\n mid_idx = array.length / 2\n\n case array[mid_idx] <=> target\n when -1\n right_idx = bsearch(array[mid_idx+1..-1], target)\n mid_idx + right_idx + 1 unless right_idx == nil\n when 0\n mid_idx\n when 1\n bsearch(array[0...mid_idx], target)\n end\nend", "def bsearch(array, target)\n mid_idx = array.length / 2\n if array[mid_idx] == target\n mid_idx\n elsif array.length == 1\n nil\n elsif array[mid_idx] > target\n bsearch(array[0...mid_idx], target)\n elsif array[mid_idx] < target\n after_mid_idx = mid_idx + 1\n recursion = bsearch(array[after_mid_idx..-1], target)\n recursion.nil? ? nil : after_mid_idx + recursion\n end\nend", "def b_find_number(n, number_to_find)\n n.bsearch {|x| puts x }\nend", "def bsearch(arr, num)\n return nil if !arr.include?(num)\n\n mid_idx = arr.length / 2\n if arr[mid_idx] == num\n return mid_idx\n elsif arr[mid_idx] > num\n lower_half = arr[0...mid_idx]\n bsearch(lower_half, num)\n else\n upper_half = arr[(mid_idx + 1)..-1]\n bsearch(upper_half, num)\n end\n\nend", "def bi_search(search_array, search_value, low = 0, high = nil)\n high ||= search_array.length - 1\n middle = ((low + high) / 2).ceil\n if low > high\n return -1\n elsif search_value == search_array[middle]\n return middle\n elsif search_value < search_array[middle]\n high = middle - 1\n elsif search_value > search_array[middle]\n low = middle + 1\n end\n bi_search(search_array, search_value, low = low, high = high)\nend", "def bsearch(arr, target)\n return nil if arr.empty?\n middle_idx = (arr.length/2) # odd_arrays = direct middle, even arrays = HIGHER MIDDLE\n if arr[middle_idx] == target\n return middle_idx\n elsif arr[middle_idx] > target\n bsearch(arr[0...middle_idx], target)\n else\n idx = bsearch(arr[(middle_idx+1)..-1], target)\n if idx.is_a?(Fixnum)\n idx + middle_idx + 1\n else\n nil\n end\n end\nend", "def bsearch(arr, target)\n return nil if arr.empty?\n mid_idx = arr.length / 2\n pivot = arr[mid_idx]\n return mid_idx if pivot == target\n if pivot > target\n bsearch(arr[0...mid_idx], target)\n else\n result = bsearch(arr[mid_idx + 1..-1], target)\n if result == nil\n nil\n else\n mid_idx + 1 + result\n end\n end\nend", "def bsearch(arr, target)\n if arr.length == 1 \n if arr[0] == target\n return 0\n else\n return nil\n end\n end\n arr.sort!\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle + 1..-1]\n if arr[middle] == target\n return middle\n elsif arr[middle] < target\n if bsearch(right, target).nil?\n return nil\n # else\n return left.length + 1 + bsearch(right, target)\n end\n else \n bsearch(left, target)\n end\nend", "def bsearch(array, target)\n return nil if array.length == 1 && array.first != target\n return 0 if array.length == 1\n\n guess = array.length / 2\n left = array.take(guess)\n right = array.drop(guess)\n\n if target < array[guess]\n bsearch(left, target)\n else\n right_search = bsearch(right, target)\n right_search.nil? ? nil : guess + right_search\n end\nend", "def bsearch(arr, target)\n return nil if arr.length <= 1\n\n mid = arr.length / 2\n case target <=> arr[mid]\n when -1\n bsearch(arr[0..mid], target)\n when 0\n mid\n when 1\n bsearch(arr[mid..-1], target)\n end\nend", "def bsearch(array, target)\n mid_point = array.length / 2\n\n return mid_point if target == array[mid_point]\n return nil if array.length == 1\n\n left_hand = array[0...mid_point]\n right_hand = array[mid_point..-1]\n\n if target < array[mid_point]\n bsearch(left_hand, target)\n else\n result = bsearch(right_hand, target)\n return nil if result.nil?\n mid_point + result\n end\n\nend", "def bsearch(nums, target)\n # nil if not found; can't find anything in an empty array\n return nil if nums.empty?\n \n probe_index = nums.length / 2\n case target <=> nums[probe_index]\n when -1\n # search in left\n bsearch(nums.take(probe_index), target)\n when 0\n probe_index # found it!\n when 1\n # search in the right; don't forget that the right subarray starts\n # at `probe_index + 1`, so we need to offset by that amount.\n sub_answer = bsearch(nums.drop(probe_index + 1), target)\n sub_answer.nil? ? nil : (probe_index + 1) + sub_answer\n end\n \n # Note that the array size is always decreasing through each\n # recursive call, so we'll either find the item, or eventually end\n # up with an empty array.\n end", "def bsearch(nums, target)\n # nil if not found; can't find anything in an empty array\n return nil if nums.empty?\n \n probe_index = nums.length / 2\n case target <=> nums[probe_index]\n when -1\n # search in left\n bsearch(nums.take(probe_index), target)\n when 0\n probe_index # found it!\n when 1\n # search in the right; don't forget that the right subarray starts\n # at `probe_index + 1`, so we need to offset by that amount.\n sub_answer = bsearch(nums.drop(probe_index + 1), target)\n sub_answer.nil? ? nil : (probe_index + 1) + sub_answer\n end\n \n # Note that the array size is always decreasing through each\n # recursive call, so we'll either find the item, or eventually end\n # up with an empty array.\n end", "def bsearch(arr, target)\r\n return false if arr.length == 0\r\n\r\n mid = arr.length/2\r\n\r\n return mid if arr[mid] == target\r\n if arr[mid] > target\r\n found = bsearch(arr[mid+1..-1], target)\r\n found + mid + 1 unless found == false\r\n else\r\n bsearch(arr[0...mid], target)\r\n end\r\n false\r\nend", "def search(array, value, b = 0)\n if b >= array.length\n return false\n elsif array[b] == value\n return true\n else\n return search(array, value, b + 1)\n end\nend", "def bsearch(arr,target)\n# p arr\nreturn nil if arr.length==1 && target != arr[0]\nmid =arr.length/2 # 3,1,1,0\n# if arr.length==1 && arr[0] != target\n# return nil\n# end\n\n\nif target==arr[mid]\n\nreturn mid\nelsif target<arr[mid]\n left_index = 0\n right_index = mid-1\n return bsearch(arr[left_index..right_index],target)\n# return bsearch(arr.take(mid),target)\nelse\n left_index = mid+1\n right_index = arr.length-1\n sub_position=bsearch(arr[left_index..right_index],target)\n # sub_position=bsearch(arr.drop(mid+1),target)\n return sub_position.nil? ? nil : (mid+1)+sub_position \n\nend\nend", "def bsearch(sorted_array, target)\n return nil if sorted_array.empty?\n \n i_mid = (sorted_array.length-1) / 2\n mid = sorted_array[i_mid]\n \n if target == mid\n i = i_mid\n elsif target < mid\n i = bsearch(sorted_array[0...i_mid], target)\n else\n i = bsearch(sorted_array[i_mid + 1..-1], target)\n i += mid + 1 if i\n end\n \n i\nend", "def bsearch(arr,target)\r\n return nil if arr.length == 0 \r\n midIdx = arr.length/2\r\n mid = arr[midIdx] \r\n if mid > target #left half\r\n bsearch(arr[0...midIdx],target)\r\n elsif mid < target #right half\r\n\r\n idx = bsearch(arr[midIdx+1..-1],target)\r\n if idx \r\n idx + arr[0..midIdx].length\r\n else\r\n return nil\r\n end\r\n \r\n else\r\n return midIdx\r\n end\r\n\r\nend", "def bsearch(a,s,m,n)\n\n\tmiddle=(m+n)/2\n\n\tif n<=m then\n\treturn (s > a[m])? (m + 1): m\n\t\n\n\telsif s==a[middle] \n\treturn middle+1\n\n\telsif s>a[middle] \n\treturn bsearch(a,s,middle+1,n)\n\t\t\n\t\n\telse\n\treturn bsearch(a,s,m,middle-1)\n\t\n\tend\n\tend", "def bsearch(arr, target)\n return nil if arr.length == 0\n mid = arr.length/2\n\n if target < mid\n bsearch(arr.take(mid), target)\n elsif target == arr[mid]\n return true\n else\n search_res = bsearch(arr.drop(mid + 1), target)\n search_res.nil? ? false : true\n end\nend", "def cass_bsearch(array, target)\n return nil if array.empty?\n mid_idx = array.length / 2\n return mid_idx if array[mid_idx] == target\n # debugger\n # idx_array = (0..array.length).to_a\n array_left = array[0...mid_idx]\n array_right = array[(mid_idx + 1)..-1]\n # if array[mid_idx] == target\n if array[mid_idx] > target\n cass_bsearch(array_left, target)\n else\n search_results = cass_bsearch(array_right, target)\n search_results.nil? ? nil : search_results + mid_idx + 1\n #need to make sure this isn't nil\n #add mid_idx because you have to account for everything on the left\n #add 1 to account for the fact that indexing starts at 0 not 1\n end\nend", "def linear_search(array, search_value)\n array.each_with_index do |element, index|\n if element == search_value\n return index\n elsif element > search_value\n break\n end\n end\n\n return nil\nend", "def bsearch(array, target)\n mid_idx = (array.length/2) # 2\n median = array[mid_idx] # 4\n left_array = array[0..(mid_idx - 1)]\n right_array = array[(mid_idx + 1)..-1]\n\n return mid_idx if median == target\n return nil if array.length <= 1\n\n if median < target\n result = bsearch(right_array,target)\n return nil if result.nil?\n (mid_idx + 1) + bsearch(right_array,target)\n elsif median > target\n bsearch(left_array,target)\n\n end\nend", "def binary_searcher(array, value)\n array.bsearch { |integer| value <=> integer } || false\n\nend", "def bsearch(array, target)\n return nil if arr.empty?\n\n mid_idx = array.length / 2\n lower_half = array[0...mid_idx] \n upper_half = array[mid_idx + 1..-1]\n\n return mid_idx if array[mid_idx] == target\n\n if target < array[mid_idx]\n bsearch(lower_half, target)\n else\n result = bsearch(upper_half, target)\n \n if result.nil?\n return nil # return nil to indicate target is not in the array\n else\n lower_half.length + 1 + result\n# ^ will return index, but from upper half\n\n\n# [10,21,34,89,100, 110, 150]\n# + length of lower_half + 1 ^ 2\n# target is 100\n end\n end\nend", "def bsearch(arr, val, start=0, to=nil)\n if to.nil?\n to = arr.size() -1\n end\n\n if start > to\n return -1\n end\n\n mid = (start+to) / 2\n\n # search for pivot on the left\n if arr[mid] > val\n bsearch(arr,val,start,mid-1)\n elsif arr[mid] < val\n # seach on right\n bsearch(arr,val,mid+1,to)\n else\n # found value\n return mid\n end\nend", "def b_search(arr, target)\n return false if arr.empty?\n mid = arr / 2\n if arr[mid] == target\n true\n elsif arr[mid] < target\n b_search(arr[mid..-1], target)\n else\n b_search(arr[0...mid], target)\n end\nend", "def bsearch(arr, target, sorted = false)\n debugger\n if arr.length == 1\n arr == target ? (return arr) : (return nil)\n end\n arr = arr.quicksort unless sorted\n search = arr[arr.length/2]\n case search <=> target\n when -1\n return bsearch(arr[0...search], target, true)\n when 0\n return true\n when 1\n return bsearch(arr[search + 1] , target, true)\n end\n\n\nend", "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 use_binary_search(list, item)\r\n low = 0\r\n high = list.length - 1\r\n while low <= high\r\n mid = (low + high)\r\n guess = list[mid]\r\n if guess == item\r\n return mid\r\n end\r\n if guess > item\r\n high = mid - 1\r\n else\r\n low = mid + 1\r\n end\r\n end\r\n return nil\r\nend", "def linear_search(array, search_value)\n\n # We iterate through every element in the array:\n array.each_with_index do |element, index|\n\n # If we find the value we're looking for, we return its index:\n if element == search_value\n return index\n\n # If we reach an element that is greater than the value\n # we're looking for, we can exit the loop early:\n elsif element > search_value\n break\n end\n end\n\n # We return nil if we do not find the value within the array:\n return nil\n\nend", "def binary_search(ary, value); end", "def ary_bsearch_i(ary, value)\n low = 0\n high = ary.length\n mid = nil\n smaller = false\n satisfied = false\n v = nil\n\n while low < high do\n mid = low + ((high - low) / 2)\n v = (ary[mid] > value)\n if v == true\n satisfied = true\n smaller = true\n elsif !v\n smaller = false\n else\n raise TypeError, \"wrong argument, must be boolean or nil, got '#{v.class}'\"\n end\n\n if smaller\n high = mid\n else\n low = mid + 1;\n end\n end\n\n return nil if low == ary.length\n return nil if !satisfied\n return low\n end", "def bin_search(arr, key)\n low = 0\n high = arr.length - 1\n while high >= low do\n mid = low + (high - low) / 2\n if arr[mid] > key\n high = mid - 1\n elsif arr[mid] < key\n low = mid + 1\n else\n return mid\n end\n end\n return 0\nend", "def do_search(target_value, array)\n min = 0\n max = array.length - 1\n\n binary_search(target_value, array, min, max)\nend", "def binarySearch(a, value)\n # Precondition: lst must be sorted asc (smaller first).\n\n # Searching boundaries (all vector)\n p = 0 # left limit (inclusive)\n r = a.length - 1 # right limit (inclusive)\n\n # Optimization\n # Asses that value may actually be in the array: Array range is a[0]..a[-1]\n # Array must be not empty\n if r < 0 or value < a[p] or value > a[r] then\n return nil # nil inplace of -1 to match ruby std\n end\n\n while p <= r do\n q = (p+r)/2\n if a[q] == value\n return q\n end\n if a[q] > value\n # then value is in a[p]...a[q]\n r = q-1\n else\n # then value is in a[q]...a[r]\n p = q+1\n end\n end\n\n return nil # nil inplace of -1 to match ruby std\nend", "def bsearch_index(el, b = 0, e = size, &block)\n return bsearch_index(el, b, e) { |a,b| a <=> b } if block.nil?\n return b if b == e # Return the discovered insertion index\n return if b > e\n m = (b + e) / 2 # Get Middle\n block.call(el, self[m]) > 0 ? b = m + 1 : e = m \n bsearch_index(el, b, e, &block) \n end", "def binary_search(arr,tar)\n return nil if arr.length < 1\n mid_idx = arr.length / 2\n if arr[mid_idx] == tar\n return mid_idx\n elsif arr[mid_idx] > tar\n binary_search(arr[0...mid_idx],tar)\n elsif arr[mid_idx] < tar\n subanswer = binary_search(arr[mid_idx+1..-1],tar)\n subanswer.nil? ? nil : (mid_idx+1) + subanswer\n end\nend", "def binary_search(array, length, value_to_find)\n high = length\n low = 0\n length.times do\n guess = (low + high) / 2\n return true if array[guess] == value_to_find\n return false if high - low <= 1\n array[guess] < value_to_find ? low = guess : high = guess\n end\nend", "def binary_search(value)\n search_result = binary_search_internal(value)\n return search_result[0] ? search_result[1] : -1\n end", "def search(arr, x)\n (0..arr.count).each do |i|\n return i if arr[i] == x\n end\n -1\nend", "def binary_search(array, length, value_to_find)\n puts \"NOT IMPLEMENTED\"\nend", "def simple_linear_search(array, value)\n array.each do |element|\n return value if element == value\n break \"Not in array\" if element > value\n end\n \"Not in array\"\nend", "def fast\n ARRAY.bsearch { |num| num > 80_000_000 }\nend", "def binary_search(array, length, value_to_find)\n raise NotImplementedError\nend", "def iter_bindex(array, element)\n\tupper = array.size\n\tlower = 0\n\twhile upper >= lower\n\t\tmid = (upper + lower) /2\n\t\tif array[mid] < element\n\t\t\tlower = mid + 1\n\t\telsif array[mid] > element\n\t\t\tupper = mid -1\n\t\telse \n\t\t\treturn mid\n\t\tend\n\tend\n\treturn nil\nend", "def binary_search(arr, val, strategy='rec')\n if strategy != 'rec'\n search(arr, val)\n else\n rec_search(arr, val, 0, arr.size - 1)\n end\nend", "def binsearch(ary, x)\n left = 0\n right = ary.length - 1\n while left < right\n middle = (left + right) / 2\n Tanj.array :ary, index: [:left..:right, :middle]\n if ary[middle] == x\n Tanj.message \"found it!\"\n return middle\n elsif ary[middle] < x\n Tanj.message \"too small\"\n left = middle + 1\n elsif ary[middle] > x\n Tanj.message \"too large\"\n right = middle - 1\n else\n Tanj.message \"this should be unreachable!\"\n end\n end\n Tanj.message \"didn't find it\"\n return nil\nend", "def binary_search(array, length, value_to_find)\n found = false\n length.times do |i|\n if array[i] == value_to_find\n found = true\n break\n end\n end\n return found\nend", "def binary_search(arr, target)\n binary_search_helper(arr, target, 0, arr.length - 1)\nend", "def rec_bin_search(array, target)\n return nil if array.length == 0\n\n midpoint = array.length / 2\n\n return midpoint if array[midpoint] == target\n\n if target < array[midpoint]\n rec_bin_search(array.take(midpoint), target)\n else\n top = rec_bin_search(array.drop(midpoint + 1), target)\n top == nil ? nil : top + (midpoint + 1)\n end\nend", "def search(nums, target)\n nums.each_with_index do |num, index|\n return index if num == target\n end\n -1\nend", "def linearSearch(array,value)\n array.each do |element|\n if element == value\n return value\n end \n end\n return \"not found\"\nend", "def bin_search(target,array)\n lo = 0\n hi = array.length - 1\n mid = (lo+hi)/2\n while lo <= hi\n if array[mid] > target\n hi = mid-1\n mid = (lo+hi)/2\n elsif array[mid] < target\n lo = mid+1\n mid = (lo+hi)/2\n else\n return mid\n end\n end\n return -1\nend", "def binary_search(array, target)\n lower_bound = 0\n upper_bound array.length - 1\n while lower_bound <= upper_boud do\n midpoint = (upper_bound + lower_bound) / 2\n value_at_midpoint = array[midpoint]\n if target == value_at_midpoint\n return midpoint\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n end\n end\n return nil\nend", "def bin_search(x, a, b)\r\n mid = (a + b) / 2\r\n sq = mid ** 2\r\n \r\n if a == b || sq == x\r\n mid\r\n elsif sq > x\r\n bin_search(x, a, mid - 1)\r\n else\r\n (mid + 1) ** 2 > x ? mid : bin_search(x, mid + 1, b)\r\n end\r\nend", "def binary_search(arr, value)\n\treturn [-1,0] if arr.length == 0\n\ttimes = 0\n\tmidpoint = arr.length / 2\n\tworstCaseTime = Math.log2(arr.length).floor\n\twhile times <= worstCaseTime do\n\t\ttimes += 1\n\t\tif arr[midpoint] == value\n\t\t\treturn [midpoint,times]\n\t\telsif arr[midpoint] > value\n\t\t\tmidpoint = midpoint/2\n\t\telsif arr[midpoint] < value\n\t\t\tmidpoint = (arr.length - midpoint)/2 + midpoint\n\t\tend\n\tend\n\treturn [arr.index(value),times]\nend", "def binary_search(array, length, value_to_find)\n # take the length and divide in half,\n # start_index = 0\n # end_index = length - 1\n # midpoint = length / 2\n # until start_index > end_index\n #\n # end\n\nend", "def binary_search(array, value)\n return nil if array.length == 1 && array[0] != value\n midpoint = array.length/2\n return midpoint if array[midpoint] == value\n if array[midpoint] < value\n midpoint + binary_search(array[midpoint..array.length], value) if binary_search(array[midpoint..array.length], value)\n else\n binary_search(array[0...midpoint], value)\n end\nend", "def binary_search(arr, target)\n return nil if arr.empty?\n probe_index = arr.size / 2\n probe_ele = arr[probe_index]\n\n case probe_ele <=> target\n when 1\n left_arr = arr.take(probe_index) \n return binary_search(left_arr,target)\n when 0 \n return probe_index\n when -1\n compensated_index = (probe_index + 1)\n right_arr = arr.drop(compensated_index)\n return nil if binary_search(right_arr,target).nil?\n return binary_search(right_arr,target) + compensated_index\n end\nend", "def linear_search(sorted_array, desired_item)\n index = 0\n sorted_array.length.times do \n if desired_item == sorted_array[index]\n break \n else \n index += 1\n end\n if index > sorted_array.length - 1\n index = nil \n end\n end\n return index \nend", "def binary_search(a, key)\n return binary_search_rec(a, key, 0, a.length - 1)\nend", "def simple_search(arr, number)\n\tmatching_index = nil\n\tcurrent_index = 0\n\tarr.each do |num|\n\t\tif num == number\n\t\t\tmatching_index = current_index\n\t\tend\n\t\tcurrent_index += 1\n\tend \n\tmatching_index\nend", "def binary_search(array, target)\n mid = array.length / 2\n\n if target < array[mid]\n binary_search(array[0...mid], target)\n elsif value > array[mid]\n function = binary_search(array[mid + 1..-1], target)\n function.nil? ? nil : function + mid + 1\n else\n return mid\n end\nend", "def binary_search(array, target)\n return nil if array.empty?\n\n middle_idx = array.length/2\n\n case target <=> array[middle_idx]\n\n when -1\n binary_search(array.take(middle_idx), target)\n when 0\n return middle_idx\n when 1\n binary_search(array[middle_idx..-1], target)\n end\n\nend", "def 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 bsearch(needle, haystack=ranges, first=0, last=ranges.size-1)\n return nil if last < first # not found, or empty range\n\n cur = first + (last - first)/2\n case haystack[cur] <=> needle\n when -1 # needle is larger than cur value\n bsearch(needle, haystack, cur+1, last)\n when 1 # needle is smaller than cur value\n bsearch(needle, haystack, first, cur-1)\n when 0\n haystack[cur]\n end\n end", "def binary_search(arr, target, idx_puls = 0)\n mid = arr.length / 2\n return mid + idx_puls if arr[mid] == target\n return nil if arr.length == 1\n\n if arr[mid] < target\n binary_search(arr[(mid + 1)..-1], target, mid + 1)\n else\n binary_search(arr[0...mid], target, idx_puls)\n end\n\nend", "def binary_search(array, target)\n lower_bound = 0\n upper_bound = array.length - 1\n while lower_bound <= upper_bound\n midpoint = (lower_bound + upper_bound) / 2\n value_at_midpoint = array[midpoint]\n if target = value_at_midpoint\n return midpoint\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n end\n end\n return nil\nend", "def binary_search(numbers, element)\n min = 0\n max = numbers.size - 1\n\n index = nil\n\n while index.nil? do\n middle_element_index = (min + max) / 2 # Every iteration (N / 2) = O(log n)\n middle_element = numbers[middle_element_index] \n \n if element < middle_element\n max = middle_element_index\n elsif element > middle_element\n min = middle_element_index\n elsif element == middle_element\n index = middle_element_index\n end\n end\n\n index\nend", "def binary_search(arry, target)\n return \"Empty Array\" if arry.size < 1\n lower_limit = 0\n upper_limit = arry.size - 1\n search_string = binary_search_with_limits(arry, target, lower_limit, upper_limit)\nend", "def binary_search(target, array)\r\n\t#Your code here\r\n\tindex = array.length / 2\r\n\tlo = 0\r\n\thi = array.length - 1\r\n\twhile array[index] != target && array.include?(target)\r\n\t\tif array[index] > target\r\n\t\t\thi = index - 1\r\n\t\t index = (lo + hi) / 2\r\n\t\telsif array[index] < target\r\n\t\t\tlo = index + 1\r\n\t\t\tindex = (lo + hi) / 2\r\n\t\tend\r\n\tend\r\n\tif array[index] == target\r\n\t\treturn index\r\n\telse\r\n\t\treturn -1\r\n\tend \r\nend", "def binary_search(array, find)\n\tlow = 0\n\thi = array.length-1 \n\n\twhile (low <= hi)\n\t\tmid = low + (hi-low)/2\n\n\t\tif array[mid] == find\n\t\t\treturn mid\n\t\telsif array[mid] < find\n\t\t\tlow = mid + 1\n\t\telse \n\t\t\thi = mid - 1\n\t\tend\t\n\tend\n\n\treturn \"Value not found in array\"\n\nend", "def binary_search(a, key)\n low = 0\n high = a.length - 1\n\n while low <= high\n mid = low + ((high - low) / 2)\n\n return mid if a[mid] == key\n\n if key < a[mid]\n high = mid - 1\n else\n low = mid + 1\n end\n end\n\n return -1\nend", "def search(arr, item)\n\tarr.index(item) || -1\nend", "def search_array(arr, x)\r\n index = 0 \r\n default = nil\r\n arr.each do if x == arr[index]\r\n return index\r\n # default = index\r\n end\r\n index += 1\r\n end\r\n return default \r\nend", "def binary_search(arr, target)\n return nil if !arr.include?(target)\n middle_ele = arr[arr.length / 2]\n middle_idx = arr.length / 2\n if target == middle_ele\n return middle_idx\n elsif target > middle_ele\n binary_search(arr[middle_idx+1..-1], target) + arr[0..middle_idx].length\n else\n binary_search(arr[0...middle_idx], target)\n end\nend", "def binary_search(array, value, lower = 0, upper = nil)\n upper = array.count - 1 unless upper\n\n return \"Not in array\" if lower > upper\n\n mid = (lower + upper) / 2\n\n if value < array[mid]\n return binary_search(array, value, lower, mid - 1)\n elsif value > array[mid]\n return binary_search(array, value, mid + 1, upper)\n else\n return mid\n end\nend", "def binary_search(array, value, from=0, to=nil)\n if to == nil\n to = array.count - 1\n end\n\n mid = (from + to) / 2\n\n if value < array[mid]\n return binary_search array, value, from, mid - 1\n elsif value > array[mid]\n return binary_search array, value, mid + 1, to\n else\n return mid\n end\nend" ]
[ "0.81812066", "0.81799465", "0.8134341", "0.80885816", "0.8026114", "0.80193424", "0.80049294", "0.79533374", "0.794989", "0.7945327", "0.79355997", "0.79161984", "0.7915403", "0.79104483", "0.7908109", "0.7894346", "0.7870683", "0.78651357", "0.7860259", "0.78494185", "0.7849409", "0.78250974", "0.78226936", "0.78134674", "0.7811187", "0.778656", "0.7775648", "0.77749336", "0.7772606", "0.77268356", "0.77210623", "0.771872", "0.77126384", "0.76920825", "0.76920825", "0.7678246", "0.76532143", "0.76438475", "0.76180077", "0.75711757", "0.75690544", "0.74766606", "0.74356693", "0.7421711", "0.7415022", "0.737809", "0.7361685", "0.7355875", "0.7339739", "0.7322187", "0.7307015", "0.7294465", "0.7283192", "0.72817177", "0.72403353", "0.72308993", "0.72047853", "0.7187125", "0.71546555", "0.707687", "0.7073155", "0.70205134", "0.70115316", "0.7007471", "0.70011795", "0.69971645", "0.6989225", "0.698735", "0.69868803", "0.6977316", "0.6972259", "0.6963992", "0.6960074", "0.6956063", "0.6948077", "0.6947465", "0.69317526", "0.6928473", "0.6888642", "0.68879616", "0.6882488", "0.6874592", "0.6873279", "0.68666923", "0.6845018", "0.68282515", "0.6822948", "0.6814591", "0.68100196", "0.68019694", "0.6798558", "0.6797078", "0.6792625", "0.6791977", "0.67882615", "0.67763823", "0.67647517", "0.6761842", "0.67611766", "0.6756411", "0.6755468" ]
0.0
-1
p merged_sort([1, 6, 3, 3, 5, 2]) p merged_sort([3, 6, 12, 1, 0, 9, 15, 25, 0, 8, 13, 11, 90, 1564])
def array_subsets(arr) return [[]] if arr.empty? partial_subset = array_subsets(arr[0..-2]) addition = partial_subset.map {|ele| ele + [arr[-1]]} partial_subset + addition end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_sort(&prc)\n end", "def merge_sort(&prc)\n prc || = proc { |num1, num2| num1 <=> num2 }\n return self if length <= 1\n mid = length / 2\n left = self.take(mid).merge_sort(&prc)\n right = self.drop(mid).merge_sort&prc)\n Array.merge(left, right, &prc)\nend", "def merged_sort(arr)\n return arr if arr.length <= 1\n left_arr = arr[0...arr.length/2]\n right_arr = arr[arr.length/2..-1]\n \n combine(merged_sort(left_arr), merged_sort(right_arr))\nend", "def merge_sort numbers, si=0, ei=nil\n\n # TODO: your cool code goes here\n\nend", "def merge_sort(nums)\n len = nums.length\n return nums if len < 2\n mid_index = len / 2\n\n left_sorted = merge_sort(nums[0...mid_index])\n right_sorted = merge_sort(nums[mid_index...len])\n merge(left_sorted, right_sorted)\nend", "def merge_sort (array, &prc)\n return array if array.length <= 1\n\n mid_idx = array.length / 2\n merge(\n merge_sort(array.take(mid_idx), &prc),\n merge_sort(array.drop(mid_idx), &prc),\n &prc\n )\nend", "def merge_sort(array)\n return array if array.length <= 1\n\n mid_point = array.length / 2\n\n left_hand = merge_sort(array.take(mid_point))\n right_hand = merge_sort(array.drop(mid_point))\n\n merge_sort_compare(left_hand, right_hand)\n #left_hand + right_hand\nend", "def do_merge_sort(first, last)\n return if first >= last\n \n mid = (first + last)/2\n do_merge_sort(first, mid)\n do_merge_sort(mid+1, last)\n do_simple_merge(first,mid,last)\n end", "def merge_sort(arr)\n return arr if arr.size < 2\n middle = arr.size / 2\n # cut in half for sort selection\n arr1 = merge_sort(arr[0...middle])\n arr2 = merge_sort(arr[middle..-1])\n merge(arr1, arr2)\nend", "def merge_sort(a)\n\tif n == 1\n\t\treturn a\n\tend\n\n\tm = n/2\n\n\tb = merge_sort(a)\n\tc = merge_sort(c)\n\t\n\tresult = merge(b,c)\n\n\treturn result\nend", "def merge_sort(numbers)\n return numbers if numbers.size == 1\n mid = numbers.size / 2\n left = numbers[0...mid]\n right = numbers[mid..-1]\n merge(merge_sort(left), merge_sort(right))\nend", "def merge_sort(numbers)\n return numbers if numbers.size == 1\n mid = numbers.size / 2\n left = numbers[0...mid]\n right = numbers[mid..-1]\n merge(merge_sort(left), merge_sort(right))\nend", "def merge_sort(array)\n length_of_array = array.length\n\n if length_of_array < 2\n sorted_array = array\n return sorted_array\n end\n\n array_half_a = array.slice(0, (length_of_array.to_f / 2).round)\n array_half_b = array.slice((length_of_array.to_f / 2).round, length_of_array / 2)\n sorted_array_a = merge_sort(array_half_a)\n sorted_array_b = merge_sort(array_half_b)\n merged_sorted_array = []\n index_array_a = 0\n index_array_b = 0\n\n while index_array_a < sorted_array_a.length && index_array_b < sorted_array_b.length\n if sorted_array_a[index_array_a] < sorted_array_b[index_array_b]\n merged_sorted_array << sorted_array_a[index_array_a]\n index_array_a += 1\n else\n merged_sorted_array << sorted_array_b[index_array_b]\n index_array_b += 1\n end\n end\n\n merged_sorted_array += if index_array_a == sorted_array_a.length\n sorted_array_b.slice(index_array_b, sorted_array_b.length)\n else\n sorted_array_a.slice(index_array_a, sorted_array_a.length)\n end\n\n merged_sorted_array\nend", "def merge_sort(arr)\n \n midpoint = arr.size/2\n sub_list_a = arr[0, midpoint]\n sub_list_b = arr[(midpoint + 1)..(arr.size - 1)]\n \n sub_list_a = merge_sort(sub_list_a) \n sub_list_b = merge_sort(sub_list_b) \n \n merge(sub_list_a, sub_list_b)\n \nend", "def mergesort lst\n _mergesort_ lst.dup\nend", "def merge_sort(array, &prc)\n return array if array.length <= 1\n\n prc ||= Proc.new { |el1, el2| el1 - el2 }\n\n mid_idx = array.length / 2\n sorted_left = merge_sort(array[0...mid_idx], &prc)\n sorted_right = merge_sort(array[mid_idx..-1], &prc)\n\n sorted = []\n until sorted_left.empty? || sorted_right.empty?\n if prc.call(sorted_left.first, sorted_right.first) <= 0\n sorted << sorted_left.shift\n else\n sorted << sorted_right.shift\n end\n end\n\n sorted + sorted_left + sorted_right\nend", "def merge_sort(&prc)\n prc ||= Proc.new { |x, y| x <=> y }\n return self if length <= 1\n\n midpoint = self.length / 2\n left = self.take(midpoint).merge_sort(&prc)\n right = self.drop(midpoint).merge_sort(&prc)\n\n Array.merge(left, right, &prc)\n end", "def merge_sort(array)\n if array.size <= 1\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n\n # 1. Divide\n mid = array.size / 2\n part_a = merge_sort(array.slice(0, mid))\n part_b = merge_sort(array.slice(mid, array.size - mid))\n\n\n# 2. Conquer\n array = []\n offset_a = 0\n offset_b = 0\n while offset_a < part_a.count && offset_b < part_b.count\n a = part_a[offset_a]\n b = part_b[offset_b]\n \n if a <= b\n array << a\n offset_a += 1\n else\n array << b\n offset_b += 1\n end\n end\n \n while offset_a < part_a.count\n array << part_a[offset_a]\n offset_a += 1\n end\n \n while offset_b < part_b.count\n array << part_b[offset_b]\n offset_b += 1\n end\n \n return array\nend", "def merge_sort(list)\n length = list.length\n\n if length <= 1\n\treturn list\n end\n \n mid = length/2\n a = list.slice(0...mid)\n b = list.slice(mid..-1)\n ma = merge_sort(a)\n mb = merge_sort(b)\n\n merge(ma, mb)\n end", "def merge_sort(array)\r\n return array if array.length <= 1\r\n\r\n mid = array.length / 2\r\n\r\n left = merge_sort(array.take(mid)),\r\n right = merge_sort(array.drop(mid))\r\n merge(left, right)\r\nend", "def merge_sort(arr)\n # [6]\n # arr[0] > arr[1]\n # arr[0], arr[1] = arr[1], arr[0]\n return arr if arr.length <= 1\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle..-1]\n a = merge_sort(left) \n b = merge_sort(right)\n merge(a,b)\nend", "def merge_sort(array)\n return array if array.length <= 1 \n mid = array.length / 2\n sorted_left = merge_sort(array.take(mid))\n sorted_right = merge_sort(array.drop(mid))\n \n merge(sorted_left, sorted_right)\n \nend", "def merge_sort(array, p, r)\n return array if p >= r\n q = (p + r) / 2\n merge_sort(array, p, q)\n merge_sort(array, q + 1, r)\n merge(array, p, q, r)\nend", "def merge_sort(array)\n \n middle = array.length/2-1\n left = [0..middle]\n right = [middle+1..[-1]]\n merge_sort(left) + merge_sort(right)\nend", "def mergeSort array\n if array.count <= 1\n return array\n end\n\n middle = array.count / 2\n left = mergeSort array.slice(0, middle)\n right = mergeSort array.slice(middle, array.count)\n\n left_offset = 0\n right_offset = 0\n\n while left_offset < left.count && right_offset < right.count\n a = left[left_offset]\n b = right[right_offset]\n\n if a <= b\n array.push a\n left_offset += 1\n else\n array.push b\n right_offset += 1\n end\n end\n return merge(left, right)\nend", "def merge_sort(a)\n return a if a.length == 1\n\n n = divide(a, a.length / 2)\n\n half_1 = n.shift\n half_2 = n\n\n return merge(merge_sort(half_1), merge_sort(half_2))\nend", "def merge_sort(array=@base)\n return array if array.size < 2\n mid = array.size/2\n left = array[0..mid-1]\n right = array[mid..-1]\n\n left_merge = merge_sort(left)\n right_merge = merge_sort(right)\n merge_sort_merge(left_merge, right_merge)\n end", "def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left, right= arr.take(mid), arr.drop(mid)\n sorted_left, sorted_right = merge_sort(left), merge_sort(right)\n\n merge(sorted_left, sorted_right)\nend", "def merge_sort(collection)\n if collection.length <= 1\n collection\n else\n mid = (collection.length / 2).floor\n left = merge_sort(collection[0..mid - 1])\n right = merge_sort(collection[mid..collection.length])\n merge(left, right)\n end\n end", "def merge_sort(array, start_index, end_index)\n if start_index < end_index\n middle_index = (start_index + end_index)/2\n merge_sort(array, start_index, middle_index)\n merge_sort(array, middle_index + 1, end_index)\n merge(array, start_index, middle_index, end_index)\n end\nend", "def merge_sort(lst)\n if lst.length <= 1\n lst\n else\n mid = (lst.length / 2).floor\n left = merge_sort(lst[0..mid - 1])\n right = merge_sort(lst[mid..lst.length])\n merge(left, right)\n end\nend", "def merge_sort(arr)\n if arr.length < 2\n arr\n else\n sorted = []\n left = merge_sort(arr[0..arr.length / 2 - 1])\n right = merge_sort(arr[arr.length / 2..-1])\n while left[0] && right[0]\n sorted << (left[0] > right[0] ? right.shift : left.shift)\n end\n sorted += left + right\n end\nend", "def merge_sort(list)\n if list.length <= 1\n list\n else\n mid = (list.length / 2).floor\n left = merge_sort(list[0..mid - 1])\n right = merge_sort(list[mid..list.length])\n merge(left, right)\n end\nend", "def mergeSort(ia)\n mergeSortHelper(ia, 0, ia.length-1)\nend", "def merge_sort(&predicate)\n return self.dup if size <= 1\n mid = size / 2\n left = self[0, mid].dup\n right = self[mid, size].dup\n merge(left.merge_sort(&predicate), right.merge_sort(&predicate), &predicate)\n end", "def merge_sort(&predicate)\n return self.dup if size <= 1\n mid = size / 2\n left = self[0, mid].dup\n right = self[mid, size].dup\n merge(left.merge_sort(&predicate), right.merge_sort(&predicate), &predicate)\n end", "def merge_sort(array)\n split_index = array.size / 2\n arr1 = array[0..split_index]\n arr2 = array[split_index..-1]\n binding.pry\n merged_array = merge(arr1, arr2)\n # check to see if array is sorted; otherwise recursively call merge_sort on merged_array.\n sorted = false\n merged_array.each_with_index do |el, indx|\n sorted = true if !merged_array[indx + 1] \n if el < merged_array[indx + 1] then next\n else break\n end\n end\n sorted ? merged_array : merge_sort(merged_array)\nend", "def merge_sort(nums)\n # Base case, no sorting to do on a single element, collapses recursion branch\n return nums if nums.length <= 1\n # Divide\n a = nums[0..(nums.length/2)-1]\n b = nums[(nums.length/2)..-1]\n # Conquer\n result = merge(merge_sort(a), merge_sort(b))\nend", "def mergeSort(arr)\n\tif arr.length == 1\n\t\treturn arr\n\tend\n\n\tmidpoint = arr.length/2.round\n\tleft = arr[0...midpoint]\n\tright = arr[midpoint..-1]\n\tleft = mergeSort(left) #[4,6]\n\tright = mergeSort(right) #[8, 2]\n\n\treturn merge(left, right)\nend", "def merge_sort list\n midpoint = list.length/2\n\n if list.length < 2\n return list\n else\n list_left = list[0..(midpoint - 1)]\n list_right = list[midpoint..-1]\n\n list_left = merge_sort(list_left)\n list_right = merge_sort(list_right)\n\n return result = merge_lists(list_left, list_right)\n end\nend", "def merge_sort(numbers)\n # Base case\n # Rearrangement is no longer possible, there's only 1 element in `numbers`!\n return numbers if numbers.size == 1\n\n # Partition unsorted elements into groups\n # Continue until n sublists, each containing 1 element (i.e. all reached base case)\n mid = numbers.size / 2\n left = numbers[0...mid] # alternatively: numbers.take(mid)\n right = numbers[mid..-1] # alternatively: numbers.drop(mid)\n\n # Recursively break down sublists into smaller problems\n # until each list has 1 element\n left_nums = merge_sort(left)\n right_nums = merge_sort(right)\n\n # Merge individual sublists to produce sorted sublists when\n # left_nums && right_nums are available\n merge(left_nums, right_nums)\nend", "def merge_sort(arr)\n return arr if arr.size < 2\n middle = arr.size / 2\n left = merge_sort(arr[0...middle])\n right = merge_sort(arr[middle..arr.size])\n merge(left, right)\n end", "def merge_sort array\n size = array.size\n if size < 2\n array\n else\n merge_array = array.each_slice((size/2.0).round).to_a\n array_a = merge_sort(merge_array[0])\n array_b = merge_sort(merge_array[1])\n new_array = []\n a = 0\n b = 0\n while new_array.size != size\n if array_a.nil? || array_a[a].nil?\n return new_array += array_b[b..-1]\n elsif array_b.nil? || array_b[b].nil?\n return new_array += array_a[a..-1]\n elsif array_a[a] < array_b[b]\n new_array << array_a[a]\n a += 1\n else\n new_array << array_b[b]\n b += 1\n end\n end\n end\nend", "def merge_sort(a)\n return a if a.length <= 1\n\n half_length = a.length / 2\n front = a.take half_length\n back = a.drop half_length\n\n combine(merge_sort(front), merge_sort(back))\nend", "def mergeSortHelper(ia, left, right)\n if(left < right)\n mid = ((left + right) / 2).to_i\n\n mergeSortHelper(ia, left, mid)\n mergeSortHelper(ia, mid + 1, right)\n\n merge(ia, left, mid, right)\n end\nend", "def merge_sort(arr)\n return arr if arr.length <= 1\n\n mid_idx = arr.length / 2 # this is really for breaking down the array into singletons\n left_side = arr[0...mid_idx]\n right_side = arr[mid_idx..-1]\n\n left = merge_sort(left_side)\n right = merge_sort(right_side)\n\n merge(left, right) # this does the actual sorting\nend", "def merge_sort(arr)\n if arr.length <= 1\n return arr\n else \n mid = arr.length/2\n left = merge_sort(arr.slice(0...mid))\n right = merge_sort(arr.slice(mid...arr.length))\n merge(left, right)\n end \nend", "def merge_sort_merge(left, right)\n sorted = []\n until left.empty? || right.empty?\n if left[0] <= right[0]\n sorted << left.shift\n else\n sorted << right.shift\n end\n end\n sorted += left + right\n sorted\n end", "def merge_sort(array)\n return array if array.length < 2\n midpoint = array.length / 2\n merge(merge_sort(array[0...midpoint]), merge_sort(array[midpoint..-1]))\nend", "def merge_sort(arr)\n return arr if arr.length <= 1\n\n middle_idx = arr.length / 2\n\n left = arr[0...middle_idx]\n right = arr[middle_idx..-1]\n\n merge(merge_sort(left), merge_sort(right))\n\nend", "def merge_sort(arr)\n return arr if arr.length < 2\n\n arr1 = merge_sort(arr.take(arr.length/2))\n arr2 = merge_sort(arr.drop(arr.length/2))\n\n return merge(arr1,arr2)\nend", "def merge_sort(array)\n if array.length <= 1\n return array\n end\n merge(merge_sort(array[0...array.length/2]), merge_sort(array[array.length/2...array.length]))\nend", "def merge_sort(arr)\n return arr if arr.length == 1 \n mid = (arr.length/2).floor\n left = merge_sort(arr[0..mid - 1])\n right = merge_sort(arr[mid..-1])\n merge(left, right)\nend", "def merge_print_sort\n @merge.print_sort\n end", "def merge_sort\n if self.length <= 1\n return self\n else\n mid = self.length/2\n return merge(self[0...mid].merge_sort, self[mid..-1].merge_sort)\n end\n end", "def merge_sort(arr)\n cr_size = 1\n while cr_size <= arr.size - 1\n left = 0\n while left < arr.size - 1\n mid = [(left + cr_size - 1), (arr.size - 1)].min\n right = if (2 * cr_size + left - 1) < (arr.size - 1)\n 2 * cr_size + left - 1\n else\n arr.size - 1\n end\n arr[left..right] = merge(arr[left..mid], arr[mid+1..right])\n left += cr_size * 2\n end\n cr_size *= 2\n end\n arr\nend", "def mergesort(array)\n if array.count <= 1\n # Array of length 1 or less is always sorted\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n\n # 1. Divide\n mid = array.count / 2\n part_a = mergesort array.slice(0, mid)\n part_b = mergesort array.slice(mid, array.count - mid)\n\n # 2. Conquer\n array = []\n offset_a = 0\n offset_b = 0\n while offset_a < part_a.count && offset_b < part_b.count\n a = part_a[offset_a]\n b = part_b[offset_b]\n # Take the smallest of the two, and push it on our array\n if a <= b\n array << a\n offset_a += 1\n else\n array << b\n offset_b += 1\n end\n end\n\n # There is at least one element left in either part_a or part_b (not both)\n while offset_a < part_a.count\n array << part_a[offset_a]\n offset_a += 1\n end\n\n while offset_b < part_b.count\n array << part_b[offset_b]\n offset_b += 1\n end\n\n return array\nend", "def merge_sort(arr)\n return arr if arr.length <= 1\n\n mid = arr.length / 2\n\n left = arr[0...mid]\n right = arr[mid..-1]\n\n my_merge(merge_sort(left), merge_sort(right))\nend", "def mergesort!(src, dst, lo, hi, metadata)\n return if hi <= lo\n\n mid = lo + (hi - lo) / 2\n mergesort! dst, src, lo, mid, metadata\n mergesort! dst, src, mid+1, hi, metadata\n merge! src, dst, lo, mid, hi, metadata\nend", "def merge_sort(ary)\n# base case\n return ary if ary.size < 2\n\n# divide(recursively dividing the array)\n left = merge_sort(ary[0...ary.size/2])\n right = merge_sort(ary[ary.size/2...ary.size])\n\n sorted = []\n# conquer(sort)\n while left.length > 0 && right.length > 0\n# until left.empty? || right.empty? # until one array is empty. In other words, when both are not empty.\n sorted << (left.first > right.first ? right.shift : left.shift)\n end\n\n# if one of the array is empty, add the other array to the sorted list\n left.empty? ? sorted += right : sorted += left\nend", "def merge_sort(fishes)\n return fishes if self.length <= 1\n mid = fishes.length / 2\n sort_left = fishes.take(mid).merge_sort(fishes)\n sort_right = fishes.drop(mid).merge_sort(fishes)\n merge(sort_left, sort_right)\nend", "def merge_sort(list)\n return list if list.length <= 1\n\n middle = list.length / 2\n left = list[0..middle - 1]\n right = list[middle..-1]\n left = merge_sort(left)\n right = merge_sort(right)\n merge(left, right)\nend", "def merge_sort(array)\r\n\tif array.length > 1\r\n\t\tleft_array = []\r\n\t\t\t(array.length/2).times { left_array << array.shift }\r\n\t\tright_array = array\r\n\t\tleft_sorted = merge_sort(left_array)\r\n\t\tright_sorted = merge_sort(right_array)\r\n\t\tresult = []\r\n\t\twhile left_sorted.length>0 && right_sorted.length>0\r\n\t\t\tif left_sorted[0] <= right_sorted[0]\r\n\t\t\t\tresult << left_sorted.shift\r\n\t\t\telse\r\n\t\t\t\tresult << right_sorted.shift\r\n\t\t\tend\r\n\t\tend\r\n\t\tif left_sorted.length>0\r\n\t\t\tleft_sorted.each { |e| result << e }\r\n\t\telsif right_sorted.length>0\r\n\t\t\tright_sorted.each { |e| result << e }\r\n\t\tend\r\n\t\treturn result\r\n\telse\r\n\t\treturn array\r\n\tend\r\nend", "def merge_sort(arr)\n return arr if arr.length < 2\n mid_idx = arr.length/2\n left = arr[0...mid_idx]\n right = arr[mid_idx..-1]\n return merge(merge_sort(left), merge_sort(right))\nend", "def merge_sort(arr)\n return arr if arr.length < 2\n middle = arr.length / 2\n half1 = arr[0...middle]\n half2 = arr[middle..-1]\n merge(merge_sort(half1), merge_sort(half2))\nend", "def merge_sort(array)\n return array if array.length <= 1\n middle = array.length / 2\n sorted_left = merge_sort(array[0...middle])\n sorted_right = merge_sort(array[middle..-1])\n merge(sorted_right, sorted_left)\nend", "def merge_sort(array)\n # we split the array into 1 element long arrays\n return array if array.length <= 1\n\n mid = array.length / 2\n left = merge_sort(array[0..mid - 1])\n right = merge_sort(array[mid..-1])\n # once we have 1 element long arrays we start merging them\n if left.last <= right.first\n left + right\n else\n merge(left, right)\n end\n end", "def merge_sort( arr )\n return arr if arr.length == 1\n\n mid = arr.length / 2\n\n arr1 = merge_sort( arr[0...mid] )\n arr2 = merge_sort( arr[mid..-1] )\n\n sort_and_merge( arr1, arr2 )\nend", "def merge_sort(array)\n return array if array.size == 1\n left_array,right_array = array.each_slice( (array.size/2.0).round ).to_a\n arr1 = merge_sort(left_array)\n arr2 = merge_sort(right_array)\n arr = merge(arr1, arr2)\n arr\nend", "def mergesort(elements)\n\t#Base Case \n return elements if elements.size == 1\n\n #Divide \n mid = elements.size / 2\n left = elements[0, mid]\n right = elements[mid, elements.size]\n \n left_sorted = mergesort(left)\n right_sorted = mergesort(right)\n\n #Conquer\n merge(left_sorted,right_sorted)\nend", "def mergesort(array)\n if array.count <= 1\n # Array of length 1 or less is always sorted\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n\n # Divide\n mid = array.count / 2\n part_a = mergesort array.slice(0, mid)\n part_b = mergesort array.slice(mid, array.count - mid)\n\n # Conquer\n array = []\n offset_a = 0\n offset_b = 0\n while offset_a < part_a.count && offset_b < part_b.count\n a = part_a[offset_a]\n b = part_b[offset_b]\n\n # Take the smallest of the two, and push it on our array\n if a <= b\n array << a\n offset_a += 1\n else\n array << b\n offset_b += 1\n end\n end\n\n # There is at least one element left in either part_a or part_b (not both)\n while offset_a < part_a.count\n array << part_a[offset_a]\n offset_a += 1\n end\n\n while offset_b < part_b.count\n array << part_b[offset_b]\n offset_b += 1\n end\n\n return array\nend", "def merged(first, second)\n first.concat(second).sort!\nend", "def merge_sort(array)\n low = 0\n high = array.length - 1\n\n # // divide the array into blocks of size m\n # // m = [1, 2, 4, 8, 16...]\n m = 1\n while m <= (high-low)\n i = low\n while i < high\n from = i\n mid = i + m - 1\n if i + (2 * m) - 1 < high\n to = i + (2 * m) - 1\n else\n to = high\n end\n\n array = merge(array, from, mid, to)\n i = i + (2*m)\n end\n m = 2*m\n end\n array\nend", "def merge_sort(array)\n return array if array.length <= 1\n mid = array.length / 2\n left = merge_sort(array[0...mid])\n right = merge_sort(array[mid..-1])\n merge(left, right)\nend", "def merge_sort(arr)\n return arr if arr.length <= 1\n \n mid = arr.length / 2\n left, right = arr[0...mid], arr[mid..-1]\n left, right = merge_sort(left), merge_sort(right)\n\n merge(left, right)\nend", "def merge_sort(array)\n return array if array.length <= 1\n mid = array.size / 2\n left = array[0...mid]\n right = array[mid..-1]\n sorted_left = merge_sort(left)\n sorted_right = merge_sort(right)\n return merge(sorted_left, sorted_right)\nend", "def mergeSort(arr)\n\n if (arr.length == 1)\n return arr\n end\n\n center = (arr.length / 2).floor\n left = arr[0...center] # takes values from 0 to center excluding the center index\n right = arr[center...arr.length] # takes values from center to end\n\n return merge( mergeSort(left), mergeSort(right) )\nend", "def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left = merge_sort(arr[0...mid])\n right = merge_sort(arr[mid..-1])\n merge(left, right)\nend", "def merge_sort(array)\n\tif array.length <= 1\n\t\treturn array\n\telse\n\t\tmiddle = (array.length/2).floor\n\t\tleft = array[0...middle]\n\t\tright = array[middle...array.length]\n\t\treturn merge(merge_sort(left), merge_sort(right));\n\tend\nend", "def merge_sort(array)\n return array if array.length <= 1\n mid = array.length/2\n\n left = merge_sort(array[0...mid])\n right = merge_sort(array[mid..-1])\n\n merge(left, right)\nend", "def merge_sort(array) # ***\n return array if array.length <= 1\n mid_idx = (array.length - 1) / 2\n\n first_half = merge_sort(array[0..mid_idx])\n second_half = merge_sort(array[mid_idx + 1..-1])\n\n merge(first_half, second_half)\n # merge(merge_sort(array[0..mid_idx]), merge_sort(array[mid_idx + 1..-1]))\nend", "def merge_sort!(&block)\n become_clone_of merge_sort(&block)\n end", "def merge_sort(array)\n return array if array.length == 1\n mid = array.length / 2\n merge(merge_sort(array[0..mid -1]), merge_sort(array[(mid)..-1]))\nend", "def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left = merge_sort(arr[0...mid])\n right = merge_sort(arr[mid..-1])\n\n merge(left, right)\nend", "def merge_sort(arr)\n return arr if arr.length <= 1\n\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle..-1]\n merge(merge_sort(left), merge_sort(right))\nend", "def merge_sort(arr)\n return arr if arr.length <= 1\n first_half = arr[0...(arr.length / 2)]\n second_half = arr[(arr.length / 2)..-1]\n merge(merge_sort(first_half), merge_sort(second_half))\nend", "def merge_sort(array)\n return array if array.size <= 1\n mid = array.size / 2\n left = array[0...mid]\n right = array[mid...array.size]\n merge(merge_sort(left), merge_sort(right))\nend", "def mergesort(array)\n if array.count <= 1\n return array\n end \n middle = array.count/2 \n return merge(mergesort(array[0, middle]), mergesort(array[middle, array.count]))\nend", "def merge_sort(unordered_list)\n p unordered_list\n \n if unordered_list.size < 2\n return unordered_list\n else\n middle = unordered_list.size / 2\n left = merge_sort(unordered_list[0,middle])\n right = merge_sort(unordered_list[middle,unordered_list.size])\n together = merge(left,right)\n puts \"merged: #{together.inspect}\"\n return together\n end \nend", "def test_merge_sort_helper\n # Arrange\n hundred_elements = (0..100).to_a\n cases = [{input: [0], expected: [0]},\n {input: [0, 1], expected: [0, 1]},\n {input: [0, 1, 2, 5, 7], expected: [0, 1, 2, 5, 7]},\n {input: [1, 5, 2, 0], expected: [0, 1, 2, 5]},\n {input: hundred_elements.shuffle, expected: hundred_elements}]\n\n\n cases.each { |test_case|\n # Act\n @aux = Array.new(test_case[:input].length)\n actual = standard_merge_sort test_case[:input], 0, test_case[:input].length - 1\n\n # Assert\n assert_equal test_case[:expected], actual\n }\n end", "def merge_sort(array)\n return array if array.length == 1\n l, r = array.take(array.count / 2), array.drop(array.count / 2)\n merge(merge_sort(l), merge_sort(r))\nend", "def merge_sort(array)\n return array if array.length == 1\n mid = (array.length - 1)/ 2\n left = array[0..mid]\n right = array[mid+1..array.length-1]\n merge(merge_sort(left), merge_sort(right))\nend", "def merge_sort(array)\n return array if array.length == 1\n\n # Divide & conquer\n half1 = merge_sort(array[0..array.length/2 - 1])\n half2 = merge_sort(array[array.length/2..-1])\n\n # Initialize result array\n sorted = []\n \n while half1.length > 0 && half2.length > 0\n if half1[0] <= half2[0]\n sorted << half1.shift\n else\n sorted << half2.shift\n end\n end\n if half1.length > 0\n sorted.concat half1\n elsif half2.length > 0\n sorted.concat half2\n end\n \n return sorted\nend", "def merge_sort(arr)\n return arr if arr.length < 2\n middle_index = arr.length / 2\n left_arr = merge_sort(arr[0...middle_index])\n right_arr = merge_sort(arr[middle_index..-1])\n merge_fn(left_arr,right_arr)\nend", "def merge_sort(arr)\n return arr if arr.length < 2\n middle_index = arr.length / 2\n one_half = arr[0...middle_index]\n two_half = arr[middle_index..-1]\n merge(merge_sort(one_half), merge_sort(two_half))\nend", "def merge_sort(array)\n if array.length < 2\n return array\n end\n first_half = array[0...array.length / 2]\n second_half = array[array.length / 2..-1]\n\n merge(merge_sort(first_half), merge_sort(second_half))\nend", "def merge_sort(array)\n return array if array.length <= 1\n middle = array.length / 2\n merge(merge_sort(array[0...middle]), merge_sort(array[middle..-1]))\nend", "def mergesort(array)\n # Base case\n if array.count <= 1\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n # 1. Divide\n mid = array.count / 2\n left_partition = mergesort array.slice(0, mid)\n right_partition = mergesort array.slice(mid, array.count - mid)\n\n # 2. Conquer\n array = []\n left_lead = 0\n right_lead = 0\n while left_lead < left_partition.count && right_lead < right_partition.count\n a = left_partition[left_lead]\n b = right_partition[right_lead]\n\n # Take the smallest of the two, and push it on our array\n if a <= b\n array << a\n left_lead += 1\n else\n array << b\n right_lead += 1\n end\n end\n\n # Either left or right may have elements left; consume them.\n # (Only one of the following loops will actually be entered.)\n while left_lead < left_partition.count\n array << left_partition[left_lead]\n left_lead += 1\n end\n\n while right_lead < right_partition.count\n array << right_partition[right_lead]\n right_lead += 1\n end\n\n return array\nend", "def merge_sort(array)\n # p array\n return array if array.size == 1\n\n sub_array_1 = array[0...array.size / 2]\n sub_array_2 = array[array.size / 2...array.size]\n\n sub_array_1 = merge_sort(sub_array_1)\n sub_array_2 = merge_sort(sub_array_2)\n\n merge(sub_array_1, sub_array_2)\nend", "def merge_sort(arr)\n return arr if arr.length == 1\n\n half_idx = arr.length / 2\n first_half = arr[0...half_idx]\n second_half = arr[half_idx..-1]\n\n merge(merge_sort(first_half), merge_sort(second_half))\nend", "def merge_sort(array)\n return array if array.length < 2\n\n midpoint = array.length / 2\n left = array[0...midpoint]\n right = array[midpoint..-1]\n\n return merge(merge_sort(left), merge_sort(right))\nend" ]
[ "0.7901355", "0.77504057", "0.77203107", "0.7656196", "0.7608429", "0.7590312", "0.753318", "0.75045013", "0.7478862", "0.7466347", "0.74622244", "0.74622244", "0.7453215", "0.7422421", "0.74007636", "0.73996234", "0.73926634", "0.7374733", "0.73224396", "0.73116267", "0.7307682", "0.7303989", "0.73024434", "0.72950137", "0.7292669", "0.72864413", "0.7271427", "0.72623867", "0.7254244", "0.7234999", "0.72333664", "0.7227635", "0.72157586", "0.721518", "0.7214136", "0.7214136", "0.72101426", "0.7196022", "0.71929145", "0.71872306", "0.7183682", "0.71771556", "0.717472", "0.7174013", "0.7172595", "0.716501", "0.7157707", "0.71527725", "0.7149951", "0.71469474", "0.7125755", "0.7124869", "0.71231616", "0.71218", "0.71137065", "0.7113417", "0.7108818", "0.7106054", "0.71052086", "0.7104344", "0.7104075", "0.7101005", "0.7097343", "0.7091527", "0.7085943", "0.7081937", "0.708178", "0.7065523", "0.7065274", "0.70639455", "0.70593435", "0.70573384", "0.70564526", "0.7055121", "0.70533437", "0.7044639", "0.7043174", "0.70405143", "0.7036628", "0.70351404", "0.7035082", "0.70340246", "0.7033541", "0.70310897", "0.7029976", "0.70258516", "0.7025545", "0.7023178", "0.7022308", "0.7014946", "0.7009704", "0.7004335", "0.69985104", "0.69904566", "0.6989593", "0.69882166", "0.69846994", "0.6975306", "0.6975063", "0.69727963", "0.6961679" ]
0.0
-1
p array_subsets([]) p array_subsets([1]) p array_subsets([1,2]) p array_subsets([1,2,3]) p array_subsets([1,2,3,4])
def permutation(array) return array if array.length == 1 smaller = permutation(array[0...-1]) combination_array = [] (smaller.length + 1).times do |index| combination_array += smaller.dup.insert(index, array[-1]) # debugger end combination_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subsets(arr)\n return [arr] if arr.empty?\nsubsets(arr[])\nend", "def subsets(array)\n\nend", "def subsets(array)\n\nend", "def subsets(array)\n\nend", "def array_subsets(array)\n return [array] if array.empty?\n \nend", "def subsets(arr)\r\n comb = [] #set up return array\r\n\r\n for x in 0..arr.length do # gives a value from 0 to arr.length to pass below\r\n arr.combination(x) {|y| comb << y} # pushes to the return all of the possible combinations of the array\r\n end # the x insures that all possible lengths of combinations are returned.\r\n\r\n comb # returns all combinations\r\nend", "def subsets(array)\n return [[]] if array.empty?\n number = array.pop\n prev_subsets = subsets(array)\n new_subsets = []\n prev_subsets.each do |subset|\n new_subsets << ([number] + subset)\n end\n prev_subsets + new_subsets\nend", "def subsets_of(array)\n 0.upto(array.length).flat_map { |n| array.combination(n).to_a }\n end", "def subsets(nums)\n result = []\n subsets_helper(nums, [], result, 0)\n result\nend", "def subsets(array)\n if array.length <= 1\n return array\n end\n subset_array = []\n (0..array.length - 1).each do |i|\n subset_array << subsets(array[0...i]) << subsets(array[0...i]).concat([array[-1]])\n end\n return subset_array\nend", "def array_subsets(arr)\n return arr if arr.length == 0 || arr.length == 1\n new_arr = []\n new_arr << [arr[0]] + array_subsets(arr[1..-1])\n \n # length = 1\n # new_arr = [[]]\n # while length <= arr.length\n # arr.each do |el|\n # new_arr << Array.new(length) { el }\n # end\n # length += 1\n # end\nend", "def subsets(array)\n if array.empty?\n return [[]]\n end\n\n el = array.shift[0]\n old_subsets = subsets(array)\n new_subsets = old_subsets.map { |old_subset| [el] + old_subset }\n new_subsets + old_subsets\nend", "def subsets(arr)\n subsets_helper(result = [], temp = [], arr, 0)\nend", "def subsets(array) # [1, 2], [1]\n return [[]] if array.length == 0\n # return [[], array ] if array.length == 1\n\n except_last = subsets(array[0...-1]) #subsets([1]), subsets([])\n combination = except_last.map { |ele| ele += [array[-1]]} #map subsets([1]) + [2], \n\n except_last + combination\nend", "def subsets(arr)\n return [arr] unless arr.is_a?(Array)\n return [arr] if arr.empty?\n\n # return [arr] if arr.length == 1\n # first = arr.shift\n # all_subsets << subsets(first)\n # all_subsets << subsets(arr)\n\n # [[],[1]] << [2],[1,2] [each, last] << [last] [each,last]\n # subsets(arr-1) << subsets(arr)[-1]\n all_subsets = [[]]\n\n arr.each { |ele| all_subsets << [ele] }\n\n (0...(arr.length - 1)).each do |idx1|\n # all_subsets << [arr[idx1]] unless all_subsets.include?(arr[idx1])\n (1...arr.length).each do |idx2|\n if idx2 > idx1 && !all_subsets.include?(arr[idx2])\n # all_subsets << [arr[idx2]]\n all_subsets << arr[idx1..idx2]\n end\n end\n end\n\n all_subsets\nend", "def subsets(arr)\n return [arr] if arr.empty?\n # p arr\n # if arr.length == 1\n # return subsets(arr[0...0]) + [arr]\n # end\n\n arr.each {|ele| subsets(arr -[ele]) } + [arr]\nend", "def subsets(arr)\n return [self] if arr.length == 1\n\n subs + subsets()\nend", "def subsets(array)\n return [[]] if array.empty?\n subs = array[0...-1]\n smaller_subs = subsets(subs)\n bigger_subs = []\n smaller_subs.each do |sub|\n bigger_subs << sub + [array[-1]]\n end\n smaller_subs + bigger_subs\nend", "def common_subsets(array_one, array_two)\n\nend", "def powerset(array)\n subsets = [[]]\n\n array.each do |elem|\n (1..subsets.length - 1).each do |i|\n current_subset = subsets[i]\n subsets.append(current_subset + [elem])\n end\n end\n\n return subsets\nend", "def subsets(set)\n return [[]] if set.empty?\n smaller_set = set.take(set.count-1)\n smaller_subsets = subsets(smaller_set)\n bigger_subsets = []\n smaller_subsets.each do |smaller_subset|\n bigger_subsets << smaller_subset + [set.last]\n end\n\n smaller_subsets + bigger_subsets\nend", "def powerset(array)\n subsets = [[]]\n array.each { |element|\n for i in 0..subsets.length - 1\n current_subset = subsets[i]\n subsets << (current_subset + [element])\n end\n }\n return subsets\nend", "def subsets(array)\n return [[]] if array.empty?\n\n val = array[0]\n subs = subsets(array.drop(1))\n new_subs = subs.map { |sub| sub + [val] }\n\n subs + new_subs\nend", "def subsets(array)\n return [[]] if array.empty?\n\n dupped = array.dup\n last = dupped.pop\n sets = subsets(dupped)\n\n subsets(dupped).each do |set|\n sets << (set << last)\n end\n\n sets\nend", "def subsets(set)\n return [[]] if set == []\n \n res= [[]]\n \n 0.upto set.length-1 do |i|\n subsets(set[(i+1)..-1]).each do |subsubset|\n res << [set[i]] + subsubset\n end\n end\n \n res\nend", "def subsets(arr)\n return [ [] ] if arr.empty?\n subs = subsets(arr.drop(1)) # [ [] ]\n return subs.concat(subs.map { |sub| [arr.first].concat(sub) })\nend", "def find_subsets(nums)\n\tsorted_nums = nums.sort()\n\n\tsubsets = []\n\tsubsets.append([])\n\n\tstart_index, end_index = 0, 0\n\n\tfor i in 0..(nums.length - 1)\n\t\tstart_index = 0\n\t\t0\n\t\t0\n\t\tif i > 0 and nums[i] == nums[i - 1]\n\t\t\tstart_index = end_index + 1\n\t\tend\n\n\t\tend_index = subsets.length - 1\n\t\t0\n\t\t1\n\t\tfor j in start_index..end_index\n\t\t\tsubset1 = Array.new(subsets[j])\n\t\t\t[]\n\t\t\t[]\n\t\t\tsubset1.append(nums[i])\n\t\t\t[1]\n\t\t[3]\n\t\t\tsubsets.append(subset1)\n\t\t\t[[],[1],[3]]\n\t\tend\n\tend\n\n\treturn subsets\nend", "def subsets (arr)\n return [[]] if arr.length == 0\n\n interim = subsets(arr[0...-1])\n interim + interim.map do |el|\n el + [arr[-1]]\n end\nend", "def subsets(array)\n return [[]] if array.empty?\n\n subs = subsets(array[0..-2])\n subs.concat(subs.map{|el| el += [array.last]})\nend", "def subsets(array)\n return [[]] if array.empty?\n\n subs = subsets(array[0..-2])\n subs.concat(subs.map{|el| el += [array.last]})\nend", "def subsets(arr)\n return [arr] if arr.empty?\n out = []\n subsets(arr[1..-1]).each do |s|\n out << s\n out << [arr[0]] + s\n end\n out\nend", "def subsets(array)\n return [[]] if array == []\n\n sets = subsets(array[0...-1])\n sets + sets.map { |el| el += [array.last] }\nend", "def subsets(arr)\n return [[]] if arr.empty?\n s = subsets(arr - [arr.last])\n s + s.map { |el| el + [arr.last] }\nend", "def array_subsets(arr)\n return [[]] if arr.empty?\n partial_subset = array_subsets(arr[0..-2])\n addition = partial_subset.map {|ele| ele + [arr[-1]]}\n partial_subset + addition\nend", "def subsets(arr)\n return [[]] if arr.empty?\n # debugger\n # take - return first n elements\n\n subArr = arr.take(arr.count - 1)\n\n subs = subsets(subArr)\n\n # concat Appends the elements of other_ary to self.\n # tyle co +\n subArrays = subs.map { |sub| sub + [arr.last] }\n subs.concat(subArrays)\nend", "def subsets(arr)\n return [[]] if arr.empty?\n subsets_arr = []\n cur_el = arr[0]\n prior_subs = subsets(arr[1..-1])\n prior_subs.each do |subset|\n subsets_arr << subset.dup.push(cur_el)\n end\n subsets_arr + prior_subs\nend", "def subsets(arr)\n return [[]] if arr.length == 0\n #return [arr] if arr.length == 1\n\n prev_set = subsets(arr[0..-2])\n new_subset = prev_set.map { |subarr| subarr + [arr[-1]] }\n\n prev_set + new_subset\nend", "def subsets(arr)\n ans = [[]]\n arr.length.times do |id|\n id2 = id + 1\n ans << [arr[id]]\n while id2 < arr.length\n ans << arr[id..id2]\n id2 += 1\n end\n end\n ans\nend", "def generate_n_sets(array, number_of_sets)\n\nend", "def subsets(nums)\n return [[]] if nums.empty?\n first = nums[0]\n prev_subs = subsets(nums[1..-1])\n new_subs = prev_subs.map do |sub|\n sub + [first]\n end \n prev_subs + new_subs\nend", "def subsets(array)\n\n return [[]] if array == []\n all_but_last = subsets(array[0...array.length - 1].dup)\n last = array.last\n all_but_last.map { |el| el.dup } + all_but_last.map { |el| el << last }\nend", "def subsets(arr)\n return [[]] if arr.empty?\n\n val = arr[0]\n subs = subsets(arr.drop(1))\n new_subs = subs.map{ |sub| sub + val }\n\n subs + new_subs\nend", "def subsets(array)\n return [[]] if array.empty?\n subs = subsets(array[0..-2])\n subs += subs.map { |el| el += [array.last] }\n end", "def powerset(array, index = nil)\n if index.nil?\n index = array.length - 1\n elsif index < 0\n return [[]]\n end\n\n ele = array[index]\n subsets = power(array, index - 1)\n (0..subsets.length - 1).each do |i|\n current_subset = subsets[i]\n subsets.append(current_subset + [ele])\n end\n\n subsets\nend", "def subsets(arr)\n return [[]] if arr == [] \n\n new_arr = []\n last = arr[-1]\n subset = subsets(arr[0..-2])\n\n subset.each do |suba|\n new_arr << suba + [last]\n end\n \n subset + new_arr\n\nend", "def recursive_subsets(arr)\n return [[]] if arr.empty?\n last_el = arr.pop\n p sub_arr = recursive_subsets(arr)\n p last_el\n sub_arr += sub_arr.map { |el| el + [last_el] }\nend", "def subsets(arr)\n #base case(s)\n p arr\n return [arr] if arr.empty?\n # return [[], arr] if arr.length == 1\n #inductive step\n remaining_arr = subsets(arr[0...-1])\n remaining_arr + remaining_arr.map { |ele| ele + [arr.last] }\n # subsets(arr) + subsets(arr[0...-1])\nend", "def subsets(nums)\n return [[]] if nums.empty?\n return [[],[nums.first]] if nums.size == 1\n [[], (0...nums.size).map {|x|\n [[nums[x]], subsets(nums[x + 1..-1]).map { |y| [nums[x]] + y }]\n }.flatten]\nend", "def common_subsets(arr1, arr2)\n subsets(intersection3(arr1, arr2))\nend", "def subsets(arr)\n res = [] \n if arr.length == 1 \n res << [] \n res << [arr[0]]\n return res \n elsif arr.empty?\n return [[]]\n end\n \n last = arr.pop \n old_set = subsets(arr)\n res = old_set\n \n res += old_set.map{ |i| i + [last] }\nend", "def subsets(ary)\n # base case\n return [[]] if ary.empty?\n\n # create subsets without the last element (smaller array)\n subs = subsets(ary.take(ary.length - 1))\n\n # adds the subs with the last element that was omitted.\n subs.concat( subs.map { |sub| sub + [ary.last] })\n\nend", "def subsets(arr)\n return [arr] if arr.empty?\n prev = subsets(arr[0..-2]) \n next_one = []\n prev.each { |sub| next_one << sub + [arr[-1]] }\n return prev + next_one\nend", "def powerset(array, idx = nil)\n if (idx == nil)\n idx = array.length - 1\n end\n if (idx < 0)\n return [[]]\n end\n element = array[idx]\n subsets = powerset(array, idx - 1)\n for i in 0..subsets.length - 1\n current_subset = subsets[i]\n subsets << current_subset + ([element])\n end\n return subsets\nend", "def find_subsets(arr, target_value)\n rec(arr, target_value, arr.length - 1)\nend", "def subsets_iter(arr)\n new_arr = [[]]\n # byebug\n i = 0\n while i < arr.length\n# byebug\n ele1 = arr[i]\n new_arr << [ele1]\n\n if arr.length > 2\n sub_arr = [ele1]\n j = i + 1\n while j < arr.length\n # byebug\n ele2 = arr[j]\n sub_arr << ele2\n new_arr << sub_arr.dup\n sub_arr.pop\n j += 1\n end\n end\n i += 1\n end\n# byebug\n new_arr << arr unless arr.length < 2\n\n new_arr\nend", "def common_subsets(array_one, array_two)\n subsets(fast_intersection(array_one, array_two))\nend", "def common_subsets(array_one, array_two)\n common_array = fast_intersection(array_one, array_two)\n subsets(common_array)\nend", "def subsets(arr)\n # return an empty array (tech a subset of an empty array) - base case\n return [[]] if arr.empty?\n # take out the last el\n last = arr[-1]\n # take all the other els\n # find all subsets don't have the last element\n subsets_without_last = subsets(arr[0...-1])\n # create an array with a combo of s (the el) & the last ele in arr\n # find all subsets that have the last element\n subsets_with_last = subsets_without_last.map { |s| s.dup << last }\n # merge with prior subsets\n # all subsets of arr either have the last element, or they don't.\n subsets_without_last + subsets_with_last\nend", "def subsets_with_dup(nums)\n result = []\n nums.sort!\n subsets_helper(nums, [], result, 0, {})\n result\nend", "def subsets(arr)\n return [[]] if arr.empty?\n\n # new_series = subsets(arr[0..-2]).each do |subarr|\n # subarr << arr[-1]\n # end\n # subsets(arr[0..-2]) + new_series\n\n prev = subsets(arr[0..-2])\n prev.concat( prev.map { |subarr| subarr + [arr.last] } )\n\nend", "def subsets(arr)\n return [[]] if arr.empty?\n\n last_el = arr.last\n results = []\n\n\n subsets(arr[0..-2]).each do |el|\n sub_arr = el << last_el\n results << sub_arr\n end\n\n subsets(arr[0..-2]) + results\nend", "def subsets_2(nums, results = [], solution = [], current_idx = 0)\n results << solution.clone\n return if current_idx >= nums.length\n\n current_idx.upto(nums.length - 1) do |i|\n solution << nums[i]\n subsets(nums, results, solution, i + 1)\n solution.pop\n end\n\n results\nend", "def find_subsets_of_points(options={})\n puts \"Calculating subsets\"\n puts \"Set of #{@points_amount} points: 2^#{@points_amount} subsets = #{2**@points_amount} different subsets\"\n @points_subsets = Array.new(@points_amount) { Array.new }\n # amount of all subsets of a set 2^n-1 (-1, as we're excluding the empty set {})\n (1..2**@points.length-1).each { |i|\n p i if i%100000 == 0\n subset_size = subset_size(i)\n if (options[:with_first_point_only] != true) || (options[:with_first_point_only] == true and i % 2 == 1)\n @points_subsets[subset_size-1] << i\n end\n }\n\n (2..@points_amount).each do |subset_size|\n subsets = @points_subsets[subset_size-1]\n puts \"Subset size: \" + subset_size.to_s + \"; Subsets total: \" + subsets.size.to_s\n end\n\n puts \"Done calculating subsets\"\n end", "def subsets(arr)\n # byebug\n return [arr] if arr.empty?\n\n if arr.length.odd?\n mid_idx = arr.length / 2\n else\n mid_idx = arr.length / 2 - 1\n end\n# byebug\n with_last = subsets(arr[1..-1])\n # byebug\n without_last = subsets(arr[0...-1])\n # byebug\n combined1 = subsets(arr[0...mid_idx] + arr[mid_idx + 1..-1])\n # combined2 = subsets(arr[0..mid_idx] + arr[mid_idx + 2..-1]) # this didn't work. still missing [1, 2, 4] with [1, 2, 3, 4] original input\n# byebug\n output = without_last + combined1 + with_last + [arr] # combined2\n output.uniq\nend", "def subsets_3(nums, results = [], solution = [], current_idx = 0)\n results << solution.clone\n return if current_idx == nums.length\n\n nums[current_idx..-1].each_with_index do |num, i|\n solution << num\n subsets(nums, results, solution, current_idx + i + 1)\n solution.pop\n end\n\n results\nend", "def each_subset(array)\n subsets_of(array).each {|subset| yield(subset)}\n end", "def powerset(arr)\n arr.inject([Set.new].to_set) do |powerset, el|\n new_powerset = Set.new\n powerset.each do |subset|\n new_powerset << subset\n new_powerset << subset + [el]\n end\n new_powerset\n end\n end", "def get_power_set_1(set)\n\t(0..set.length).map {|i| set.combination(i).to_a}.flatten(1)\nend", "def index\n @subsets = Subset.all\n end", "def subset_content\n self.class.subsets[subset.to_sym] if valid_subset? \n end", "def subsets(arr)\n return [[]] if arr.empty?\n sub = subsets(arr[0...-1])\n newsub = sub.map { |ele| ele + [arr.last] } \n sub + newsub\n\n\n# sub + arr[-1]\nend", "def common_subset(arr1, arr2)\n i = intersection(arr1, arr2)\n subsets(i)\nend", "def subset_in_array?(array, value)\n result = 1.upto(array.length).flat_map do |n|\n array.combination(n).to_a\n end\n result.include?(value)\nend", "def subsets(arr, n = arr.size-1)\n #Heaps permutations\n @sol = [] if n == arr.size - 1\n\n if n == 0\n p arr\n @sol << arr\n return arr\n else\n (n+1).times do |i|\n p i\n subsets(arr,n-1)\n if( (n - 1) % 2 == 1)\n arr[1],arr[n] = arr[n],arr[1]\n else\n arr[i],arr[n] = arr[n],arr[i]\n end\n end\n end\nend", "def get_power_set_2(set)\n\treturn [[]] if set.empty?\n\n\tnum = set.pop\n\tprevious_subsets = get_power_set_2(set)\n\n\tprevious_subsets.map do |subset|\n\t\t[subset.dup.push(num), subset]\n\tend.flatten(1)\n\nend", "def subset\n { subset: @superset }\n end", "def multipleSet(n)\n return (n..99).step(n).to_a.to_set\nend", "def permutations(array)\n return [array] if array.length <= 1\n\n\n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n\n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend", "def permutations(array)\n return [array] if array.length <= 1\n \n \n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n \n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n \n \n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend", "def recompute_recursive_subsets\n @recursive_subsets = subsets.inject(ValueSet.new) do |set, child|\n set.merge(child.recursive_subsets)\n end\n if parent\n parent.recompute_recursive_subsets\n end\n end", "def permutations(array)\n return [array] if array.length <= 1\n\n # Similar to the subsets problem, we observe that to get the permutations of \n # [1, 2, 3] we can look at the permutations of [1, 2] which are [1, 2] and \n # [2, 1] and add the last element to every possible index getting [3, 1, 2], \n # [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1], [2, 1, 3]\n\n # pop off the last element\n first = array.shift\n\n # make the recursive call\n perms = permutations(array)\n\n # we will need an array to store all our different permutations\n total_permutations = []\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).to_a.each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n\n total_permutations\nend", "def points_of_subset_simple subset\n subset = subset.to_s(2)\n (2 ... subset.length+1).find_all { |i| subset[-i,1] == '1' }\n end", "def permutation (array)\n# yields permutation set WITH duplicates\nend", "def PowerSetCount(arr)\n combinations = []\n (0..arr.size).each { |combo| combinations += arr.combination(combo).to_a }\n combinations.size\nend", "def subset name, options = {}\n @subsets ||= {}\n @subsets_scopes ||= {}\n\n options[:fieldsets] = [options[:fieldsets]] unless options[:fieldsets].blank? || options[:fieldsets].is_a?(Array)\n\n # Subset is an extension\n if options[:extends]\n # Force extends option to Array\n options[:extends] = [options[:extends]] unless options[:extends].is_a?(Array)\n options[:extends].each do |source_subset|\n next unless @subsets.has_key? source_subset\n source_options = @subsets[source_subset].clone\n source_options.delete :template\n options = source_options.merge options\n options[:scopes] = [source_options[:scopes], options[:scopes]].flatten.uniq if source_options[:scopes]\n end\n\n # Include all opt-out fieldsets by default\n elsif options[:fieldsets].blank?\n options[:fieldsets] = @fieldsets.reject{ |k,v| v[:options][:opt_in] }.keys\n end\n\n # Handle fieldsets restriction list\n if options[:only]\n options[:only] = [options[:only]] unless options[:only].is_a?(Array)\n options[:fieldsets] &= options[:only]\n end\n\n # Handle fieldsets exclusion list\n if options[:except]\n options[:except] = [options[:except]] unless options[:except].is_a?(Array)\n options[:fieldsets] -= options[:except]\n end\n\n # Handle additional fieldsets list\n if options[:add]\n options[:add] = [options[:add]] unless options[:add].is_a?(Array)\n options[:fieldsets] |= options[:add]\n end\n\n # Handle scopes\n options[:scopes] ||= []\n options[:scopes] = [options[:scopes]] unless options[:scopes].is_a?(Array)\n options[:scopes].each do |subset_scope|\n @subsets_scopes[subset_scope] ||= []\n @subsets_scopes[subset_scope] << name unless options[:template]\n if respond_to?(subset_scope)\n (class << self; self; end).class_eval %Q\"remove_method :#{subset_scope}\"\n scopes.delete subset_scope\n end\n scope subset_scope, where(:subset.in => @subsets_scopes[subset_scope])\n end\n\n # Cleanup\n options[:fieldsets] = options[:fieldsets].uniq & @fieldsets.keys\n options[:group] ||= :default\n remove_options = [:extends, :add, :only, :except]\n options = options.clone\n options.delete_if{ |key, value| remove_options.include?(key) }\n\n # Register subset\n @subsets[name] = options\n end", "def subset_fields name\n return unless subsets.has_key?(name) && subsets[name].has_key?(:fieldsets)\n subset_fields = []\n subsets[name][:fieldsets].each do |fieldset|\n fields = @fieldsets[fieldset][:fields]\n fieldset = fields.is_a?(Array) ? fields : [fields]\n subset_fields |= fieldset\n end\n subset_fields.uniq\n end", "def set_subset\n @subset = Subset.find(params[:id])\n end", "def subarray_bitwise_o_rs(a)\n result_set = Set.new()\n a.size.times do |i|\n (1..a.size-i).each do |length|\n subarray = a[i, length]\n #puts subarray.inspect\n result = subarray.reduce(0) do |bor, elem|\n bor | elem\n end\n #puts result\n result_set << result\n end\n end\n result_set.size\nend", "def subsets_scopes\n @subsets_scopes\n end", "def minProductSubset(a, n) \t\n\tif (n == 1) \n\t\treturn a[0]\n end\n\t# Find count of negative numbers,\n\t# count of zeros, maximum valued\n\t# negative number, minimum valued\n\t# positive number and product\n\t# of non-zero numbers\n\tmax_neg = 0\n\tmin_pos = 0\n\tcount_neg = 0\n\tcount_zero = 0\n\tprod = 1\n\n\tfor i in 0..n-1 do\n\t\t# If number is 0, we don't\n\t\t# multiply it with product.\n\t\tif (a[i] == 0) \t\n\t\t count_zero = count_zero + 1\n\t\t continue\n end\n\t\t# Count negatives and keep\n\t\t# track of maximum valued\n\t\t# negative.\n\t\tif (a[i] < 0) \t\n\t\t\tcount_neg = count_neg + 1\n\t\t\tmax_neg = [max_neg, a[i]].max\n end\n\t\t# Track minimum positive\n\t\t# number of array\n\t\tif (a[i] > 0)\n\t\t\tmin_pos = [min_pos, a[i]].max\n end\n\t\tprod = prod * a[i]\n end\n\n\t# If there are all zeros\n\t# or no negative number\n\t# present\n\tif (count_zero == n or ((count_neg == 0)\tand count_zero > 0)) \n\t return 0;\n end\n\n\t# If there are all positive\n\tif (count_neg == 0) \n\t\treturn min_pos\n end \n\n\t# If there are even number of\n\t# negative numbers and count_neg\n\t# not 0\n\tif ((count_neg & 1) == 0 and\n\t\t\t\t\tcount_neg != 0) \n\n\t\t# Otherwise result is product of\n\t\t# all non-zeros divided by\n\t\t# maximum valued negative.\n\t\tprod = int(prod / max_neg)\n \n end \n\treturn prod;\nend", "def combinations(n)\n \n end", "def subset?(arr, valid_arr)\n\t\tvalid_set = Set.new valid_arr\n\t\tset = Set.new arr\n\t\treturn set.subset?(valid_set)\n\tend", "def sub_arrays\n result = []\n self.each_index do |i|\n self.each_index do |j|\n result << self[i..j] if j >= i\n end\n end\n result\n end", "def all_choices_from(arrs) \n max_index = arrs.map { |x| x.size }.max - 1\n\n generate_power_set_of_size((0..max_index).to_a, arrs.size) do |indexes|\n next_set = []\n\n skip = false\n\n indexes.each_with_index do |j, i|\n v = arrs[i][j]\n skip ||= v.nil?\n next_set << v\n end\n\n yield next_set unless skip\n end\n end", "def valid_sets; end", "def mixed_combinations\n combination_generator.mixed_combinations\n end", "def sets\n end", "def to_multiset_simple n\n @set.permutation(n).to_a.sort_by { rand }\n end", "def rand_subarrays(n = 1)\n raise ArgumentError, 'negative argument' if n < 0\n (1..n).map do\n r = rand(2**self.size)\n self.select.with_index { |_, i| r[i] == 1 }\n end\n end", "def valid_subset?\n return true if self.class.subsets.keys.include?(subset.to_s.to_sym)\n errors.add(:subset, :invalid) if respond_to?(:errors)\n false\n end", "def print_all_combinations(selected_set, left_over_set)\ndebug(\"first #{selected_set} - left over #{left_over_set}\")\n left_over_set.each do |left_over|\n save(selected_set + [left_over])\n end\nend" ]
[ "0.84753776", "0.8217911", "0.8217911", "0.8217911", "0.82110196", "0.8095407", "0.7994123", "0.7846153", "0.7780534", "0.7761643", "0.7755116", "0.7736509", "0.7734516", "0.7697075", "0.76968116", "0.75354934", "0.7526128", "0.74741256", "0.747332", "0.74587274", "0.7435874", "0.74180955", "0.7401224", "0.7401057", "0.7398521", "0.7343719", "0.73342025", "0.73109615", "0.7255897", "0.7255897", "0.72286445", "0.7207942", "0.72045565", "0.7194466", "0.71821845", "0.717126", "0.71509165", "0.71326137", "0.71269625", "0.7104583", "0.7097192", "0.7092405", "0.7078408", "0.7075645", "0.7070292", "0.7032155", "0.7013552", "0.701203", "0.69499356", "0.6927391", "0.6923312", "0.690656", "0.6871358", "0.6839881", "0.6815511", "0.68007386", "0.6790326", "0.6754267", "0.6746066", "0.6710409", "0.6703197", "0.66432065", "0.6590547", "0.65555984", "0.65528464", "0.6546993", "0.6474725", "0.6418861", "0.6329847", "0.63223374", "0.6282548", "0.62644553", "0.62616396", "0.6247836", "0.62235886", "0.6159287", "0.598983", "0.5968554", "0.5957543", "0.5920684", "0.5911734", "0.58415556", "0.5747473", "0.57042295", "0.569968", "0.56894344", "0.5683394", "0.56265867", "0.56216687", "0.560222", "0.56015444", "0.55999726", "0.5599131", "0.55942243", "0.558651", "0.5537367", "0.5532415", "0.55138797", "0.550901", "0.5505962", "0.548487" ]
0.0
-1
Is the order 100% ready to be merged?
def ready_for_merge?(order_detail) case order_detail.product when Service order_detail.valid_service_meta? when Instrument order_detail.valid_reservation? else true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def order_completable?\n force_completion || actual_end_at || reserve_end_at < Time.current\n end", "def complete?\n !pending?\n end", "def complete?()\n if (self.order_in_lines.length == 0)\n return false\n end\n self.order_in_lines.each do | line |\n if (line.qty < line.qty_in)\n return false\n end\n end\n return true\n end", "def complete?\n true\n end", "def complete?\n true\n end", "def available_for_order?(_order)\n true\n end", "def complete?\n end", "def complete?\n true\n end", "def complete?\n true\n end", "def complete?\n complete == true\n end", "def unappliable_order?\n order.bought? == false\n end", "def settled?\n return !self.pending?\n end", "def complete?\n false\n end", "def shouldnt_count_as_a_contribution?\n merge? || backported_from_master?\n end", "def merged?\n !!merge_ticket_id\n end", "def complete?\n @complete\n end", "def complete?\n !incomplete?\n end", "def complete?\n !incomplete?\n end", "def has_confirmed_order?\n confirmed_order = false\n open_orders.each do |o|\n if o.confirmed\n confirmed_order = true\n break\n end\n end\n confirmed_order\n end", "def complete?\n @complete\n end", "def transaction_already_completed?\n if self.status != \"pending\"\n return false\n else\n true\n end\n end", "def check_for_completeness\n mark_complete(Time.now) if paid? && received?\n end", "def completed?\n \t\tlatest_transaction.completed? unless transactions.empty?\n \tend", "def mergable?\n merge_bps <= 20.minutes.to_i\n end", "def is_conflict?\n from_json\n (@order && @order.paid?).tap do |x|\n @error = true if x\n end\n end", "def complete?\r\n @is_complete\r\n end", "def complete?\n self.state == 'complete'\n end", "def update_ok?(order_hash)\n\t\tif !order_hash[:order_number]\n\t\t\treturn false\n\t\telsif order_hash[:status] == 'SH' \n\t\t\t\treturn true unless order_hash[:tracking_number] == nil || order_hash[:ship_method] == nil\n\t\telse\n\t\t\treturn true\n\t\tend \n\tend", "def update_ok?(order_hash)\n\t\tif !order_hash[:order_number]\n\t\t\treturn false\n\t\telsif order_hash[:status] == 'SH' \n\t\t\t\treturn true unless order_hash[:tracking_number] == nil || order_hash[:ship_method] == nil\n\t\telse\n\t\t\treturn true\n\t\tend \n\tend", "def ready_save_and_check_summary\n\t\tself.finished_and_ready = true\n\t\tself.save!\n\t\t@round = Round.find(self.round_id)\n\t\[email protected] do |p|\n\t\t\tif !p.finished_and_ready\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t\n\tend", "def complete?\n self.complete\n end", "def pending_promotions?\n !pending_promotions.empty?\n end", "def ready_to_approve?\n status = self.units.map(&:unit_status) & ['condition', 'copyright', 'unapproved']\n return status.empty?\n end", "def order?\n !order.nil?\n end", "def complete?\n synchronize do\n (@bars - [@top_bar]).all?(&:complete?)\n end\n end", "def probe?\n self.order == -1\n end", "def incomplete?\n not complete?\n end", "def check_if_round_part_b_ready_to_start\n self.creator_preferences.each do |creator_preference|\n # return false if !creator_preference.is_ready\n return false if !creator_preference.finished_round\n end\n self.donor_preferences.each do |donor_preference|\n return false if !donor_preference.is_ready\n end\n self.part_b_started = true\n self.start_time = DateTime.now\n self.save!\n end", "def incomplete?\r\n !complete?\r\n end", "def is_open?\n bookings.completed.empty?\n end", "def complete?\n return state == \"complete\"\n end", "def insync?(is)\n (is.size == should.size && is.sort == should.sort)\n end", "def handle_stock_counts?\n current_shipment.order.completed? && current_stock_location != desired_stock_location\n end", "def update_completed? ; false ; end", "def insync?(current)\n current.sort == should.sort\n end", "def insync?(current)\n current.sort == should.sort\n end", "def insync?(current)\n current.sort == should.sort\n end", "def insync?(current)\n current.sort == should.sort\n end", "def check_for_completeness\n purch_states = purchases.pluck(:state)\n unique_states = purch_states.uniq\n return unless unique_states.size.eql? 1\n purchases_state = unique_states.first\n complete(Time.now) if purchases_state.eql? 'completed'\n end", "def merged?\n @merged\n end", "def mark_order_complete\n order_params = (driver_order_params)\n order_params[:payable_attributes][:driver_id] = current_user.customer_id\n if @order.single?\n if( (Time.now >= Time.parse(@order.place_date + ' ' + @order.timeslot.start) || true) && (@order.pending? ) && @order.update(order_params) )\n render json: @order, status: 200\n else\n render json: {'errorrs': ['Order can not be completed']}, status: :unprocessable_entity\n end\n else\n if(@order.update(order_params))\n render json: @order, status: 200\n else\n render json: {'errorrs': ['Order can not be completed']}, status: :unprocessable_entity\n end\n end\n end", "def insync?(is)\n is.sort! == should.sort!\n end", "def possibly_set_as_completed\n # this is a guard against setting something completed that isn't and that will make this method fail\n return false unless available_in_merritt? # this also sets @mrt_results member variable so we don't have to redo the query again\n\n merritt_id = \"#{APP_CONFIG[:repository][:domain]}/d/#{@mrt_results['ark']}\"\n StashEngine.repository.harvested(identifier: resource.identifier, record_identifier: merritt_id)\n\n if StashEngine::RepoQueueState.where(resource_id: resource_id, state: 'completed').count < 1\n StashEngine.repository.class.update_repo_queue_state(resource_id: resource_id, state: 'completed')\n end\n\n update_size!\n ::StashEngine.repository.cleanup_files(resource)\n true\n end", "def checkout_needed?\n\t\ttrue\n\tend", "def is_under_process?\n #if true then this sub has got orders which are under process(by payment / shipment)\n self.orders.where('(delivery_date <= ? and delivery_date > ?) or (state = ? and payment_state = ?)', ORDER_UPDATE_LIMIT.days.from_now.to_date, Time.now, 'placed', 'paid').present?\n end", "def common_boost_ready?\n [\n available_items(:common_boost).any?,\n available_items(:boost).length > 1,\n ! has_effect?(ItemClasses.boost),\n points == 1\n ].all?\n end", "def up_to_date?\n return not_covered.count > 0 ? false : true\n end", "def anything_to_do?\n (pending.length + state_check.length) > 0\n end", "def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end", "def is_ordered?\n # TODO Stubbed - Requires definition and implementation\n end", "def due_status?(order)\n order.relevant_delivery_date &&\n (order.shippable? || order.collectable?) &&\n !order.shipped_at &&\n order.collection_ready_emails.empty?\n end", "def is_ready\n if self.tasks.empty? and not self.is_done # no tasks assigned for this\n false\n elsif (self.tasks.find_by is_done: false).nil? # can't find any false => all tasks are done\n self.update_attribute(:is_done, true)\n true\n else\n false\n end\n end", "def push_to_epic_complete?\n %w(complete failed).include? last_epic_push_status\n end", "def update_order_done_cutting\n all_order_rolls = Roll.where(order_id: order_id)\n if all_order_rolls.where('roll_cut_complete = ?', false).count == 0\n order.update(cut_complete: true)\n\n else\n order.update(cut_complete: false)\n end\n end", "def has_order_items?\n @cores != nil || @ram != nil || @max_port_speed != nil\n end", "def finished?\n finished = nil\n active_item_orders = item_orders.where(active: true)\n if state_reached?(:fulfilled)\n if active_item_orders.length == 0\n finished = true\n else\n active_item_orders.each do |io|\n i = io.item\n if !i.obsolete\n last_transition = i.state_transitions.where(order_id: id).first\n\n if last_transition && (last_transition.to_state == i.final_state.to_s)\n finished = true\n else\n finished = false\n break\n end\n end\n end\n end\n end\n finished\n end", "def cycle_complete?\n !self.sf_integrity_hash.nil? and !self.acf_integrity_hash.nil?\n end", "def incomplete?\n !@complete\n end", "def acyclic?\n topsort.size == size\n end", "def recalculate_ready!\n self.ready = articles.not_ready.empty?\n self.save!\n end", "def is_done?\n return self.status == Erp::QuickOrders::Order::STATUS_DONE\n end", "def ready_to_exchange?\n self.balance >= self.promotion.points_to_exchange\n end", "def check_order_status(id)\n @order = Order.find_by_id(id)\n\n incomplete = 0\n @order.order_items.each do |item|\n if item.ship_status == false\n incomplete += 1\n end\n end\n\n if incomplete == 0\n @order.status = 'complete'\n @order.save\n else\n @order.status = 'paid'\n @order.save\n end\n return @order\n end", "def orders?\n return orders.any?\n end", "def checkout_promotions?\n !checkout_promotions.empty?\n end", "def fully_downloaded?\n self.transmission_status == 8 && self.transmission_total_size == self.transmission_downloaded_size\n end", "def checkout(attributes)\n completed = false\n transaction do\n update!(attributes.merge(status: \"Completed\"))\n orderitems.each do |item|\n raise ActiveRecord::Rollback unless item.reduce_stock\n end\n completed = true\n end\n\n completed\n end", "def marked_as_complete?\n get[state.to_s] and get[state.to_s].to_sym == :complete\n end", "def complete?\n\t\t@cards >= COMPLETE_COLLECTION\n\tend", "def updated_values?(order)\n super or submitted_assets_have_changed?(order)\n end", "def ready?\n pending? and not dependencies_have_failed? and dependencies_are_ready? and concurrency_available?\n end", "def any_items_ready?\n ready = false\n if items.blank?\n ready = true\n else\n items.each do |i|\n if !i.obsolete\n if i.digital_object\n ready = i.state_reached_for_order(:ready_at_use_location, self.id)\n else\n ready = i.state_reached_for_order(:ready_at_temporary_location, self.id)\n end\n end\n break if ready\n end\n end\n ready\n end", "def became_completed?\n completed_changed? && completed\n end", "def complete?\n self.status == STATUS[:complete] \n #self.status == 1\n end", "def all_complete\n self.tasks.count == self.tasks.done.count\n end", "def ready_to_create?\n valid? && processed? && import_level_ok?\n end", "def merge_step(buy_orders, sell_orders, official_spread, order_filler)\n buy_queue, buy_order = first_buy_order buy_orders, official_spread\n return false unless buy_order\n sell_queue, sell_order = first_sell_order sell_orders, official_spread\n return false unless sell_order\n \n buy_price = buy_order.limit_price || official_spread.last\n sell_price = sell_order.limit_price || official_spread.first\n return false if buy_price < sell_price\n # divides by 2 and rounds to cents\n price = Stock.clean_price((buy_price + sell_price) / 2)\n quantity = [buy_order.unfilled_quantity, sell_order.unfilled_quantity].min\n \n order_filler.call buy_queue, buy_order, price, quantity\n order_filler.call sell_queue, sell_order, price, quantity\n return true\n end", "def incomplete?\n !completed\n end", "def complete?\n status == \"Completed\"\n end", "def commit_required?\n @entry_set.each do |e|\n return true if e.dirty\n end\n @comment != @stored_comment || @entry_set != @stored_entries || @create\n end", "def can_combine?(order)\n self.combine &&\n order.credits(:join => :adjustment_source).all?{|pc| pc.adjustment_source.combine}\n end", "def incomplete?\n running? || pending? || initialized?\n end", "def complete!\n return false unless pending? && transfer.feasible?\n transfer.complete!\n update shipped_at: Time.current\n order.update_shipped!\n email.shipment(to: order.billing_recipient)&.deliver_later if order.billing_address.present?\n email.shipment(to: order.shipping_recipient, bcc: false)&.deliver_later if order.has_contact_email?\n true\n end", "def insync?(is)\n ((@should - is).length == 0)\n end", "def pending?\n return self.settled_at.nil?\n end", "def completed?\n !self.shift_jobs.empty?\n end", "def ready?\n @latch.count == 0\n end", "def orderable?\n return false unless active?\n return false if has_variants?\n true\n end", "def punch_out_order_message?\n !punch_out_order_message.nil?\n end", "def any_waiting?\n synchronize do\n @num_waiting > 0\n end\n end" ]
[ "0.6725433", "0.6615383", "0.6569081", "0.6562348", "0.6552683", "0.65318865", "0.6455695", "0.6444472", "0.6444472", "0.64153403", "0.63636947", "0.63022274", "0.6259894", "0.6247822", "0.6246679", "0.6242941", "0.62382346", "0.62382346", "0.6233442", "0.62197524", "0.62066704", "0.620155", "0.61860955", "0.6181525", "0.6180322", "0.6172198", "0.61617815", "0.61315715", "0.61315715", "0.61192447", "0.61073023", "0.6106326", "0.61048895", "0.6103063", "0.6091869", "0.6091239", "0.60892326", "0.6069585", "0.6053234", "0.6047932", "0.60437125", "0.6042981", "0.6040552", "0.60402507", "0.60379916", "0.60379916", "0.60379916", "0.60379916", "0.60319734", "0.60238624", "0.6018777", "0.60131025", "0.5987776", "0.5987733", "0.5985426", "0.59829044", "0.5964632", "0.5964518", "0.5963856", "0.59622544", "0.59618163", "0.59605813", "0.5958287", "0.5954372", "0.5954126", "0.5950995", "0.5949272", "0.5947771", "0.5940575", "0.593981", "0.593406", "0.5924983", "0.5916092", "0.5912192", "0.59084505", "0.59064144", "0.59060574", "0.5899024", "0.5895574", "0.5895019", "0.58846223", "0.58790725", "0.5877563", "0.5876115", "0.5871931", "0.58703196", "0.58701724", "0.5869632", "0.5865772", "0.586481", "0.5859608", "0.5857032", "0.58570015", "0.58491707", "0.58440244", "0.58316505", "0.58235466", "0.5815727", "0.58148295", "0.58084214" ]
0.70886475
0
show quiz as user
def show @quiz = Quiz.find_by(user_id: current_user) if !@quiz redirect_to quiz_types_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @quiz = Quiz.find(params[:id])\n @user = User.find(params[:user_id])\n end", "def show_user_questions\n\t\tif logged_in?\n\t\t\t@user_questions = @current_user.question\n\t\tend\n\tend", "def show\n if @question.user_id.nil?\n @question_author = 'anonymous'\n else\n @question_author = User.find(@question.user_id).name\n end\n end", "def show\n @user = User.find(params[:user_id])\n @answer = @question.make_answer(@user)\n @previous_question = @question.previous\n @next_question = @question.next\n end", "def show\n if user_signed_in? && current_user.admin?\n @question = @quiz.questions.build\n elsif user_signed_in?\n else\n redirect_to root_url, notice: \"Sorry, you have to sign in first.\"\n end\n end", "def show\n if current_user.has_role? :admin\n else\n session[:quiz_id] = @quiz.id\n redirect_to quiz_items_url\n end\n end", "def show\n @user = User.find(params[:id])\n @quiz = @user.quizzes.last\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def show\n @question = Question.find(params[:id])\n @avatar = Avatar.find_by_user_id(@question.user_id)\n @user = User.find(@question.user_id)\n @answers = Question.findanswers(@question.id.to_s)\n @correctanswers = Question.findcorrectanswers(@question.id.to_s)\n @totalanswers = @answers.size + @correctanswers.size\n\t if current_user == @user\n @asker = true\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @question }\n end\n end", "def show\n if current_user.has_role? :admin\n else\n @quiz = Quiz.find(session[:quiz_id])\n @cardbox = Cardbox.find(session[:cardbox_id])\n @practice = @quiz_item.practice\n end\n end", "def quiz\n end", "def quiz_owner_user\n unless quiz_owner?(params[:id])\n redirect_to quizzes_path\n flash[:error] = \"Step Off!! You don't own that quiz\"\n end\n end", "def set_quiz_user\n @quiz_user = QuizUser.find(params[:id])\n end", "def show\n\t\tif next_quiz == 0\n \tredirect_to quizzes_path\n\t\t\tsession[:quiz_index] = 0\n\t\t\tuser_lesson = UserLesson.find_by(lesson_id: current_lesson.id)\n\t\t\tuser_lesson.status = \"completed\"\n\t\t\tuser_lesson.save\n\t\telse\n\t\t\t@quiz = Quiz.find(next_quiz)\n\t\t\tif @quiz == nil\n\t\t\t\tsession[:quiz_index] = 0 \n\t\t\telse\n\t\t\t\tif UserLessonQuiz.check_presence(@quiz.id).empty?\n\t\t\t\t\tUserLessonQuiz.create(user_id: current_user.id, lesson_id: current_lesson.id, quiz_id: @quiz.id)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n end", "def show\n invalid_questionnaires if @questionnaire.user != @current_user_email\n end", "def show\n @rec_not_saved = false\n @question = Question.find(params[:id])\n @answers = @question.answers.find(:all, :order => \"answers.created_at ASC\", :include => :user)\n @answer = @question.answers.new\n @answer.user_id = session[:user_id]\n end", "def show\n @questions = get_questions\n @answers\n @count = -1\n @total_questions\n @new_quiz = Quiz.new\n end", "def show\n # @answers = @response.answers\n # @questionnaire_name = @response.questionnaire.name\n # @user = @response.user\n end", "def show\n @user = current_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @user_answer = @user_answer.decorate\n end", "def show\n \t@quiz = Quiz.find(params[:id])\n end", "def show\n @feedback_active = !!current_user\n @new_answer = @question.answers.new\n end", "def show\n @questions = @quiz.questions\n @results = @quiz.results\n if current_viewer\n QuizViewLog.create(quiz_id: @quiz.id, viewer_id: current_viewer.id, status: \"viewed\")\n end\n unless @quiz.is_live? or (@quiz.is_preview? and user_signed_in?)\n render text: \"Nothing here\"\n end\n\n end", "def show\n if @user\n @unattempted = @quiz.unattempted(@user).shuffle\n render :json => @quiz.as_json.merge({unattempted: @unattempted, numquestions: @quiz.questions.count, hearts: @user.hearts})\n else \n render text: \"Token failed verification\", status: 422\n end\n end", "def show\n set_user\n end", "def show\n #TODO: Qiita 記事がない場合はrouteを変えて飛ばす\n if @question == nil\n render \"questions/delete_question\"\n return\n end\n # before_action :set_question\n if @question.best_answer_id\n @bestanswer = Answer.find(@question.best_answer_id)\n end\n\n if user_signed_in?\n @answer = @question.answers.build(user_id: current_user.id)\n end\n impressionist(@question, nil, unique: [:session_hash])\n\n end", "def quiz_answer(quiz)\n if quiz.answer_type == 'multi'\n show_multi_answer(quiz.answers.first.text, quiz.answer_input)\n elsif quiz.answer_type == 'check'\n show_check_answer(quiz.answers.first.text, quiz.answer_input)\n else\n quiz.answers.first.text\n end\n end", "def show\n require_user()\n end", "def show\n @quiz = Quiz.find(params[:id])\n end", "def show\n authorize @question\n end", "def index\n if session[:user_id] and User.find_by(id: session[:user_id]).name == \"admin\"\n @scores = Score.all\n elsif session[:user_id]\n # @users = User.all\n redirect_to quiz_url\n else\n redirect_to login_url\n end\n end", "def index\n if current_user.admin?\n @quiz_attempts = QuizAttempt.all\n else\n @quiz_attempts = QuizAttempt.where(user_id: current_user.id).all\n end\n \n end", "def show\n verifica_user\n end", "def show\n set_user\n end", "def show\n if current_user\n @question = Question.find_by_id(params[:question_id])\n if @question \n @answers = Answer.where(:question_id => @question.id).order('vote DESC').all\n render :layout => false\n else\n render :nothing => true\n end\n else\n render :nothing => true\n end\n end", "def show\n if logged_as_student?\n student = Student.find(session[:user_id])\n group = Group.find(student.group_id)\n if !Sqanswer.where(:teacher_id => group.teacher_id, :student_id => student.id, :sidequest_id => @sidequest.id, :reward => @sidequest.reward, :read => false).exists?\n @sqanswer = Sqanswer.new(:teacher_id => group.teacher_id, :student_id => student.id, :sidequest_id => @sidequest.id, :reward => @sidequest.reward, :read => false)\n @sqanswer.save\n else\n @sqanswer = Sqanswer.find_by(:student_id => student, :sidequest_id => @sidequest.id)\n end\n end\n \n if logged_as_teacher?\n @sidequest = Sidequest.find(params[:id])\n @sqanswers = Sqanswer.where(sidequest_id: @sidequest.id, read: false).sort_by{|e| e[:time]}.reverse \n end\n end", "def show\n @quiz = params[:quiz_id]\n @fake_answers = FakeAnswer.where(question_id: params[:id])\n end", "def show\n # @answers = Answer.wheres(user_id: current_user.id)\n # time = Time.now\n @answers = current_user.answers\n # Question.where(operation_id: nil)\n # raise 'hi'\n # @oquestions = current_user.operation.questions\n end", "def show\n authorize! :show, Quiz\n @quiz_perguntas = QuizPergunta.where(quiz_id: @quiz).order('created_at')\n @quiz.pontuacao\n end", "def view\n @quiz = Quiz.find(params[:id])\n render 'show'\n end", "def set_user\n if self.question and self.question.user\n self.user = self.question.user\n end\n end", "def show\n @user = User.find(params[:id])\n @questions = []\n @answers = []\n # if current_user is viewing his or her profile\n # show all questions and answers regardless of\n # anonymity. Otherwise only fetch public posts\n if current_user.id == @user.id\n @questions = current_user.questions\n @user.answers.each do |ans|\n @answers << Question.find(ans.question_id)\n end\n else\n @questions = @user.questions.where(:is_anon => false)\n @user.answers.each do |ans|\n q = Question.find(ans.question_id)\n if !ans.is_anon?\n @answers << q\n end\n end\n end\n\n @follows = []\n user_follows = Follow.where(:user_id => @user.id)\n user_follows.each do |fol|\n if Question.exists?(fol.question_id)\n @follows << Question.find(fol.question_id)\n end\n end\n end", "def perform(user, questions)\n \n end", "def index \n @answers = Answer.all\n @user = current_user\n end", "def show\n @quiz_result = QuizResult.find(params[:id])\n\n respond_to do |format|\n if @role == 'student'\n if !current_student.quiz_results.include? @quiz_result\n flash[:notice] = \"You are not authorized to view that quiz result.\"\n format.html { redirect_to quiz_results_path }\n else\n format.html # show.html.erb\n end \n elsif @role == 'admin'\n if !current_admin.school.students.include? @quiz_result.student\n flash[:notice] = \"You are not authorized to view that quiz result.\"\n format.html { redirect_to show_students_path }\n else\n format.html # show.html.erb\n end\n elsif @role == 'teacher'\n if !current_teacher.classroom.students.include? @quiz_result.student\n flash[:notice] = \"You are not authorized to view that quiz result.\"\n format.html { redirect_to show_students_path }\n else\n format.html # show.html.erb\n end\n elsif @role == 'parent'\n if !current_parent.students.include? @quiz_result.student\n flash[:notice] = \"You are not authorized to view that quiz result.\"\n format.html { redirect_to show_students_path }\n else\n format.html # show.html.erb\n end\n end\n end\n\n end", "def show\n redirect_to quiz_attempts_path\n end", "def ask_question\n @question = Question.new\n puts \"#{@current_player.name}: #{@question.show}\"\n end", "def take_quiz\n end", "def index\n @quiz_users = QuizUser.all\n end", "def question\n @title_page = 'Question'\n user_obj = User.new(params['user'],params['pass'])\n\n response = Request.post_request(URL_USERS, {\n user: user_obj.user,\n pass: user_obj.pass\n })\n\n if response.success?\n @questions = check_questions\n\n if @questions.empty?\n erb :upload, layout: :session\n else\n erb :table, layout: :session\n end\n else\n redirect '/login'\n end\nend", "def correct_user\n @question = Question.find(params[:id])\n redirect_to(root_url) unless current_user == @question.user\n end", "def show\n @question = Question.find(params[:id])\n\n @prev_questions = @question.participant.questions.order(\"created_at DESC\").all\n @answers = Answer.find(:all, :conditions=>{:question_id=>params[:id]})\n if @question.participant.user == current_user || !current_user.is_participant?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @question }\n end\n else\n raise CanCan::AccessDenied \n end\n end", "def show\n @question = Question.find(params[:id])\n\n @is_asker_or_follower = false;\n if @question.user == current_user || @question.followers.find(current_user)\n @is_asker_or_follower = true;\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def instructor_show\n\t\t\tif (current_instructor.quizzes.exists?(:id => params[:id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:id])\n\t\t\t\tquestions = quiz.questions\n\t\t\t\trender json: questions, status: 200\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 404\n\t\t\tend\n\t\tend", "def show\n @question = Question.find(params[:id])\n\n @answers = Answer.where(question_id: @question.id).order(created_at: :desc)\n @users = User.includes(:userprofile).all\n @question = Question.find(params[:id])\n @userprofile = @users.find(@question.user_id)\n\n end", "def author\n # data = QuestionsDatabase.instance.execute(\"SELECT fname, lname FROM questions\")\n User.find_by_user_id(@author_id)\n\n end", "def show\n\t\t@user = current_user\n\tend", "def show\n @score = Evaluation.eval_user(@user)\n end", "def show\n show_user\n end", "def show\n if @user\n @answers = @question.answers.shuffle\n @equestion = @question.as_json.merge({:answers => @answers, :hearts => @user.hearts})\n render :json => @equestion\n else \n render text: \"Token failed verification\", status: 422\n end\n end", "def show\n @result = Result.new\n questions = @quiz_run.questions\n # Retrieve 5 random questions, and paginate them\n @questions = questions.offset(rand(questions.count)).paginate(:page => params[:page], :per_page => 1, :total_entries => 5)\n end", "def show\n check_user\n end", "def info() quiz_question.info end", "def view_quiz\n @questionnaire = Questionnaire.find(params[:id])\n @participant = Participant.find_by_id(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit\n render :view\n end", "def getanswerable\n @the_question = Question.find(params[:id])\n @user_id = session[:user_id]\n if @the_question.user.id == @user_id\n render json: [{question: @the_question}]\n end\n end", "def view_quiz\n @questionnaire = Questionnaire.find(params[:id])\n @participant = Participant.find(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit\n render :view\n end", "def edit_q\n if @question.user_id != current_user.id \n #@question.user_id = Question.find(params[:id]) \n #@user.question = User.find(params[:id])\n #@user = User.find(session[:user_id])\n redirect_to(root_url) #unless current_user?(@user)\n end\n end", "def show\n @course = Course.find(@question.course_id)\n @user = User.find(@question.user_id)\n #this select gets all answers for this question, and includes the summed score for all the votes on each answer\n @answers = Answer.select(\"answers.*, SUM(votes.score) score\").joins(\"LEFT OUTER JOIN votes on votes.answer_id = answers.id\").where(question_id: @question.id).group(\"answers.id\")\n end", "def show\n authorize! :read, @admin_question\n end", "def create\n \t@quiz = Quiz.create(quiz_params)\n \[email protected] = current_user\n \tredirect_to :back\n\tend", "def student_show\n\t\t\tif (current_student.quizzes.exists?(:id => params[:id]))\n\t\t\t\tquiz = current_student.quizzes.find(params[:id])\n\t\t\t\tstudent_quiz_obj = StudentResultQuiz.where(student_id:current_student.id).where(quiz_id:quiz.id).first\n\t\t\t\tif( quiz.expiry_date < DateTime.current ) \t\n\t\t\t\t\tanswers = student_quiz_obj.student_ans\n\t\t\t\t\tstudent_result = student_quiz_obj.result\n\t\t\t\t\tif (student_result == nil)\n\t\t\t\t\t\tstudent_result = 0\n\t\t\t\t\t\tanswers = []\n\t\t\t\t\tend\n\t\t\t\t\tquestions = quiz.questions\n\t\t\t\t\trender json: {:quiz => quiz, :questions => questions, :student_answers => answers, :result => student_result}, status: 200\n\t\t\t\telsif (student_quiz_obj.result == nil)\n\t\t\t\t\tquestions = quiz.questions\n\t\t\t\t\trender json: questions, status: 200\n\t\t\t\telse\n\t\t\t\t\trender json: { error:\"You have already taken the quiz\" }, status: 422\n\t\t\t\tend\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 404\n\t\t\tend\n\t\tend", "def show\n @user_picture = @user.profile_image.expiring_url(3600, :square)\n @bookmarks = @user.bookmarks\n @enrollments = @user.courses\n @enrollments_visible = @user.course_enrollments_visible_for_user(current_user)\n @completions_visible = @user.course_results_visible_for_user(current_user)\n end", "def show\n ap @user\n end", "def show\n # @u = current_user\n end", "def answered_questionnaire?(user)\n answered_users.include?(user)\n end", "def show\n @question = Question.find(params[:id])\n @answers = Answer.all.where(question: @question).order(created_at: :desc)\n @answer = Answer.new\n authorize @question\n end", "def show\n @user_answer = UserAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_answer }\n end\n end", "def show\n @me = current_user\n end", "def set_question\n @question = current_user.questions.find(params[:id])\n end", "def show\n\t@solution = @examquestion.question.solutions.build.tap { |sol| sol.user_id = current_user.id } if user_signed_in?\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def run_quiz\n self.questions_explanation\n self.display_questions\n self.skipped_questions_explanation\n self.skipped_questions\n self.answers_explanation\n self.display_results\n self.show_score\n end", "def show\n @user = current_user\n end", "def index\n @user = current_user\n @questions = @user.questions.all\n end", "def show\n @user = current_user\n end", "def show\n @user = find_user\n end", "def show\n @quizSelect = Quiz.find(1)\n @questions = @quizSelect.questions\n @cards = Card.all.limit(@quizSelect.questions.count*3).shuffle\n\n \tend", "def show\n @user = User.find_by(id: @feedback.user_id)\n end" ]
[ "0.7509028", "0.74126077", "0.714882", "0.6950221", "0.69024473", "0.67744875", "0.675918", "0.67573017", "0.67550015", "0.67458963", "0.67403835", "0.6598986", "0.6564972", "0.6538785", "0.6472537", "0.6462741", "0.6448848", "0.6443549", "0.6442064", "0.642126", "0.64183754", "0.64159447", "0.63995075", "0.6394125", "0.63831204", "0.63786644", "0.6364986", "0.6357319", "0.63560843", "0.6274284", "0.62556875", "0.62366766", "0.62229407", "0.6205908", "0.6185665", "0.61835057", "0.61818266", "0.6155105", "0.6139278", "0.61335343", "0.61294127", "0.61270833", "0.6122847", "0.6121097", "0.61093843", "0.60989976", "0.6098219", "0.6090738", "0.6073523", "0.6071518", "0.6066832", "0.60665005", "0.60611", "0.6054577", "0.6050065", "0.6042485", "0.6006681", "0.6005751", "0.60037357", "0.5998087", "0.5979753", "0.5966074", "0.5946963", "0.59339154", "0.5933141", "0.5930806", "0.59289503", "0.5925007", "0.59211195", "0.5917598", "0.5904858", "0.5904006", "0.58919793", "0.5890688", "0.5887683", "0.5884016", "0.5876876", "0.587488", "0.5872092", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.58676296", "0.5867536", "0.5867118", "0.5866806", "0.58667743", "0.58561134", "0.5855578", "0.5848575" ]
0.7248873
2
view any quiz as admin
def view @quiz = Quiz.find(params[:id]) render 'show' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n authorize! :read, @admin_question\n end", "def show\n if current_user.has_role? :admin\n else\n session[:quiz_id] = @quiz.id\n redirect_to quiz_items_url\n end\n end", "def edit \n redirect_to root_path unless current_user.is_admin?\n \t@quiz = Quiz.find(params[:id]) \n end", "def index\n if current_user.admin?\n @quiz_attempts = QuizAttempt.all\n else\n @quiz_attempts = QuizAttempt.where(user_id: current_user.id).all\n end\n \n end", "def show\n if user_signed_in? && current_user.admin?\n @question = @quiz.questions.build\n elsif user_signed_in?\n else\n redirect_to root_url, notice: \"Sorry, you have to sign in first.\"\n end\n end", "def index\n @admin_academy_questions = Academy::Question.all\n end", "def show\n @quiz = Quiz.find_by(user_id: current_user)\n if !@quiz\n redirect_to quiz_types_path\n end\n end", "def show\n if current_user.has_role? :admin\n else\n @quiz = Quiz.find(session[:quiz_id])\n @cardbox = Cardbox.find(session[:cardbox_id])\n @practice = @quiz_item.practice\n end\n end", "def index\n unless current_user.admin?\n respond_to do |format|\n format.html { redirect_to '/', alert: \"You don't have access to view that page\" }\n format.json { render :show, status: :ok, location: @user }\n end\n end\n @questions = Question.all\n end", "def index\n redirect_to admin_faqs_path\n end", "def show\n checkadmin\n end", "def set_admin_question\n @admin_question = Admin::Question.find(params[:id])\n end", "def index\n if session[:user_id] and User.find_by(id: session[:user_id]).name == \"admin\"\n @scores = Score.all\n elsif session[:user_id]\n # @users = User.all\n redirect_to quiz_url\n else\n redirect_to login_url\n end\n end", "def quiz\n end", "def index\n if current_user.admin?\n @q = Quiz.ransack(params[:q])\n @quizzes = @q.result.includes(:questions, :section).paginate(page: params[:page])\n else\n redirect_to root_path\n flash[:notice] = \"Whoops! You're not supposed to be there!\"\n end\n end", "def show\n\t\trequire_admin!\n\tend", "def set_admin_academy_question\n @admin_academy_question = Academy::Question.find(params[:id])\n end", "def show\n redirect_to quiz_attempts_path\n end", "def index\n session[:quiz_itme_id] = nil\n if current_user.has_role? :admin\n @quiz_items = QuizItem.all\n elsif session[:quiz_id]\n @quiz = Quiz.find(session[:quiz_id])\n @quiz_items = QuizItem.where(quiz_id: @quiz.id)\n else\n redirect_back fallback_location: root_path, notice: \"没有相应的测试。\"\n end\n end", "def show\n authorize @question\n end", "def index\n redirect_to root_path and return unless current_user.admin? #FIXME Make this it is visible to instructors\n @answers = Answer.where('assignment_id = ? and active =?', params[:assignment_id], true).order('user_id').order('created_at DESC').paginate(:page => params[:page])\n end", "def index\n @questions = Question.all\n authorize @questions\n end", "def index\n @quizzes = Quiz.all.where(lesson_id: current_lesson.id)\n end", "def show\n\t\tif next_quiz == 0\n \tredirect_to quizzes_path\n\t\t\tsession[:quiz_index] = 0\n\t\t\tuser_lesson = UserLesson.find_by(lesson_id: current_lesson.id)\n\t\t\tuser_lesson.status = \"completed\"\n\t\t\tuser_lesson.save\n\t\telse\n\t\t\t@quiz = Quiz.find(next_quiz)\n\t\t\tif @quiz == nil\n\t\t\t\tsession[:quiz_index] = 0 \n\t\t\telse\n\t\t\t\tif UserLessonQuiz.check_presence(@quiz.id).empty?\n\t\t\t\t\tUserLessonQuiz.create(user_id: current_user.id, lesson_id: current_lesson.id, quiz_id: @quiz.id)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n end", "def set_admin_faq\n @admin_faq = Admin::Faq.find(params[:id])\n end", "def edit_quiz\n\n @questionnaire = Questionnaire.find(params[:id])\n render :edit\n end", "def update\n if current_user.admin?\n respond_to do |format|\n if @quiz.update(quiz_params)\n format.html { redirect_to @quiz, notice: 'Quiz was successfully updated.' }\n format.json { render :show, status: :ok, location: @quiz }\n else\n format.html { render :edit }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to root_url, notice: \"Sorry, you need to sign in first.\"\n end\n end", "def index\n if params[:quiz_id]\n @quiz = Quizzes::Quiz.find(params[:quiz_id])\n @quizzes_questions = @quiz.questions\n else\n @quizzes_questions = Quizzes::Question.all\n end\n end", "def show\n isadmin\n end", "def admin\n end", "def admin\n end", "def admin\n end", "def admin\n end", "def admin\n #TODO\n end", "def show\n \t@quiz = Quiz.find(params[:id])\n end", "def show\n @questions = @quiz.questions\n @results = @quiz.results\n if current_viewer\n QuizViewLog.create(quiz_id: @quiz.id, viewer_id: current_viewer.id, status: \"viewed\")\n end\n unless @quiz.is_live? or (@quiz.is_preview? and user_signed_in?)\n render text: \"Nothing here\"\n end\n\n end", "def authorize_admin_manage_quests\n unless current_user.permission.manage_quests\n redirect_back fallback_location: root_path\n end\n end", "def admin\n\n end", "def index\n if user_signed_in? && current_user.admin?\n @quizzes = Quiz.all.order(due_date: :asc)\n elsif user_signed_in?\n @quizzes = current_user.enrolled_courses.first.quizzes.order(due_date: :asc)\n else\n redirect_to root_url, notice: \"Sorry, you need to sign in first.\"\n end\n end", "def show\n @quiz = Quiz.find(params[:id])\n end", "def index\n @quiz = Quiz.all\n end", "def index\n @qas = session[:admin] ? Qa.find(:all, :order => \"created_at DESC\") : Qa.find(:all, :conditions => \"answer != ''\",:order => \"created_at DESC\")\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @qas }\n end\n end", "def test_admin\n return if session[:admin]\n if %w[destroy edit update].index(action_name)\n redirect_to @materiel, notice: \"Vous n'êtes pas administrateur\"\n else\n redirect_to materiels_url, notice: \"Vous n'êtes pas administrateur\"\n end\n end", "def index\n @quiz_answers = QuizAnswer.all\n end", "def index\n authorize! :index, Question\n @admin_questions = Admin::Question.accessible_by(current_ability, :read)\n @admin_questions = @admin_questions.search(params[:search]) unless params[:search].blank?\n @admin_questions = @admin_questions.order(\"#{sort_column} #{sort_direction}\") unless sort_column.blank?\n @admin_questions = @admin_questions.paginate(page: params[:page], per_page: params[:per_page] || 100)\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @quizzes = Quiz.all\n end", "def show\n is_admin?\n end", "def show\n authorize @admin\n end", "def index\n# return redirect_to Quiz.published.first\n @quizzes = Quiz.all\n end", "def index\n authorize! :manage, :all\n @question_templates = QuestionTemplate.all\n end", "def index\n # redirect to show or to new quiz path randomly\n if (rand * 10).to_i > 9\n redirect_to new_topics_quizzes_path(@topic)\n else\n # puts 'WHAT'\n # puts @topic.quizzes.all.inspect\n # puts @topic.inspect\n redirect_to topic_quiz_path(id: @topic.quizzes.shuffle.first, topic_id: @topic)\n end\n end", "def show\n @quiz = Quiz.find(params[:id])\n @user = User.find(params[:user_id])\n end", "def index\n @quizzes_answers = Quizzes::Answer.all\n end", "def set_survey_quiz\n @survey_quiz = @survey_questionnaire = Survey::Quiz.find(params[:id])\n authorize @survey_quiz\n end", "def correct_admin\n @admin_admin = Admin::Admin.find(params[:id])\n redirect_to(admin_admins_path) unless current_user?(@admin_admin)\n end", "def show\n is_admin?\n end", "def edit\n\t\t@quiz = Quiz.find(params[:id])\n \tend", "def edit_quiz\n @questionnaire = Questionnaire.find(params[:id])\n if [email protected]_by_anyone?\n render :edit\n else\n flash[:error] = \"Your quiz has been taken by some other students, editing cannot be done any more.\"\n redirect_to controller: 'submitted_content', action: 'view', id: params[:pid]\n end\n end", "def show\n @questions = get_questions\n @answers\n @count = -1\n @total_questions\n @new_quiz = Quiz.new\n end", "def index\n @pub_quiz_answers = PubQuizAnswer.all\n end", "def index\n @quizzes = Quiz.all\n if current_user.has_role? :admin\n @quizzes = QuizItem.all\n elsif session[:cardbox_id]\n @cardbox = Cardbox.find(session[:cardbox_id])\n @quizzes = Quiz.where(cardbox_id: @cardbox.id, user_id: current_user.id).order(id: :desc)\n else\n redirect_to cardboxes_path, notice: \"没有相应的测试。请指定一个卡片盒。\"\n end\n end", "def show\n # authorize Admin\n end", "def show\n @question = Question.find(params[:id])\n @answers = Answer.all.where(question: @question).order(created_at: :desc)\n @answer = Answer.new\n authorize @question\n end", "def show\n @quiz = params[:quiz_id]\n @fake_answers = FakeAnswer.where(question_id: params[:id])\n end", "def quiz_owner_user\n unless quiz_owner?(params[:id])\n redirect_to quizzes_path\n flash[:error] = \"Step Off!! You don't own that quiz\"\n end\n end", "def instructor_show\n\t\t\tif (current_instructor.quizzes.exists?(:id => params[:id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:id])\n\t\t\t\tquestions = quiz.questions\n\t\t\t\trender json: questions, status: 200\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 404\n\t\t\tend\n\t\tend", "def checkAdmin\n if !admin_signed_in?\n # if current user is not an admin then can't access the page like add teacher,department,college and new subject\n redirect_to root_path, notice: \"Only Admin Can Access This Page\"\n end\n end", "def show\n authorize! :show, Quiz\n @quiz_perguntas = QuizPergunta.where(quiz_id: @quiz).order('created_at')\n @quiz.pontuacao\n end", "def show\n\t\t\tputs current_user.is_admin?\n\tend", "def check_authentication\n if @quiz.user != current_user\n redirect_to quizzes_path\n flash[:notice] = 'Can be modified only by the owner.' \n end\n end", "def correct_admin\n @admin = Admin.find(params[:id])\n redirect_to(root_url) unless current_admin?(@admin)\n end", "def show_topic_test\n \n @quiz = Quiz.scoped_for_user(current_user).find_by_slug(params[:quiz_slug])\n \n if (@quiz == nil || @quiz.quiz_type_id != QuizType.find_by_name(\"TopicQuiz\").id)\n redirect_to \"/404.html\"\n else\n render 'show_test_detail'\n end \n end", "def admin\n unless current_user.admin?\n #if logged user is not admin display error message and redirect to application INDEX (store_path)\n flash[:error] = \"Authorisation is required to access this content.\"\n redirect_to store_path\n end\n end", "def user_is_admin\n unless current_user.admin?\n flash[:notice] = \"You may only view existing scenarios.\"\n redirect_to root_path\n end\n end", "def index\n @admin_surveys = Admin::Survey.all\n end", "def admin_user\n unless @is_admin\n flash[:danger] = \"Must be admin to modify recipes\"\n redirect_to(recipes_url) \n end\n end", "def show\n @user = current_user\n @admin = @user.admin\n unless @admin\n redirect_to :root, :alert => t(\"notice.access\")\n end\n end", "def index\n @admin_faqs = Admin::Faq.order(:sort_id)\n end", "def show\n \n\n #find the option id\n a=params[:id]\n #find the option\n o=Option.find(a)\n #Find the question id\n z=o.Question.id\n #Find the Question\n question=Question.find(z)\n #Find the Quiz id of the Question\n x=question.Quiz.id\n #Find the actual quiz that the question belongs to\n quiz=Quiz.find(x)\n #This query can also be written in one line as\n #ans=Quiz.find(Question.find(Option.find(params[:id]).Question.id).Quiz.id) \n\n\n\n return redirect_to \"/quizzes/#{x}\"\n end", "def admin_user\n if current_user.admin? || current_user.subadmin?\n # pass\n else\n flash[:error] = \"曲情報を変更する権限がありません。\"\n redirect_to(root_path)\n end\n end", "def index\n @quiz_results = current_student.quiz_results\n @unfiltered_quizzes = current_student.classroom.teacher.quizzes\n @quizzes = Quiz.TakeableQuizzes(@unfiltered_quizzes, @quiz_results)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def view_quiz\n @questionnaire = Questionnaire.find(params[:id])\n @participant = Participant.find(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit\n render :view\n end", "def admin\n\t\tif !session[:admin]\n\t\t\tredirect_to root_url\n\t\tend\n\tend", "def show\n authorize! :read, @admin_operator\n end", "def show\n admin_only do\n end\n end", "def view_quiz\n @questionnaire = Questionnaire.find(params[:id])\n @participant = Participant.find_by_id(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit\n render :view\n end", "def correct_admin\n @admin = Admin.find(params[:id])\n redirect_to(root_url) unless current_admin?(@admin)\n end", "def index\n @add_quizid_to_quesitons = AddQuizidToQuesiton.all\n end", "def show\n @quiz_result = QuizResult.find(params[:id])\n\n respond_to do |format|\n if @role == 'student'\n if !current_student.quiz_results.include? @quiz_result\n flash[:notice] = \"You are not authorized to view that quiz result.\"\n format.html { redirect_to quiz_results_path }\n else\n format.html # show.html.erb\n end \n elsif @role == 'admin'\n if !current_admin.school.students.include? @quiz_result.student\n flash[:notice] = \"You are not authorized to view that quiz result.\"\n format.html { redirect_to show_students_path }\n else\n format.html # show.html.erb\n end\n elsif @role == 'teacher'\n if !current_teacher.classroom.students.include? @quiz_result.student\n flash[:notice] = \"You are not authorized to view that quiz result.\"\n format.html { redirect_to show_students_path }\n else\n format.html # show.html.erb\n end\n elsif @role == 'parent'\n if !current_parent.students.include? @quiz_result.student\n flash[:notice] = \"You are not authorized to view that quiz result.\"\n format.html { redirect_to show_students_path }\n else\n format.html # show.html.erb\n end\n end\n end\n\n end", "def index\n @examquestions = Examquestion.all\n end", "def destroy\n @quiz = Quiz.find(params[:id])\n @quiz.destroy\n redirect_to admin_panel_quizzes_path\n end", "def show\n if current_user.has_role?(:admin)\n else\n redirect_to root_path, alert: \"No tienes permiso para esta accion\"\n end\n end", "def admin\n\t\tcan :manage, :all\n\tend", "def admin\n @courses = Course.all\n @student = Student.all\n @taken = Taken.all\n @willing_to_ta = WillingToTa.all\n @willing_to_grade = WillingToGrade.all\n @willing_to_ta_languages = WillingToTaLanguage.all\n @past_ta = PastTa.all\n @language_proficiency = LanguageProficiency.all\n end", "def show_quant_test\n \n @quiz = Quiz.scoped_for_user(current_user).section.quant.find_by_slug(params[:quiz_slug])\n \n if (@quiz == nil)\n redirect_to \"/404.html\"\n else\n render 'show_test_detail'\n end\n end", "def show\n set_administrator\n end" ]
[ "0.72880316", "0.72719544", "0.7267393", "0.7036107", "0.6971414", "0.6913896", "0.68071365", "0.67505145", "0.6728845", "0.6694874", "0.66897047", "0.6667931", "0.6610755", "0.65898114", "0.65684885", "0.655935", "0.65232867", "0.65132487", "0.6492512", "0.6461967", "0.6445655", "0.64359266", "0.6430348", "0.6408256", "0.6402701", "0.639452", "0.6387657", "0.6365305", "0.6361921", "0.6348775", "0.6348775", "0.6348775", "0.6348775", "0.6344164", "0.6333987", "0.6319738", "0.63183016", "0.6303735", "0.62762654", "0.62709767", "0.62704927", "0.62647283", "0.62606055", "0.62486994", "0.62336606", "0.6224815", "0.6224815", "0.6224815", "0.6224815", "0.6224815", "0.6188571", "0.61768544", "0.6172417", "0.616006", "0.6154416", "0.61496603", "0.61409855", "0.61389416", "0.61342186", "0.6133286", "0.6132811", "0.6118674", "0.6112579", "0.609511", "0.6087879", "0.6077889", "0.6060285", "0.605532", "0.60430765", "0.6036686", "0.60309345", "0.6026755", "0.6025523", "0.6021818", "0.602052", "0.6011236", "0.60053474", "0.6003821", "0.5999687", "0.599799", "0.5979069", "0.5978807", "0.59742033", "0.59674406", "0.5964704", "0.5963835", "0.59637696", "0.59505117", "0.59467834", "0.5943613", "0.5933544", "0.5918175", "0.5918029", "0.59152603", "0.5915003", "0.58993953", "0.5899153", "0.5895839", "0.5893335", "0.5892482" ]
0.6178523
51
Creates a new JSONSpectacular::Matcher object.
def initialize(expected) @expected = expected @message = '' @reported_differences = {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eql_json(expected)\n JSONSpectacular::Matcher.new(expected)\n end", "def new_matcher(node)\n # FIXME: Catch exceptions\n matcher = ResponseMatcher.new(node, @domain)\n @matchers[node] = matcher\n end", "def initialize\n @matchers = []\n @matches = {}\n end", "def initialize(matcher)\n @matcher = matcher\n end", "def create_a_match(jm) #jm stands for json match\n\t\tapi_fetch = APIFetcher.new\n\t\ttemp_match = Match.new(riot_game_id: api_fetch.is_nil_ret_int(jm.dig(\"gameId\")), \\\n\t\t\t\t\t created_at: jm[\"gameCreation\"], \\\n\t\t\t\t\t updated_at: Time.now, \\\n\t\t\t\t\t season_id: api_fetch.is_nil_ret_int(jm.dig(\"seasonId\")), \\\n\t\t\t\t\t queue_id: api_fetch.is_nil_ret_int(jm.dig(\"queueId\")), \\\n\t\t\t\t\t game_version: api_fetch.is_nil_ret_char(jm.dig(\"gameVersion\")), \\\n\t\t\t\t\t platform_id: api_fetch.is_nil_ret_char(jm.dig(\"platformId\")), \\\n\t\t\t\t\t game_mode: api_fetch.is_nil_ret_char(jm.dig(\"gameMode\")), \\\n\t\t\t\t\t map_id: api_fetch.is_nil_ret_int(jm.dig(\"mapId\")), \\\n\t\t\t\t\t game_type: api_fetch.is_nil_ret_char(jm.dig(\"gameType\")), \\\n\t\t\t\t\t game_duration: api_fetch.is_nil_ret_int(jm.dig(\"gameDuration\")), \\\n\t\t\t\t\t game_creation: api_fetch.is_nil_ret_int(jm.dig(\"gameCreation\")), \\\n\t\t\t\t\t analyzed: false)\n\t\t\t\t\t temp_match.save\n\t\treturn temp_match\n\tend", "def new \n\t\t@match = Match.new\n\tend", "def parse_matcher(matcher)\n matcher\n end", "def matcher(key, value)\n if value.is_a?(Hash)\n name = \"Humanoid::Matchers::#{value.keys.first.gsub(\"$\", \"\").camelize}\"\n return name.constantize.new(attributes[key])\n end\n Default.new(attributes[key])\n end", "def matching(source)\r\n Matching.new(parser(source))\r\n end", "def matchers\n @matchers ||= {}\n end", "def matcher_name; end", "def matcher_name; end", "def matcher; end", "def matcher; end", "def initialize(match_ast)\n @match_ast = match_ast\n end", "def create_pattern_match(branches:)\n Qo::PatternMatchers::PatternMatch.create(branches: branches)\n end", "def underlying_matcher; end", "def underlying_matcher; end", "def create\n\t\t@match = Match.new(match_params)\n\tend", "def initialize(match, name, attributes)\n @match, @name, @attributes = match, name, attributes\n end", "def matcher(code = nil, &block)\n CodeTree::Matcher.new(parse(code, &block))\n end", "def initialize(name, matchers = {}, options = {})\n @name, @matchers, @options = name, matchers, options\n end", "def initialize(hash, tag_matcher_uuid)\n super()\n\n @noun = \"tag/#{tag_matcher_uuid}/matcher\"\n from_hash(hash) unless hash == nil\n if @compare != \"equal\" && @compare != \"like\"\n @compare = nil\n end\n\n if @inverse != \"true\" && @inverse != \"false\"\n @inverse = nil\n end\n end", "def instance_by_json(json_obj = {})\n obj = self.new \n obj.set_attributes_by_json( json_obj )\n return obj\n end", "def create_matcher(type, name, &block)\n matcher = StepMatcher.new(name, &block)\n @hash_of_lists_of_matchers[type] << matcher\n matcher\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match }\n end\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match }\n end\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match }\n end\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match }\n end\n end", "def add_matcher(matcher)\n @matchers << matcher\n self\n end", "def match(str=nil)\n return DelayedMatchConstructor.new unless str\n \n return Atoms::Re.new(str)\n end", "def build_matcher(options, whitelist_option, blacklist_option); end", "def matcher(value, path)\n StringValueMatcher.new(value, JsonEvent::StringRetriever.new(path))\n end", "def Controller(matcher)\n make(matcher)\n end", "def klass_matcher(&block)\n return @klass_matcher if defined?(@klass_matcher)\n\n unless block_given?\n val, mask = status_value_and_mask\n block = proc { |d| (d[0] & mask) == val }\n end\n\n @klass_matcher = Matcher.new(self, &block)\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @match }\n end\n end", "def matching(regexp)\n regexp = Helpers.regexp_to_string regexp if regexp.is_a? Regexp\n @type = :matches\n @value = regexp\n @request_builder\n end", "def matchers\n self.class.matchers\n end", "def matchers\n @matchers ||= []\n end", "def new\n\t\t@matching = Matching.new\n\t\tputs \"**********************************\"\n\t\tputs request.host_with_port\n\tend", "def initialize(config)\n @config = config\n @matchers = []\n end", "def type_matcher(mod)\n TypeMatcher.new(mod)\n end", "def match(golden_master)\n QueryResultMatcher.new(Slacker.filter_golden_master(golden_master))\n end", "def initialize\n super(NO_MATCH)\n end", "def clone()\n Match.new(@team_a.clone, @team_b.clone, @judges.map {|j| j.clone})\n end", "def initialize(input, match)\n @input = input\n @match = match\n end", "def team_matcher\n @teams_matcher ||= FuzzyStringMatcher.new( all_teams, :name )\n end", "def matching_json_path(json_path)\n @type = :matchesJsonPath\n @value = json_path\n @request_builder\n end", "def create_match(userid,user2id)\n match = Match.new(userid,user2id)\n @matches[match.m_id] = match\n end", "def same\n LoopbackMatcher.instance\n end", "def new(*args)\n B.rr.new_object(@jsvalue, *args)\n end", "def matchers\n cached_matchers\n end", "def from_json(json)\n new JSON.parse(json)\n end", "def create\n @match = Match.new(params[:match])\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, :notice => 'Match was successfully created.' }\n format.json { render :json => @match, :status => :created, :location => @match }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @match.errors, :status => :unprocessable_entity }\n end\n end\n end", "def from_hash(hash)\n super(hash)\n new_tag_matchers_array = []\n @tag_matchers.each do\n |tag_matcher|\n if tag_matcher.class != ProjectHanlon::Tagging::TagMatcher\n new_tag_matchers_array << ProjectHanlon::Tagging::TagMatcher.new(tag_matcher, @uuid)\n else\n new_tag_matchers_array << tag_matcher\n end\n end\n end", "def new\n @match_stat = MatchStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match_stat }\n end\n end", "def initialize key, opts={}, **kwargs\n ({ id: nil, name: nil, property_matchers: [], function_matchers: [], combinator: nil }).merge(opts).merge(kwargs) => { id:, name:, property_matchers:, function_matchers:, combinator: }\n @combinator = combinator\n @key = key.blank? ? '*' : key.downcase\n @property_matchers = property_matchers\n @function_matchers = function_matchers\n\n @property_matchers << Paradoxical::Search::PropertyMatcher.new( 'id', operator: '=', value: id ) unless id.nil?\n @property_matchers << Paradoxical::Search::PropertyMatcher.new( 'name', operator: '=', value: name ) unless name.nil?\n end", "def create\n # Read the Matches from the JSON Object\n data = params[:matches]\n matches = data.to_a\n\n MatchCreatorJob.perform_later(matches: matches)\n\n render json: {}, status: :ok\n\n end", "def match\n self.class.match.with_instance(self)\n end", "def match(&block)\n begin\n @env_used = true\n map = @suite_map ? @env.suite_map_path(@map) : @map\n @match = Bcpm::Tests::TestMatch.new @side, @vs, map, @env, @options\n self.class_eval(&block)\n @matches << @match\n ensure\n @match = nil\n end\n end", "def from_hash(hash)\n super(hash)\n new_tag_matchers_array = []\n @tag_matchers.each do\n |tag_matcher|\n if tag_matcher.class != ProjectRazor::Tagging::TagMatcher\n new_tag_matchers_array << ProjectRazor::Tagging::TagMatcher.new(tag_matcher, @uuid)\n else\n new_tag_matchers_array << tag_matcher\n end\n end\n end", "def initialize(json, locator = nil)\n @source_json = json\n if @source_json.is_a? String\n @source_hash = JSON.parse(json).with_indifferent_access\n else\n @source_hash = @source_json\n end\n @locator = locator\n end", "def initialize(json, locator = nil)\n @source_json = json\n if @source_json.is_a? String\n @source_hash = JSON.parse(json).with_indifferent_access\n else\n @source_hash = @source_json\n end\n @locator = locator\n end", "def construct_new_resource(response)\n data = JSON.parse(response.body, symbolize_names: true)\n new(data)\n end", "def create\n @match = Match.new(match_params)\n @match.user_id = @current_user.id\n if @match.save\n options = {include: [:user]}\n render json: serializer.new(@match, options), include: ['user']\n else\n render json: @match.errors, status: :unprocessable_entity\n end\n end", "def initialize(matcher = nil, &intercept_block)\n define_method_missing(matcher, &intercept_block) unless matcher.nil?\n end", "def initialize(grader, h, config={})\n raise(ArgumentError, \"no regex\") unless @regex = h[\"match\"]\n\n @config = config\n @desc = h[\"desc\"] || h[\"match\"]\n @regex = /#{@regex}/\n end", "def initialize(grader, h, config={})\n raise(ArgumentError, \"no regex\") unless @regex = h[\"match\"]\n\n @config = config\n @desc = h[\"desc\"] || h[\"match\"]\n @regex = /#{@regex}/\n end", "def match(matcher, handler)\n routes << Route.new(matcher, handler)\n end", "def from_json json\n template = new\n if json[:seats]\n template.seats = json[:seats].map { |s| s[:position] }\n end\n\n if json[:starting_seats]\n template.starting_seats = json[:starting_seats]\n end\n\n if json[:matches]\n template.matches = json[:matches]\n end\n\n template\n end", "def compare_matchers(key, new_matcher, matcher)\n cmp = compare_matcher_properties(new_matcher[:block], matcher[:block])\n return cmp if cmp != 0\n\n cmp = compare_matcher_properties(new_matcher[:platform_version], matcher[:platform_version])\n return cmp if cmp != 0\n\n cmp = compare_matcher_properties(new_matcher[:platform], matcher[:platform])\n return cmp if cmp != 0\n\n cmp = compare_matcher_properties(new_matcher[:platform_family], matcher[:platform_family])\n return cmp if cmp != 0\n\n cmp = compare_matcher_properties(new_matcher[:os], matcher[:os])\n return cmp if cmp != 0\n\n cmp = compare_matcher_properties(new_matcher[:override], matcher[:override])\n return cmp if cmp != 0\n\n # If all things are identical, return 0\n 0\n end", "def init(match)\n self.match = match\n match = match[0] if match.kind_of?(Array) && match.length == 1\n case match\n when String then init_string match\n when Regexp then init_regex match\n when Symbol then init_rule match\n when PatternElementHash then init_hash match\n when Array then init_array match\n else raise \"invalid pattern type: #{match.inspect}\"\n end\n end", "def new(*args, &block)\n object = mapper.new_object(*args, &block)\n track(object)\n object\n end", "def match(attributes = nil)\r\n body = { query: { match: attributes } }\r\n result = client.search index: index, type: type, body: body\r\n\r\n result_instance(result)\r\n end", "def create_matcher(type, name, &block)\n matcher = Step.new(name, &block)\n @hash_of_lists_of_steps[type] << matcher\n matcher\n end", "def create\n @clan_match = ClanMatch.new(clan_match_params)\n\n if @clan_match.save\n render json: @clan_match, status: :created, location: @clan_match\n else\n render json: @clan_match.errors, status: :unprocessable_entity\n end\n end", "def initialize\n @match_count = 0\n @history = []\n end", "def matcher_name=(_arg0); end", "def creatematch(deck)\n if current_user\n puts \"NOT MATCHES HUZZAHHHHHHHHHHHHHHHHHHHHHHHHHHh\"\n playerarray = {}\n\n playerarray[0] = {}\n playerarray[0][\"id\"] = current_user.id\n playerarray[0][\"player\"] = current_user.email\n playerarray[0][\"score\"] = 5050\n playerarray[0][\"hand\"] = []\n druck = \"[#{getDeckFromNames(deck)}]\"\n Match.new({\n active:true,\n players: playerarray.to_json,\n max_players: 2,\n turn: 0,\n decks: druck\n }).save\n end\n end", "def initialize(json)\n @json = json\n end", "def match(object); end", "def initialize(match)\n match.each do |key, value|\n next if value.nil? # this is an illegal response, match id 1 is bogus\n\n if %w[created_at updated_at].include?(key)\n instance_variable_set(\"@#{key}\".to_sym, Time.parse(value))\n else\n instance_variable_set(\"@#{key}\".to_sym, value)\n end\n end\n end", "def create\n @match = Match.new(params[:match])\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, notice: 'Match was successfully created.' }\n format.json { render json: @match, status: :created, location: @match }\n else\n format.html { render action: \"new\" }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @match = Match.new(params[:match])\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, notice: 'Match was successfully created.' }\n format.json { render json: @match, status: :created, location: @match }\n else\n format.html { render action: \"new\" }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @match = Match.new(params[:match])\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, notice: 'Match was successfully created.' }\n format.json { render json: @match, status: :created, location: @match }\n else\n format.html { render action: \"new\" }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def construct(json={})\n refresh_from(json)\n end", "def construct(json={})\n refresh_from(json)\n end", "def is(arg=nil,&block)\n Ruk::Matcher.build(arg,&block)\n end", "def create\n @match_set = MatchSet.new(match_set_params)\n\n respond_to do |format|\n if @match_set.save\n format.html { redirect_to @match_set, notice: 'Match set was successfully created.' }\n format.json { render :show, status: :created, location: @match_set }\n else\n format.html { render :new }\n format.json { render json: @match_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def match_selector(...)\n Matchers::MatchSelector.new(...)\n end", "def initialize(requested_media_type, response, agent)\n @agent = agent\n @response = response\n @requested_media_type = requested_media_type\n @representor = deserialize(requested_media_type, response.body)\n handle_extensions\n end", "def create!(type, matcher, algorithm)\n generator = new(type, matcher, algorithm)\n instances.unshift(generator)\n generator\n end", "def get_matcher\n @matcher_string = self.class.to_s.split('::').last.gsub(/([A-Z][a-z]+)/,'\\1_').chomp('_').upcase\n @log_line_matcher = RailsLogStat.const_get( @matcher_string )\n end", "def create\n @match = Match.new(match_params)\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to matches_url, notice: 'Match créé avec succès' }\n format.json { render :index, status: :created, location: @match }\n else\n format.html { render :new }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def match\n @match\n end", "def initialize(options={})\n raise TypeError, 'options must be a Hash or respond to #to_h or #to_hash' unless options.is_a?(Hash) || options.respond_to?(:to_h) || options.respond_to?(:to_hash)\n options = options.to_h rescue options.to_hash\n \n @options = {\n matched_routes: [],\n ignored_routes: [],\n robots_json: SnapSearch.root.join('resources', 'robots.json'),\n extensions_json: SnapSearch.root.join('resources', 'extensions.json'),\n check_file_extensions: false\n }.merge(options) # Reverse merge: The hash `merge` is called on is used as the default and the options argument is merged into it\n \n @matched_routes, @ignored_routes, @check_file_extensions = options.values_at(:matched_routes, :ignored_routes, :check_file_extensions)\n \n self.robots_json = @options[:robots_json] # Use the setter method which sets the @robots_json instance variable to the path, then sets @robots to the parsed JSON of the path's contents.\n self.extensions_json = @options[:extensions_json] # Use the setter method which sets the @extensions_json instance variable to the path, then sets @extensions to the parsed JSON of the path's contents.\n end", "def create\n @match = Match.new(match_params)\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, notice: 'Match was successfully created.' }\n format.json { render :show, status: :created, location: @match }\n else\n format.html { render :new }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @match = Match.new(match_params)\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, notice: 'Match was successfully created.' }\n format.json { render :show, status: :created, location: @match }\n else\n format.html { render :new }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @match = Match.new(match_params)\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, notice: 'Match was successfully created.' }\n format.json { render :show, status: :created, location: @match }\n else\n format.html { render :new }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @match = Match.new(match_params)\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, notice: 'Match was successfully created.' }\n format.json { render :show, status: :created, location: @match }\n else\n format.html { render :new }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @match = Match.new(match_params)\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, notice: 'Match was successfully created.' }\n format.json { render :show, status: :created, location: @match }\n else\n format.html { render :new }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.689661", "0.68811506", "0.6474461", "0.64732826", "0.5916947", "0.5896641", "0.5668591", "0.560833", "0.55786866", "0.55646175", "0.5492894", "0.5492894", "0.54348624", "0.54348624", "0.53743714", "0.53486145", "0.53438413", "0.53438413", "0.5303306", "0.5276354", "0.5269915", "0.5269048", "0.52455604", "0.5206443", "0.5159157", "0.5139443", "0.5139443", "0.5139443", "0.5139443", "0.51321113", "0.5116333", "0.5109911", "0.5108888", "0.5101342", "0.5100646", "0.50834227", "0.50819933", "0.5075909", "0.50594765", "0.5014573", "0.5010887", "0.50077623", "0.50036556", "0.49815094", "0.49786922", "0.49496403", "0.49392495", "0.49383187", "0.4937143", "0.49276212", "0.4916628", "0.49160218", "0.48962364", "0.48937732", "0.48881742", "0.4887236", "0.48826653", "0.48784462", "0.48682657", "0.48681772", "0.48621622", "0.4855497", "0.4855497", "0.48346525", "0.48222187", "0.4820877", "0.48177633", "0.48177633", "0.48104742", "0.48070496", "0.48002648", "0.47971606", "0.47854355", "0.47698173", "0.47599825", "0.47591668", "0.47465473", "0.47461054", "0.4743526", "0.47338644", "0.47269312", "0.472642", "0.47143263", "0.47143263", "0.47143263", "0.47131065", "0.47131065", "0.46862835", "0.46818835", "0.4671832", "0.46653134", "0.46612915", "0.46506855", "0.46409124", "0.46374995", "0.4636893", "0.46321264", "0.46321264", "0.46321264", "0.46321264", "0.46321264" ]
0.0
-1
Declares that RSpec should not attempt to diff the actual and expected values to put in the failure message. This class takes care of diffing and presenting the differences, itself.
def diffable? false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def failure_message\n @message += \"Expected: #{@expected}\\n\\n\"\n @message += \"Actual: #{@actual}\\n\\n\"\n @message += \"Differences\\n\\n\"\n\n add_diff_to_message(@actual, @expected)\n\n @message\n end", "def failure_message_when_negated\n \"expected #{@actual.inspect} not to be true or false\"\n end", "def failure_message_when_negated\n actual = prettify_args(@actual)\n\n if @description\n \"'#{actual}' should not #{@description}\"\n else\n \"'#{actual}' should not satisfy the requirements\"\n end\n end", "def failure_message\n \"expected #{@actual.inspect} to be true or false\"\n end", "def failure_message_when_negated\n # Failure cases:\n # * object is not a model (\"to respond to valid\")\n # * expected one or more errors, received one or more (\"not to have\n # errors\")\n # * expected one or more messages on attribute, received one or more\n # (\"not to have errors on\")\n # * expected specific messages on attribute, received all (\"not to have\n # errors on\")\n\n if !@validates\n \"expected #{@actual.inspect} to respond to :valid?\"\n elsif expected_errors.empty?\n return \"expected #{@actual.inspect} not to have errors#{received_errors_message}\"\n else\n return \"expected #{@actual.inspect} not to have errors#{expected_errors_message}#{received_errors_message}\"\n end # if-else\n end", "def failure_message_when_negated\n actual = prettify_args(@actual)\n matcher = prettify_matcher(@metadata[:name])\n\n if @metadata[:args].count > 0\n args = prettify_args(*@metadata[:args])\n\n \"'#{actual}' should not #{matcher} '#{args}'\"\n else\n \"'#{actual}' should not #{matcher}\"\n end\n end", "def negative_failure_message\n \"expected #{@target.name} not to provide #{@expected}, but it does\"\n end", "def failure_message\n actual = prettify_args(@actual)\n\n if @description\n \"'#{actual}' should #{@description}\"\n else\n \"'#{actual}' should satisfy the requirements\"\n end\n end", "def failure_message_when_negated; end", "def failure_message_when_negated; end", "def failure_message_when_negated; end", "def failure_message\n \"expected #{@target.name} to provide #{@expected}, but it doesn't\"\n end", "def error_message\n unless passed?\n \"#{expression.inspect} didn't change by #{expected_difference} (expecting #{expected_value}, but got #{after_value})\"\n end\n end", "def assert_not_equals(actual, expected, msg = nil, options = nil)\n if actual == expected\n msg = msg ? msg + ' - ' : ''\n message = \"#{msg}Not expected: #{actual.inspect}\"\n Test.expect(false, message)\n end\n end", "def negative_failure_message\n \"expected document to not #{description}; got: #{@rendered}\"\n end", "def negative_failure_message\n \"expected document to not #{description}; got: #{@rendered}\"\n end", "def failure_message\n actual = prettify_args(@actual)\n matcher = prettify_matcher(@metadata[:name])\n\n if @metadata[:args].count > 0\n args = prettify_args(*@metadata[:args])\n\n \"'#{actual}' should #{matcher} '#{args}'\"\n else\n \"'#{actual}' should #{matcher}\"\n end\n end", "def assertNotEqualWithMessageTest expected, value, message\n assertNotEqual expected, value, message\n end", "def describe_mismatch(name, expected, actual, tense = :ignored)\n tense_deprecated unless tense == :ignored\n errors = describe(expected, actual, [SubjectPathElement.new(name)])\n case errors.size\n when 0\n ''\n when 1\n errors[0].format.strip\n else\n errors.map { |error| error.format }.join(\"\\n \")\n end\n end", "def failure_message_for_should\n message = \"expected #{@collection_key} to match the user's mental model, but:\\n\"\n unless expected_items_found?\n message += \"expected to be present: #{pp_array(expected_items)}\\n\"\n message += \"the missing elements were: #{pp_array(expected_items_that_were_not_found)}\\n\"\n end\n if unexpected_items_found?\n message += \"expected to not be present: #{pp_array(unexpected_items)}\\n\"\n message += \"the unexpected extra elements: #{pp_array(unexpected_items_that_were_found)}\\n\"\n end\n message\n end", "def negative_failure_message\n matchers.map(&:negative_failure_message).join(\" and \")\n end", "def failure_message_when_negated\n build_failure_message(negated: true)\n end", "def assertNotEqualWithMessageFailTest expected, value, message\n rescue_assertion ASSERT_NOT_EQUAL_ERROR, message do\n assertNotEqual expected, value, message\n end\n end", "def negative_failure_message\n \"expected following text to not match selector #{@expected}:\\n#{@document}\"\n end", "def negative_failure_message\n \"expected following text to not match selector #{@expected}:\\n#{@document}\"\n end", "def negative_failure_message\n \"expected following text to not match selector #{@expected}:\\n#{@document}\"\n end", "def failure_message\n matching_files = @fixture.files & @local.files\n fixture_only_files = @fixture.files - @local.files\n local_only_files = @local.files - @fixture.files\n buf = \"expected fixture #{@fixture.path} to match files:\\n\"\n (@fixture.files | @local.files).sort.each do |file|\n if matching_files.include?(file)\n local_file = @local.absolute(file)\n fixture_file = @fixture.absolute(file)\n if File.directory?(local_file) && File.directory?(fixture_file)\n # Do nothing\n elsif File.directory?(fixture_file)\n buf << \" #{file} should be a directory\\n\"\n elsif File.directory?(local_file)\n buf << \" #{file} should not be a directory\"\n else\n actual = IO.read(local_file)\n expected = IO.read(fixture_file)\n if actual != expected\n # Show a diff\n buf << \" #{file} does not match fixture:\"\n buf << differ.diff(actual, expected).split(/\\n/).map {|line| ' '+line }.join(\"\\n\")\n end\n end\n elsif fixture_only_files.include?(file)\n buf << \" #{file} is not found\\n\"\n elsif local_only_files.include?(file)\n buf << \" #{file} should not exist\\n\"\n end\n end\n buf\n end", "def failure_message_for_should_not\n \"expected #{@collection_key} not to match the user's mental model\"\n end", "def failure_message\n build_failure_message(negated: false)\n end", "def failure_message_for_should_with_errors_on_extensions\n case @collection_name\n when :errors_on\n \"expected #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}, got #{@actual}\"\n when :error_on\n \"expected #{relativities[@relativity]}#{@expected} error on :#{@args[0]}, got #{@actual}\"\n else\n failure_message_for_should_without_errors_on_extensions\n end\n end", "def assert_no_difference(expressions, message = nil, &block)\n message ||= \"Expected #{expressions} not to change but it did\"\n assert_difference(expressions, 0, message, &block)\n end", "def expected_differences\n @expected_differences ||= {\n User => [:display_name]\n }\n end", "def failure_message\n \"expected document to #{description}; got: #{@rendered}\"\n end", "def failure_message\n \"expected document to #{description}; got: #{@rendered}\"\n end", "def assertNotEqualTest expected, value\n assertNotEqual expected, value\n end", "def assert_not_same(expected, actual, message=\"\")\n msg = message(msg) { build_message(message, <<EOT, expected, expected.__id__, actual, actual.__id__) }\n<?>\nwith id <?> expected to not be equal\\\\? to\n<?>\nwith id <?>.\nEOT\n assert(!actual.equal?(expected), msg)\n end", "def negative_failure_message\n \"validation succeeded, expected one or more validation errors\"\n end", "def initialize(expected)\n @expected = expected\n @message = ''\n @reported_differences = {}\n end", "def assertNotEqualFailTest expected, value\n rescue_assertion ASSERT_NOT_EQUAL_ERROR do\n assertNotEqual expected, value\n end\n end", "def assert_no_difference(expressions, message = nil, &block)\n assert_difference expressions, 0, message, &block\n end", "def failure_message\n message = \"expected #{@actual.inspect} to alias :#{old_method_name}\"\n\n message << \" as #{new_method_name.inspect}\" if new_method_name\n\n if @errors[:does_not_respond_to_old_method]\n message << \", but did not respond to :#{old_method_name}\"\n\n return message\n end # if\n\n if @errors[:does_not_respond_to_new_method]\n message << \", but did not respond to :#{new_method_name}\"\n\n return message\n end # if\n\n if @errors[:does_not_alias_method]\n message <<\n \", but :#{old_method_name} and :#{new_method_name} are different \"\\\n \"methods\"\n\n return message\n end # if\n\n message\n end", "def negative_failure_message\n end", "def failure_message_when_negated\n failure_message.sub \"to\", \"not to\"\n end", "def assert_no_difference(expressions, message = nil, &block)\n assert_difference expressions, 0, message, &block\n end", "def match_failure_messages(_actual, _identifier = \"value\")\n raise NotImplementedError, :match_failure_messages\n end", "def assert_not_equal(exp, act, msg=nil)\n EqualityFailure.refute(act, exp, :message=>msg, :backtrace=>caller)\n end", "def failure_message\n \"validation failed with #{@errors.inspect}, expected no validation errors\"\n end", "def assert actual, expected, message\n display message\n puts actual == expected || display_error(actual, expected)\nend", "def suppress_diff_output\n return if @config[:runtime_config][:diff]\n\n @run_data[:profiles]&.each do |p|\n p[:controls]&.each do |c|\n c[:results]&.each do |r|\n next unless r[:message] # :message only set on failure\n\n pos = r[:message].index(\"\\n\\nDiff:\")\n next unless pos # Only textual tests get Diffs\n\n r[:message] = r[:message].slice(0, pos)\n end\n end\n end\n end", "def assertEqualWithMessageFailTest expected, value, message\n rescue_assertion ASSERT_EQUAL_ERROR, message do\n assertEqual expected, value, message\n end\n end", "def refute_cmp(expect, actual)\n actual = rspec_expect actual\n expect = cmp expect\n\n assert_raises RSpec::Expectations::ExpectationNotMetError do\n actual.to expect\n end\n end", "def test_generate_message_exclusion_with_default_message\n assert_equal \"is reserved\", @person.errors.generate_message(:title, :exclusion, value: \"title\")\n end", "def customise_error_values(values)\n values[:expected] = Ward::Errors.format_exclusive_list(@expected)\n values\n end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def negative_failure_message\n \"expected#{inspect_target} not to redirect\"\n end", "def assertFalseFailWithMessageTest value, message\n rescue_assertion /#{ASSERT_FALSE_ERROR}/, message do\n assertFalse value, message\n end\n end", "def failure_message\n if @found\n \"\\nexpected: #{@expect}\\n got: #{@actual}\\n\"\n else\n \"\\nCould not find a snapshot at #{snap_path}.\\n Failing \" \\\n \"instead of creating; save_snapshots is set to #{save_config}.\"\n end\n end", "def test_ut_diff_warning_02\n assert_equal 2,@diff_warning.diff_status_id\n assert_equal 1,@diff_warning.diff_file_id\n assert_equal 1,@diff_warning.rule_set\n assert_equal 1,@diff_warning.warning_id\n assert_equal 1,@diff_warning.original_file_id\n end", "def failure_message(description, options={})\n message = String.new(\"expected to find #{description}\")\n if options[:count]\n message << \" #{options[:count]} #{declension('time', 'times', options[:count])}\"\n elsif options[:between]\n message << \" between #{options[:between].first} and #{options[:between].last} times\"\n elsif options[:maximum]\n message << \" at most #{options[:maximum]} #{declension('time', 'times', options[:maximum])}\"\n elsif options[:minimum]\n message << \" at least #{options[:minimum]} #{declension('time', 'times', options[:minimum])}\"\n end\n message\n end", "def assert_rejects(matcher, target, options = {})\n if matcher.respond_to?(:in_context)\n matcher.in_context(self)\n end\n\n not_match = matcher.respond_to?(:does_not_match?) ? matcher.does_not_match?(target) : !matcher.matches?(target)\n\n if not_match\n assert true\n\n if options[:message]\n assert_match options[:message], matcher.failure_message\n end\n else\n assert false, matcher.failure_message\n end\n end", "def failure_message\n @message\n end", "def assertEqualFailTest expected, value\n rescue_assertion ASSERT_EQUAL_ERROR do\n assertEqual expected, value\n end\n end", "def assert_not_same(exp, act, msg=nil)\n test = ! exp.equal?(act)\n msg = \"Expected #{act.inspect} to not be the same as #{exp.inspect}\" unless msg\n __assert__(test, msg)\n end", "def util_raises msg = nil\n e = assert_raises MockExpectationError do\n yield\n end\n assert_equal mu_pp_for_diff(msg), mu_pp_for_diff(e.message) if msg\n end", "def assert_equals(actual, expected, msg = nil, options = nil)\n if actual != expected\n msg = msg ? msg + ' - ' : ''\n message = \"#{msg}Expected: #{expected.inspect}, instead got: #{actual.inspect}\"\n Test.expect(false, message)\n end\n end", "def negative_failure_message\n return '' if found.nil?\n return [\n \"expected no tubes matching #{expected.to_s},\",\n \"found #{strategy.pretty_print_tube(found)}\",\n ].join(' ')\n end", "def failure_reason\n return nil unless (tf = terminal_failures) && tf.size > 0\n\t\"Expected \" +\n\t (tf.size == 1 ?\n\t tf[0].expected_string :\n \"one of #{tf.map{|f| f.expected_string}.uniq*', '}\"\n\t ) +\n \" at line #{failure_line}, column #{failure_column} (byte #{failure_index+1})\" +\n \" after #{input[index...failure_index]}\"\n end", "def assertNotSameWithMessageFailTest object, message\n rescue_assertion ASSERT_NOT_SAME_ERROR, message do\n assertNotSame object, object, message\n end\n end", "def assertNotFailWithMessageTest value, message\n rescue_assertion /#{ASSERT_NOT_ERROR}/, message do\n assertNot value, message\n end\n end", "def correct!\n if @failures.any?\n unless @failures.all? {|matcher| @scenarios[:failed].any? {|s| matcher.match? s}}\n missing_failures = @failures.reject {|matcher| @scenarios[:failed].any? {|s| matcher.match? s}}\n missing_failures = missing_failures.collect{|f| \" - #{f.to_s}\"}.join(\"\\n\")\n mods = self.desc || \"(None)\"\n mods = \" - #{mods}\"\n raise IncorrectAnswer, \"The following scenarios passed incorrectly (should have failed):\\n#{missing_failures}\\nwith the following modifications:\\n#{mods}\"\n end\n else\n unless @scenarios[:failed].empty? or @scenarios[:steps][:total] != @scenarios[:steps][:passed]\n raise IncorrectAnswer, \"Feature should have passed, but had the following failures:\\n#{@scenarios[:failed].collect {|f| \" #{f}\"}}\"\n end\n end\n true\n end", "def to_failure msg:, warnings: [], depreciations: [], **values\n self.class.new \\\n failed: true,\n msg: msg,\n warnings: (self.warnings + warnings),\n depreciations: (self.depreciations + depreciations)\n end", "def failure_message\n if @options[:count]\n \"expected following text to match selector #{@expected} #{@options[:count]} times, but found it #{@occurences} times:\\n#{@document} \"\n else\n \"expected following text to match selector #{@expected}:\\n#{@document}\"\n end\n end", "def assertFalseWithMessageTest value, message\n assertFalse value, message\n end", "def report expected, actual\n if expected == actual\n puts \"Yes, found '#{actual}'\"\n else\n puts \"Failed, found '#{actual}' but was expecting '#{expected}'\"\n end\nend", "def does_not_match? actual\n super\n\n @negative_expectation = true\n\n return false unless @validates = actual.respond_to?(:valid?)\n\n !matches?(actual)\n end", "def assertFalseFailTest value\n rescue_assertion /#{ASSERT_FALSE_ERROR}/ do\n assertFalse value\n end\n end", "def failure_details(io)\n super\n unless test_case.input.empty?\n format_block(io, \"Input\", test_case.input)\n end\n format_block(io, \"Evaluated commands\", test_case.evaluated_commands)\n comparisons.each do |expectation|\n expectation.format_details(io)\n end\n unless test_case.scope.debug.empty?\n format_block(io, \"Contents of *debug*\", test_case.scope.debug)\n end\n format_block(io, \"How to run this test\", test_case.shell_command_details)\n end", "def assertNotSameWithMessageTest expected, object, message\n assertNotSame expected, object, message\n end", "def when_negated_expectation(actual)\n expect(result(&actual)).not_to public_send(*expectation_args)\n end", "def failure_message\n +\"expected to find #{description}\" << count_message\n end", "def should_not_allow_values_for(attribute, *bad_values)\n message = get_options!(bad_values, :message)\n bad_values.each do |value|\n matcher = allow_value(value).for(attribute).with_message(message)\n should \"not #{matcher.description}\" do\n assert_rejects matcher, subject\n end\n end\n end", "def assert_rejects(matcher, target)\n success = !matcher.matches?(target)\n assert_block(matcher.negative_failure_message) { success }\n end", "def assert(actual, expected)\n\traise \"actual: #{actual}, expected: #{expected}\" unless expected == actual\nend", "def failure_message\n return '' unless found.nil?\n return \"expected tube matching #{expected.to_s}, found none.\"\n end", "def present_non_assertion_error_summary\n return if non_assertion_errors.empty?\n Terminal.format_title(@io, 2, \"Errors other than assertion failures\")\n non_assertion_errors.each do |error|\n error.non_assertion_error_details(@io)\n end\n end", "def assert_no_difference(expression, &block)\n assert_difference expression, 0, &block\n end", "def fail(message = nil)\r\n @status = FAIL\r\n @assert = false\r\n end", "def assert_false( actual, msg = nil )\n msg = message(msg) { \"should be false (instance of FalseClass), not <#{mu_pp(actual)}>\" }\n assert actual == false, msg\n end", "def test_generate_message_invalid_with_default_message\n assert_equal \"is invalid\", @person.errors.generate_message(:title, :invalid, value: \"title\")\n end", "def failure_message\n @failures.map(&:failure_message).join(\" and \")\n end", "def assert_not_equal(exp, act, msg=nil)\n msg = message(msg) { \"<#{mu_pp(exp)}> expected to be != to\\n<#{mu_pp(act)}>\" }\n assert(exp != act, msg)\n end", "def assertNotFailTest value\n rescue_assertion /#{ASSERT_NOT_ERROR}/ do\n assertNot value\n end\n end", "def assertNotMatchWithMessageFailTest pattern, value, message\n rescue_assertion ASSERT_NOT_MATCH_ERROR, message do\n assertNotMatch pattern, value, message\n end\n end", "def failure_message\n messages = [subject.inspect]\n attributes.each do |attribute|\n messages << subject.errors.full_messages_for(attribute)\n end\n messages.compact.join(\"\\n\")\n end", "def assert_not_include(actual, expected, options = nil)\n if actual.include?(expected)\n msg = msg ? msg + ' - ' : ''\n message = \"#{msg}Expected: #{actual.inspect} to not include #{expected.inspect}\"\n Test.expect(false, message)\n end\n end" ]
[ "0.7619436", "0.7617784", "0.7464784", "0.7421844", "0.7359554", "0.7260809", "0.72444683", "0.72002774", "0.7098776", "0.7098776", "0.7098776", "0.7026485", "0.7026196", "0.6992354", "0.69616383", "0.69616383", "0.6949639", "0.6921867", "0.6887702", "0.6865488", "0.68566406", "0.6770527", "0.6757996", "0.6757126", "0.6757126", "0.67414784", "0.6716982", "0.6712497", "0.66614896", "0.66514903", "0.66383636", "0.6598878", "0.65768623", "0.65768623", "0.6550433", "0.65365833", "0.6519362", "0.64984107", "0.649185", "0.64683414", "0.64278865", "0.64186734", "0.63544184", "0.6336976", "0.62719554", "0.6246312", "0.62428254", "0.6228654", "0.6203644", "0.62022614", "0.6181363", "0.61779815", "0.6173828", "0.617347", "0.617347", "0.617347", "0.617347", "0.617347", "0.617347", "0.617347", "0.61600465", "0.6146958", "0.61419296", "0.6138841", "0.61347765", "0.6080951", "0.6068328", "0.60651565", "0.6050883", "0.60480535", "0.6045588", "0.6013886", "0.6005025", "0.5998342", "0.5990723", "0.59840024", "0.5982007", "0.59758145", "0.596975", "0.59648144", "0.59549683", "0.5954707", "0.5952991", "0.59506565", "0.59496486", "0.5926966", "0.59236866", "0.5899445", "0.5867831", "0.5861262", "0.58577883", "0.5853485", "0.58426374", "0.58408546", "0.5839891", "0.5836911", "0.5828078", "0.5821688", "0.57992256", "0.57860464", "0.57753426" ]
0.0
-1
Whether the actual value and the expected value are considered equal.
def matches?(actual) @actual = actual @expected.eql?(@actual) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matches?(actual)\n expected_value == actual\n end", "def matches?\n @actual == @expected\n end", "def eql(expected)\n set_relativity(:eql, expected)\n end", "def verifyEqual(exp_val,act_val)\n assert_equal(exp_val, act_val,\"Wrong value Expected #{exp_val} Actual #{act_val}\")\n end", "def matches?(actual)\n @expected.include?(actual)\n end", "def actual?\n @actual\n end", "def == expected\n self.out == expected\n end", "def are_equal(value1, value2)\n EqualityAssertion.new(value1, value2)\n end", "def assert_same_values(expected, actual)\n actual.each_pair do |k,v|\n next unless expected[k]\n assert_equal expected[k], v, \"Values for #{k} are not matching\"\n end\n end", "def test_equality(expected, actual)\n \tif expected == actual\n \t\tputs \"pass :):):)\"\n \telse\n \t\tputs \"fail :(:(:(\"\n\tend\nend", "def assert_equals(actual, expected, msg = nil, options = nil)\n if actual != expected\n msg = msg ? msg + ' - ' : ''\n message = \"#{msg}Expected: #{expected.inspect}, instead got: #{actual.inspect}\"\n Test.expect(false, message)\n end\n end", "def eql?(other)\n\t if other.respond_to?(:units)\n\t\t(@units == other.units) and (@value == other.value)\n\t elsif other == 0\n\t\t@value == other\n\t else\n\t\t(@units == nil) and (@value == other)\n\t end\n\tend", "def ==(other)\n @value == other.value\n end", "def equal?(a, b)\n if a == b\n puts 'PASS'\n else\n puts 'FAILS'\n end\n end", "def check\n if @value1 == @value2\n @message = \"#{@value1} == #{@value2}\"\n true\n else\n @message = \"#{@value1} != #{@value2}\"\n false\n end\n end", "def must_almost_equals(expected, actual)\n case expected\n when nil\n true\n when Array\n unless actual.instance_of?(Array)\n raise ComparisonError, \"Inconsistent type: expected type of #{expected}: Array, actual type of #{actual}: #{actual.class}\"\n end\n unless expected.size == actual.size\n raise ComparisonError, \"Different size of arrays: expected size of #{expected}: #{expected.size}, actual size of #{actual}: #{actual.size}\"\n end\n\n expected.to_enum.with_index.each do |e, i|\n begin\n must_almost_equals(e, actual[i])\n rescue ComparisonError => e\n raise ComparisonError, \"Different value of #{i}-th element of array\"\n end\n end\n when Hash\n # Note: It is OK when `actual` has additional entries.\n unless actual.instance_of?(Hash)\n raise ComparisonError, \"Incensistent type: expected type of #{expected}: Hash, actual type of #{actual}: #{actual.class}\"\n end\n\n expected.each do |k, v|\n begin\n unless actual.include?(k)\n raise ComparisonError, \"Missing key `#{k}` in actual: #{actual}\"\n end\n must_almost_equals(v, actual[k])\n rescue ComparisonError => e\n if not e.cause.nil? and e.cause.message.match(/^Missing key `#{k}`/)\n raise e\n end\n raise ComparisonError, \"Different value for `#{k}`\"\n end\n end\n else\n unless expected == actual\n raise ComparisonError, \"Comparison failed: #{expected} == #{actual}\"\n end\n end\nend", "def assert_equal(actual, expected)\n\tif (actual == expected)\n\t\tputs \"pass\"\n\telse\n\t\tputs \"fail\"\n\tend\nend", "def matches? actual\n super\n\n true === actual || false === actual\n end", "def equal?(other); end", "def equals_to?\n values = {}\n @maximum_values.each { |k, v| values[k] = v }\n @minimum_values.each { |k, v| values[k] = v }\n\n values.each do |key, value|\n return false, :count => value unless good?(value, default_message_for(key))\n end\n true\n end", "def eql?(other)\n self.class == other.class && value == other.value\n end", "def eql?(other)\n self.class == other.class && value == other.value\n end", "def assert_equal(expected, actual)\n if expected.is_a?(Nokogiri::XML::Node) && actual.is_a?(Nokogiri::XML::Node)\n assert(EquivalentXml.equivalent?(expected, actual,\n element_order: false, normalize_whitespace: true),\n \"XML nodes were not equal\")\n elsif expected.is_a?(String) && actual.is_a?(String)\n ex_bin = expected.dup.force_encoding('BINARY')\n act_bin = actual.dup.force_encoding('BINARY')\n\n assert(ex_bin == act_bin,\n \"strings were not equal\")\n else\n assert(expected == actual, \"expected `#{expected}`, got `#{actual}`\")\n end\n end", "def assert_equal(expected, actual)\n\tif expected == actual\n\t\tputs \":)\"\n\telse\n\t\tputs \"This should have been #{expected} not #{actual}\"\n\tend\nend", "def eql?(other)\n self.class.equal?(other.class) && value == other.value\n end", "def eql?(other)\n self.class.equal?(other.class) && value == other.value\n end", "def equal?(p0) end", "def ==(other)\n lcm_div = @div.lcm(other.div)\n (@val * (lcm_div / @div)) == (other.val * (lcm_div / other.div))\n end", "def assertEquals(results, expected, msg)\n puts \"#{calling_method}: #{msg}\\n\"\n if(results != expected)\n puts \"Expected #{expected} not #{results}\\n\"\n return false\n end\n \n return true\n end", "def ==(val)\n return true if @val == val\n end", "def assert_equal(expected, actual, message=nil)\n assert expected == actual, message || \"#{expected.inspect} expected but was #{actual.inspect}\"\n end", "def ==(other)\n other.is_a?(self.class) &&\n other.attribute == attribute &&\n other.validation == validation &&\n other.expected == expected &&\n other.actual == actual\n end", "def ==(other)\n a, b = self.to_f, other.to_f\n a == b\n end", "def eql?(other)\n\t if other.zero?\n\t\[email protected]?\n\t elsif other.respond_to?(:units)\n\t\tif other.respond_to? :value\n\t\t @units.eql?(other.units) and @value.eql?(other.value)\n\t\telse\n\t\t other == self\n\t\tend\n\t else\n\t\[email protected]? and @value.eql?(other)\n\t end\n\tend", "def approx_same_values_as?(other)\n delta = s_copy.sub(other).to_a.inject(0.0) do |result, element|\n result + element**2.0\n end\n delta < EPSILON\n end", "def is_equal?(a)\n @amount == a.amount && @code == a.code\n end", "def assert_equal(actual, expected, message='', node=nil)\n assert actual == expected, \"expected #{expected}, got #{actual} #{message}\", node\n end", "def matches?(actual)\n @matching_values.include?(actual)\n end", "def assert_equal(expected, actual)\n if expected.is_a?(String) && actual.is_a?(String)\n ex_bin = expected.dup.force_encoding('BINARY')\n act_bin = actual.dup.force_encoding('BINARY')\n\n assert(ex_bin == act_bin,\n \"expected string `#{ex_bin}`, got `#{act_bin}`\")\n else\n assert(expected == actual, \"expected `#{expected}`, got `#{actual}`\")\n end\n end", "def expected?\n false\n end", "def assert_equals_with_expect(left, right)\n assert left == right, expect_got(right, left)\n end", "def ==(other)\n self.class == other.class && value == other.value\n end", "def matches?(actual)\n @actual = actual\n expected_items_found? && !unexpected_items_found?\n end", "def test_not_same_value_as\n #G\n white_pair = PAIR_OF_4\n black_value = VALUE_2\n\n #W\n result = white_pair.same_value? black_value\n\n #T\n assert_false result\n end", "def matches?(other)\n operable_values == other.operable_values\n end", "def version_equals?(v1, v2)\n return false unless v1 && v2\n\n v1 == v2\n end", "def ==(other)\n @value == other.value and @annotation == other.annotation\n end", "def assert_nil_or_equal(expected, actual, msg = nil)\n if expected.nil?\n assert_nil(actual, msg)\n else\n assert_equal(expected, actual, msg)\n end\n end", "def assert_equal(actual, expected)\n if actual == expected\n puts \"pass\"\n else\n puts \"fail\"\n end\nend", "def test_Complex_InstanceMethods_eql?\n\t\tassert_equal(true, Complex(1,0).eql?(Complex(1,0)))\n\t\tassert_equal(false, Complex(1,0).eql?(Complex(1.0,0)))\n\t\tassert_equal(false, Complex(1,0).eql?(1))\n\t\tassert_equal(true, Complex(1,0) == Complex(1,0))\n\t\tassert_equal(true, Complex(1,0) == Complex(1.0, 0))\n\t\tassert_equal(true, Complex(1,0) == 1)\n\tend", "def is_equivalent_to?(other)\n return false if other.nil?\n return false unless self.factor == other.factor\n return false unless self.scaling == other.scaling\n return false unless self.dimensions == other.dimensions\n true\n end", "def passed?\n if expected_value.is_a?(Range)\n expected_value.include?(after_value)\n else\n expected_value == after_value\n end\n end", "def pass?\n expected_array.size == actual_array.size &&\n [expected_array, actual_array].transpose.all? do |expected_element, actual_value|\n expected_element.match_against_actual_value(actual_value)\n end\n end", "def == other\n (self.start_value == other.start_value) &&\n (self.value_changes == other.value_changes)\n end", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got.inspect}\"\nend", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got.inspect}\"\nend", "def eql?(other)\n return false unless other.captures_hash == captures_hash\n return false unless other.squares_hash == squares_hash\n return false unless other.turn == turn\n return false unless other.state == state\n\n true\n end", "def assertSimilar( expected, actual, errmsg=nil )\n\t\tif expected != ODE::Infinity && expected != -ODE::Infinity && expected.kind_of?( Float )\n\t\t\tassert_in_delta expected, actual, Tolerance, errmsg\n\t\telsif expected.is_a?( Class )\n\t\t\tassert_instance_of expected, actual\n\t\telse\n\t\t\tassert_equal expected, actual, errmsg\n\t\tend\n\tend", "def eql?(other)\n\t\tother = other.value if other.is_a? self.class\n\t\treturn value.eql?(other)\n\tend", "def == other\n return (@value == other.value) &&\n (@transition == other.transition)\n end", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def eqv?(obj1, obj2)\n obj1 == obj2\n end", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected}\" :\n \"Assertion failed\\nExpected: #{expected}\\nGot: #{got}\"\nend", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got}\"\nend", "def eql?(other)\n (@x == other.x) && (@y == other.y)\n end", "def assert_equal_even_if_nil(expect, actual)\n if expect.nil?\n assert_nil(actual)\n else\n assert_equal(expect, actual)\n end\n end", "def assertSimilar( expected, actual, errmsg=nil )\n\t\tif expected != ODE::Infinity && expected.kind_of?( Float )\n\t\t\tassert_in_delta expected, actual, Tolerance, errmsg\n\t\telsif expected.is_a?( Array )\n\t\t\tassert_kind_of Array, actual\n\t\t\tassert_equal expected.length, actual.length\n\n\t\t\t# Recurse for each value\n\t\t\texpected.each_index {|i| assertSimilar(expected[i], actual[i], errmsg)}\n\t\telsif expected.is_a?( ODE::Vector )\n\t\t\tassert actual.similarTo?( expected ),\n\t\t\t\t\"#{actual.inspect} was not similar to #{expected.inspect}\"\n\t\telse\n\t\t\tassert_equal expected, actual, errmsg\n\t\tend\n\tend", "def eql?(other)\n return false\n end", "def ==(other)\n eql?(other)\n end", "def xml_should_eql(actual, expected)\n same = xml_cmp(actual, expected)\n actual.should.== expected unless same \nend", "def safe_equals? a, b\n check = a.bytesize ^ b.bytesize\n a.bytes.zip(b.bytes) { |x, y| check |= x ^ y.to_i }\n check.zero?\n end", "def eql?(other); self == other; end", "def check\n prefix = File.basename(@expected)\n if File.exist?(@expected)\n no_change = FileUtils.identical?(@expected, @actual)\n if no_change\n # Files are exact match.\n @message = \"#{prefix} : Actual and expected files are an exact match.\"\n return true\n end\n @message = \"#{prefix} : Actual file did not match expected file!\"\n else\n @message = \"#{prefix} : Expected file not found.\"\n end\n # Comparison failed.\n false\n end", "def ==(other)\n (other.base == self.base) && other.factor == self.factor\n end", "def ==(other)\n eql?(other)\n end", "def eql?(other)\n return self == other\n end", "def is_equal?\n @is_equal ||= if prepared_expected.is_a? Pathname\n FileUtils.compare_file(prepared_expected, prepared_produced)\n else\n prepared_expected == prepared_produced\n end\n end", "def ===(value)\n # MRI uses <=> to compare, so must we.\n\n beg_compare = (@begin <=> value)\n return false unless beg_compare\n\n if Comparable.compare_int(beg_compare) <= 0\n end_compare = (value <=> @end)\n if @excl\n return true if Comparable.compare_int(end_compare) < 0\n else\n return true if Comparable.compare_int(end_compare) <= 0\n end\n end\n\n return false\n end", "def eql?(other)\n if ! other.is_a?(self.class)\n false\n else\n [@mean, @variance] == [other.mean, other.variance]\n end\n end", "def eql?(other)\n instance_of?(other.class) &&\n operand.eql?(other.operand)\n end", "def equal?(other)\n return false unless type == other.type\n return false unless power == other.power\n return false unless prefix == other.prefix\n return true\n end", "def ==(other)\n self.<=>(other).zero?\n end", "def eql? other\n self == other\n end", "def assert_not_same(expected, actual, message=\"\")\n msg = message(msg) { build_message(message, <<EOT, expected, expected.__id__, actual, actual.__id__) }\n<?>\nwith id <?> expected to not be equal\\\\? to\n<?>\nwith id <?>.\nEOT\n assert(!actual.equal?(expected), msg)\n end", "def values_sndiff_equal?(bav, pav)\n bav == pav || string_numeric_diff_ignored? && bav.is_a?(String) && pav.is_a?(Numeric) && to_number_or_nil(bav) == pav\n end", "def assert_equals(expected, actual, failure_message)\n if expected == actual\n \"Ok!\"\n else\n \"Expected '\" + expected.to_s + \"', but found '\" + actual.to_s + \"': \" + failure_message\n end\nend", "def ==(b)\n case b\n when Int\n @value == b.value\n when Numeric\n @value == b\n else\n false\n end\n end", "def ==(other)\n self.class == other.class && value == other.value\n end", "def json_should_eql(actual, expected)\n same = json_cmp(actual, expected)\n actual.should.== expected unless same \nend", "def falsy_or_equal? first, second\n (!first && !second) || first == second\n end", "def =~(other)\n case other\n when VectorType then equalish_vec4(other)\n when Numeric then equalish_scalar(other)\n else false\n end\n end", "def assert_value(actual,expected,message)\n puts message\n puts actual == expected\nend", "def ==(other)\n\t\ttemp = other.convert_to(self.currency)\n\t\treturn self.amount.round(2) == temp.amount.round(2)\n\tend", "def assertEqualTest expected, value\n assertEqual expected, value\n end", "def eql?(other)\n self == other\n end", "def eql?(p0) end" ]
[ "0.8196923", "0.79405427", "0.7089745", "0.7003615", "0.7002349", "0.6946374", "0.6906515", "0.6860677", "0.6847903", "0.68109816", "0.6779479", "0.6727026", "0.67059284", "0.6663392", "0.6657142", "0.66064507", "0.65785754", "0.6511842", "0.65073717", "0.6494001", "0.64684606", "0.64684606", "0.6454519", "0.6431287", "0.64264655", "0.64264655", "0.6425588", "0.6424896", "0.64218986", "0.6415793", "0.6397108", "0.6389706", "0.6368209", "0.6363112", "0.63542527", "0.6347842", "0.63335156", "0.63295215", "0.6299187", "0.6295127", "0.6293317", "0.62927073", "0.6288162", "0.62808776", "0.6266443", "0.626034", "0.62575585", "0.62553567", "0.6253772", "0.62511736", "0.6245657", "0.62381554", "0.62293136", "0.6226972", "0.6225418", "0.6225418", "0.6219569", "0.62146574", "0.6214478", "0.6213472", "0.62037086", "0.62037086", "0.62037086", "0.62037086", "0.62037086", "0.6201093", "0.6195671", "0.6192375", "0.6188503", "0.6186591", "0.6186102", "0.6182858", "0.61783814", "0.61782116", "0.6177336", "0.61669177", "0.61619675", "0.6142548", "0.61417866", "0.6137845", "0.61169255", "0.61137116", "0.6109648", "0.61071855", "0.60995805", "0.60908055", "0.6086655", "0.608049", "0.6080334", "0.6077267", "0.6055932", "0.6055746", "0.6054478", "0.60501826", "0.60448027", "0.604203", "0.6040931", "0.6035336", "0.60326016", "0.60305965" ]
0.7592921
2
Message to display to StdOut by RSpec if the equality check fails. Includes a complete serialisation of expected and actual values and is then followed by a description of only the (possibly deeply nested) attributes that are different
def failure_message @message += "Expected: #{@expected}\n\n" @message += "Actual: #{@actual}\n\n" @message += "Differences\n\n" add_diff_to_message(@actual, @expected) @message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_equals(actual, expected, msg = nil, options = nil)\n if actual != expected\n msg = msg ? msg + ' - ' : ''\n message = \"#{msg}Expected: #{expected.inspect}, instead got: #{actual.inspect}\"\n Test.expect(false, message)\n end\n end", "def assert_not_same(expected, actual, message=\"\")\n msg = message(msg) { build_message(message, <<EOT, expected, expected.__id__, actual, actual.__id__) }\n<?>\nwith id <?> expected to not be equal\\\\? to\n<?>\nwith id <?>.\nEOT\n assert(!actual.equal?(expected), msg)\n end", "def test_equality(expected, actual)\n \tif expected == actual\n \t\tputs \"pass :):):)\"\n \telse\n \t\tputs \"fail :(:(:(\"\n\tend\nend", "def assert_equal_attributes(object, expected_attributes)\n expected_attributes.each do |index, value|\n assert_equal value, object[index], \"#{index}\"\n end\n end", "def report expected, actual\n if expected == actual\n puts \"Yes, found '#{actual}'\"\n else\n puts \"Failed, found '#{actual}' but was expecting '#{expected}'\"\n end\nend", "def assert_not_equals(actual, expected, msg = nil, options = nil)\n if actual == expected\n msg = msg ? msg + ' - ' : ''\n message = \"#{msg}Not expected: #{actual.inspect}\"\n Test.expect(false, message)\n end\n end", "def assert_equal(expected, actual, message=nil)\n assert expected == actual, message || \"#{expected.inspect} expected but was #{actual.inspect}\"\n end", "def assert_equal(expected, actual)\n\tif expected == actual\n\t\tputs \":)\"\n\telse\n\t\tputs \"This should have been #{expected} not #{actual}\"\n\tend\nend", "def assert_same_elements(expected, actual, message = '')\n if expected.nil? && actual.nil?\n return\n end\n if !expected.nil? && actual.nil?\n flunk \"#{message}\\n Expected #{expected} but was nil\"\n elseif expected.nil? && !actual.nil?\n flunk \"#{message}\\n Expected nil but was #{actual}\"\n end\n _expected = expected\n if !_expected.is_a?(Set)\n _expected = Set.new(_expected)\n end\n _actual = actual\n if !_actual.is_a?(Set)\n _actual = Set.new(_actual)\n end\n difference = _expected.difference(_actual)\n if !difference.empty?\n if expected.empty?\n expected_message = \"[]\"\n else\n expected_message = expected.to_a.join(', ')\n end\n if actual.empty?\n actual_message = \"[]\"\n else\n actual_message = actual.to_a.join(', ')\n end\n flunk \"#{message}\\n Expected \\n#{expected_message} but was \\n#{actual_message}.\\ Difference: #{difference.to_a.join(', ')}\"\n end\n end", "def dump_attributes_and_build_failure_message(all_generated_attributes_json)\n generated_attributes_file = Rails.root.join('tmp/generated_attributes_file.json')\n\n File.write(generated_attributes_file, all_generated_attributes_json)\n\n \"Generated attributes do not match expected attributes.\\n\" \\\n \"Compare #{generated_attributes_file} and \" \\\n \"#{expected_time_slot_attributes_file} for further checks\"\n end", "def assert_equal(actual, expected, message='', node=nil)\n assert actual == expected, \"expected #{expected}, got #{actual} #{message}\", node\n end", "def describe_mismatch(name, expected, actual, tense = :ignored)\n tense_deprecated unless tense == :ignored\n errors = describe(expected, actual, [SubjectPathElement.new(name)])\n case errors.size\n when 0\n ''\n when 1\n errors[0].format.strip\n else\n errors.map { |error| error.format }.join(\"\\n \")\n end\n end", "def assert_equal_marshal(expected, actual, message=nil)\n\t\tfull_message = build_message(message, <<EOT, expected, actual)\n<?> expected but was\n<?>.\nEOT\n\t\tassert_block(full_message) { \n\t\t\tMarshal.dump(expected) == Marshal.dump(actual) \n\t\t}\n\tend", "def assert_equals(expected, actual, failure_message)\n if expected == actual\n \"Ok!\"\n else\n \"Expected '\" + expected.to_s + \"', but found '\" + actual.to_s + \"': \" + failure_message\n end\nend", "def assert_output_equal!(a, b, msg=nil)\n if a == b\n assert true\n else\n flunk %Q{\n#{msg}\n==================== expected output ====================\n#{whitespace_escape(a)}\n======================== but was ========================\n#{whitespace_escape(b)}\n=========================================================\n}\n end\n end", "def failure_message\n \"expected #{@actual.inspect} to be true or false\"\n end", "def error_message\n unless passed?\n \"#{expression.inspect} didn't change by #{expected_difference} (expecting #{expected_value}, but got #{after_value})\"\n end\n end", "def assertNotSameWithMessageTest expected, object, message\n assertNotSame expected, object, message\n end", "def assert_equal_enumerables(expected, actual, message)\n diff = expected - actual\n unless diff.empty?\n fail(\"#{message}. Expected to find #{diff.join(', ')} in #{actual.join(', ')}\")\n end\n \n diff = actual - expected\n unless diff.empty?\n fail(\"#{message}. Did not expect #{diff.join(', ')} in #{actual.join(', ')}\")\n end\n \n expected.each_with_index do |expected_member, index|\n actual_member = actual[index]\n assert_equal(expected_member, actual_member, \"Expected #{expected_member} at index #{index}, but was #{actual_member}\")\n end\n end", "def assert_same_values(expected, actual)\n actual.each_pair do |k,v|\n next unless expected[k]\n assert_equal expected[k], v, \"Values for #{k} are not matching\"\n end\n end", "def assertNotEqualWithMessageTest expected, value, message\n assertNotEqual expected, value, message\n end", "def equal_list(expected)\n message = \"#{Helpers.inspect_records(@object)} has the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id)\n right = expected.map(&:id)\n \n test_case.assert(left != right, message)\n end", "def assert_equality_of_methods( expected, actual, *methods )\n failed = false\n \n results_msg = {}\n results_msg[:expected] = \"The following methods were not equal: \\nExpected: #{mu_pp(expected)}\"\n results_msg[:actual] = \"\\n--------------------\\nActual: #{mu_pp(actual)}\"\n \n \n for method in methods\n no_error_on_method = true\n responses = {}\n \n for obj, response_sym in [[expected, :expected], [actual, :actual]]\n responses[response_sym] = begin\n obj.send( method )\n rescue StandardError => e\n e\n end\n \n if responses[response_sym].is_a?( StandardError )\n failed = true\n no_error_on_method = false\n results_msg[response_sym] << \"\\n\\t#{method}(): ERROR: #{responses[response_sym].class} #{responses[response_sym].message}\"\n end\n end\n \n if responses[:expected] != responses[:actual] && no_error_on_method\n failed = true\n \n for response_sym in [:expected, :actual]\n results_msg[response_sym] << \"\\n\\t#{method}(): #{responses[response_sym].inspect}\"\n end\n end\n end\n \n \n assert !failed, results_msg[:expected] + results_msg[:actual]\n end", "def equal_list(expected)\n message = \"#{Helpers.inspect_records(@object)} does not have the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id)\n right = expected.map(&:id)\n \n test_case.assert(left == right, message)\n end", "def differ\n RSpec::Expectations.differ\n end", "def _param_diff(params, spec_params)\n params = params.dup\n # Compile a list of mismatched params values\n diff = spec_params.map { |k,v|\n param_value = params.delete(k)\n unless v == param_value\n \"#{k.inspect} should equal #{v.inspect} but got \"\\\n \"#{param_value.inspect}\"\n end\n }.compact.join(', ')\n\n unless params.empty?\n # Add any param keys which aren't specified in the spec\n diff << ', and ' unless diff.empty?\n unexpected_str = params.keys.map(&:to_s).map(&:inspect).join(', ')\n diff << \"received unexpected key(s): #{unexpected_str}\"\n end\n\n diff\n end", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got.inspect}\"\nend", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got.inspect}\"\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(att, value, error = [att, :not_equal])\n assert value === send(att), error\n end", "def expected_differences\n @expected_differences ||= {\n User => [:display_name]\n }\n end", "def equal_set(expected)\n message = \"#{Helpers.inspect_records(@object)} has the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id).sort\n right = expected.map(&:id).sort\n \n test_case.assert(left != right, message)\n end", "def equal_set(expected)\n message = \"#{Helpers.inspect_records(@object)} does not have the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id).sort\n right = expected.map(&:id).sort\n \n test_case.assert(left == right, message)\n end", "def assertNotSameTest expected, object\n assertNotSame expected, object\n end", "def failure_message_when_negated\n # Failure cases:\n # * object is not a model (\"to respond to valid\")\n # * expected one or more errors, received one or more (\"not to have\n # errors\")\n # * expected one or more messages on attribute, received one or more\n # (\"not to have errors on\")\n # * expected specific messages on attribute, received all (\"not to have\n # errors on\")\n\n if !@validates\n \"expected #{@actual.inspect} to respond to :valid?\"\n elsif expected_errors.empty?\n return \"expected #{@actual.inspect} not to have errors#{received_errors_message}\"\n else\n return \"expected #{@actual.inspect} not to have errors#{expected_errors_message}#{received_errors_message}\"\n end # if-else\n end", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got}\"\nend", "def xml_should_be_same(expected, actual)\n expected = Hpricot(expected)\n actual = Hpricot(actual)\n \n blame = \"\\n\\n#################### expected\\n#{expected.to_html}\\n\\n\" \"#################### actual:\\n#{actual.to_html}\\n\\n\" \n (xml_cmp(expected, actual)).should.blaming(blame).equal true\nend", "def test_ut_diff_warning_02\n assert_equal 2,@diff_warning.diff_status_id\n assert_equal 1,@diff_warning.diff_file_id\n assert_equal 1,@diff_warning.rule_set\n assert_equal 1,@diff_warning.warning_id\n assert_equal 1,@diff_warning.original_file_id\n end", "def assert actual, expected, message\n display message\n puts actual == expected || display_error(actual, expected)\nend", "def assert_equal( expected, obtained, msg = nil )\n unless expected == obtained\n fail \"*** assert_equal( #{expected.inspect}, #{obtained.inspect}, #{msg} )\"\n end\nend", "def test_equality_simple\n value1_ = ::Versionomy.create(:major => 2, :minor => 0, :release_type => :alpha, :alpha_version => 5)\n value2_ = ::Versionomy.create(:major => 2, :release_type => :alpha, :alpha_version => 5)\n assert_equal(value2_, value1_)\n assert_equal(value2_.hash, value1_.hash)\n end", "def assert_equal_dates(expected, actual, message = nil, format = \"%Y-%m-%d\")\n if expected != nil && (expected.is_a?(Date) || expected.is_a?(DateTime) || expected.is_a?(Time))\n expected = expected.strftime(format)\n end\n formatted_actual = actual\n if !actual.nil? and (actual.is_a?(Date) || actual.is_a?(DateTime) || actual.is_a?(Time))\n formatted_actual = actual.strftime(format)\n end\n flunk(\"#{message} \\nExpected #{expected} \\nbut was #{formatted_actual}\") unless expected == formatted_actual\n end", "def assert_equal_dates(expected, actual, message = nil, format = \"%Y-%m-%d\")\n if expected != nil && (expected.is_a?(Date) || expected.is_a?(DateTime) || expected.is_a?(Time))\n expected = expected.strftime(format)\n end\n formatted_actual = actual\n if !actual.nil? and (actual.is_a?(Date) || actual.is_a?(DateTime) || actual.is_a?(Time))\n formatted_actual = actual.strftime(format)\n end\n flunk(\"#{message} \\nExpected #{expected} \\nbut was #{formatted_actual}\") unless expected == formatted_actual\n end", "def assert_equivalent_xml(expected, actual)\n expected_xml = Nokogiri::XML(\"<test-xml>\\n#{expected}\\n</test-xml>\")\n actual_xml = Nokogiri::XML(\"<test-xml>\\n#{actual}\\n</test-xml>\")\n ignored_attributes = %w(style data-disable-with)\n\n equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml, {\n ignore_attr_values: ignored_attributes\n }) do |a, b, result|\n if result === false && b.is_a?(Nokogiri::XML::Element)\n if b.attr('name') == 'utf8'\n # Handle wrapped utf8 hidden field for Rails 4.2+\n result = EquivalentXml.equivalent?(a.child, b)\n end\n if b.delete('data-disable-with')\n # Remove data-disable-with for Rails 5+\n # Workaround because ignoring in EquivalentXml doesn't work\n result = EquivalentXml.equivalent?(a, b)\n end\n if a.attr('type') == 'datetime' && b.attr('type') == 'datetime-local'\n a.delete('type')\n b.delete('type')\n # Handle new datetime type for Rails 5+\n result = EquivalentXml.equivalent?(a, b)\n end\n end\n result\n end\n\n assert equivalent, lambda {\n # using a lambda because diffing is expensive\n Diffy::Diff.new(\n sort_attributes(expected_xml.root),\n sort_attributes(actual_xml.root)\n ).to_s(:color)\n }\n end", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected}\" :\n \"Assertion failed\\nExpected: #{expected}\\nGot: #{got}\"\nend", "def assert_equal(exp, act, msg = nil)\n msg = message(msg) {\n exp_str = mu_pp(exp)\n act_str = mu_pp(act)\n exp_comment = ''\n act_comment = ''\n if exp_str == act_str\n if (exp.is_a?(String) && act.is_a?(String)) ||\n (exp.is_a?(Regexp) && act.is_a?(Regexp))\n exp_comment = \" (#{exp.encoding})\"\n act_comment = \" (#{act.encoding})\"\n elsif exp.is_a?(Float) && act.is_a?(Float)\n exp_str = \"%\\#.#{Float::DIG+2}g\" % exp\n act_str = \"%\\#.#{Float::DIG+2}g\" % act\n elsif exp.is_a?(Time) && act.is_a?(Time)\n if exp.subsec * 1000_000_000 == exp.nsec\n exp_comment = \" (#{exp.nsec}[ns])\"\n else\n exp_comment = \" (subsec=#{exp.subsec})\"\n end\n if act.subsec * 1000_000_000 == act.nsec\n act_comment = \" (#{act.nsec}[ns])\"\n else\n act_comment = \" (subsec=#{act.subsec})\"\n end\n elsif exp.class != act.class\n # a subclass of Range, for example.\n exp_comment = \" (#{exp.class})\"\n act_comment = \" (#{act.class})\"\n end\n elsif !Encoding.compatible?(exp_str, act_str)\n if exp.is_a?(String) && act.is_a?(String)\n exp_str = exp.dump\n act_str = act.dump\n exp_comment = \" (#{exp.encoding})\"\n act_comment = \" (#{act.encoding})\"\n else\n exp_str = exp_str.dump\n act_str = act_str.dump\n end\n end\n \"<#{exp_str}>#{exp_comment} expected but was\\n<#{act_str}>#{act_comment}\"\n }\n assert(exp == act, msg)\n end", "def assertEquals(results, expected, msg)\n puts \"#{calling_method}: #{msg}\\n\"\n if(results != expected)\n puts \"Expected #{expected} not #{results}\\n\"\n return false\n end\n \n return true\n end", "def initialize(expected)\n @expected = expected\n @message = ''\n @reported_differences = {}\n end", "def assert_value(actual,expected,message)\n puts message\n puts actual == expected\nend", "def diff(other_message)\n out = self.class.new\n\n self.class.valid_attrs.each do |attr|\n ours = read(attr)\n theirs = other_message.read(attr)\n\n if ours != theirs\n out.write(attr, ours)\n end\n end\n\n out\n end", "def failure_message_when_negated\n \"expected #{@actual.inspect} not to be true or false\"\n end", "def assertNotSameWithMessageFailTest object, message\n rescue_assertion ASSERT_NOT_SAME_ERROR, message do\n assertNotSame object, object, message\n end\n end", "def test_spec_invalidity\n assert !@invalid_spec.valid?\n attributes = [:gender, :zip_code]\n attributes.each do |attr|\n assert @invalid_spec.errors.invalid?(attr)\n end\n end", "def assert_xml_not_equal(expected_doc, actual_doc, message = nil)\r\n expected_doc = parse_xml(expected_doc)\r\n actual_doc = parse_xml(actual_doc)\r\n _wrap_assertion do\r\n full_message = build_message(message, <<EOT, actual_doc.inspect, expected_doc.inspect)\r\n\r\n<?> expected not to be equal to\r\n<?> but was equal.\r\nEOT\r\n assert_block(full_message){ ! are_equal?(expected_doc, actual_doc)}\r\n end\r\n end", "def assertNotEqualTest expected, value\n assertNotEqual expected, value\n end", "def assert_not_equal(exp, act, msg=nil)\n EqualityFailure.refute(act, exp, :message=>msg, :backtrace=>caller)\n end", "def assert(actual, expected)\n\traise \"actual: #{actual}, expected: #{expected}\" unless expected == actual\nend", "def ==(other)\n other.is_a?(self.class) &&\n other.attribute == attribute &&\n other.validation == validation &&\n other.expected == expected &&\n other.actual == actual\n end", "def failure_message\n actual = prettify_args(@actual)\n matcher = prettify_matcher(@metadata[:name])\n\n if @metadata[:args].count > 0\n args = prettify_args(*@metadata[:args])\n\n \"'#{actual}' should #{matcher} '#{args}'\"\n else\n \"'#{actual}' should #{matcher}\"\n end\n end", "def assertNotSameFailTest object\n rescue_assertion ASSERT_NOT_SAME_ERROR do\n assertNotSame object, object\n end\n end", "def assert_equals_with_expect(left, right)\n assert left == right, expect_got(right, left)\n end", "def assertNotEqualWithMessageFailTest expected, value, message\n rescue_assertion ASSERT_NOT_EQUAL_ERROR, message do\n assertNotEqual expected, value, message\n end\n end", "def == expected\n self.out == expected\n end", "def json_should_eql(actual, expected)\n same = json_cmp(actual, expected)\n actual.should.== expected unless same \nend", "def ==(other)\n attributes == other.attributes\n end", "def expect_hash_equal(actual, expected)\n expected.each do |key, expected_value|\n expect(actual).to have_key(key)\n if expected_value.is_a?(Hash)\n expect_hash_equal(actual[key], expected_value)\n else\n expect(actual[key]).to eq(expected_value)\n end\n end\n expect(actual).to eq(expected)\n end", "def verifyEqual(exp_val,act_val)\n assert_equal(exp_val, act_val,\"Wrong value Expected #{exp_val} Actual #{act_val}\")\n end", "def assertNotEqualFailTest expected, value\n rescue_assertion ASSERT_NOT_EQUAL_ERROR do\n assertNotEqual expected, value\n end\n end", "def assert_equal(expected, actual)\n if expected.is_a?(Nokogiri::XML::Node) && actual.is_a?(Nokogiri::XML::Node)\n assert(EquivalentXml.equivalent?(expected, actual,\n element_order: false, normalize_whitespace: true),\n \"XML nodes were not equal\")\n elsif expected.is_a?(String) && actual.is_a?(String)\n ex_bin = expected.dup.force_encoding('BINARY')\n act_bin = actual.dup.force_encoding('BINARY')\n\n assert(ex_bin == act_bin,\n \"strings were not equal\")\n else\n assert(expected == actual, \"expected `#{expected}`, got `#{actual}`\")\n end\n end", "def eql(expected)\n set_relativity(:eql, expected)\n end", "def xml_should_eql(actual, expected)\n same = xml_cmp(actual, expected)\n actual.should.== expected unless same \nend", "def assert_dom_not_equal(expected, actual, message=\"\")\n clean_backtrace do\n expected_dom = HTML::Document.new(expected).root\n actual_dom = HTML::Document.new(actual).root\n full_message = build_message(message, \"<?> expected to be != to\\n<?>.\", expected_dom.to_s, actual_dom.to_s)\n assert_block(full_message) { expected_dom != actual_dom }\n end\n end", "def ==(other)\n self.attributes == (other.respond(:attributes) || {} )\n end", "def assert_equal_expected_keys(expected, actual)\n expected.each do |key, value|\n # As we receive a warning that this will fail in MT6, though ugly, we gate\n # the assertion on whether the expected value is nil.\n if value.nil?\n assert_nil actual.with_indifferent_access[key], \"for key #{key}\"\n else\n assert_equal value, actual.with_indifferent_access[key], \"for key #{key}\"\n end\n end\n end", "def failure_message_for_should\n message = \"expected #{@collection_key} to match the user's mental model, but:\\n\"\n unless expected_items_found?\n message += \"expected to be present: #{pp_array(expected_items)}\\n\"\n message += \"the missing elements were: #{pp_array(expected_items_that_were_not_found)}\\n\"\n end\n if unexpected_items_found?\n message += \"expected to not be present: #{pp_array(unexpected_items)}\\n\"\n message += \"the unexpected extra elements: #{pp_array(unexpected_items_that_were_found)}\\n\"\n end\n message\n end", "def print_output(expected, actual)\n puts \"expect: \" + expected.robust\n puts \"actual: \" + actual.robust\nend", "def assert_dom_equal(expected, actual, message=\"\")\n clean_backtrace do\n expected_dom = HTML::Document.new(expected).root\n actual_dom = HTML::Document.new(actual).root\n full_message = build_message(message, \"<?> expected to be == to\\n<?>.\", expected_dom.to_s, actual_dom.to_s)\n assert_block(full_message) { expected_dom == actual_dom }\n end\n end", "def test_equals\n result = Person.new(\"Fred\", \"Jones\", 34) == Person.new(\"Fred\", \"Jones\", 34)\n assert_equals(true, result, \"The same person was not found to be equal.\")\nend", "def assert_equal(exp, act, msg=nil)\n EqualityFailure.assert(act, exp, :message=>msg, :backtrace=>caller)\n end", "def compare_contractor_data(contractor)\n message_good = \"Each attribute value is equal to the corresponding attributes of a freelancer #{contractor[:name]} on a profile page:\\n#{contractor}\"\n message_bad = \"Freelancer attribute values ​​not equal to the corresponding attributes in the shared page. Expected:\\n#{contractor}\\nGot:\\n#{@hash_contractor}\"\n #hash_contractor = @hash_contractor\n (contractor == @hash_contractor) ? (puts message_good) : (puts message_bad)\n end", "def failure_message\n \"expected #{@target.name} to provide #{@expected}, but it doesn't\"\n end", "def are_equal(value1, value2)\n EqualityAssertion.new(value1, value2)\n end", "def summary\n if error?\n error.message\n elsif actual.is_a?(::Exception)\n actual.message\n elsif actual == expected\n [\"expected\", negation, \"to\", definition].compact.join(SPACE)\n else\n [\"expected\", actual.inspect, negation, \"to\", definition].compact.join(SPACE)\n end\n end", "def test_equalcomparison\n a = Grade.new(\"A\")\n anotherA = Grade.new(\"A\")\n assert (a == anotherA) # should return true\n end", "def refute_cmp(expect, actual)\n actual = rspec_expect actual\n expect = cmp expect\n\n assert_raises RSpec::Expectations::ExpectationNotMetError do\n actual.to expect\n end\n end", "def assert_model_invalid(instance, *missing_attributes)\n expect do\n instance.value_attributes_for_avro\n end.to raise_error do |error|\n expect(error).to be_a_kind_of(Avromatic::Model::ValidationError)\n missing_attributes.each do |missing_attribute|\n expect(error.message).to include(missing_attribute)\n end\n end\n\n expect(instance).to be_invalid\n missing_attributes.each do |missing_attribute|\n expect(instance.errors[:base]).to include(\"#{missing_attribute} can't be nil\")\n end\n end", "def failure_message_when_negated\n actual = prettify_args(@actual)\n matcher = prettify_matcher(@metadata[:name])\n\n if @metadata[:args].count > 0\n args = prettify_args(*@metadata[:args])\n\n \"'#{actual}' should not #{matcher} '#{args}'\"\n else\n \"'#{actual}' should not #{matcher}\"\n end\n end", "def assert_equal(*args, &block)\n adapter = AssertionAdapter::Minitest.new\n adapter.assert_equal(*args, &block) # FIXME: this sucks: Minitest catches the Assertion exception here, instead of properly passing it up the chain.\n\n pp adapter\n # instead, there should be an API in Minitest so we can pass it results (failures and passes?) and it \"does the rest\" .\n @assertions ||=[]\n @assertions << @description\n end", "def failure_message\n if @found\n \"\\nexpected: #{@expect}\\n got: #{@actual}\\n\"\n else\n \"\\nCould not find a snapshot at #{snap_path}.\\n Failing \" \\\n \"instead of creating; save_snapshots is set to #{save_config}.\"\n end\n end", "def assert_not_same(exp, act, msg=nil)\n test = ! exp.equal?(act)\n msg = \"Expected #{act.inspect} to not be the same as #{exp.inspect}\" unless msg\n __assert__(test, msg)\n end", "def assert_equal(actual, expected)\n\tif (actual == expected)\n\t\tputs \"pass\"\n\telse\n\t\tputs \"fail\"\n\tend\nend", "def assertSameWithMessageFailTest expected, object, message\n rescue_assertion ASSERT_SAME_ERROR, message do\n assertSame expected, object, message\n end\n end", "def must_almost_equals(expected, actual)\n case expected\n when nil\n true\n when Array\n unless actual.instance_of?(Array)\n raise ComparisonError, \"Inconsistent type: expected type of #{expected}: Array, actual type of #{actual}: #{actual.class}\"\n end\n unless expected.size == actual.size\n raise ComparisonError, \"Different size of arrays: expected size of #{expected}: #{expected.size}, actual size of #{actual}: #{actual.size}\"\n end\n\n expected.to_enum.with_index.each do |e, i|\n begin\n must_almost_equals(e, actual[i])\n rescue ComparisonError => e\n raise ComparisonError, \"Different value of #{i}-th element of array\"\n end\n end\n when Hash\n # Note: It is OK when `actual` has additional entries.\n unless actual.instance_of?(Hash)\n raise ComparisonError, \"Incensistent type: expected type of #{expected}: Hash, actual type of #{actual}: #{actual.class}\"\n end\n\n expected.each do |k, v|\n begin\n unless actual.include?(k)\n raise ComparisonError, \"Missing key `#{k}` in actual: #{actual}\"\n end\n must_almost_equals(v, actual[k])\n rescue ComparisonError => e\n if not e.cause.nil? and e.cause.message.match(/^Missing key `#{k}`/)\n raise e\n end\n raise ComparisonError, \"Different value for `#{k}`\"\n end\n end\n else\n unless expected == actual\n raise ComparisonError, \"Comparison failed: #{expected} == #{actual}\"\n end\n end\nend", "def expected_errors\n @expected_errors ||= ActiveSupport::OrderedHash.new\n end", "def ==(other)\n other.present? && self.attributes == other.attributes\n end", "def assert_equal(expected, actual)\n raise \"Expected #{expected} to match #{actual}\" unless expected == actual\nend" ]
[ "0.6432467", "0.6316401", "0.62427676", "0.62104106", "0.61899346", "0.61573005", "0.61454767", "0.6130725", "0.6130129", "0.61241424", "0.6124119", "0.6088345", "0.60785687", "0.60714924", "0.6061393", "0.603216", "0.59935045", "0.59505934", "0.5933843", "0.58957833", "0.5890591", "0.58729976", "0.5867444", "0.5859535", "0.58510417", "0.5850002", "0.5840246", "0.5840246", "0.5837533", "0.5837533", "0.5837533", "0.5837533", "0.5837533", "0.58369726", "0.5833011", "0.58162224", "0.58080184", "0.5800415", "0.57955515", "0.57927114", "0.57850444", "0.57835096", "0.5782228", "0.5777117", "0.57607484", "0.57552576", "0.5754697", "0.57519037", "0.57473916", "0.57300687", "0.57289946", "0.57220066", "0.57201856", "0.5693902", "0.5686135", "0.56675065", "0.56611574", "0.5657466", "0.5657054", "0.5656463", "0.5653444", "0.5650597", "0.5636489", "0.5635576", "0.5627547", "0.562493", "0.56207085", "0.5612999", "0.5611994", "0.56086075", "0.5604038", "0.5597927", "0.55969805", "0.55968046", "0.5596169", "0.5594989", "0.5593914", "0.55721223", "0.5541592", "0.55378836", "0.5535858", "0.5529334", "0.55249643", "0.5513336", "0.55100924", "0.5504086", "0.54842365", "0.54805684", "0.54771763", "0.5470282", "0.54560876", "0.5452089", "0.5451512", "0.5436183", "0.5436127", "0.5434672", "0.54215527", "0.54196805", "0.5407979", "0.53947747" ]
0.5658647
57
Build a select field tag. If a block is given only build the label an yield the given block. Else, try to build a select for the given attr_name.
def agile_board_select_field(f, attr_name, label, model, required = false) content_tag :div, class: 'autocomplete-combobox' do concat(required ? required_form_label(f, attr_name, label) : f.label(attr_name, label)) if block_given? concat yield else concat f.select "#{attr_name}_id", model.send("#{attr_name}_options"), {include_blank: !required}, {class: "chzn-select#{'-deselect' unless required} cbb-medium search"} end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_select(type, select_options_as_html); end", "def build_select(type, select_options_as_html)\n select_options = {\n id: input_id_from_type(type),\n name: input_name_from_type(type)\n }.merge!(@html_options)\n select_options[:disabled] = \"disabled\" if @options[:disabled]\n select_options[:class] = css_class_attribute(type, select_options[:class], @options[:with_css_classes]) if @options[:with_css_classes]\n\n select_html = +\"\\n\"\n select_html << content_tag(\"option\", \"\", value: \"\", label: \" \") + \"\\n\" if @options[:include_blank]\n select_html << prompt_option_tag(type, @options[:prompt]) + \"\\n\" if @options[:prompt]\n select_html << select_options_as_html\n\n (content_tag(\"select\", select_html.html_safe, select_options) + \"\\n\").html_safe\n end", "def in_my_select attrs = nil\n attrs[:class] ||= ''\n attrs[:class] << ' myselect'\n attrs[:class] = attrs[:class].strip\n\n # La taille du menu peut être déterminé par :width\n size = attrs.delete(:size) || 'normal'\n\n # Il faut ajouter un champ hidden qui contiendra vraiment\n # la valeur avec le nom déterminé\n fid = attrs[:id] || attrs[:name]\n fname = attrs[:name] || attrs[:id]\n attrs[:id] = \"myselect_#{fid}\"\n attrs[:name] = \"myselect_#{fname}\"\n \"<div class=\\\"container_myselect #{size}size\\\">\" +\n attrs[:selected].in_hidden(id: fid, name: fname) +\n self.class.opened_tag('div', attrs) + self.to_s + '</div>' +\n '</div>'\n end", "def initialize(attr_name, xml_label: nil, &block)\n @name = attr_name\n\n @xml_label = xml_label.presence || attr_name\n @target_value = block if block_given?\n\n @target_value = attr_name.to_sym if @target_value.blank?\n end", "def select_field_tag(name, current_value, choices, html_options = {})\r\n #MGS- force the name to be set to the name, no matter the html options\r\n html_options['name'] = name\r\n #MES- Set the ID to the name, if no ID was supplied\r\n if !html_options.has_key?('id')\r\n #MES- Replace '[' with '_' and ']' with '' because square brackets are not\r\n # allowed in IDs.\r\n html_options['id'] = name.sub(/[\\[]/, '_').sub(/\\]/, '')\r\n end\r\n\r\n options = ''\r\n choices.each do | item |\r\n options << option_tag(item[1], item[0], current_value.to_s == item[0].to_s)\r\n end\r\n #MGS- use this rails helper to build the select element\r\n content_tag(\"select\", options, html_options)\r\n end", "def type_select object, method, label_text, options\n content_tag :div, :class => :\"type-select\" do\n attr_id = \"#{object.class.to_s.downcase}[#{method}]\".to_sym\n output = String.new\n output << content_tag(:label, label_text, :for => attr_id) unless label_text.blank?\n output << select_tag(attr_id, options)\n end\n end", "def select name, options, attrs = {}\n options = select_options options, attrs\n attrs.delete :selected\n Tagz.tag :select, options, { :name => name }.merge(attrs)\n end", "def options_for_component_select var_name, var_data, fields, item\n options = []\n\n # _nil\n unless var_data[:required]\n options.push ['', '_nil']\n end\n\n # fields\n fields.each do |field|\n options.push [field, field]\n end\n\n # _literal\n options.push ['Literal...', '_literal']\n\n # figure\n current = value_for_data(var_name, item)\n\n return options_for_select(options, current)\n end", "def ui_dropdown_select_field(content = nil, options = nil, html_options = nil, &block)\n UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new(content, options, html_options, &block).render\n end", "def _whimsy_forms_select(\n name: nil,\n label: 'Enter string',\n value: '', # Currently selected value\n valuelabel: '', # Currently selected valuelabel\n options: nil, # ['value'] or {\"value\" => 'Label for value'} of all selectable values\n multiple: false, # Not currently supported\n required: false,\n readonly: false,\n icon: nil,\n iconlabel: nil,\n iconlink: nil,\n placeholder: nil, # Currently displayed text if value is blank (not selectable)\n helptext: nil\n )\n return unless name\n aria_describedby = \"#{name}_help\" if helptext\n _div.form_group do\n _label.control_label.col_sm_3 label, for: \"#{name}\"\n _div.col_sm_9 do\n _div.input_group do\n _select.form_control name: \"#{name}\", id: \"#{name}\", aria_describedby: \"#{aria_describedby}\", required: required, readonly: readonly do\n if ''.eql?(value)\n if ''.eql?(placeholder)\n _option '', value: '', selected: 'selected'\n else\n _option \"#{placeholder}\", value: '', selected: 'selected', disabled: 'disabled', hidden: 'hidden'\n end\n else\n _option ''.eql?(valuelabel) ? \"#{value}\" : \"#{valuelabel}\", value: \"#{value}\", selected: 'selected'\n end\n if options.kind_of?(Array)\n options.each do |opt|\n _option opt, value: opt\n end\n else\n options.each do |val, disp|\n _option disp, value: val\n end\n end\n end\n _whimsy_forms_iconlink(icon: icon, iconlabel: iconlabel, iconlink: iconlink)\n end\n if helptext\n _span.help_block id: \"#{aria_describedby}\" do\n _markdown \"#{helptext}\"\n end\n end\n end\n end\n end", "def select_tag(name, option_tags = T.unsafe(nil), options = T.unsafe(nil)); end", "def ui_select_field(content = nil, options = nil, html_options = nil, &block)\n UiBibz::Ui::Core::Forms::Selects::SelectField.new(content, options, html_options, &block).render\n end", "def select(resource_name, field_name, options_list, selected_value)\n html = ''\n options_list.each do |nv_pair|\n option_value = nv_pair.keys.first\n option_name = nv_pair.values.first\n html << \"<option value=\\\"#{option_value}\\\"\"\n html << \" selected=\\\"selected\\\"\" if option_value == selected_value\n html << '>'\n html << option_name\n html << \"</option>\"\n end\n \"<select id=\\\"#{resource_name}_#{field_name}\\\" name=\\\"#{resource_name}_#{field_name}\\\" class=\\\"required\\\">#{html}</select>\"\n end", "def selection_group(fieldname, options={})\n labels = options.delete(:labels)\n title = options.delete(:title) || build_title(fieldname)\n choices = options.delete(:choices)\n selected = options.delete(:selected)\n\n # TODO: Uses option_groups_from_collection_for_select here!\n select_options = ''\n choices.each_with_index do |v,k| #build optiongroup for each given object group\n unless v.empty?\n select_options << \"<optgroup label='#{labels[k]}'>\"\n select_options << @template.options_from_collection_for_select(v, :id, :to_s, selected) #still hardcoded\n select_options << \"</optgroup>\"\n end\n end\n tag_wrapper title, select_tag(fieldname, select_options.html_safe, options)\n end", "def select(*args, &block)\n _gestalt_call_tag(:select, args, &block)\n end", "def render(field_id, value = nil, product = nil)\r\n\t\t\tselected_value = !value.nil? ? value : self.default_value || nil\r\n\t\t\tr = \"<select name=\\\"#{field_id}\\\">\"\r\n\t\t\tavailable_values(product).each do |v|\r\n\t\t\t\tr += \"<option value=\\\"#{v.id}\\\"\"\r\n\t\t\t\tif v.id.to_s == selected_value.to_s then\r\n\t\t\t\t\tr += \" selected=\\\"selected\\\"\"\r\n\t\t\t\tend\r\n\t\t\t\tr += \">#{v.value}</option>\"\r\n\t\t\tend\r\n\t\t\tr += \"</select>\"\r\n\t\tend", "def method_missing(name, &block)\n sel = selectify(name)\n if block_given?\n open_block(sel)\n yield\n closed_block\n else\n chain(sel)\n end\n self\n end", "def build_select(arel)\n if select_values.any?\n cols = arel_columns(select_values.uniq).map do |col|\n # if it is a virtual attribute, then add aliases to those columns\n if col.kind_of?(Arel::Nodes::Grouping) && col.name\n col.as(connection.quote_column_name(col.name))\n else\n col\n end\n end\n arel.project(*cols)\n else\n super\n end\n end", "def build_field_options(value, _index)\n return super if defined?(super)\n\n dom_id = input_dom_id if respond_to?(:input_dom_id)\n dom_id ||= \"#{object_name}_#{attribute_name}\"\n\n input_html_options.dup.tap do |options|\n options[:value] = value\n\n options[:id] ||= dom_id\n options[:class] ||= []\n options[:class] += [\"#{dom_id} form-control\"]\n options[:'aria-labelledby'] ||= \"#{dom_id}_label\"\n end\n end", "def _gestalt_build_tag(name, attr = {}, text = [])\n @out << \"<#{name}\"\n @out << attr.map{|(k,v)| %[ #{k}=\"#{_gestalt_escape_entities(v)}\"] }.join\n if text != [] or block_given?\n @out << \">\"\n @out << _gestalt_escape_entities([text].join)\n if block_given?\n text = yield\n @out << text.to_str if text != @out and text.respond_to?(:to_str)\n end\n @out << \"</#{name}>\"\n else\n @out << ' />'\n end\n end", "def each_subfield_for(tag_name, is_new = false)\n layout_key = is_new ? \"layout_new\" : \"layout\"\n if options_config.include?(tag_name) && options_config[tag_name].include?(layout_key)\n # we must have 'fields' if we have 'layout'\n options_config[tag_name][layout_key][\"fields\"].each do |field, config|\n yield [field, config]\n end\n elsif labels_config.include?(tag_name) && labels_config[tag_name].include?(:fields)\n labels_config[tag_name][:fields].each do |field|\n yield [field[0], {\"cols\" => 1, \"growfield\" => true}]\n end\n end\n end", "def format_select\n @attr[:multiple] = :multiple if @opts[:multiple]\n copy_options_to_attributes([:size])\n\n os = process_select_optgroups(:_format_select_optgroup) do |label, value, sel, attrs|\n if !value.nil? || sel\n attrs = attrs.dup\n attrs[:value] = value unless value.nil?\n attrs[:selected] = :selected if sel\n end\n tag(:option, attrs, [label])\n end\n tag(:select, @attr, os)\n end", "def select_tag(name, option_values, options={})\n label = options.delete(:label) || name.titleize\n label.gsub!(' ', '&nbsp;')\n content_tag(\"dt\", content_tag(\"label\" , \"#{label}:\", :for => name )) + \"\\n\" +\n content_tag(\"dd\", @super.select_tag(name, option_values, options))\n end", "def field_tag(options_or_label = {}, content = nil, &block)\n label, options = \"\", {}\n if options_or_label.class == String\n label = options_or_label\n options[:class] = \"field\"\n else\n options = options_or_label\n # grab the error indicator out of the options\n has_error = options.delete(:has_error) || false\n\n # grab the field_type out of the options\n field_type = options.delete(:field_type) || nil\n\n # append field as css class for div options\n options[:class] = \"field #{field_type} #{options[:class]} #{'withErrors' if has_error}\"\n end\n \n if block_given?\n concat(content_tag(:div, options) do\n (label.blank? ? \"\" : content_tag(:label, label.strip)) +\n capture(&block)\n end, block.binding)\n else\n content_tag(:div, options) do\n (label.blank? ? \"\" : content_tag(:label, label.strip))+content.to_s\n end\n end\n end", "def option_tag(text); end", "def generate_attribute_input(attr_label)\r\n input_html = ''.html_safe\r\n\r\n # Get the attribute hash corresponding to the given attribute\r\n attr = @metadata.select{ |attr_hash| attr_hash[\"attribute\"].to_s.eql?(attr_label) }.first\r\n\r\n if attr[\"enforce\"].include?(\"integer\")\r\n number_field :submission, attr[\"attribute\"].to_s.to_sym, value: @submission.send(attr[\"attribute\"])\r\n\r\n elsif attr[\"enforce\"].include?(\"date_time\")\r\n if @submission.send(attr[\"attribute\"]).nil?\r\n date_value = nil\r\n else\r\n date_value = DateTime.parse(@submission.send(attr[\"attribute\"])).to_date.to_s\r\n end\r\n text_field(:submission, attr[\"attribute\"].to_s.to_sym, :class => \"datepicker\", value: \"#{date_value}\")\r\n\r\n elsif attr[\"enforce\"].include?(\"textarea\")\r\n text_area(:submission, attr[\"attribute\"].to_s.to_sym, rows: 3, value: @submission.send(attr[\"attribute\"]))\r\n\r\n # Create select dropdown when there are enforcedValues for the attr. But also let the user enter its own value if Other selected\r\n elsif !attr[\"enforcedValues\"].nil?\r\n metadata_values = @submission.send(attr[\"attribute\"])\r\n select_values = attr[\"enforcedValues\"].collect{ |k, v| [v,k]}\r\n # Add in the select ontologies that are not in the portal but are in the values\r\n if metadata_values.kind_of?(Array)\r\n metadata_values.map do |metadata|\r\n if !select_values.flatten.include?(metadata)\r\n select_values << metadata\r\n end\r\n end\r\n else\r\n if (!select_values.flatten.include?(metadata_values) && !metadata_values.to_s.empty?)\r\n select_values << metadata_values\r\n end\r\n end\r\n\r\n if attr[\"enforce\"].include?(\"list\")\r\n input_html << select_tag(\"submission[#{attr_label}][]\", options_for_select(select_values, metadata_values), :multiple => 'true',\r\n \"data-placeholder\".to_sym => \"Select ontologies\", :style => \"margin-bottom: 15px; width: 100%;\", :id => \"select_#{attr[\"attribute\"]}\", :class => \"selectOntology\")\r\n\r\n input_html << text_field_tag(\"add_#{attr[\"attribute\"].to_s}\", nil, :style => \"margin-left: 1em; margin-right: 1em;width: 16em;\", :placeholder => \"Or provide the value\",\r\n :onkeydown => \"if (event.keyCode == 13) { addOntoToSelect('#{attr[\"attribute\"]}'); return false;}\")\r\n\r\n input_html << button_tag(\"Add new value\", :id => \"btnAdd#{attr[\"attribute\"]}\", :style => \"margin-bottom: 2em;vertical-align: baseline;\",\r\n :type => \"button\", :class => \"btn btn-info btn-sm\", :onclick => \"addOntoToSelect('#{attr[\"attribute\"]}')\")\r\n\r\n else\r\n\r\n select_values << [\"None\", \"\"]\r\n select_values << [\"Other\", \"other\"]\r\n\r\n if metadata_values.nil?\r\n metadata_values = \"\"\r\n end\r\n\r\n input_html << select(\"submission\", attr[\"attribute\"], select_values, { :selected => metadata_values}, {:class => \"form-control\", :id => \"select_#{attr[\"attribute\"]}\", :style=> \"margin-bottom: 1em;\"})\r\n\r\n # Button and field to add new value (that are not in the select). Show when other is selected\r\n input_html << text_field_tag(\"add_#{attr[\"attribute\"].to_s}\", nil, :style => \"margin-left: 1em; margin-right: 1em;width: 16em;display: none;\", :placeholder => \"Or provide the value\",\r\n :onkeydown => \"if (event.keyCode == 13) { addValueToSelect('#{attr[\"attribute\"]}'); return false;}\")\r\n\r\n input_html << button_tag(\"Add new value\", :id => \"btnAdd#{attr[\"attribute\"]}\", :style => \"margin-bottom: 2em;display: none;vertical-align: baseline;\",\r\n :type => \"button\", :class => \"btn btn-info btn-sm\", :onclick => \"addValueToSelect('#{attr[\"attribute\"]}')\")\r\n\r\n # To show/hide textbox when other option is selected or not\r\n input_html << javascript_tag(\"$(function() {\r\n $('#select_#{attr[\"attribute\"]}').change(function() {\r\n if ($('#select_#{attr[\"attribute\"]}').val() == 'other') {\r\n $('#add_#{attr[\"attribute\"].to_s}').val(\"\");\r\n $('#btnAdd#{attr[\"attribute\"]}').show();\r\n $('#add_#{attr[\"attribute\"].to_s}').show();\r\n } else {\r\n $('#btnAdd#{attr[\"attribute\"]}').hide();\r\n $('#add_#{attr[\"attribute\"].to_s}').hide();\r\n }\r\n });\r\n })\")\r\n\r\n end\r\n\r\n\r\n return input_html\r\n\r\n\r\n elsif attr[\"enforce\"].include?(\"isOntology\")\r\n metadata_values = @submission.send(attr[\"attribute\"])\r\n select_values = @ontologies_for_select.dup\r\n # Add in the select ontologies that are not in the portal but are in the values\r\n if metadata_values.kind_of?(Array)\r\n metadata_values.map do |metadata|\r\n if !select_values.flatten.include?(metadata)\r\n select_values << metadata\r\n end\r\n end\r\n else\r\n\r\n if !select_values.flatten.include?(metadata_values)\r\n select_values << metadata_values\r\n end\r\n end\r\n\r\n if attr[\"enforce\"].include?(\"list\")\r\n input_html << select_tag(\"submission[#{attr_label}][]\", options_for_select(select_values, metadata_values), :multiple => 'true',\r\n \"data-placeholder\".to_sym => \"Select ontologies\", :style => \"margin-bottom: 15px; width: 100%;\", :id => \"select_#{attr[\"attribute\"]}\", :class => \"selectOntology\")\r\n\r\n else\r\n input_html << select_tag(\"submission[#{attr_label}]\", options_for_select(select_values, metadata_values), \"data-placeholder\".to_sym => \"Select ontology\",\r\n :style => \"margin-bottom: 15px; width: 100%;\", :id => \"select_#{attr[\"attribute\"]}\", :class => \"selectOntology\", :include_blank => true)\r\n end\r\n # Button and field to add new value (not in the select)\r\n input_html << tag(:br)\r\n\r\n input_html << text_field_tag(\"add_#{attr[\"attribute\"]}\", nil, :style => \"margin-left: 1em; margin-right: 1em;vertical-align: super;width: 16em;\",\r\n :placeholder => \"Ontology outside of the Portal\", :onkeydown => \"if (event.keyCode == 13) { addOntoToSelect('#{attr[\"attribute\"]}'); return false;}\")\r\n\r\n input_html << button_tag(\"Add new ontology\", :id => \"btnAdd#{attr[\"attribute\"]}\", :style => \"margin-bottom: 2em;margin-top: 1em;\",\r\n :type => \"button\", :class => \"btn btn-info btn-sm\", :onclick => \"addOntoToSelect('#{attr[\"attribute\"]}')\")\r\n\r\n return input_html\r\n\r\n elsif attr[\"enforce\"].include?(\"uri\")\r\n if @submission.send(attr[\"attribute\"]).nil?\r\n uri_value = \"\"\r\n else\r\n uri_value = @submission.send(attr[\"attribute\"])\r\n end\r\n\r\n if attr[\"enforce\"].include?(\"list\")\r\n input_html << button_tag(\"Add new value\", :id => \"add#{attr[\"attribute\"]}\", :style => \"margin-bottom: 0.5em;margin-top: 0.5em;margin-left: 0.5em;\",\r\n :type => \"button\", :class => \"btn btn-info btn-sm\", :onclick => \"addInput('#{attr[\"attribute\"]}', 'url')\")\r\n input_html << url_field_tag(\"submission[#{attr[\"attribute\"].to_s}][]\", uri_value[0], :id => attr[\"attribute\"].to_s, class: \"metadataInput\")\r\n # Add field if list of URI\r\n if [email protected](attr[\"attribute\"]).nil? && @submission.send(attr[\"attribute\"]).any?\r\n @submission.send(attr[\"attribute\"]).each_with_index do |metadata_val, index|\r\n if index != 0\r\n input_html << url_field_tag(\"submission[#{attr[\"attribute\"].to_s}][]\", metadata_val, :id => \"submission_#{attr[\"attribute\"].to_s}\", class: \"metadataInput\")\r\n end\r\n end\r\n end\r\n input_html << content_tag(:div, \"\", id: \"#{attr[\"attribute\"]}Div\")\r\n\r\n else\r\n # if single value\r\n input_html << text_field(:submission, attr[\"attribute\"].to_s.to_sym, value: uri_value, class: \"metadataInput\")\r\n end\r\n return input_html\r\n\r\n elsif attr[\"enforce\"].include?(\"boolean\")\r\n select(\"submission\", attr[\"attribute\"].to_s, [\"none\", \"true\", \"false\"], { :selected => @submission.send(attr[\"attribute\"])},\r\n {:class => \"form-control\", :style => \"margin-top: 0.5em; margin-bottom: 0.5em;\"})\r\n\r\n else\r\n # If input a simple text\r\n\r\n if attr[\"enforce\"].include?(\"list\")\r\n input_html << button_tag(\"Add new value\", :id => \"add#{attr[\"attribute\"]}\", :style => \"margin-bottom: 0.5em;margin-top: 0.5em;\",\r\n :type => \"button\", :class => \"btn btn-info btn-sm\", :onclick => \"addInput('#{attr[\"attribute\"]}', 'text')\")\r\n firstVal = \"\"\r\n if [email protected](attr[\"attribute\"]).nil? && @submission.send(attr[\"attribute\"]).any?\r\n firstVal = @submission.send(attr[\"attribute\"])[0]\r\n end\r\n input_html << text_field_tag(\"submission[#{attr[\"attribute\"].to_s}][]\", firstVal, :id => attr[\"attribute\"].to_s, class: \"metadataInput\")\r\n\r\n # Add field if list of metadata\r\n if [email protected](attr[\"attribute\"]).nil? && @submission.send(attr[\"attribute\"]).any?\r\n @submission.send(attr[\"attribute\"]).each_with_index do |metadata_val, index|\r\n if index != 0\r\n input_html << text_field_tag(\"submission[#{attr[\"attribute\"].to_s}][]\", metadata_val, :id => \"submission_#{attr[\"attribute\"].to_s}\", class: \"metadataInput\")\r\n end\r\n end\r\n end\r\n\r\n input_html << content_tag(:div, \"\", id: \"#{attr[\"attribute\"]}Div\")\r\n\r\n else\r\n # if single value text\r\n # TODO: For some reason @submission.send(\"URI\") FAILS... I don't know why... so I need to call it manually\r\n if attr[\"attribute\"].to_s.eql?(\"URI\")\r\n input_html << text_field(:submission, attr[\"attribute\"].to_s.to_sym, value: @submission.URI,class: \"metadataInput\")\r\n else\r\n input_html << text_field(:submission, attr[\"attribute\"].to_s.to_sym, value: @submission.send(attr[\"attribute\"]), class: \"metadataInput\")\r\n end\r\n end\r\n return input_html\r\n end\r\n end", "def select_html(type, options, prefix = nil, include_blank = false, discard_type = false, disabled = false)\n select_html = %(<select name=\"#{prefix || 'date'})\n select_html << \"[#{type}]\" unless discard_type\n select_html << %(\")\n select_html << %( disabled=\"disabled\") if disabled\n select_html << %(>\\n)\n select_html << %(<option value=\"\"></option>\\n) if include_blank\n select_html << options.to_s\n select_html << \"</select>\\n\"\n select_html.html_safe\n end", "def scaffold_select_tag(name, collection, multiple = false)\n \"<select name='#{name}#{scaffold_param_list_suffix if multiple}' id='#{name}' #{\"multiple='multiple'\" if multiple}>#{'<option></option>' unless multiple}#{collection.collect{|obj| \"<option value='#{i = obj.scaffold_id}' id='#{name}_#{i}'>#{h obj.scaffold_name}</option>\"}.join(\"\\n\")}</select>\"\n end", "def make_select\n text = \"<select name='event'>\"\n @@events.each do |key, val|\n text+= \"<option value='#{key}'>#{val}</option>\"\n end\n text += \"</select>\"\n text\n end", "def input_select(name, options = [])\n field = field_content(name)\n input = {}\n opts = []\n unless field.nil?\n input[:id] = field_id(name)\n input[:label] = label(field, name)\n input[:name] = name\n input[:placeholder] = prop(field, 'placeholder')\n if options.present?\n # Should be we're getting data from BE controller\n opts = options\n else\n # Should be we're getting data from FE field construction\n options = prop(field, 'options') || []\n options.each do |option|\n label = value_by_key(option, :label)\n opts.push(text: label, value: clean_str(label))\n end\n end\n input[:options] = opts\n end\n input\n end", "def fields_for(name, attrs = {}, &blk)\n attrs ||= {}\n with_form_context(name, attrs.delete(:builder)) do\n capture(&blk)\n end\n end", "def build_element(element_name, my_target)\r\n\t\tdst = Rex::Text.to_unescape([my_target['DispatchDst']].pack(\"V\"))\r\n\t\telement = ''\r\n\r\n\t\tif my_target.name =~ /IE 8/\r\n\t\t\tmax = 63 # Number of attributes for IE 8\r\n\t\t\tindex = 1 # Where we want to confuse the type\r\n\t\telse\r\n\t\t\tmax = 55 # Number of attributes for before IE 8\r\n\t\t\tindex = 0 # Where we want to confuse the type\r\n\t\tend\r\n\r\n\t\telement << \"var #{element_name} = document.createElement(\\\"select\\\")\" + \"\\n\"\r\n\r\n\t\t# Build attributes\r\n\t\t0.upto(max) do |i|\r\n\t\t\tobj = (i==index) ? \"unescape(\\\"#{dst}\\\")\" : \"alert\"\r\n\t\t\telement << \"#{element_name}.w#{i.to_s} = #{obj}\" + \"\\n\"\r\n\t\tend\r\n\r\n\t\treturn element\r\n\tend", "def render_crud_form_field(column, item, locals)\n locals = locals.merge({:item => item, :column => column})\n\n if param(column,:grouped_select)\n return content_tag(\n \"select\",\n tag(\"option\", :value => \"\") + grouped_options_for_select(param(column,:grouped_select), @item.send(column[:name])),\n :id => \"#{@singular.underscore}_#{column[:name]}\",\n :name => \"#{@singular.underscore}[#{column[:name]}]\"\n )\n elsif param(column,:select)\n locals[:f].select(column[:name].to_s, param(column,:select).collect {|element| element.is_a?(Array) && element.length == 2 ? element : [element.to_s, element.to_s]}, { :include_blank => true }.merge(param(column, :params, {})), param(column, :params, {}))\n else\n type = param(column, :type, (item.attributes.include?(column[:name].to_s) ? item.column_for_attribute(column[:name]).type : \"other\")).to_s\n type = 'other_record' if param(column, :type, '') == '' && item.respond_to?(column[:name].to_s+\"_id\") && (attribute_class(column).respond_to?(:find) || column.include?(:find_class))\n locals = locals.merge({:type => type})\n\n if class_exists?('Lico::AutoCrud::Types::' + type.classify)\n return get_class('Lico::AutoCrud::Types::' + type.classify).to_input(item, column[:name], locals[:f], locals[:params])\n end\n \n return case type.to_sym\n when :boolean then locals[:f].check_box(column[:name], :class => 'in_boolean')\n when :country_select then locals[:f].localized_country_select(\n column[:name].to_s,\n [:NL, :BE, :LU, :FR, :DE],\n { :include_blank => '' },\n param(column, :params, { }).merge({ :class => 'in_country_select' })\n )\n when :currency then number_to_currency(0, :format => \"%u\") + \"&nbsp;\".html_safe + locals[:f].text_field(column[:name], :class => 'in_currency', :style => 'text-align: right', :value => number_to_currency(@item.send(column[:name]).to_f, :separator => \".\", :delimiter => \"\", :format => \"%n\"))\n when :custom then send(\"input_for_#{@singular.underscore}_#{column[:name].to_s}\", locals[:f], item)\n when :date then locals[:f].date_select(column[:name], param(column, :options, {}),{ :class => 'in_date' })\n when :time then locals[:f].time_select(column[:name], param(column, :options, {}),{ :class => 'in_time' })\n when :datetime then locals[:f].datetime_select(column[:name], :minute_step => 15, :class => 'in_datetime')\n when :file then locals[:f].file_field(column[:name], :class => 'in_file')\n when :hidden then locals[:f].hidden_field(column[:name], param(column, :params, { }).merge({:class => 'in_hidden'}))\n when :no_input then @item.send(column[:name])\n when :other_record then\n find_class = column.include?(:find_class) ? column[:find_class] : attribute_class(column)\n find_conditions = column[:conditions]\n find_items = find_class.find(:all, :select => param(column, :select, nil), :joins => param(column, :joins, []), :include => param(column, :include, []), :conditions => find_conditions).collect do |element| \n [ element.to_s, element.id ]\n end\n locals[:f].select(\"#{column[:name].to_s}_id\", find_items, { :include_blank => true }.merge(param(column, :options, {})))\n when :paperclip then\n item.send(column[:name].to_s).nil? ? \n # no image\n locals[:f].file_field(column[:name], :class => 'in_paperclip') :\n\n # with image\n image_tag(item.send(column[:name].to_s, param(column, :size))) +\n content_tag(\n \"div\", \n t('paperclip.upload_new') + \" \" + locals[:f].file_field(column[:name], :class => 'in_paperclip') +\n content_tag(\n \"div\",\n locals[:f].check_box(\"#{column[:name]}_delete\") +\n locals[:f].label(\"#{column[:name]}_delete\", t('paperclip.select_unlink'))\n )\n )\n when :password then locals[:f].password_field(column[:name], :class => 'in_password')\n when :select then locals[:f].select(column[:name].to_s, param(column,:select).collect {|element| element.is_a?(Array) && element.length == 2 ? element : [element.to_s, element.to_s]}, { :include_blank => true }.merge(param(column, :params, {})), param(column, :params, {}))\n when :textarea then locals[:f].text_area(column[:name], {:class => 'in_textarea'}.merge(param(column, :params, { })))\n else\n locals[:f].text_field(column[:name], param(column, :params, { }).merge({:class => 'in_' + type}))\n end\n end\n end", "def build_options_and_select(type, selected, options = T.unsafe(nil)); end", "def render\n return ro_standard if @readonly\n set_initial_value('html','selected')\n#\n @yaml['html'].symbolize_keys!\n record = record_text_for(@yaml['name'])\n if @yaml['multiple'] \n @html << @parent.select(record, @yaml['name'], get_choices, @yaml['html'], {multiple: true})\n @js << \"$('##{record}_#{@yaml['name']}').selectMultiple();\"\n else\n @html << @parent.select(record, @yaml['name'], get_choices, @yaml['html'])\n end\n self\nend", "def prepare_param_tag(name_or_tag, &block) # :yields: tag\n tag = case name_or_tag\n when WWW::Delicious::Tag\n name_or_tag\n else\n Tag.new(:name => name_or_tag.to_s)\n end\n\n yield(tag) if block_given?\n # TODO: validate tag with tag.validate!\n raise \"Invalid `tag` value supplied\" unless tag.api_valid?\n tag\n end", "def format_as_block_html(name, attr, body, indent); end", "def account_select_or_create(form, &_block)\n options = {}\n yield options if block_given?\n\n content_tag(:div, class: 'label') do\n t(:account).html_safe +\n content_tag(:span, id: 'account_create_title') do\n \" (#{t :create_new} #{t :or} <a href='#' onclick='crm.show_select_account(); return false;'>#{t :select_existing}</a>):\".html_safe\n end +\n content_tag(:span, id: 'account_select_title') do\n \" (<a href='#' onclick='crm.show_create_account(); return false;'>#{t :create_new}</a> #{t :or} #{t :select_existing}):\".html_safe\n end +\n content_tag(:span, ':', id: 'account_disabled_title')\n end +\n account_select(options) +\n form.text_field(:name, style: 'width:324px; display:none;')\n end", "def select(attribute, choices, options = {})\n object_value = @object ? @object.send(attribute) : nil # grab the object's value\n options.reverse_merge!(:label => attribute.to_s.titleize, :id => \"#{object_name(:id)}_#{attribute}\")\n @renderer.select_tag(\"#{object_name}[#{attribute}]\", @template.options_for_select(choices, object_value), options)\n end", "def label_tag(name = T.unsafe(nil), content_or_options = T.unsafe(nil), options = T.unsafe(nil), &block); end", "def assignee_menu( mt_req, building, tag_name = \"mtreq_assignee\" )\n # build the array from which we will build the select\n arr = [];\n if building!=nil && building.has_mt_company?\n \n if building.has_mt_manager?\n arr << [ \"#{building.mt_manager.hr_name} (#{ loc.term(Localization::BUILDING_MANAGER)})\",\n unique_obj_id(building.mt_manager) ];\n else\n #arr << [ \"mt_building_manager == nil\", \"xxx\"];\n end\n \n building.mt_company.workers.each do | wkr | \n if ( wkr.role.professional? )\n arr << [ \"#{wkr.role.name} (#{wkr.hr_name})\", unique_obj_id(wkr) ];\n end\n end\n \n arr << [ \"#{building.mt_company.name} (#{loc.term(Localization::MT_COMPANY)})\", \n unique_obj_id(building.mt_company) ];\n else\n if mt_req.has_mt_company?\n mt_req.mt_company.workers.each do | wkr | \n if ( wkr.role.professional? )\n arr << [ \"#{wkr.role.name} (#{wkr.hr_name})\", unique_obj_id(wkr) ];\n end\n end \n end \n end\n \n if building.respond_to?(:has_owner) && building.has_owner?\n arr << [ \"#{building.building_owner} (#{loc.term(Localization::BUILDING_OWNER)})\",\n unique_obj_id(building.building_owner) ];\n end\n \n # TODO add vaad.\n \n selected_id = \"\";\n selected_id = unique_obj_id(mt_req.assignee) unless mt_req.nil?\n \n return \"<select id='#{tag_name.gsub(\"[\",\"_\").gsub(\"]\",\"\")}' name='#{tag_name}'>\n #{options_for_select(arr, selected_id)}\n </select>\"; \n end", "def metadata_input(attribute_name, incoming_opts = {}, &block)\n metaopts = object.metadata_attributes[attribute_name]\n options = incoming_opts.dup\n\n options[:label] ||= metaopts[:label] if metaopts[:label]\n\n unless options.has_key?(:as)\n options[:as] = metaopts[:as] || case metaopts[:type]\n when :enum\n metaopts[:kind] == :short ? 'radio_buttons' : 'select'\n when :bitmask\n options[:wrapper] = :check_boxes\n 'check_boxes'\n when :foreign_key\n 'select'\n when :integer, :float\n 'numeric'\n when :tags\n raw_value = self.object.send(attribute_name) || []\n options[:class] = \"#{options[:class]} metadata-tags\"\n options[:input_html] = {:value => raw_value.join(',') } # We don't want the direct array.to_s as our form value\n 'string'\n when :date\n options[:wrapper_class] = \"#{options[:class]} date_picker\"\n 'string'\n when :color\n options[:wrapper_class] = \"#{options[:class]} color_picker\"\n 'color_picker'\n when :text, :boolean\n metaopts[:type]\n end\n end\n\n if metaopts.has_key?(:values)\n options[:collection] = extract_values(metaopts[:values])\n options[:include_blank] = false if metaopts[:required] == true\n\n if metaopts[:type] == :bitmask\n options[:label_method] = :humanize\n options[:value_method] = :to_sym\n end\n end\n\n input(attribute_name, options, &block)\n end", "def render_field(field_value,field_name,field_spec,language = OpenMoneyDefaultLanguage)\n html_field_name = \"flow_spec[#{field_name}]\"\n\n field_description = get_language_translated_spec(field_spec,'description',language)\n\n field_type = field_spec['type']\n case \n when field_spec['values_enum']\n enum = field_spec['values_enum']\n if enum.is_a?(Hash)\n enum = enum[enum.has_key?(language) ? language : OpenMoneyDefaultLanguage ]\n end\n select_tag(html_field_name,options_for_select(enum,field_value))\n when field_type == \"boolean\"\n select_tag(html_field_name,options_for_select([[l('Yes'), \"true\"], [l('No'), \"false\"]],field_value))\n when field_type == \"submit\"\n submit_tag(field_description,:id=>\"commit\") << '<span id=\"commit_processing\" style=\"display:none\">Processing...</span>'\n when field_type == \"text\"\n text_field_tag(html_field_name,field_value)\n when field_type == \"float\"\n text_field_tag(html_field_name,field_value)\n when field_type == \"unit\"\n UnitToHTMLMap[field_name]\n else\n text_field_tag(field_name,field_value)\n end\n end", "def semantic_fields_for(name, *args, &block)\n use_semantic_builder(:fields_for, name, *args, &block)\n end", "def tag_block tagname, children, **attr_map\n ch = a_indent(children)\n attr_str = mk_attr_str(attr_map)\n [\"<#{tagname}#{attr_str}>\", ch, \"</div>\"].flatten\n end", "def render_tag(tag_name, html_options = {}, &block)\n options = ['']\n options << %{id=\"#{html_options[:id]}\"} if html_options[:id].present?\n options << %{class=\"#{html_options[:css]}\"} if html_options[:css].present?\n\n %{<#{tag_name}#{options.join(' ')}>#{yield}</#{tag_name}>}\n end", "def build_field_options(value, index)\n options = input_html_options.dup\n\n\n #options[:value] = value if options[:value].nil?\n if !value.blank?\n options[:value] = value\n elsif value.blank? and !options[:value].blank?\n options[:value] = options[:value]\n else\n options[:value] = value\n end\n\n\n if @rendered_first_element\n options[:id] = nil\n options[:required] = nil\n else\n options[:id] ||= input_dom_id\n end\n options[:class] ||= []\n options[:class] += [\"#{input_dom_id} form-control multi-text-field\"]\n options[:'aria-labelledby'] = label_id\n @rendered_first_element = true\n\n options\n end", "def html_for_non_date_field(object, field)\n \"<p>\n <label for = '#{field}' >\n Select your #{field}:\n </label>\n <input type = 'text' \n name = create_form[#{field}]\n placeholder = 'Type in the #{field}'\n value = '#{object.send(field)}'>\n </input>\n </p>\"\n end", "def get_field_edit_rtpl\n ([email protected]? && @multiple != '') ? multiple = @multiple : multiple = ''\n\n select_str = '<select id=\"' + @id + '\" name=\"' + @name + '\" ' + multiple + '>'\n select_str << @option_str\n select_str << '</select>'\n\n select_str\n end", "def select_option value, contents, attrs = {}\n Tagz.tag :option, contents, { :value => value }.merge(attrs)\n end", "def scaffold_field_tag(field_type, options, object=nil, field=nil, record_name=nil, field_id=nil)\n options[:name] ||= options[:id] if options[:id]\n value = options[:value] || object.scaffold_value(field)\n case field_type\n when :text\n \"<textarea #{scaffold_options_to_html(options)}>#{h value.to_s}</textarea>\"\n when :boolean\n s = {value=>\"selected='selected'\"}\n \"<select #{scaffold_options_to_html(options)}><option></option><option value='f' #{s[false]}>False</option><option value='t' #{s[true]}>True</option></select>\"\n when :association\n klass = object.class\n if klass.scaffold_association_use_auto_complete(field)\n assocated_object = klass.scaffold_associated_objects(field, object, :session=>scaffold_session)\n options[:value] = assocated_object ? assocated_object.scaffold_name_with_id : ''\n scaffold_text_field_tag_with_auto_complete(options[:id], record_name, field, options)\n else\n s = {object.scaffold_value(field_id).to_i=>\"selected='selected'\"}\n associated_objects = klass.scaffold_association_find_objects(field, :session=>scaffold_session, :object=>object)\n \"<select #{scaffold_options_to_html(options)}><option></option>#{associated_objects.collect{|ao| \"<option value='#{i = ao.scaffold_id}' #{s[i]}>#{h ao.scaffold_name}</option>\"}.join}</select>\"\n end\n else\n options[:type] = :text\n case field_type\n when :submit, :password, :hidden, :file\n options[:size] ||= 30 if field_type == :password \n options[:type] = field_type\n when :date, :integer, :float\n options[:size] ||= 10\n else\n options[:size] ||= 30\n end\n options[:value] ||= value\n \"<input #{scaffold_options_to_html(options)} />\"\n end\n end", "def field *args, &block\n type, name, options = _extract_field_args(args)\n out = ''.html_safe\n\n input_options = {}\n input_args = []\n\n unless options[:autocomplete].nil?\n options.delete(:autocomplete)\n input_options[:autocomplete] = 'off'\n end\n\n unless options[:placeholder].nil?\n input_options[:placeholder] = if (placeholder = options.delete(:placeholder)) == true then name.to_s.humanize else placeholder end\n end\n\n unless options[:hidden].nil?\n input_options[:class] = 'hidden' if options[:hidden] == true\n end\n\n unless options[:required].nil?\n input_options[:required] = 'required' if options[:required] == true\n end\n\n unless options[:choices].nil?\n input_args << options[:choices]\n end\n\n out.concat options[:prepend] if options[:prepend]\n\n\n label_html = label(name, options[:label], class: 'control-label')\n\n out.concat label_html if options[:label] && options[:label_first]\n\n if options[:help_text]\n help_text = send(\"#{name}_help_text\")\n help_html = %Q(<a class=\"tipsy\" title=\"#{help_text}\" href=\"#\">learn more</a>).html_safe\n out.concat help_html\n end\n\n out.concat(@template.content_tag(:div, class: \"controls #{type}\") do\n merged_input_args = input_args << input_options\n controls = send(_field_types(type), name, *merged_input_args)\n controls.concat @template.content_tag(:div, options[:help_block], class: 'help-block') if options[:help_block].present?\n controls\n end)\n\n out.concat label_html if options[:label] && !options[:label_first]\n\n out.concat options[:append] if options[:append]\n out.concat yield if block_given?\n\n if options[:wrap_field]\n field_wrapper(type, name) { out }\n else\n out\n end\n end", "def map_nodes!(&ruby_block)\n @select = ruby_block.call(@select)\n @select.parent = self unless @select.parent\n map_choices!(&ruby_block)\n end", "def ui_dropdown(name, options = nil, html_options = nil, &block)\n UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new(name, options, html_options).tap(&block).render\n end", "def select_field_user_att(user, att_id, choices, options = {})\r\n return select_field_tag(\"user_atts[#{att_id}]\", user.get_att_value(att_id), choices, options.update({:id => \"user_atts_#{att_id}\"}))\r\n end", "def input_tag_label_and_widget(record_name, column)\n column_name = column.send(column.is_a?(String) || column.is_a?(Symbol) ? :to_s : :name)\n label_id, tag = if column.class.name =~ /Reflection/\n next unless column.macro == :belongs_to\n [\"#{record_name}_#{column.options[:foreign_key] || column.klass.table_name.classify.foreign_key}\", association_select_tag(record_name, column_name)]\n else\n [\"#{record_name}_#{column_name}\", input(record_name, column_name) || text_field(record_name, column_name)]\n end\n [\"<label for='#{label_id}'>#{@scaffold_class ? @scaffold_class.scaffold_column_name(column_name) : column_name.to_s.humanize}</label>\", tag]\n end", "def select(field, values, options = {})\n opts = set_options(:select, field, options)\n opts.delete(:type)\n\n values = [values] if values.is_a?(String) || values.is_a?(Symbol)\n values = Hash[values.map { |k| [k.to_s, k.to_s] }] if values.is_a?(Array)\n\n id = opts[:id]\n vals = opts.delete(:value) || ''\n content = values.map do |value_, label_|\n opts_ = {}\n opts_[:id] = \"#{id}_#{value_.to_s.underscore}\"\n opts_[:value] = value_\n opts_[:selected] = 'selected' if vals.to_s == value_.to_s\n tag :option, label_, opts_\n end.join('')\n\n tag :select, content, opts\n end", "def label_tag(attr_name, options = {})\n return '' if options.delete(:no_label)\n\n @template.content_tag 'label',\n \"#{(options.delete(:label) || attr_name.to_s.humanize)}:\",\n :for => \"#{@object_name}_#{attr_name}\",\n :class => (options[:long] ? 'long' : '')\n end", "def select(label, name, args = {})\n id = args[:id] ? args[:id] : id_for(name)\n multiple, size = args.values_at(:multiple, :size)\n \n # Get all the values\n if !args[:values] and @form_values.respond_to?(name)\n values = @form_values.send(name)\n else\n values = args[:values]\n args.delete(:values)\n end\n \n args[:multiple] = 'multiple' if multiple\n args[:size] = (size || values.count || 1).to_i\n args[:name] = multiple ? \"#{name}[]\" : name\n args = args.merge(:id => id)\n\n # Retrieve the selected value\n has_selected, selected = args.key?(:selected), args[:selected]\n selected = [selected] if !selected.is_a?(Array)\n args.delete(:selected)\n\n @g.p do\n label_for(id, label, name)\n @g.select args do\n values.each do |value, o_name|\n o_name ||= value\n o_args = {:value => value}\n \n if has_selected and selected.include?(value)\n o_args[:selected] = 'selected'\n end\n \n @g.option(o_args){ o_name }\n end\n end\n end\n end", "def fields_for(record_or_name_or_array, *args, &block) #:nodoc:\n opts = args.extract_options!\n opts.merge!(:builder => Transit::Builders::FormBuilder)\n args.push(opts)\n super(record_or_name_or_array, *args, &block)\n end", "def label_tag(name = nil, content_or_options = nil, options = nil, &block)\n if block_given? && content_or_options.is_a?(Hash)\n options = content_or_options = content_or_options.stringify_keys\n else\n options ||= {}\n options = options.stringify_keys\n end\n options[\"for\"] = sanitize_to_id(name) unless name.blank? || options.has_key?(\"for\")\n content_tag :label, content_or_options || name.to_s.humanize, options, &block\n end", "def combobox_tag(name, options, opts= {})\n @template.content_tag(:input, :name => \"findpost[\"+sanitize_to_id(name)+\"]\", :placeholder => \"ENGL\", :maxlength => 4, :style => \"width: 55px;\", :type => \"text\", :list => opts[:list_id]) do\n content_tag(:datalist, :id => opts[:list_id]) {options}\n end \n end", "def tag(type, attr={}, children=[], &block)\n tag = _tag(type, attr, children)\n if block\n capture(block) do\n emit(serialize_open(tag))\n Array(tag.children).each{|c| emit(c)}\n yield self\n emit(serialize_close(tag))\n end\n else\n tag\n end\n end", "def parse_options_and_selects!\n\n #field :field_value, :type => Object, :default => nil\n #field :select_options, :type => Array, :default => nil\n\n if params[:option].present?\n params[:file_metadata_schema][:field_value] = params[:option]\n end\n\n if params[:value].present?\n values = Array.new\n params[:value].each_with_index do |v,i|\n values << Hash[:value => v[1], :selected => is_selected?(i)]\n end\n params[:file_metadata_schema][:select_options] = values\n end\n \n end", "def advanced_field_select_option(blacklight_config, index, _par = params)\n index = index.to_s\n field_list = blacklight_config.search_fields.map do |field_key, field|\n [field.label, field_key]\n end\n\n # omit the \"select\" message, just default to \"any field\"\n # field_list = [[\"Select a field...\", \"\"]] | field_list\n\n default_value = params['adv'] &&\n params['adv'][index] &&\n (!params['adv'][index]['value'].to_s.empty? &&\n params['adv'][index]['field'])\n default_value ||= 'all_fields'\n select_tag(\"adv[#{index}][field]\", options_for_select(field_list, default_value), class: 'form-control')\n end", "def render\n return ro_standard if @readonly\n\n set_initial_value('html','selected')\n # separate options and html part\n options_part = {}\n @yaml['html'].symbolize_keys!\n %i(selected include_blank).each { |sym| options_part[sym] = @yaml['html'].delete(sym) if @yaml['html'][sym] }\n @yaml['html'][:multiple] = true if @yaml['multiple']\n\n record = record_text_for(@yaml['name'])\n if @yaml['html'][:multiple]\n @html << @parent.select(record, @yaml['name'], get_choices, options_part, @yaml['html'])\n @js << \"$('##{record}_#{@yaml['name']}').selectMultiple();\"\n else\n @html << @parent.select(record, @yaml['name'], get_choices, options_part, @yaml['html'])\n # add code for view more data\n @html << add_view_code() if @yaml['view']\n end\n self\nend", "def format_select\n t = super\n children = [t.children.select{|o| o.attr[:selected]}.map(&:children).join(', ')] if t.children\n tag(:span, {}, children)\n end", "def generate_codebook_time_series_group_option(group)\n cls = group.parent_id.present? ? 'subgroup' : 'group'\n content = 'data-content=\\'<span>' + group.title + '</span><span class=\"right-icons\">'\n desc = group.description.present? ? group.description : I18n.t('app.msgs.jumpto_group')\n if group.parent_id.present?\n content << subgroup_icon(desc)\n else\n content << group_icon(desc)\n end\n content << '</span>\\''\n\n return \"<option value='#{group.id}' class='#{cls}' #{content}>#{group.title}</option>\"\n end", "def inputs_for_nested_attributes(*args, &block) #:nodoc:\n options = args.extract_options!\n args << options.merge!(:parent => { :builder => self, :for => options[:for] })\n\n fields_for_block = if block_given?\n raise ArgumentError, 'You gave :for option with a block to inputs method, ' <<\n 'but the block does not accept any argument.' if block.arity <= 0\n lambda do |f|\n contents = f.inputs(*args){ block.call(f) }\n template.concat(contents)\n end\n else\n lambda do |f|\n contents = f.inputs(*args)\n template.concat(contents)\n end\n end\n\n fields_for_args = [options.delete(:for), options.delete(:for_options) || {}].flatten\n semantic_fields_for(*fields_for_args, &fields_for_block)\n end", "def dropdown_input(friendly_name, name, dropdown_elements, has_empty_element, default_element=-1)\n @options_string = has_empty_element ? \"<option></option>\" : \"\"\n for i in 0..(dropdown_elements.length-1)\n @options_string += \"<option value='#{dropdown_elements[i]}'\" + (i == default_element ? \"selected=\\\"selected\\\"\" : \"\") + \">\" + dropdown_elements[i].to_s + \"</option>\"\n end\n \"<div class=\\\"input-group\\\">\n <span class=\\\"input-group-addon\\\" id=\\\"basic-addon-#{name}\\\">#{friendly_name}</span>\n <select class=\\\"form-control\\\" name=\\\"#{name}\\\">\" + @options_string + \"</select>\n </div>\"\n end", "def nested_select(object, method, collection, options = {}, html_options = {})\n choices = nested_as_options(collection) { |record| [\"#{@indent} #{record.name}\", record.id] }\n select(object, method, choices, options, html_options)\n end", "def build_field_options(value, _index)\n options = input_html_options.dup\n\n options[:value] = value\n if @rendered_first_element\n options[:id] = nil\n options[:required] = nil\n else\n options[:id] ||= input_dom_id\n end\n options[:class] ||= []\n options[:class] += [\"#{input_dom_id} form-control multi-text-field\"]\n options[:'aria-labelledby'] = label_id\n @rendered_first_element = true\n\n options\n end", "def tag(*a, &block)\n form._tag(*a, &block)\n end", "def label_for_field(field, options = {})\n return ''.html_safe if options.delete(:no_label)\n text = ''\n text += yield if block_given?\n text += options[:label].is_a?(Symbol) ? l(options[:label]) : options[:label] if options[:label]\n text += @template.t(field.to_s, :scope => [:activerecord, :attributes, object_name.underscore]) unless options[:label]\n @template.content_tag(:label, text.html_safe,\n :class => (block_given? ? \"checkbox \" : \"control-label \").to_s + (@object && @object.errors[field].present? ? \"error\" : nil).to_s,\n :for => (@object_name.to_s.gsub(/[\\[\\]]/,'_') + \"_\" + field.to_s).gsub(/__/, '_'))\n end", "def lm_fields_for(name, *args, &block)\n raise ArgumentError, \"Missing block\" unless block_given?\n options = args.last.is_a?(Hash) ? args.pop : {}\n options = options.merge(:builder => LMFormBuilder)\n object = args.first\n yield((options[:builder] || FormBuilder).new(name, object, self, options, block))\n end", "def label_html_for(attr, text, options = {}, &block)\n return nil unless text\n return @template.content_tag :label, text, options if attr.nil?\n options[:class] ||= ''\n options[:class] << ' is-invalid-label' if object.errors[attr].any?\n label attr, text, options, &block\n end", "def select(method, choices, options = { }, html_options = { }) \n label_text = options.delete(:label)\n label_text += \"*\" if attr_required?(method)\n @template.content_tag(:div, :class => \"inline-input-field\") do\n label(method, label_text) +\n super +\n error_html(method)\n end\n end", "def association_ajax_select_tag(id, record, reflection)\n if reflection.klass.scaffold_use_auto_complete\n scaffold_text_field_tag_with_auto_complete(id, reflection.klass)\n else\n singular_class = record.class\n foreign_key = reflection.options[:foreign_key] || singular_class.table_name.classify.foreign_key\n association_foreign_key = reflection.options[:association_foreign_key] || reflection.klass.table_name.classify.foreign_key\n join_table = reflection.options[:join_table] || ( singular_class.table_name < reflection.klass.table_name ? '#{singular_class.table_name}_#{reflection.klass.table_name}' : '#{reflection.klass.table_name}_#{singular_class.table_name}')\n items = reflection.klass.find(:all, :order => reflection.klass.scaffold_select_order, :conditions =>[\"#{reflection.klass.table_name}.#{reflection.klass.primary_key} NOT IN (SELECT #{association_foreign_key} FROM #{join_table} WHERE #{join_table}.#{foreign_key} = ?)\", record.id], :include=>reflection.klass.scaffold_include)\n select_tag(id, \"<option></option>\" << items.collect{|item| \"<option value='#{item.id}' id='#{id}_#{item.id}'>#{h item.scaffold_name}</option>\"}.join(\"\\n\"))\n end\n end", "def content_tag_with_block(name, content_or_options_with_block=nil,options={})\n if block_given?\n options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)\n content_tag_without_block(name, yield, options)\n else\n content_tag_without_block(name, content_or_options_with_block, options)\n end\n end", "def select_with_name(val)\n option_locator = \"label=regexi:^#{val}$\"\n @driver.sc_select(:view, option_locator, self.abs_path)\n stall :select\n end", "def on_html_attrs(*attrs)\n if attrs.any? { |attr| splat?(attr) }\n builder, block = make_builder(attrs)\n [:multi,\n block,\n [:dynamic, \"#{builder}.build_attrs\"]]\n else\n super\n end\n end", "def nacho_select_tag(name, choices = nil, options = {}, html_options = {})\n nacho_options = build_options(name, choices, options, html_options)\n select_element = select_tag(name, options_for_select(nacho_options[:choices]), nacho_options[:options], nacho_options[:html_options])\n select_element += nacho_options[:button] if nacho_options[:html_options][:multiple]\n\n select_element\n end", "def create_select_options(choice, collection, options={})\n options[:text] ||= 'name'\n options[:value] ||= 'id'\n options[:include_blank] = true if options[:include_blank].nil?\n options[:clear] ||= []\n pre = options[:include_blank] ? \"<option value=\"\">\"\"</option>\" : \"\"\n collection.each { |c| pre << \"<option value=#{c.send(options[:value])} #{\"selected=\\\"selected\\\"\" if choice == c.send(options[:value])}>#{c.send(options[:text])}</option>\" }\n pre\n end", "def on_html_tag(name, attrs, content = nil)\n return super if name != '*'\n builder, block = make_builder(attrs[2..-1])\n if content\n [:multi,\n block,\n [:slim, :output, false,\n \"#{builder}.build_tag #{empty_exp?(content) ? '{}' : 'do'}\",\n compile(content)]]\n else\n [:multi,\n block,\n [:dynamic, \"#{builder}.build_tag\"]]\n end\n end", "def ui_split_dropdown(name, options = nil, html_options = nil, &block)\n UiBibz::Ui::Core::Forms::Dropdowns::SplitDropdown.new(name, options, html_options).tap(&block).render\n end", "def association_select_tag(record, association)\n reflection = record.camelize.constantize.reflect_on_association(association)\n foreign_key = reflection.options[:foreign_key] || reflection.klass.table_name.classify.foreign_key\n if reflection.klass.scaffold_use_auto_complete\n scaffold_text_field_with_auto_complete(record, foreign_key, reflection.klass.name.underscore)\n else\n items = reflection.klass.find(:all, :order => reflection.klass.scaffold_select_order, :conditions => reflection.klass.interpolate_conditions(reflection.options[:conditions]), :include=>reflection.klass.scaffold_include)\n select(record, foreign_key, items.collect{|i| [i.scaffold_name, i.id]}, {:include_blank=>true})\n end\n end", "def build_options_and_select(type, selected, options = {})\n build_select(type, build_options(selected, options))\n end", "def bp_group options, &block\n label = options[:label].blank? ? \"\" : options[:label]\n id = options[:id].blank? ? \"\" : options[:id]\n style = options[:style].blank? ? \"\" : options[:style]\n\n out = content_tag :li, :class => bp_class(\"group #{options[:class]}\"), :id => \"#{id}\", :style => style do\n content_tag :fieldset do\n fieldset = label.blank? ? \"\" : content_tag(:legend, label, :class => \"label\")\n fieldset += content_tag(:ol, capture(&block))\n fieldset.html_safe\n end\n end\n\n bp_html_print out\n end", "def render_search_dropdown(search_fields)\n content_tag(:ul, class: 'dropdown-menu', id: 'js_search_type') do\n search_fields.each do |key, value|\n # FIXME: It sould not be necessary to camelcase anything here, since the fieldname is all_fields and date_issued - but somewhere the keys gets translated/labeled\n key = key.gsub(/\\s+/, \"\").camelize(:lower) # FIXME: This is part of the uneven translation thing we need to look into\n concat(content_tag(:li, content_tag(:a, t('kb.search.limit.' + key), {href: '#'}), {id: value}))\n end\n end\n end", "def select(&block)\n scope.select(*build_attributes(true, &block))\n end", "def day_sequenced_form_column(record, input_name)\n select_tag(input_name, options_for_select(DD, record.collected_on_day))\n end", "def field_set_tag(legend = T.unsafe(nil), options = T.unsafe(nil), &block); end", "def render_field_block(f, klass, attribute, field_method, field_options)\n render :partial => 'shared/form_field',\n :locals => {f: f, klass: klass, attr: attribute, type: field_method, opts: field_options}\n end", "def build_options(node)\n options = {}\n node.elements.each(\"option\") do |option|\n options[attr(option, :name)] = attr(option, :value)\n end\n options\n end", "def build_language_autocomplete(val)\n options = {\n value: val,\n name: autocomplete_name,\n placeholder: autocomplete_placeholder,\n class: 'form-control',\n data: {\n 'autocomplete-url': '/authorities/search/language',\n 'autocomplete': 'language-label'\n }\n }\n\n @builder.text_field(\"#{attribute_name}_language\", options)\n end", "def semantic_fieldset_tag(name=nil, options={}, &block)\n concat(tag(:fieldset, options, true))\n concat(content_tag(:legend, name)) if name\n concat(tag(:dl, { :class => 'semantic-form' }, true))\n yield FieldsRenderer.new(self) # yield the field renderer\n concat(\"</dl>\")\n concat(\"</fieldset>\")\n end", "def select_with_grouped_options(object, method, choices, selected_key = nil, prompt = nil)\n name = object.class.name.downcase\n html = \"<select id=\\\"#{name}_#{method}\\\" name=\\\"#{name}[#{method}]\\\">\"\n html += grouped_options_for_select(choices, selected_key, prompt)\n html += \"</select>\"\n end", "def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end", "def form_tr_select_cat_from_tree(form, obj, root, name, col, id, display_name, selected_obj, *args)\n options = args.extract_options!\n out = ''\n out += '<tr><td class=\"label\">'\n out += form.label col.to_sym, name\n out += ' : </td>'\n out += '<td class=\"field\">'\n out += select_cat_from_tree(obj, col, root, selected_obj, options)\n out += '</td></tr>'\n return out\n end", "def indent_child_options_for_category_select(parent, category, child_indent = \"&nbsp;&nbsp;&nbsp;\")\n html_code = \"\"\n parent.children.each do |child|\n options = {:value => child.id}\n options = options.merge({:selected=>\"selected\"}) if child == category\n html_code += tag(\"option\", options, true) + child_indent + child.name + \"</option>\" + indent_child_options_for_category_select(child, category, child_indent + child_indent)\n end\n html_code\n end" ]
[ "0.63471705", "0.60647494", "0.56057066", "0.5558431", "0.5557816", "0.5530677", "0.5378787", "0.5273259", "0.52455086", "0.5243248", "0.5215386", "0.5209045", "0.5202424", "0.5189559", "0.51645595", "0.5159746", "0.5155336", "0.5130471", "0.511608", "0.51103425", "0.5072829", "0.50708073", "0.50640595", "0.50542825", "0.5053516", "0.5037646", "0.50349456", "0.5028888", "0.50017786", "0.4998135", "0.49500793", "0.49362546", "0.48899058", "0.4864996", "0.48515853", "0.48453927", "0.48302406", "0.48146632", "0.480253", "0.47946954", "0.47918582", "0.4790731", "0.47893712", "0.478633", "0.47847307", "0.4762652", "0.4762124", "0.47547925", "0.47541726", "0.4748111", "0.47426918", "0.47420692", "0.47309458", "0.47299635", "0.47282806", "0.47280645", "0.47188446", "0.47106287", "0.47031975", "0.4701393", "0.4693941", "0.46899548", "0.4683441", "0.46776944", "0.46774438", "0.4668526", "0.46672451", "0.46669126", "0.4665845", "0.46643984", "0.46533844", "0.46492893", "0.46481472", "0.46469414", "0.4646409", "0.4635954", "0.46256983", "0.462566", "0.46216837", "0.46193036", "0.4610457", "0.46081316", "0.46035835", "0.45940655", "0.45846242", "0.45810398", "0.45655492", "0.4559918", "0.45568728", "0.4555302", "0.4534098", "0.45296448", "0.4522325", "0.45221344", "0.45215216", "0.45213345", "0.44997", "0.44933328", "0.44775727", "0.44754142" ]
0.589055
2
this will be replaced by adding the ability to add workflow packages by workflow through the ui
def create_workflow_packages workflow = Workflow.find_by(name: 'Agile Acquisition Workflow', package_name: 'Solicitation') package = WorkflowPackage.create!(name: 'My First Solicitation Package', user: self, workflow: workflow) WorkflowStep.where(workflow: workflow).each do |wfs| WorkflowStepPackage.create!(user: self, workflow_step: wfs, workflow_package: package) unless WorkflowStepPackage.find_by(user: self, workflow_step: wfs, workflow_package: package).present? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def workflow\n end", "def before_package_create(package)\n end", "def before_package_create(package)\n end", "def handle_package_set_add\n if package_set\n order = cart_manager.order(shop: package_set.shop)\n order_maker = OrderMaker.new(identity_solver, order)\n add = order_maker.package_set(package_set).refresh!(1, increment: true)\n if add.success?\n cart_manager.store(order)\n end\n end\n end", "def create\n @package = Package.new(package_params)\n add_items\n \n respond_to do |format|\n if @package.save\n \n format.html { redirect_to @package, notice: 'Package was successfully created.' }\n format.json { render action: 'show', status: :created, location: @package }\n else\n format.html { render action: 'new' }\n format.json { render json: @package.errors, status: :unprocessable_entity }\n end\n end\n end", "def after_package_create(package)\n end", "def after_package_create(package)\n end", "def install\n \n end", "def packages()\n\t\t\tend", "def packages; end", "def action_install\n run_package_action(:install)\n end", "def action_install\n grunt_package.run_action(:install)\n wh_package.run_action(:install)\n new_resource.installed = true\n end", "def install\n end", "def install\n end", "def before_workflow_launch(workflow, user)\n #raise \"Must implement in target model!\"\n end", "def installed_packages()\n\t\t\tend", "def setup_new_package(package_name, parent_ids=[])\n package_id, definition = add_package(package_name, parent_ids)\n\n # update current package id\n set(current_package_id: package_id, current_definition: definition)\n end", "def action_before_deploy\n install_packages\n end", "def create_package( package_name, is_public=true )\n page = \"/frs/admin/\"\n\n form = {\n \"func\" => \"add_package\",\n \"group_id\" => group_id,\n \"package_name\" => package_name,\n \"is_public\" => (is_public ? 1 : 0),\n \"submit\" => \"Create This Package\"\n }\n\n http_post(page, form)\n end", "def setup\n super\n handle_packages\n end", "def doit\n puts \"\\nadd user to ALL workflows\"\n netid = ask('Netid ? ')\n\n p = DEPerson.find(netid)\n\n if !p\n puts \"no such account #{netid}\"\n else\n DSpace.login DConstants::LOGIN\n create_tasks p\n if 'Y' == ask('Commit changes: Yes or No (Y/N) ')\n DSpace.commit\n else\n DSpace.context_renew\n end\n end\n doit\nend", "def create\n @mathematica_package = MathematicaPackage.new(mathematica_package_params)\n repo=\"#{@mathematica_package.owner}/#{@mathematica_package.repository}\"\n flag=Octokit.repository?(repo)\n @mathematica_package.description = Octokit.repository(repo)['description'] if flag\n flash[:alert]= \"Repository not found #{repo}\" if !flag\n respond_to do |format|\n if flag and @mathematica_package.save \n format.html { redirect_to @mathematica_package, notice: 'Mathematica package was successfully created.' }\n format.json { render :show, status: :created, location: @mathematica_package }\n else\n format.html { render :new }\n format.json { render json: @mathematica_package.errors, status: :unprocessable_entity }\n end\n end\n end", "def action_package(type)\n name = prompt('Name : ')\n dest = Automation::Converter.to_unix_path(prompt('Destination : '))\n require REQUIRE_MAP[type] % {name: name}\n\n raise Automation::ConsoleError.new(\"No definition found for package '#{name}'\") unless PACKAGE_CLASS.has_key?(name)\n plugin = PACKAGE_CLASS[name].new\n plugin.package(dest)\n puts \"Packaged '#{type}' - #{plugin.name}\"\n end", "def install\n end", "def ingest_stix_package(uploaded_file, skip_validations, lst, user, to_save)\n do_not_create_package = nil\n lst.each do |rpt|\n obs_wo_inds = rpt['observables_without_indicators']\n pkg = StixPackage.ingest(uploaded_file, rpt, user) # Package (Top-Level)\n return if pkg.blank?\n if pkg.short_description == '##--DO-NOT-CREATE-PACKAGE--##'\n do_not_create_package = true\n pkg = {} # Instead of setting to nil, create a Hash to serve as a\n # dummy container for passing uploaded_kill_chains. Check the class\n # type and/or the do_not_create_package flag as appropriate to\n # ensure that operations proceed approprately below.\n else\n pkg.uploaded_file_id = uploaded_file.guid\n pkg.is_upload = true\n skip_validations << pkg\n to_save << pkg\n end\n if rpt.kill_chains.present?\n uploaded_kill_chains = []\n rpt.kill_chains.each do |i|\n k = KillChain.ingest(uploaded_file, i) # KillChain -------\n unless k.nil?\n # Temporarily store kill chains for later use\n uploaded_kill_chains << k\n to_save << k\n end\n end\n if do_not_create_package\n # Add uploaded_kill_chains to the dummy package hash.\n pkg[:uploaded_kill_chains] = uploaded_kill_chains\n else\n # Add uploaded_kill_chains to the StixPackage via the accessor.\n pkg.uploaded_kill_chains = uploaded_kill_chains\n end\n end\n # Contributing Source, MUST BE BEFORE STIX MARKING\n if rpt.contributing_sources.present? && !do_not_create_package\n # If the package was not created because of the\n # do_not_create_package flag, skip ingestion of contributing\n # sources since the ingest method will return immediately if the\n # pkg parameter is nil.\n rpt.contributing_sources.each do |i|\n s = ContributingSource.ingest(uploaded_file,i,pkg)\n unless s.nil?\n to_save << s\n pkg.contributing_sources << s\n end\n end\n end\n if rpt.markings.present? && !do_not_create_package\n # If the package was not created because of the\n # do_not_create_package flag, skip ingestion of markings since the\n # ingest method will return immediately if the pkg parameter is nil.\n rpt.markings.each do |i|\n m = StixMarking.ingest(uploaded_file, i, pkg) # Marking ---------\n if m.present? && m.valid?\n to_save << m\n else\n IngestUtilities.add_error(uploaded_file, \"#{m.errors.full_messages.first}\")\n end\n end\n end\n # Make sure the associated STIX_ID gets stored, so everything is linked\n if pkg.present? && pkg.class == StixPackage\n oi = OriginalInput.where(\"uploaded_file_id = ? and input_category <> 'SOURCE'\", uploaded_file.guid).first\n oi.update_attribute(:remote_object_id, pkg.stix_id)\n oi.update_attribute(:remote_object_type, pkg.class.to_s)\n end\n # course_of_actions\n if rpt.course_of_actions.present?\n rpt.course_of_actions.each do |c|\n self.ingest_course_of_action(uploaded_file, skip_validations, c, user, pkg, to_save)\n end # --- course_of_actions.each\n end # --- course_of_actions.present?\n # exploit_targets\n if rpt.exploit_targets.present?\n rpt.exploit_targets.each do |e|\n self.ingest_exploit_target(uploaded_file, skip_validations, e, user, pkg, to_save)\n end\n end\n # ttps\n if rpt.ttps.present?\n rpt.ttps.each do |t|\n self.ingest_ttp(uploaded_file, skip_validations, t, user, pkg, to_save)\n end\n end\n if rpt.indicators.present?\n all_indicators = []\n rpt.indicators.each do |i|\n self.ingest_stix_indicator(uploaded_file, skip_validations, i, user, pkg, to_save) # Indicator\n end # --- Indicators.each\n # Get the list of indicators\n to_save.each do |e|\n all_indicators << e if e.class == Indicator\n end\n # Now that we have all of the indicators created, we need to\n # see if there are any related indicators to match up\n begin\n rpt.indicators.each do |i|\n if self.read_only || (Setting.CLASSIFICATION == true && self.overwrite)\n next unless to_save.select {|x| x.class == Indicator}.collect(&:stix_id).include?(i.stix_id + Setting.READ_ONLY_EXT)\n else\n next unless to_save.select {|x| x.class == Indicator}.collect(&:stix_id).include?(i.stix_id)\n end\n if i.related_indicators.present?\n i.related_indicators.each do |x|\n if self.read_only || (Setting.CLASSIFICATION == true && self.overwrite)\n ind = all_indicators[all_indicators.find_index{|ai| ai.stix_id == i.stix_id + Setting.READ_ONLY_EXT}]\n rind = all_indicators[all_indicators.find_index{|ai| ai.stix_id == x.indicator + Setting.READ_ONLY_EXT}]\n else\n ind = all_indicators[all_indicators.find_index{|ai| ai.stix_id == i.stix_id}]\n rind = all_indicators[all_indicators.find_index{|ai| ai.stix_id == x.indicator}]\n end\n # Relationships have more moving pieces to deal with, so the \"parent\"\n # we're passing in is really a hash.\n r = Relationship.ingest(uploaded_file, x, { parent_indicator: ind,\n child_indicator: rind })\n to_save << r unless r.nil?\n end\n end\n end\n rescue\n # Continue onward if the relationships don't load\n end\n end # --- Indicators.present?\n if obs_wo_inds.any?\n obs_wo_inds.each do |observ|\n self.ingest_observable(uploaded_file, skip_validations, observ, \"Observable\", pkg, to_save)\n end # --- Observable.present?\n end\n end # --- Packages.each\n do_not_create_package\n end", "def install(pkg)\n package pkg do\n action :install\n end\nend", "def workflow=(value)\n @workflow = value\n end", "def workflow\r\n if @openstudio_2\r\n super\r\n else\r\n @workflow\r\n end\r\n end", "def set_work_package\n @work_package = WorkPackage.find(params[:id])\n end", "def build\n @model.custom_package? ? custom_package : standard_package\n end", "def packages\n # implement inside child\n end", "def metapackage(name, *packages)\n Autoproj.workspace.manifest.metapackage(name, *packages)\nend", "def action_install\n remote_file.run_action(:create)\n package.run_action(:install)\n new_resource.installed = true\n end", "def install\n end", "def package_selected?(name)\n Autoproj.workspace.manifest.package_selected?(name, false)\nend", "def create\n # authorize! :manage, @packages , :message => \"Access denied.\"\n @package = @product.packages.new(package_params)\n\n respond_to do |format|\n if @package.save\n format.html { redirect_to [@package.product, @package], notice: 'Package was successfully created.' }\n format.json { render :show, status: :created, location: @package }\n else\n format.html { render :new }\n format.json { render json: @package.errors, status: :unprocessable_entity }\n end\n end\n end", "def install\n # nothing to do\n end", "def set_workpackage\n @workpackage = Workpackage.find(params[:id])\n end", "def set_workpackage\n @workpackage = Workpackage.find(params[:id])\n end", "def workflow\n []\n end", "def workflow\n []\n end", "def create_manifests_node\n Bebox::Provision.add_node_to_step_manifests(self.project_root, self)\n end", "def tailor_package_to_platform\n @package.app('Dropbox')\n @package.volumes_dir('Dropbox Installer')\n @package.source(URI.encode(\"file://#{download_dest}\"))\n end", "def new\n @pagetitle = \"New package\"\n @package = Package.new\n end", "def HandleProposalPackages\n #Use PackagesProposal to ensure that package selection\n #does not get reset by this module (#433001)\n Yast.import \"PackagesProposal\"\n\n proposal_ID = \"storage_proposal\"\n pkgs = AddPackageList()\n\n #Set rather than Add, there might be some packs left over\n #from previous 'MakeProposal' we don't need now\n #This also covers the case when AddPackagesList returns [] or nil\n if !PackagesProposal.SetResolvables(proposal_ID, :package, pkgs)\n Builtins.y2error(\n \"PackagesProposal::SetResolvables() for %1 failed\",\n pkgs\n )\n Report.Error(\n Builtins.sformat(\n _(\"Adding the following resolvables failed: %1\"),\n pkgs\n )\n )\n end\n\n SaveUsedFs() if Stage.initial\n Pkg.PkgSolve(true)\n\n nil\n end", "def toolbox(type)\n end", "def toolbox(type)\n end", "def toolbox(type)\n end", "def workflow_params\n params.require(:workflow).permit(:title, :description, :user_id, :workflow_content, :doi,\n :remote_created_date, :remote_updated_date, { keywords: [] },\n { scientific_topic_names: [] }, { scientific_topic_uris: [] }, :licence,\n :difficulty_level, { contributors: [] }, { authors: [] }, { target_audience: [] },\n :hide_child_nodes, :public)\n end", "def package(name)\n Packaged.instance self , name\n end", "def add_package_set_to_layout(package_set)\n validate_package_set_in_self(package_set)\n add_metapackage_to_layout(package_set.metapackage)\n end", "def add_to_library\n self.button(:text=>\"Add to library\").click\n self.wait_until { self.text.include? \"Save to\" }\n self.class.class_eval { include SaveContentPopUp }\n end", "def action_install(type)\n from = Automation::Converter.to_unix_path(prompt('Install from : '))\n package_rb = File.join(from, 'package.rb')\n require package_rb\n\n raise Automation::ConsoleError.new(\"No definition found for package '#{package_rb}'\") unless PACKAGE_CLASS.has_key?(package_rb)\n plugin = PACKAGE_CLASS[package_rb].new\n plugin.install(from)\n puts \"Installed '#{type}' - #{plugin.name}\"\n end", "def create\n @package = Package.new(params[:package])\n cleanup_package_name(@package.name)\n\n @package.created_by = current_user.id\n @package.updated_by = current_user.id\n\n @package.tags = process_tags(params[:tags], params[:package][:task_id])\n\n respond_to do |format|\n if @package.save\n expire_all_fragments\n flash[:notice] = 'Package was successfully created.'\n\n if Rails.env.production?\n url = get_package_link(params, @package, :create)\n\n if Setting.activated?(@package.task, Setting::ACTIONS[:created])\n Notify::Package.create(current_user, url, @package, Setting.all_recipients_of_package(@package, nil, :create))\n end\n\n unless params[:div_package_create_notification_area].blank?\n Notify::Package.create(current_user, url, @package, params[:div_package_create_notification_area])\n end\n end\n\n format.html { redirect_to(:controller => :packages, :action => :show,\n :id => escape_url(@package.name), :task_id => escape_url(@package.task.name), :user => params[:user]) }\n else\n\n @user = params[:user]\n format.html { render :action => :new }\n end\n end\n end", "def create\n @work_package = WorkPackage.new(work_package_params)\n\n respond_to do |format|\n if @work_package.save\n format.html { redirect_to @work_package, notice: 'Work package was successfully created.' }\n format.json { render :show, status: :created, location: @work_package }\n else\n format.html { render :new }\n format.json { render json: @work_package.errors, status: :unprocessable_entity }\n end\n end\n end", "def install_message; end", "def install_packages(app)\n\n `installer -pkg \"#{app}\" -target /`\n\nend", "def create\n api_service = Api.find_by(status: true).name\n result_hash = RouteCalculator.call(package_params.merge(service: api_service))\n @package = current_user.packages.new(result_hash.merge(package_params))\n \n respond_to do |format|\n if @package.save\n format.html { redirect_to @package, notice: \"Package was successfully created.\" }\n format.json { render :show, status: :created, location: @package }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @package.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_package\n @package = Package.find(params[:package_id])\n end", "def new\n @package = current_user.packages.new\n #@package.package_pois.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @package }\n end\n end", "def create\n @workpackage = Workpackage.new(workpackage_params)\n if @workpackage.parent\n @workpackage.level = @workpackage.parent.level + 1\n else\n @workpackage.level = 0\n end\n\n respond_to do |format|\n if @workpackage.save\n format.html { redirect_to @workpackage, notice: 'Workpackage was successfully created.' }\n format.json { render :show, status: :created, location: @workpackage }\n else\n format.html { render :new }\n format.json { render json: @workpackage.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_workflow(new_workflow_name)\n\t\t\tensure_hash_has_symbol(self, :_id)\n\n\t\t\tthis_workflow_type=WorkflowTypes.db_get_with_id :_id=>self[:_id]\n\t\t\traise \"Cannot generate workflows for a non-existing workflow type - have you committed this workflow type to db yet?\" if this_workflow_type.nil?\n\n\t\t\twf=Workflowz.new\n\t\t\twf.update :_id=>new_workflow_name, :type=>self[:_id]\n\t\t\twf\n\t\tend", "def set_package\n @package = @product.packages.friendly.find(params[:id])\n end", "def install(context={})\n \n SystemConfiguration::Variable.first_or_create({:name => 'cms.author_url'},\n {:value => '/profile/%s', :description => 'author url. Example /profile/%s', :module => :cms})\n\n SystemConfiguration::Variable.first_or_create({:name => 'cms.comments.pager'},\n {:value => 'page_list', :description => 'comments pager', :module => :cms})\n\n SystemConfiguration::Variable.first_or_create({:name => 'cms.comments.page_size'},\n {:value => '10', :description => 'comments page size', :module => :cms})\n\n SystemConfiguration::Variable.first_or_create({:name => 'cms.templates.page_size'},\n {:value => '20', :description => 'templates page size', :module => :cms})\n\n ContentManagerSystem::ContentType.first_or_create({:id => 'page'},\n {:name => 'Pagina', :description => 'Representa una página web. Es una forma sencilla de gestionar información que no suele cambiar como la página acerca de o condiciones. Suelen mostrarse en el menú.'})\n \n ContentManagerSystem::ContentType.first_or_create({:id => 'story'},\n {:name => 'Articulo', :description => 'Tiene una estructura similar a la página y permite crear y mostrar contenido que informa a los visitantes del sitio. Notas de prensa, anuncios o entradas informales de blog son creadas como páginas.'})\n\n ContentManagerSystem::ContentType.first_or_create({:id => 'fragment'},\n {:name => 'Fragmento', :description => 'Representan bloques de información que se pueden mostrar en diferentes páginas. Banners son creados como fragmentos.'})\n\n SystemConfiguration::Variable.first_or_create({:name => 'cms.force_trailing_slash'},\n {:value => 'false', :description => 'Force trailing slash in urls', :module => :cms})\n \n Site::Menu.first_or_create({:name => 'primary_links'},\n {:title => 'Primary links menus', :description => 'Primary links menu'})\n\n Site::Menu.first_or_create({:name => 'secondary_links'},\n {:title => 'Secondary links menu', :description => 'Secondary links menu'})\n\n Site::Menu.first_or_create({:name => 'members'},\n {:title => 'Members menu', :description => 'Members menu'})\n\n Users::Group.first_or_create({:group => 'editor'},\n {:name => 'Editor', :description => 'Web content editor'})\n\n SystemConfiguration::Variable.first_or_create({:name => 'site.editor_front_page'},\n {:value => '', \n :description => 'Editor front page (dashboard)', \n :module => :cms})\n\n Users::Group.first_or_create({:group => 'webmaster'},\n {:name => 'Webmaster', :description => 'Webmaster'})\n\n SystemConfiguration::Variable.first_or_create({:name => 'site.webmaster_front_page'},\n {:value => '', \n :description => 'Webmaster front page (dashboard)', \n :module => :cms})\n\n\n ContentManagerSystem::View.first_or_create({:view_name => 'stories'},\n {\n :description => 'Published stories',\n :model_name => 'content',\n :query_conditions => {:operator => '$and', :conditions => [\n {:field => 'type', :operator => '$eq', :value => 'story'},\n {:field => 'publishing_state_id', :operator => '$eq', :value => 'PUBLISHED'}\n ]},\n :query_order => [{:field => 'publishing_date', :order => :desc}],\n :query_arguments => [],\n :style => :teaser,\n :v_fields => [],\n :render => :div,\n :render_options => {},\n :view_limit => 0,\n :pagination => true,\n :ajax_pagination => false,\n :page_size => 10,\n :pager => :default,\n :block => false,\n :url => 'stories'\n })\n \n ContentManagerSystem::View.first_or_create({:view_name => 'last_stories'},\n {\n :description => 'Last published stories',\n :model_name => 'content',\n :query_conditions => {:operator => '$and', :conditions => [\n {:field => 'type', :operator => '$eq', :value => 'story'},\n {:field => 'publishing_state_id', :operator => '$eq', :value => 'PUBLISHED'}\n ]},\n :query_order => [{:field => 'publishing_date', :order => :desc}],\n :query_arguments => [],\n :style => :fields,\n :v_fields => [\n {:field => 'photo_url_small', :image => true, :link => '#{element.path}', \n :image_alt => '#{element.summary}', :image_class => 'view_div_mini_youtube_img'},\n {:field => 'title', :link => '#{element.path}',\n :class => 'view_div_mini_youtube_title'},\n {:field => 'summary', :class => 'view_div_mini_youtube_body'}\n ],\n :render => :div,\n :render_options => {:container_class => 'view_div_mini_youtube_container',\n :container_element_class => 'view_div_mini_youtube_element'},\n :view_limit => 5,\n :pagination => false,\n :ajax_pagination => false,\n :page_size => 0,\n :pager => :default,\n :block => true\n })\n\n Media::Album.first_or_create({name: 'resources'},\n {description: 'Album for common resources'})\n Media::Album.first_or_create({name: 'content_resources'},\n {description: 'Album for content resources'})\n\n # Sitemap.xml and robots.txt templates\n sitemap_xml = <<-SITEMAP\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n <url>\n <loc>https://mysite.com/</loc>\n <lastmod>2018-11-02T00:24:48+00:00</lastmod>\n <priority>1.00</priority>\n </url>\n</urlset>\n SITEMAP\n\n robots_txt = <<-ROBOTS\n# Rule\nUser-agent: *\nAllow: /\n\nSitemap: http://mysite.com/sitemap.xml \n ROBOTS\n\n ContentManagerSystem::Template.first_or_create({:name => 'sitemap_xml'},\n {description: 'Plantilla para sitemap.xml',\n text: sitemap_xml })\n\n ContentManagerSystem::Template.first_or_create({:name => 'robots_txt'},\n {description: 'Plantilla para robots.txt',\n text: robots_txt})\n\n end", "def create\n @package = Package.new(params[:package])\n @package.show = true\n @package.completed = false\n @package.problem = false\n \n @package.priority = Priority.find(params[:package_priority].to_i)\n # logger.debug @package\n links = []\n @package.s_links.each { |linha| links.push linha.chomp }\n respond_to do |format|\n if @package.save\n # _TODO_: verificar se todos os links foram salvos corretamente, se não mostrar erro!\n links.each do |url|\n Link.create(:package => @package, :url => url)\n end\n flash[:notice] = 'Package was successfully created.'\n format.html { redirect_to(@package) }\n format.xml { render :xml => @package, :status => :created, :location => @package }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @package.errors, :status => :unprocessable_entity }\n end\n end\n end", "def package_params\n params.require(:package).permit(:name, :link, :description, :service_id, :user_id)\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def set_package\n @package = Package.find(params[:id])\n end", "def add( name , options={} , &proc )\n options = name if name.is_a? Hash\n if options[:package]\n package options.delete(:package)\n else\n package self\n end.add( name , options , &proc )\n end", "def create\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id)\n\n tmpl_item = Item.find(params[:select_workflow])\n\n item = tmpl_item.copy(@login_user.id, my_wf_folder.id)\n\n attrs = ActionController::Parameters.new({title: tmpl_item.title + t('msg.colon') + User.get_name(@login_user.id), public: false})\n item.update_attributes(attrs.permit(Item::PERMIT_BASE))\n\n item.workflow.update_attribute(:status, Workflow::STATUS_NOT_ISSUED)\n\n sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id)\n @workflows = Workflow.find_by_sql(sql)\n\n render(:partial => 'ajax_workflow', :layout => false)\n\n rescue => evar\n Log.add_error(request, evar)\n render(:partial => 'ajax_workflow', :layout => false)\n end", "def InstallStack\n\n end", "def create\n @admin_package = Package.new(params[:package])\n\n respond_to do |format|\n if @admin_package.save\n format.html { redirect_to(admin_package_path(@admin_package), :notice => 'Package was successfully created.') }\n format.xml { render :xml => @admin_package, :status => :created, :location => @admin_package }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @admin_package.errors, :status => :unprocessable_entity }\n end\n end\n end", "def action_install\n install_bundler\n run_bundler('install')\n set_state\n end", "def post_install; end", "def work_packages\n respond_to?(:procedureHasWorkPackage) ? procedureHasWorkPackage : []\n end", "def create_workflows_export\n Pundit.policy!(@user, @klass).scope_for(:create_workflows_export)\n end", "def add_package(package)\n [package_handler(File.extname(package).tr(\".\", \"\")).add(content, package)].flatten.compact\n end", "def register_flavored_package_set(package_set)\n package_sets << package_set\n end", "def set_package_item\n @package_item = PackageItem.find(params[:id])\n end", "def install_actions\n return []\n end", "def set_project_type_workflow\n @project_type_workflow = ProjectTypeWorkflow.find(params[:id])\n end", "def generate_package\n if @language_package_service.autograded?\n new_package = @language_package_service.generate_package(@question.attachment)\n @question.file = new_package if new_package.present?\n else\n templates = @language_package_service.submission_templates\n @question.imported_attachment = nil\n @question.import_job_id = nil\n @question.non_autograded_template_files = templates.map do |template|\n Course::Assessment::Question::ProgrammingTemplateFile.new(template)\n end\n end\n end", "def set_workflow\n @workflow = Workflow.find(params[:id])\n end", "def multipackage_resource(new_resource, action)\n package_name_array = package_name.is_a?(Array) ? package_name : package_name.split(\", \")\n version_array = [new_resource.version].flatten if new_resource.version\n if new_resource.per_package_timeout\n total_timeout = new_resource.per_package_timeout *\n package_name_array.count\n end\n package new_resource.name do\n package_name package_name_array\n version version_array if version_array\n options new_resource.options if new_resource.options\n timeout total_timeout if total_timeout\n action action\n end\nend", "def append_node\r\n # Load parent package.\r\n parent_package = ProductPackage.find params[:id], :include => \"product_package_nodes\"\r\n # position = parent_package.product_package_nodes.collect{|node| node.position}.sort.last.nexts\r\n \r\n # Build a child node.\r\n case params[:node_type]\r\n when \"package\"\r\n parent_package.product_package_nodes << ProductPackage.new(:name => params[:new_package_name])\r\n when \"product\"\r\n parent_package.product_package_nodes << ProductPackageProduct.new(:product_id => params[:product_id], :display_style => \"checkbox\")\r\n end\r\n \r\n # Save node and redirect back.\r\n redirect_to :back\r\n end", "def workflow_exists\n errors.add(:workflow, 'is not valid') unless valid_workflow?\n end", "def initialize( *args )\n super\n @action = :install\nend", "def initialize( *args )\n super\n @action = :install\nend", "def mathematica_package_params\n params.require(:mathematica_package).permit(:owner, :repository, :description, :downloads)\n end", "def main\n job1 = OpenGov::Model::Job.new(\"My_Job_1\")\n job2 = OpenGov::Model::Job.new(\"My_Job_2\")\n job3 = OpenGov::Model::Job.new(\"My_Job_3\") \n\n job1.add_dependency(job2, job3)\n job2.add_dependency(job3)\n\n workflow = OpenGov::Model::WorkFlow.new(\"My_Workflow\")\n workflow.register(job1, job2, job3)\n\n workflow.execute\nend", "def needpackage *args\n\t\tpackage *args\n\tend", "def package\n bs_request.bs_request_actions.first.target_package\n end" ]
[ "0.6381666", "0.57877624", "0.57877624", "0.563234", "0.5619007", "0.561347", "0.561347", "0.55591905", "0.5528315", "0.55161864", "0.5505606", "0.5449082", "0.54382867", "0.54382867", "0.5434265", "0.5431292", "0.542181", "0.5391144", "0.5383205", "0.5375659", "0.5367948", "0.53672117", "0.53608066", "0.5347686", "0.5329878", "0.5320724", "0.53046167", "0.5304078", "0.52937657", "0.52645427", "0.5237542", "0.52270114", "0.52239895", "0.5210738", "0.5201771", "0.5196343", "0.519046", "0.5182689", "0.5182689", "0.51664406", "0.51664406", "0.51655793", "0.5161623", "0.5153857", "0.51534736", "0.5134183", "0.5134183", "0.5134183", "0.5124954", "0.51225615", "0.5122387", "0.51159185", "0.5114933", "0.5108375", "0.51014894", "0.5093553", "0.508709", "0.50856847", "0.5080887", "0.50803775", "0.50755787", "0.5068544", "0.5066652", "0.504463", "0.50410306", "0.5031941", "0.5031021", "0.50253934", "0.50253934", "0.50253934", "0.50253934", "0.50253934", "0.50253934", "0.50253934", "0.50253934", "0.50253934", "0.5022064", "0.5018334", "0.5016742", "0.50071955", "0.500556", "0.5003183", "0.50027215", "0.5000173", "0.49994528", "0.49895087", "0.49860752", "0.49852225", "0.4982939", "0.49821222", "0.49789166", "0.49779654", "0.4969554", "0.49644747", "0.49607557", "0.49607557", "0.49545056", "0.49540204", "0.495381", "0.49500778" ]
0.674353
0
override to get user roles in response
def token_validation_response self.as_json(include: :roles, except: [ :tokens, :created_at, :updated_at ]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_roles\n @roles = @user.roles.pluck(:name)\n render json: @roles\n end", "def roles\n response[\"roles\"]\n end", "def roles\n roles_from_users\n end", "def roles\n self.dig_for_array(\"roles\")\n end", "def my_roles(user)\n user.roles & self.design_review_results.collect { |drr| drr.role }\n end", "def pass_on_roles\n r = self.all_roles\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users))\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles))\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users))\n end\n return (r.is_a?(Array) ? r : [r])\n end", "def pass_on_roles\n r = self.all_roles\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users))\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles))\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users))\n end\n return (r.is_a?(Array) ? r : [r])\n end", "def roles\r\n @roles ||= user_roles.map(&:name)\r\n end", "def show\n if can?(:read, User)\n @user = User.find(params[:id])\n @roles = \"\"\n\n @user.roles.each do |role|\n if @roles == \"\"\n @roles += role.name\n else\n @roles += \", \" + role.name\n end\n end\n end\n\n respond_to do |format|\n format.json { render :json => @user }\n format.xml { render :xml => @user }\n format.html \n end\n\n rescue ActiveRecord::RecordNotFound\n respond_to_not_found(:json, :xml, :html)\n end", "def roles\n client.user_roles(id)\n end", "def roles\n client.user_roles(id)\n end", "def pass_on_roles\n r = self.roles.to_a\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users)).to_a\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles)).to_a\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users)).to_a\n end\n return (r.is_a?(Array) ? r : [r])\n end", "def display_all_roles\n # Interface method\n end", "def roles_from_users\n Role.for_resource(self)\n end", "def get_roles_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UserApi.get_roles ...'\n end\n # resource path\n local_var_path = '/api/3/roles'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'ResourcesRole')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UserApi#get_roles\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def roles\n users.map { |item| item['roles'] }.flatten.uniq\n end", "def get_roles_list()\n\n query_parameters = {}\n query_parameters['apiKey'] = @api_key\n query_parameters['apiSecret'] = @api_secret\n\n resource_path = 'identity/v2/manage/role'\n get_request(resource_path, query_parameters, nil)\n end", "def roles\n @users = User.order(\"user_name\").all\n end", "def claims\n get_all_roles\n end", "def claims\n get_all_roles\n end", "def hubssolib_get_user_roles\n user = self.hubssolib_current_user\n user ? user.user_roles.to_authenticated_roles : nil\n end", "def the_roles\n roles.each.map{|_r| User::ROLES[_r.to_sym] }\n end", "def roles!(access = {})\n json = Api::Request.new do |request|\n request[:access] = access\n request[:method] = :GET\n request[:path] = '/mgmt/{{client_id}}/roles'\n end.execute!\n\n json[:roles]\n end", "def accessible_roles\n index = ROLES.index(self.role)\n roles = User::ROLES[0..index].map{|x| [x.humanize, x]} if index\n return roles\n end", "def user_roles\n roles.collect(&:name).join(', ').split(', ').map(&:capitalize).join(', ')#.capitalize\n end", "def list\n @roles = Role.all(:include => [:groups, :users])\n end", "def get_roles(email)\n raise NotImplementedError, \"Please implement this in your concrete class\"\n end", "def show\n @user = User.find(params[:id])\n @roles = @user.roles\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end", "def role_select\n @@Roles.list\n end", "def getRole\n @users = User.where(\"role = ?\", params[:role]).NameOrder\n render json: @users\n end", "def index\n authorize Role\n\n respond_to do |format|\n format.json { render json: @roles }\n end\n end", "def list_roles(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ListRoles'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :marker\n\t\t\targs[:query]['Marker'] = optional[:marker]\n\t\tend\n\t\tif optional.key? :max_items\n\t\t\targs[:query]['MaxItems'] = optional[:max_items]\n\t\tend\n\t\tself.run(args)\n\tend", "def roles\n @resource_roles\n end", "def roles_for_user(user)\n role_ids = self.chorus_object_roles.where(:user_id => user.id).map(&:role_id)\n Role.find(role_ids)\n end", "def roles\n roles_as_editor + roles_as_reviewer + role_as_admin\n end", "def list\n # We don't use pagination here since we want to display the roles in a\n # nice tree. Additionally, there won't be more than ~100 roles in a\n # normal scenario anyway - far less!\n @roles = Role.find(:all)\n end", "def index\n @roles = @client.roles\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end", "def roles\n ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Role)\n end", "def get_external_roles\n get(\"#{url_base}/external_role_map/all?#{dc}\")[\"data\"]\n end", "def data_roles\n if current_user.has_role? :superadmin\n @roles = Role.only_super_admin.accessible_by(current_ability)\n else\n unless current_user.warehouse.blank?\n roles = \"customer\"\n else\n roles = \"supplier\"\n end\n @roles = Role.only_admin_group(roles)\n end\n end", "def my_assigned_roles(user)\n roles = []\n self.my_roles(user).each do |role|\n design_review_result = self.design_review_results.detect { |drr| drr.role == role }\n roles << role if design_review_result.reviewer == user\n end\n roles\n end", "def index\n @user_roles = UserRole.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def associated_roles\n data[:associated_roles]\n end", "def associated_roles\n data[:associated_roles]\n end", "def all\n data = []\n conn = @ec2_main.environment.iam_connection\n if conn != nil\n begin\n response = conn.list_roles()\n if response.status == 200\n data = response.body[\"Roles\"]\n end\n rescue\n puts \"ERROR: getting all roles #{$!}\"\n end\n end\n return data\n end", "def roles\n User.valid_roles\n end", "def index\n @users = User.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @user_roles }\n end\n end", "def roles\n self.class.roles.map do |name|\n __send__(name)\n end\n end", "def get_user_roles_with_http_info(user_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AuthorizationApi.get_user_roles ...\"\n end\n \n \n # verify the required parameter 'user_id' is set\n fail ArgumentError, \"Missing the required parameter 'user_id' when calling AuthorizationApi.get_user_roles\" if user_id.nil?\n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/users/{userId}/roles\".sub('{format}','json').sub('{' + 'userId' + '}', user_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'UserAuthorization')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AuthorizationApi#get_user_roles\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def roles(**opt)\n roles = present? && object.role_list || []\n html_tag(:ul, opt) do\n roles.map do |role|\n html_tag(:li, role)\n end\n end\n end", "def index\n @roles = System::Role.all\n end", "def index\n @all_roles = Role.all\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end", "def to_authenticated_roles\n return self\n end", "def render_value(value, field:, **opt)\n (value.to_s == 'roles') ? roles(**opt) : super\n end", "def show_roles_and_users\n chorus_object_roles.map(&:role).uniq.map do |r|\n [r.name, users_for_role(r).map(&:username)]\n end\n end", "def secondary_roles\n user.secondary_role\n end", "def roles\n\t\t\t\tProxy.new connection, 'role-strategy/strategy'\n\t\t\tend", "def roles\n # rocking this in memory because eager-loading\n roles = object.paper_roles.select { |role|\n role.user_id == scoped_user.id\n }.map(&:description)\n roles << \"My Paper\" if object.user_id == scoped_user.id\n roles\n end", "def show(id = @id, user = @@default_user)\n @attributes = send_request(\"roles/#{id}\", :get) do |req|\n req.params = {\n auth_token: user.auth_token\n }\n end\n end", "def groups\n roles\n end", "def edit\n @user = User.find(params[:id])\n if can?(:update, @user)\n @roles = \"\"\n\n @user.roles.each do |role|\n if @roles == \"\"\n @roles += role.name\n else\n @roles += \", \" + role.name\n end\n end\n else\n @user = nil\n end\n\n respond_to do |format|\n format.json { render :json => @user } \n format.xml { render :xml => @user }\n format.html\n end\n\n rescue ActiveRecord::RecordNotFound\n respond_to_not_found(:json, :xml, :html)\n end", "def list\n\n @roles = Role.find(:all, :order => 'name')\n\n end", "def role_list \n @role_list ||= begin\n (store.display_roles | group_store.display_roles)\n end\n end", "def GetRole id\n\n APICall(path: \"custom_roles/#{id}.json\")\n\n end", "def roles_path\n @roles_path ||= '/api/v2/roles'\n end", "def role_enum\n\t\t[:user,:vip,:admin]\n\tend", "def get_role\n # <?xml version=\"1.0\" encoding=\"utf-8\"?>\n # <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n # <soap:Header>\n # <Header xmlns=\"http://www.twinfield.com/\">\n # <SessionID>string</SessionID>\n # </Header>\n # </soap:Header>\n # <soap:Body>\n # <GetRole xmlns=\"http://www.twinfield.com/\" />\n # </soap:Body>\n # </soap:Envelope>\n raise NotImplementedError\n end", "def index\n\t\tparamsr\n\t\tglobal\n\t\t# render json: @roles, each_serializer: RoleSerializer, root: false\n\tend", "def roles\n @roles = Role.order(\"name\")\n\t@rights = Right.order(\"name\").map {|r| [r.name, r.id] }\n end", "def current_user_role_names\n container.current_user_role_names\n end", "def list_review_roles\n\n @review_roles = Role.get_review_roles\n\n end", "def role_data(id)\n @conn.get(\"/api/v1/roles/#{id}\")\n end", "def display_roles\n \n @active_roles = Role.find_all_active\n \n render(:layout => false)\n \n end", "def index\n @roles = record.roles.includes(:resource)\n render jsonapi: @roles, include: %i[users groups resource]\n end", "def additional_users_for_show\n [@role.user]\n end", "def select\n @users ||= User.role_wise_users(params[:user][:role])\n authorize! :read, @user\n end", "def accessible_roles\n #@accessible_roles = Role.accessible_by(current_ability,:read)\n @accessible_roles = User::ROLES\n end", "def resource_roles\n return @resource_roles\n end", "def get_role_info()\n make_call(NO_TIMEOUT, ABORT_ON_FAIL) { \n @conn.get_role_info(@secret) \n }\n end", "def roles\n tmp = client.get @json['user']['links']['roles']\n tmp['associatedRoles']['roles'].pmap do |role_uri|\n role = client.get role_uri\n client.factory.create(GoodData::ProjectRole, role)\n end\n end", "def index\n client_application_id = current_user.client_application_id.to_s\n @roles = Role.where(client_application_id: client_application_id)\n end", "def user_role\n USER_ROLE[role]\n end", "def load_roles\n @roles = service_user.identity.roles.keep_if do |role|\n ALLOWED_ROLES.include?(role.name) || user_has_beta_role?(role.name)\n end.sort_by(&:name)\n end", "def get_role\n\t\tself.role\n\tend", "def my_roles\n @my_roles ||= self.roles.map {|r| r.name}.flatten.freeze\n end", "def index\n\t\tindex_\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @roles }\n\t\tend\n\tend", "def role; end", "def role; end", "def get_authorization_roles_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AuthorizationApi.get_authorization_roles ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/authorization/roles\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'sortBy'] = opts[:'sort_by'] if opts[:'sort_by']\n query_params[:'expand'] = @api_client.build_collection_param(opts[:'expand'], :multi) if opts[:'expand']\n query_params[:'nextPage'] = opts[:'next_page'] if opts[:'next_page']\n query_params[:'previousPage'] = opts[:'previous_page'] if opts[:'previous_page']\n query_params[:'name'] = opts[:'name'] if opts[:'name']\n query_params[:'permission'] = @api_client.build_collection_param(opts[:'permission'], :multi) if opts[:'permission']\n query_params[:'defaultRoleId'] = @api_client.build_collection_param(opts[:'default_role_id'], :multi) if opts[:'default_role_id']\n query_params[:'userCount'] = opts[:'user_count'] if opts[:'user_count']\n query_params[:'id'] = @api_client.build_collection_param(opts[:'id'], :multi) if opts[:'id']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'OrganizationRoleEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AuthorizationApi#get_authorization_roles\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def filter_roles\n if params[:user] && params[:user][:roles]\n params[:user][:roles] = params[:user][:roles].map(&:to_i) & current_user.assignable_roles\n end\n end", "def user_roles=(value)\n roles[:user_roles]=value\n end", "def role\n @role\n end", "def index\n @roles = Role.order(\"name\").all\n @user_list = User.order(\"email\").all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles }\n end\n end", "def get_roles(options = {})\n request_params = {\n per_page: options.fetch(:per_page, nil),\n page: options.fetch(:page, nil),\n include_totals: options.fetch(:include_totals, nil),\n name_filter: options.fetch(:name_filter, nil)\n }\n get roles_path, request_params\n end", "def roles_string() \n self[:roles].join(\",\") \n end", "def user_role\n UserRole.find_by(approval_group_id: cart.approval_group.id, user_id: user_id)\n end", "def roles\n (properties[:roles] || []).map { |r| r.is_a?(Link) ? r : Link.new(r, nil, client) }\n end", "def index\n @users_roles = UsersRole.all\n end", "def get_roles\n result = {}\n roles.each do |role|\n resource = if role.resource_type == 'Conference'\n Conference.find(role.resource_id).short_title\n elsif role.resource_type == 'Track'\n Track.find(role.resource_id).name\n end\n if result[role.name].nil?\n result[role.name] = [resource]\n else\n result[role.name] << resource\n end\n end\n result\n end", "def index\n @roles = @vendor.roles.vendor_only # TODO change to roles\n end", "def roles\n Role.group_roles_from_cache(self)\n end" ]
[ "0.81225836", "0.78644425", "0.7635204", "0.75992256", "0.7187225", "0.71674234", "0.71674234", "0.7126673", "0.70601684", "0.70553744", "0.70553744", "0.7050875", "0.6988939", "0.68633914", "0.6851109", "0.6844621", "0.68243766", "0.6821807", "0.6794176", "0.6794176", "0.67794967", "0.6777387", "0.67611176", "0.6728096", "0.6721706", "0.6698953", "0.66712624", "0.6633743", "0.6624843", "0.6617522", "0.65993655", "0.65877265", "0.6561257", "0.6536565", "0.6522191", "0.6520947", "0.65142435", "0.6491235", "0.64836097", "0.64816815", "0.6459846", "0.64540374", "0.6442204", "0.6442204", "0.64380527", "0.6434246", "0.64305776", "0.64268744", "0.6423176", "0.64204305", "0.6411981", "0.6406396", "0.640632", "0.63913435", "0.63893896", "0.6381001", "0.63806874", "0.637806", "0.6370546", "0.6367513", "0.6365519", "0.6364859", "0.6364823", "0.6355714", "0.63542235", "0.63354623", "0.6328842", "0.63208044", "0.6315729", "0.63087046", "0.6307993", "0.6303596", "0.6297073", "0.6295983", "0.62951154", "0.62904423", "0.6285034", "0.62841016", "0.62821364", "0.6281269", "0.6273745", "0.6269264", "0.62656355", "0.6258097", "0.6250216", "0.624445", "0.6244083", "0.6244083", "0.6235377", "0.6232792", "0.6230611", "0.622923", "0.6223713", "0.62173027", "0.6216961", "0.6211461", "0.6211116", "0.62085617", "0.62014276", "0.6195493", "0.6194447" ]
0.0
-1
Functions for loading/writing CSV files
def from_csv path, opts={} daru_options, opts = from_csv_prepare_opts opts # Preprocess headers for detecting and correcting repetition in # case the :headers option is not specified. hsh = if opts[:headers] from_csv_hash_with_headers(path, opts) else from_csv_hash(path, opts) .tap { |hash| daru_options[:order] = hash.keys } end Daru::DataFrame.new(hsh,daru_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_csv_full\n \n end", "def import_csv_smart\n \n end", "def prepare_data\n data = CSV.read('input.csv', { col_sep: SEPARATOR })\n\n CSV.open('output.csv','wb') do |csv|\n data.each do |row|\n csv << prepare_row(row)\n end\n end\n\n rescue Errno::ENOENT\n puts 'No valid input.csv file present'\n end", "def cp_csv(from, to)\n if to.directory? || ! to.to_s.match(/\\.(csv|ad)$/)\n to = to.join(from.basename)\n end\n\n File.write(to, File.read(from).gsub(/\\r\\n/, \"\\n\"))\n end", "def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend", "def generate_csv_file(file_path, row_data)\n CSV.open(file_path, \"wb\") do |csv|\n csv << [\"first_name\", \"last_name\", \"dob\", \"member_id\", \"effective_date\", \"expiry_date\", \"phone_number\"]\n row_data.each { |row| csv << row }\n end\nend", "def collection_to_csv(filepaths, csv_name)\n output_file = CSV.open(csv_name, \"w\")\n header = JSON.parse!(File.read(filepaths[0])).keys\n output_file << header\n\n filepaths.each do |path|\n data = JSON.parse!(File.read(path))\n output_file << data.values\n end\nend", "def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/,\\\"\\\"/,'')\n # for some reason the iRacing CSV file is buggy.\n unless parsed_line == \"\\n\"\n if i == 5 or i == 6\n parsed_line = parsed_line.gsub(/\\n/,\"\\r\\n\")\n end\n self.parsed_csv_string << parsed_line\n end\n end\n unparsed_file.close\n end", "def append_csv(rainfall) # append rainfall details into CSV file\r\n filename = \"rainfall_collection.csv\"\r\n if !File.file?(filename) # places header information\r\n header = [\"Place\",\"year\",\"Month\",\r\n \"day1\",\"day2\",\"day3\",\"day4\",\"day5\",\"day6\",\"day7\",\"day8\",\"day9\",\"day10\",\r\n \"day11\",\"day12\",\"day13\",\"day14\",\"day15\",\"day16\",\"day17\",\"day18\",\"day19\",\"day20\",\r\n \"day21\",\"day22\",\"day23\",\"day24\",\"day25\",\"day26\",\"day27\",\"day28\",\"day29\",\"day30\",\r\n \"day31\"]\r\n CSV.open(filename, \"w+\") do |hdr|\r\n hdr << header\r\n hdr << rainfall\r\n end\r\n else\r\n CSV.open(filename, \"a+\") do |mth|\r\n mth << rainfall\r\n end\r\n end # end for File.file? if file exists\r\n\r\nend", "def initialize_csv\n CSV.open(\"results.csv\", \"wb\") do |csv|\n csv << [\"class\", \"title of course\", \"credits\"]\n end\nend", "def parse_csv\n if self.csv_file.present?\n csv_text = Paperclip.io_adapters.for(self.csv_file).read\n csv = CSV.parse(csv_text, :headers => false)\n\n csv_columns = ['l', 'r', 'units']\n\n csv_to_save = {}\n\n csv.each_with_index do |row, i|\n if i == 0\n csv_to_save['weight'] = row[1].split(':')[1] # string is like Weight:201, only want the number\n csv_to_save['shoe_size'] = row[2].split(':')[1] # string is like Shoe Size:9\n elsif i >= 3\n row.each_with_index do |field, j|\n if j >= 1 and !field.blank?\n csv_to_save[generate_csv_row_key(csv_columns, row, i, j)] = field\n end\n end\n end\n end\n\n # Check to see if any of the fields are nil, then we must have not received the correct file\n is_clean = true\n csv_to_save.each do |key, val|\n if val.nil?\n is_clean = false\n break\n end\n end\n\n CsvFile.create!(csv_to_save) if is_clean\n end\n end", "def updateCSVFile\n\t\tFile.open('accounts.csv', 'w') do |file|\n\t\t\tfile << \"Account,Date,Payee,Category,Outflow,Inflow\\n\"\n\t\t\[email protected] do |line|\n\t\t\t\tfile << line\n\t\t\tend\n\t\tend\n\tend", "def load_file (filename = \"students.csv\")\n CSV.foreach(filename) do |row|\n name, cohort, food = row.map{ |element| element.chomp}\n add_student(name, cohort, food)\n end\nend", "def save_csv\n CSV.open(@csv_file_path, \"wb\") do |csv|\n csv << [\"name\", \"description\", \"rating\", \"prep_time\", \"done\"]\n @recipes.each do |recipe|\n csv << [recipe.name, recipe.description, recipe.rating, recipe.prep_time, recipe.done?]\n end\n end\n end", "def import_csv\n @records = CSV.read(@filename, :headers => true, :row_sep => :auto)\n unless @records.blank?\n @linenum = 0\n if @filename.index('att') || @filename.index('Att')\n @school_year = Time.parse(@records[0][\"AbsenceDate\"]).year\n end\n @records.each { |rec |\n @linenum += 1\n @record = rec\n next unless check_record(@record)\n seed_record(@record)\n process_record(@record, rec2attrs(@record)) if rec2attrs(@record) != false\n }\n end \n end", "def csv_writer(rows)\n headers = [\"name\", \"capacity\", \"storage\"]\n CSV.open(\"reservoir_data.csv\", 'w') do |csv|\n csv << headers\n rows.each do |row|\n csv << row\n end\n end\nend", "def import\n att_file_name = File.join(@dir, \"attendance_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.csv\")\n enr_file_name = File.join(@dir, \"enrollment_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.csv\")\n ili_file_name = File.join(@dir, \"ili_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.csv\")\n EnrollmentImporter.new(@enroll_file).import_csv unless @enroll_file.blank?\n AttendanceImporter.new(@attendance_file).import_csv unless @attendance_file.blank?\n IliImporter.new(@ili_file).import_csv unless @ili_file.blank?\n File.rename(@enroll_file, enr_file_name) unless @enroll_file.blank?\n File.rename(@attendance_file, att_file_name) unless @attendance_file.blank?\n File.rename(@ili_file, ili_file_name) unless @ili_file.blank?\n FileUtils.mv(enr_file_name, File.join(@dir, \"archive\")) unless @enroll_file.blank?\n FileUtils.mv(att_file_name, File.join(@dir, \"archive\")) unless @attendance_file.blank?\n FileUtils.mv(ili_file_name, File.join(@dir, \"archive\")) unless @ili_file.blank?\n end", "def csv_write (filename = \"students.csv\")\n CSV.open(filename, \"w\") do |row|\n @students.each do |student|\n row << [student[:name], student[:cohort], student[:food]]\n end\n end\nend", "def loadCSV\n csvFile = File.open(\"app/assets/csv/test.csv\", \"r\") #Open file with readpermissions\n if csvFile #if file was successfully opened \n csvRowArray = IO.readlines(csvFile) # Turn each row into an array element\n rowId=1 #0 is the Header Row, 1 is the first dataset.\n recordsArray = Array.new(csvRowArray.size-1)\n while csvRowArray[rowId] do #for each row that exists \n rowEntry = csvRowArray[rowId]\n rowEntry.gsub!(/\"/,'') # Remove all the '\"'s\n wordArr = rowEntry.split(\",\") #Split the array on ','s into a new array \n newRecord = Record.new\n newRecord.REF_DATE = wordArr[0]\n newRecord.GEO = wordArr[1]\n newRecord.DGUID = wordArr[2]\n newRecord.Sex = wordArr[3]\n newRecord.Age_group = wordArr[4]\n newRecord.Student_response = wordArr[5]\n newRecord.UOM = wordArr[6]\n newRecord.UOM_ID = wordArr[7]\n newRecord.SCALAR_FACTOR = wordArr[8]\n newRecord.SCALAR_ID = wordArr[9]\n newRecord.VECTOR = wordArr[10]\n newRecord.COORDINATE = wordArr[11]\n newRecord.VALUE = wordArr[12]\n newRecord.STATUS = wordArr[13]\n newRecord.SYMBOL = wordArr[14]\n newRecord.TERMINATED = wordArr[15]\n newRecord.DECIMALS = wordArr[16]\n newRecord.save\n puts rowId\n rowId = rowId+1 \n end\n return recordsArray\n else #file not opened\n puts \"Unable to open file\" \n return \n end \n end", "def convert_csv(path, table_name)\n \n # csv file has a header row\n header_row = true\n\n # delimiter for csv file\n delimiter = ','\n\n # variable used to skip header row\n skip_row = true\n\n\n CSV.open(path, 'r', delimiter ) do |row|\n\n row.each_with_index do |col,index|\n if col==nil then \n row[index]='NULL'\n else\n \n col.gsub!(\"'\",\"`\")\n row[index] = \"'#{ col }'\"\n end\n end\n\n # Are we reading the header row of the csv file?\n if header_row\n row.each_with_index do |col,index|\n row[index] = \"\\\"#{ col.gsub(\"'\",'').gsub(/\\s+/,'') }\\\"\"\n end\n header_row = false\n print \"INSERT INTO #{table_name} (#{row.join delimiter }) VALUES\"\n next\n end\n\n # Only skip the first (header) row\n if skip_row == true\n # dont skip further rows\n skip_row = false\n else\n # Print end of line insert delimeter\n puts delimiter\n end\n \n # Print to stdout\n print \"(#{row.join delimiter})\"\n \n end\nend", "def save\n CSV.open(\"./db/gossip.csv\", \"ab\") do |csv|\n csv << [@author, @content]\n end\nend", "def csv_filename\n raise NotImplementedError\n end", "def save_csv\n CSV.open(@csv_file_path, 'wb') do |csv|\n @recipes.each do |recipe|\n csv << [recipe.name, recipe.description, recipe.rating, recipe.prep_time, recipe.tried]\n end\n end\n end", "def fix_csv(csv_filenames)\n # Read line from file, modify, and write back out\n first_line = true\n new_file_name = \"#{@file_name[0...-3]}csv\"\n # Open final csv for output\n File.open(new_file_name, 'w') do |fo|\n # Iterate over tmp csv files\n csv_filenames.each do |csv|\n # Go through each line of tmp csv\n CSV.foreach(csv, headers: true) do |row|\n if first_line\n headers = @col_num_hash.keys\n fo.puts headers.join(',')\n first_line = false\n else\n fo.puts fix_data(row)\n end\n end\n end\n end\nend", "def update_csv\n CSV.open(@csv_file, \"w\") do |csv|\n csv << [\"id\", \"name\", \"password\", \"title\"]\n @data.each do |record|\n csv << [record.id, record.name, record.password, record.title]\n end\n end\n end", "def load_file full_name\n file = FasterCSV.open( full_name , { :col_sep => \"\\t\"} ) \n @header = file.shift\n @data = file.readlines\n #puts @header\n @header.each do |col|\n #puts \"col=#{col}= mapped to =#{@mapping[col]}=\"\n end\n index = 0\n while index < @data.length\n row = @data[index]\n #puts \"row is \" + row.join(\"--\")\n @mapping.each do |key,val|\n #puts \"Row:#{val} at #{@mapping.index(val)} is --#{@header.index(@mapping.index(val))}--value---\"\n #puts \"--#{at_in(val,row)}--\" if @header.index(@mapping.index(val))\n end\n prod = get_product(row)\n set_attributes_and_image( prod , row )\n set_taxon(prod , row)\n #puts \"saving -\" + prod.description + \"- at \" + at_in(:price,row) #if at_in(:price,row) == \"0\"\n prod.save!\n throw \"no master for #{prod.name}\" if prod.master == nil \n# pr = get_product( row )\n# puts \"TAXONs #{pr.taxons}\"\n \n puts \"saved -\" + prod.description + \"- at \" + at_in(:price,row) #if at_in(:price,row) == \"0\"\n index = slurp_variants(prod , index + 1) #read variants if there are, returning the last read line\n end\n\n end", "def create_csv_file(keys, strings, comments = nil)\n raise \"csv_filename must not be nil\" unless @csv_filename\n CSV.open(@csv_filename, \"wb\") do |csv|\n @headers << \"Comments\" if !comments.nil? && !comments.empty?\n csv << @headers\n keys.each do |key|\n line = [key]\n default_val = strings[@default_lang][key] if strings[@default_lang]\n @filenames.each do |fname|\n lang = fname\n current_val = (lang != default_lang && strings[lang][key] == default_val) ? '' : strings[lang][key]\n line << current_val\n end\n line << comments[key] if comments && comments[key]\n csv << line\n end\n puts \"Done\"\n end\n end", "def parse_csv(path)\n require 'csv'\n\n str = Nitro::Template.new.render(File.read(path))\n\n reader = CSV::Reader.create(str)\n header = reader.shift\n\n reader.each_with_index do |row, i|\n data = {}\n row.each_with_index do |cell, j|\n data[header[j].to_s.strip] = cell.to_s.strip\n end\n self[\"#{@name}_#{i+1}\"] = obj = instantiate(data)\n @objects << obj\n end\n end", "def load_csv(csv_file_or_object, table_name, log_name = nil)\n log_name ||= \"load_csv '#{csv_file_or_object.kind_of?(CSV::Table) ? 'CSV Object' : csv_file_or_object }', 'table_name'\"\n csv_object = case csv_file_or_object\n when String then Slacker.get_csv(csv_file_or_object)\n when CSV::Table then csv_file_or_object\n when Array then Slacker.hash_array_to_csv(csv_file_or_object)\n end\n\n Slacker.load_csv(example, csv_object, table_name, log_name)\n end", "def csv_to_table\n\t\tpath = File.join(Rails.root, \"db/seed_data\")\n\t\tDir.foreach(path) do |file|\n\t\t\tif file.include?(\".csv\")\n\t\t\t\theader_row = nil\n\t\t\t\tmodel = File.basename(file, File.extname(file)).camelcase.constantize\n\t\t\t\tmodel.delete_all\n\t\t\t\tCSV.foreach(File.join(path,file)) do |row|\n\t\t\t\t\tif header_row.nil?\n\t\t\t\t\t\theader_row = row\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\tattributes = {}\n\t\t\t\t\trow.each_index do |i|\n\t\t\t\t\t\tattributes[header_row[i].to_sym] = row[i]\n\t\t\t\t\tend\n\t\t\t\t\tmodel.create!(attributes)\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\tend", "def csv_to_table\n\t\tpath = File.join(Rails.root, \"db/seed_data\")\n\t\tDir.foreach(path) do |file|\n\t\t\tif file.include?(\".csv\")\n\t\t\t\theader_row = nil\n\t\t\t\tmodel = File.basename(file, File.extname(file)).camelcase.constantize\n\t\t\t\tmodel.delete_all\n\t\t\t\tCSV.foreach(File.join(path,file)) do |row|\n\t\t\t\t\tif header_row.nil?\n\t\t\t\t\t\theader_row = row\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\tattributes = {}\n\t\t\t\t\trow.each_index do |i|\n\t\t\t\t\t\tattributes[header_row[i].to_sym] = row[i]\n\t\t\t\t\tend\n\t\t\t\t\tmodel.create!(attributes)\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\tend", "def reprocess_csv(file)\n raw = open(file).read.force_encoding(\"UTF-8\")\n csv = CSV.parse(raw, headers: true, header_converters: :symbol)\n csv.each do |row|\n data = row.to_hash.each { |k, v| v = v.to_s.gsub(/[[:space:]]+/, ' ').strip }\n data[:area_id] = data[:area].downcase\n data[:gender] = data[:gender].downcase\n data[:term] = '2013'\n %i(num).each { |i| data.delete i }\n ScraperWiki.save_sqlite([:name, :name, :term], data)\n end\nend", "def parse_to_load_file(csv)\n csv.each_with_index do |student, index|\n student = {month: csv[index][0] , name: csv[index][1], city: csv[index][2], hobby: csv[index][3]}\n @students << student\n end\nend", "def load_csv\n # read each line frmo csv and append to recipes collection\n CSV.foreach(@csv_file) do |row|\n # puts \"#{row[0]} | #{row[1]}\"\n @recipes << Recipe.new(name: row[0], description: row[1], cooking_time: row[2], difficulty: row[3], tested: row[4])\n end\n end", "def export_to_csv\n puts 'Please enter a csv file name:'\n\n filename = get_filename\n filename = add_csv_suffix_if_needed filename\n \n write_to_csv_file filename\n \n end", "def create_summary_csv(summary_csv_path)\n puts \"creating summary csv: #{summary_csv_path}\"\n\n CSV.open(summary_csv_path, \"wb\") do |csv|\n csv << SUMMARY_CSV_HEADINGS\n end\nend", "def convert_csv(original_csv)\n csv_options = {}\n csv_options[:col_sep] = option(:csv_col_sep) unless option(:csv_col_sep).blank?\n csv_options[:row_sep] = option(:csv_row_sep) unless option(:csv_row_sep).blank?\n csv_options[:quote_char] = option(:csv_quote_char) unless option(:csv_quote_char).blank?\n value_converter = option(:csv_value_proc)\n\n converted_csv = \"#{original_csv}.converting\"\n CSV.open(converted_csv, 'wb', csv_options) do |csv|\n CSV.foreach(original_csv) do |row|\n row = row.map{ |value| value.blank? ? '' : value_converter.call(value) } if value_converter\n csv << row\n end\n end\n FileUtils.remove(original_csv)\n FileUtils.move(converted_csv, original_csv)\n end", "def strip_csv_quotes(src_path, dest_path)\n\n require 'csv'\n open('LoginHistory-comma-delim.csv', 'w') do |f|\n first_line = true\n CSV.foreach('LoginHistory.csv') do |row|\n if first_line\n first_line = false\n else\n f.puts( row.join(',') )\n end\n \n end\n end\n\nend", "def import_data path, file_type\n if file_type == :csv\n csv_parse(path).each { |params| Product.new(params).save }\n elsif file_type == :xls\n #xls_parse(path)\n end\nend", "def csv_write filename , *field\n CSV.open(filename, \"a\") do |csv|\n csv << field\n end\nend", "def csv(handle, path = nil)\n @dsd = DataSourceDownload.get(handle)\n raise \"handle '#{handle}' does not exist\" if @dsd.nil? and handle != \"manual\"\n path = (handle == \"manual\") ? DataSourceDownload.flex(path) : @dsd.save_path_flex \n @handle = handle\n @csv ||= {}\n if @csv[path].nil? \n download_handle unless @dsd.nil?\n #puts path\n begin\n @csv[path] = CSV.read(path)\n @new_data = true\n rescue\n #resolve one ugly known file formatting problem with faster csv\n alternate_csv_load = alternate_fastercsv_read(path) #rescue condition if this fails\n #return \"READ_ERROR:CSV FORMAT OR FILE PROBLEM\" if alternate_csv_load.nil? \n @csv[path] = alternate_csv_load\n @new_data = true\n end\n end\n @csv[path]\n end", "def loadStructure(file)\n csv_text = File.read(file)\n return CSV.parse(csv_text, :headers => true)\n \nend", "def update_csv(rows)\n CSV.open($out_path, \"wb\") do |csv| \n\n csv << rows.first.keys\n\n rows.each do |row| \n csv << row.values\n end\n end\nend", "def writeCsvFile(ndv, p4l, csvkeys, new_datavalues, path, outputFolder)\r\n (0..ndv).each do |j|\r\n p4l[j] = csvkeys.zip(new_datavalues[j])\r\n end\r\n column_names = csvkeys\r\n csvfile = CSV.generate do |csv|\r\n csv << column_names\r\n new_datavalues.each do |elem|\r\n csv << elem\r\n end\r\n end\r\n File.write(path+\"\\\\#{outputFolder}\\\\users.csv\", csvfile)\r\n new_datavalues = []\r\n end", "def process\n validate_file_type(@file_name, 'csv')\n convert_csv_file_to_object\n end", "def save_csv(csv_filepath, gifts)\n CSV.open(csv_filepath, 'wb') do |csv|\n gifts.each do |gift| # Itera por cada todo do array com todos os TODOs\n csv << [gift] # Precisa colocar em um array porque o CSV é um array de arrays\n end\n end\nend", "def touch_csv(csv_file_or_object, fields, field_generators = {})\n Slacker.touch_csv(csv_file_or_object, fields, field_generators)\n end", "def create_csv_for_LLR(csv_data)\n\n csv_string = CSV.open(\"#{$basefile}LLR.csv\", \"wb\") do |csv|\n\n csv << csv_data.first.keys\n csv_data.each do |hash|\n csv << hash.values\n end\n end\n end", "def initialize(csv_in_filename)\n @in_file = csv_in_filename\n @csv_out_headers = nil\n @index = nil\n @csv_out_data = nil\n convert\n end", "def load_csv\n CSV.foreach(@csv_file_path) do |row|\n @recipes << Recipe.new(name: row[0], description: row[1], rating: row[2], prep_time: row[3], tried: row[4])\n end\n end", "def convert_csv_file_to_object\n begin\n CSV.foreach(@file_name) do |row|\n @csv_object.push(row)\n end \n rescue => exception\n raise FileReadError, exception\n end\n end", "def getData()\n CSV.foreach(\"SkaterProjections.csv\", :headers => true) do |row|\n @skater_data.push(row)\n end\n \n CSV.foreach(\"GoalieProjections.csv\", :headers => true) do |row|\n @goalie_data.push(row)\n end\nend", "def update_summary_csv(summary_csv_path, line)\n puts \"updating summary csv: #{summary_csv_path}\"\n\n # the results row is a string rather than an array so handle as file rather than csv\n File.open(summary_csv_path, \"a+\") do |f|\n f << line\n end\nend", "def datat_read\n \n #Read in the csv file\n @@datat_array = CSV.read(@@datat_path_specific)\n \n #Delete the row which contains the database title.\n @@datat_array.delete_at(0)\n \n ######################################\n #puts @@datat_array[2]\n #Verify the conversion has taken place\n #puts @database + \" CSV file converted\"\n ######################################\n \n end", "def save_students\n File.open(user_filename, \"w\") do |file|\n @students.each do |student|\n student_data = [student[:name], student[:cohort], student[:hobbies]]\n csv_line = student_data.join(\",\")\n file.puts csv_line\n end\n end\nend", "def ghd(path)\n Find.find(path).each do |f|\n next unless f =~ /.csv$/\n c = CSV.read(f).unshift %w(en zh)\n out = c.map { |e| e.to_csv(force_quotes: true) }\n .join\n File.write(\"#{f}.new\", out)\n end\nend", "def save\n csv = [] # store CSV lines to write to file\n # Iterate over BasicFoods and retrieve CSV format for each \n @basic_foods.each do |key, basic_food|\n csv.push(basic_food.csv)\n end\n # Iterate over Recipes and retrieve CSV format for each\n @recipes.each do |key, recipe|\n csv.push(recipe.csv)\n end\n File.write('FoodDB.txt', csv.join(\"\\n\")) # Write CSV lines to file\n end", "def write_csv(pages)\n CSV.open('pages.csv', 'w' ) do |writer|\n writer << [\"title\", \"path\", \"hero\", \"hero_tagline\", \"body\"]\n $pages.each do |c|\n writer << [c['title'], c['path'], c['hero'], c['hero_tagline'], c['body']]\n end\n end\nend", "def main\n process_csv_files_from_dir\nend", "def load_students(filename)\n CSV.foreach(filename) do |line|\n name, cohort = line[0], line[1]\n add_to_students name, cohort #refactored\n end\n success\n #file.close\nend", "def generateCSV()\n findCommits\n findLinesOfCode\n\n CSV.open(\"data.csv\", \"wb\") {|csv| @students.to_a.each {|elem| csv << elem} }\nend", "def make_testdata_reworked_csv_file\n create_column_headers_index_hash \n create_row_headers_index_hash \n clear_testdata_reworked_file\n CSV.open('testdata_reworked.csv', \"wb\") do |csv|\n CSV.foreach('testdata.csv', {headers: true}) do |row| \n row[0] = @column_hash.key(row[0].to_i)\n row[1] = @row_hash.key(row[1].to_i)\n csv << row\n end\n end\nend", "def rw_values(category, type, name, filename, outfile)\n first_line = true\n File.readlines(filename).each do |line|\n # Skip the first line, as it contains the header\n if first_line\n first_line = false\n next\n end\n \n # Split the line by commas\n fields = line.split(',')\n \n # Check that the csv is conformant to the format\n if fields.size < 9\n puts \"Malformed line: #{line}\"\n puts \"In file: #{filename}\"\n throw \"Expecting at least 9 fields in commercial building csv files\"\n end\n \n datetime = fields[0]\n energy = fields[1]\n \n # Parse the first column (datetime)\n month, day, hour = datetime.scan(/(\\d\\d)\\/(\\d\\d)\\s*(\\d\\d)/).first\n \n # In the original csv hours are 01-24, we convert it to 00-23\n hour = (hour.to_i - 1).to_s.rjust(2, '0')\n \n # We know the data is relative to 2004\n date = \"2004-#{month}-#{day}\"\n time = \"#{hour}:00\"\n \n # Write the extracted data to the output csv\n outfile.puts(\"#{category},#{type},#{name},#{date},#{time},#{energy}\")\n end\nend", "def loadCSVFile(filePath)\n data = []\n CSV.foreach(filePath, :headers => true) do |row|\n row = row.to_h\n row.each do |k, v|\n v = v.to_s\n row[k] = v\n end\n data << row\n end\n data\n end", "def save_students\n# open the csv file for writing\n puts \"Which file would you like to save the students information?\"\n filename = STDIN.gets.chomp\n CSV.open(filename, \"a+\") do |csv_object|\n @students.each do |student|\n csv_object << [student[:name], student[:cohort]]\n puts \"#{student[:name]} student has been saved into #{filename} file\"\n end\n end\nend", "def save_students(filename = \"students.csv\")\n CSV.open(filename, \"w\") do |csv|\n @students.each do |student|\n csv << [student[:name], student[:cohort]]\n end\n end\n puts \"File Saved\"\nend", "def process_and_upload_csv\n\n @has_data = get_data_from_db do |data|\n formatted_data = format_data(data)\n c_add formatted_data\n end\n\n if @has_data\n zip_folder\n upload_to_s3\n delete_local_files\n end\n\n end", "def csv\n require 'csv'\n\n unless params[:uploaded_csv].blank?\n csv_path = params[:uploaded_csv].path\n\n # Wipe database on csv load, will need to be modified when event RSS feeds are fixed\n data_validated = false\n begin\n CSV.foreach(csv_path, :headers => true) do |row|\n csv_building = row[1]\n csv_room_number = row[3]\n csv_room_name = row[4]\n csv_department = row[7]\n csv_person_name = row[9] #can be general purpose name like 'general graduate student'\n csv_last_name, csv_first_name = csv_person_name.split(',').map(&:strip)\n\n csv_person_department = row[11] # appears to be less relevant to our needs\n csv_organization = row[12]\n csv_org_code, csv_person_organization = csv_organization.split(' ', 2) # Use this for department\n csv_phone = row[13]\n csv_email = row[14]\n\n # Destroy data only if the first row was parsed successfully\n unless data_validated\n Rails.logger.debug \"[[[[[[ Data validated, wiping db!!! ]]]]]]\"\n Person.destroy_all\n Department.destroy_all\n DirectoryObject.where(type: \"Room\").delete_all\n data_validated = true\n end\n\n # Don't bother with this row if a room number doesn't exist\n if csv_room_number != \"\"\n # Parse Rooms\n results = Room.where(room_number: csv_room_number)\n # Found new room?\n if results.empty?\n room = Room.new\n room.room_number = csv_room_number\n room.save\n else\n room = results.first\n end\n\n # Ensure custom data has not already been set\n # if room.name.blank?\n # room.name = csv_room_name\n # room.save\n # end\n # Parse Department\n # Don't bother with department/person parsing, something is wrong with this row\n unless csv_organization.include?(\"Identity Purged\")\n department = nil\n results = Department.where(title: csv_person_organization.downcase).first\n if results.blank?\n department = Department.new\n if csv_person_organization.present?\n department.title = (csv_person_organization).downcase\n department.save\n else\n logger.info \"entry was missing an organization\"\n end\n else\n department = results\n end\n\n # Parsing Person\n results = Person.where(email: csv_email)\n\n # Found new person?\n if results.empty?\n person = Person.new\n\n # Found existing person?\n else\n person = results.first\n end\n # Ensure room is associated\n if room.present?\n if not person.rooms.include?(room)\n person.rooms << room\n end\n end\n # Ensure department is associated\n # Currently assumes each person has one department, seems to be the case from the data\n if person.department.blank?\n if department.present?\n person.department = department\n end\n end\n person.email = csv_email\n person.phone = csv_phone\n person.first = csv_first_name\n person.last = csv_last_name\n person.save\n end\n end\n end\n\n notice = \"CSV was successfully parsed\"\n rescue\n error = \"CSV file contains invalid data\"\n end\n else\n error = \"Error uploading file\"\n end # unless csv_path.blank?\n\n respond_to do |format|\n format.html {\n redirect_to action: \"index\",\n error: error,\n notice: notice\n }\n end\n end", "def csv\n require 'csv'\n\n unless params[:uploaded_csv].blank?\n csv_path = params[:uploaded_csv].path\n\n # Wipe database on csv load, will need to be modified when event RSS feeds are fixed\n data_validated = false\n begin\n CSV.foreach(csv_path, :headers => true) do |row|\n csv_building = row[1]\n csv_room_number = row[3]\n csv_room_name = row[4]\n csv_department = row[7]\n csv_person_name = row[9] #can be general purpose name like 'general graduate student'\n csv_last_name, csv_first_name = csv_person_name.split(',').map(&:strip)\n\n csv_person_department = row[11] # appears to be less relevant to our needs\n csv_organization = row[12]\n csv_org_code, csv_person_organization = csv_organization.split(' ', 2) # Use this for department\n csv_phone = row[13]\n csv_email = row[14]\n\n # Destroy data only if the first row was parsed successfully\n unless data_validated\n Rails.logger.debug \"[[[[[[ Data validated, wiping db!!! ]]]]]]\"\n Person.destroy_all\n Department.destroy_all\n DirectoryObject.where(type: \"Room\").delete_all\n data_validated = true\n end\n\n # Don't bother with this row if a room number doesn't exist\n if csv_room_number != \"\"\n # Parse Rooms\n results = Room.where(room_number: csv_room_number)\n # Found new room?\n if results.empty?\n room = Room.new\n room.room_number = csv_room_number\n room.save\n else\n room = results.first\n end\n\n # Ensure custom data has not already been set\n # if room.name.blank?\n # room.name = csv_room_name\n # room.save\n # end\n # Parse Department\n # Don't bother with department/person parsing, something is wrong with this row\n unless csv_organization.include?(\"Identity Purged\")\n department = nil\n results = Department.where(title: csv_person_organization.downcase).first\n if results.blank?\n department = Department.new\n if csv_person_organization.present?\n department.title = (csv_person_organization).downcase\n department.save\n else\n logger.info \"entry was missing an organization\"\n end\n else\n department = results\n end\n\n # Parsing Person\n results = Person.where(email: csv_email)\n\n # Found new person?\n if results.empty?\n person = Person.new\n\n # Found existing person?\n else\n person = results.first\n end\n # Ensure room is associated\n if room.present?\n if not person.rooms.include?(room)\n person.rooms << room\n end\n end\n # Ensure department is associated\n # Currently assumes each person has one department, seems to be the case from the data\n if person.department.blank?\n if department.present?\n person.department = department\n end\n end\n person.email = csv_email\n person.phone = csv_phone\n person.first = csv_first_name\n person.last = csv_last_name\n person.save\n end\n end\n end\n\n notice = \"CSV was successfully parsed\"\n rescue\n error = \"CSV file contains invalid data\"\n end\n else\n error = \"Error uploading file\"\n end # unless csv_path.blank?\n\n respond_to do |format|\n format.html {\n redirect_to action: \"index\",\n error: error,\n notice: notice\n }\n end\n end", "def save_as_csv\n result = get_result_all_city()\n begin\n CSV.open(\"db/city.csv\", \"wb\") do |csv|\n result.each do |city|\n convert = city.to_a\n csv << convert[0]\n end\n end\n rescue => exception\n puts \"Some errors have orcurred!\"\n end\n end", "def create_csv_for_GH(csv_data)\n\n csv_string = CSV.open(\"#{$basefile}GH.csv\", \"wb\") do |csv|\n\n csv_data.each do |hash|\n csv << hash\n\n end\n end\n end", "def load_raw_data(klass, csv_file_path)\n\t\tCSV::Converters[:blank_to_nil] = lambda do |field|\n\t\t field && field.empty? ? nil : field\n\t\tend\n\n\t\tputs \"Loading data from #{csv_file_path}\"\n\n\t\tprogress = ProgressBar.create(:title => klass.name, :starting_at => 0, :total => nil, :format => \"%t: Records: %c Elapsed %a Records/second: %r %b\")\n\t\tcount = 0\n\n\t\tbegin\n\t\t\tFile.open(csv_file_path, 'r') do |f|\n\t\t\t\theaders = nil\n\t\t\t\trows = []\n\n\t\t\t\tf.each_with_index do |row, i| \n\t\t\t\t\tbegin\n\t\t\t\t\t\t# The first 4 lines are comments and the 5th are column labels we don't use; skip them\n\t\t\t\t\t\tnext if i < 5\n\n\t\t\t\t\t\t# The last row is a 'footer', delimited with 'F'\n\t\t\t\t\t\tnext if row.starts_with? \"F \"\n\n\t\t\t\t\t\t# I know it's weird, we parse CSV only to generate CSV again, but it's to canonicalize the CSV into a form PG\n\t\t\t\t\t\t# can use, since some of the input data are, shall we say, sloppy.\n\t\t\t\t\t\trows << try_parse_csv(row).to_csv\n\n\t\t\t\t\t\tif (rows.count == ROWS_PER_BATCH) \n\t\t\t\t\t\t\tcopy_rows klass.connection, klass.table_name, rows\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tprogress.increment\n\t\t\t\t\t\tcount += 1\n\n\t\t\t\t\trescue Exception => e\n\t\t\t\t\t\tprogress.log \"#{csv_file_path}:#{i+1}: #{e.inspect}\"\n\t\t\t\t\t\tprogress.log \"Rows contents: \"\n\t\t\t\t\t\tprogress.log \" #{rows}\"\n\t\t\t\t\t\traise e\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# Any remaining rows, write now\n\t\t\t\tcopy_rows klass.connection, klass.table_name, rows\n\t\t\tend\n\n\t\t\tprogress.total = count\n\t\trescue Exception => e\n\t\t\tprogress.stop\n\t\t\traise e\n\t\tend\n\n\t\tprogress.finish\n\n\t\tputs \"Loaded #{count} records\"\n\tend", "def read_csv_file(csv_table_path)\r\n \r\n table_dimensions = detect_state_table_dim(csv_table_path)\r\n \r\n if table_dimensions==:one_d\r\n return read_1d_csv_file(csv_table_path)\r\n elsif table_dimensions==:two_d\r\n return read_2d_csv_file(csv_table_path)\r\n else\r\n raise \"Error: CSV File dimensions: #{table_dimensions}\"\r\n end # end if else \r\n \r\n end", "def csv_uploader(infile, organisationid)\n require 'csv'\n require 'timeout'\n# counter = 1\n begin \n CSV.parse(infile).drop(1).each do |row| \n# puts \"************************************\"\n# puts \"Started reading #{counter} row and inserting row in the table\"\n Customer.customer_build_from_csv(row, organisationid) \n# puts \"Ended the process of inserting #{counter} row in the table\"\n# puts \"************************************\"\n# counter += 1 \n end \n rescue\n retry\n# puts \"*****************************************\"\n# puts \"Anup got timeout error\"\n# puts \"*****************************************\" \n end\n end", "def upload_csv\n @title=\"Import Users\"\n if request.post?\n CSV.parse(params[:file].read, :encoding=>\"UTF-8\") do |row|\n row = row.collect(&:to_s).collect(&:strip).collect{|s| s.gsub(\"\\\"\", \"\")}\n # row = row[0].to_s.split(\"\\t\").collect(&:strip)\n\n\t Businessnew.create({:address=>row[3], :category=>row[10], :city=>row[4], :id=>row[0],\n :latitude=>row[9], :longitude=>row[8], :name=>row[1], :phone=>row[7],\n :postal_code=>row[6].split(\" \").join(''), :state=>row[5], :url=>row[2]}) if Businessnew.present?\n\n#force_encoding(\"UTF-8\")\n#.encode(\"ISO-8859-1\")\n#.force_encoding(\"ISO-8859-1\").encode(\"UTF-8\")\n#force_encoding(\"BINARY\")\n\n # CsvBusiness.create({\n # :address=>row[5],\n #:city=>row[6],\n #:company_name=>row[4],\n #:contact_name=>row[9],\n #:employee=>row[12],\n #:fax_number=>row[15],\n #:gender=>row[10],\n # :major_division_description=>row[0],\n # :phone_number=>row[14],\n # :province=>row[7],\n # :sales=>row[13],\n # :sic_2_code_description=>row[1],\n # :sic_4_code=>row[2],\n # :sic_4_code_description=>row[3],\n #:title=>row[11],\n #:zip_code=>row[8]\n # })\n\n=begin\n#20130615051307\n\t\tStoreTiming.create({:id=>row[0], :business_id=>row[1], :mon_from=>row[2], :mon_to=>row[3], :tue_from=>row[4], :tue_to=>row[5], :wed_from=>row[6], :wed_to=>row[7], :thur_from=>row[8], :thur_to=>row[9],\n :fri_from=>row[10], :fri_to=>row[11], :sat_from=>row[12], :sat_to=>row[13],\n :sun_from=>row[14], :sun_to=>row[15]})\n=end\n end\n\n flash[:notice] = \"Uploading completed.\"\n redirect_to root_path\n else\n render :layout => false\n end\n\n end", "def save_students\n #open the file for writing\n filename = get_filename\n #save each entry of the array @students into the file\n CSV.open(filename, \"wb\") do |csv|\n @students.each do |student|\n student_data = [student[:name], student[:cohort]]\n csv << student_data\n end\n end\n\nend", "def save_to_file(csv_file_name, trimmed_csv, saved_file = nil)\r\n unless saved_file.nil?\r\n saved_file.open(csv_file_name, 'w') { |file| file.puts(trimmed_csv) }\r\n return\r\n end\r\n\r\n dir = File.dirname(csv_file_name)\r\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\r\n File.open(csv_file_name, 'w') { |file| file.puts(trimmed_csv) }\r\n end", "def save_students\n file = CSV.open(@user_file, \"w\") do |csv|\n @students.each do |student|\n student_data = [student[:name], student[:cohort]]\n csv_line = student_data.join(\",\")\n csv << csv_line\n end\n end\nend", "def assign_csv_values_to_genericfile(row, generic_file)\n field_mappings = @import.import_field_mappings.where('import_field_mappings.key != ?', 'image_filename')\n field_mappings.each do |field_mapping|\n\n key_column_number_arr = @import.import_field_mappings.where(key: field_mapping.key).first.value.reject!{|a| a.blank? } \n key_column_value_arr = []\n\n # For certain fields the values in the csv are comma delimeted and need to be parsed\n if field_mapping.key == 'subject'\n key_column_number_arr.each do |num|\n key_column_value_arr = key_column_value_arr + (row[num.to_i].try(:split, ',') || [])\n end\n elsif field_mapping.key == 'collection_identifier'\n # it's not a multivalue field so let's just get the first mapping\n key_column_number_arr.each do |num|\n generic_file.collection_identifier = row[num.to_i]\n break\n end\n\n elsif field_mapping.key == 'measurements'\n key_column_number_arr.each do |num|\n measurement_hash = measurement_format_for(row[num.to_i].try(:strip))\n unless measurement_hash.nil?\n #insert field as a measurement object\n measurement = Osul::VRA::Measurement.create(measurement: measurement_hash[:width], measurement_unit: measurement_hash[:unit], measurement_type: \"width\") \n \n generic_file.measurements << measurement\n measurement = Osul::VRA::Measurement.create(measurement: measurement_hash[:height], measurement_unit: measurement_hash[:unit], measurement_type: \"height\") \n generic_file.measurements << measurement\n end\n end\n\n elsif field_mapping.key == 'materials'\n key_column_number_arr.each do |num|\n material_hash = material_format_for(row[num.to_i].try(:strip))\n unless material_hash.nil?\n material = Osul::VRA::Material.create(material_hash)\n generic_file.materials << material\n end\n end\n\n else\n key_column_number_arr.each do |num|\n key_column_value_arr << row[num.to_i]\n end\n end\n\n # materials and measurements are associations so they are updated differently \n unless field_mapping.key == 'materials' or field_mapping.key == 'measurements' or field_mapping.key == 'collection_identifier'\n key_column_value_arr = key_column_value_arr.map.reject{|a| a.blank?}\n generic_file.send(\"#{field_mapping.key}=\".to_sym, key_column_value_arr)\n end\n end\n end", "def write_to_csv(filename, latitude, longitude)\n CSV.open('output.csv', 'a+') do |csv|\n csv << [filename, latitude, longitude]\n end\nend", "def save_to_csv(players)\n CSV.open('../docs/collegeQBstats.csv', 'wb') do |csv|\n csv << [\"NAME\", \"POS\", \"CMP\", \"ATT\", \"CMP%\", \"YDS\", \"AVG\", \"LNG\", \"TD\", \"INT\", \"SACK\", \"RTG\"]\n for i in 0..players.length-1\n csv << [players[i].name, players[i].college, players[i].pos, players[i].cmp, players[i].att, players[i].cmp_pct, \n players[i].yds, players[i].lng, players[i].td, players[i].int, players[i].sack, players[i].rtg]\n end\n end\nend", "def read_csv(file_path)\n CSV.parse(File.read(file_path), headers: true)\nend", "def update_csv(card)\n @deck = Deck.new([card])\n text_to_add = write_csv\n file = File.open(\"./files/#{@filename}.txt\", 'a+')\n file.puts(write_csv)\n file.close\n @deck = @stupid_deck_saver\n\n end", "def process_csv\n @file = @file.tempfile\n CSV.foreach(@file, headers: false) { |row| process_item(row[0].to_i) }\n end", "def transform file_path, school_data_type\n if file_path.downcase.index('ads').blank? && !File.directory?(file_path)\n headers = @allowed_attendance_headers * \",\" if school_data_type == 'att'\n headers = @allowed_enrollment_headers * \",\" if school_data_type == 'enroll'\n headers = @allowed_ili_headers * \",\" if school_data_type == 'ili'\n perform_enrollment_transform file_path if school_data_type == 'enroll'\n file_name = File.join(@dir, \"the_temp_file.csv\")\n file_to_write = File.open(file_name, \"w\")\n line_number = 1\n file_to_write.puts headers\n IO.foreach(file_path, sep_string = get_sep_string(file_path)) do |line|\n if ( (line_number == 1 && @no_headers) || (line_number > 1) ) && !line.blank?\n values = []\n new_line = line.gsub(/[\"][^\"]*[\"]/) { |m| m.gsub(',','|') if @delimiter != \"|\" }\n new_line.gsub!(/['][^']*[']/) { |m| m.gsub(',','|') if @delimiter != \"|\" }\n new_line.gsub!(\",\",\"|\") if @delimiter == \"\\t\"\n new_line = new_line.gsub(\"\\t\", \",\")\n if @delimiter != \"\\t\" && @delimiter != \"|\" && @district.name != \"Midland\"\n new_line = new_line.gsub(\"','\", '\",\"')\n new_line = new_line.gsub(\",'\",',\"')\n new_line = new_line.gsub(', ','|')\n end\n if @delimiter == \"|\"\n new_line = new_line.gsub(\",\",\";\") if school_data_type == 'ili'\n new_line = new_line.gsub(\"|\",\",\")\n end\n value_pass = 1\n new_line.split(\",\").each do |value|\n if !value.blank?\n value.gsub!(\"|\",\",\")\n value.gsub!('\"',\"'\") if school_data_type != 'enroll'\n value.strip!\n #value.gsub!(@quote_value, \"\") if @quote_value == \"'\"\n value.gsub!(\"'\",'')\n value.strip!\n if !@six_digit_campus_id && @attendance_transform_fields.include?(value_pass) && school_data_type == 'att'\n value = \"0#{value}\" if value.length == 2\n value = \"00#{value}\" if value.length == 1\n value = \"#{@district.district_id}#{value}\"\n end\n if is_date? value\n value = is_date? value, true\n value = \"#{Time.parse(value).year}-#{Time.parse(value).month.to_s.rjust(2, '0')}-#{Time.parse(value).day.to_s.rjust(2, '0')} 00:00:00\"\n end\n value.gsub!(\"T00:\", \" 00:\") if @attendance_transform_fields.include?(value_pass) && @has_8601_date\n value.gsub!(\"T00:\", \" 00:\") if @enrollment_transform_fields.include?(value_pass) && @has_8601_date\n value.gsub!(\"T00:\", \" 00:\") if @ili_transform_fields.include?(value_pass) && @has_8601_date\n values.push('\"'+value+'\"') if school_data_type != 'enroll'\n values.push(value) if school_data_type == 'enroll'\n elsif value.blank? && school_data_type == 'ili'\n value.strip!\n values.push('\"'+value+'\"')\n end\n value_pass += 1\n end\n file_to_write.puts values.join(\",\")\n end\n line_number += 1 unless line.blank?\n end\n file_to_write.close\n File.rename(file_path, file_path+\".tmp\")\n File.rename(file_name, file_path)\n File.delete(file_path+\".tmp\")\n end\n end", "def csv_import\n @parsed_file=CSV::Reader.parse(params[:dump][:file], \";\")\n n=0\n @parsed_file.each do |row|\n c=Peca.new\n c.produto_id=row[0]\n c.codigo=row[1]\n c.descr=row[2]\n c.acab=row[3]\n c.larg=row[4]\n c.alt=row[5]\n c.prof=row[6]\n c.qtde=row[7]\n c.total=row[8]\n c.custo=row[9]\n c.fita=row[10]\n c.pino=row[11]\n c.embal=row[12]\n c.mdf=row[13]\n c.mdf2=row[14]\n c.ferr=row[15]\n c.ferr2=row[16]\n if c.save\n n=n+1\n GC.start if n%50==0\n end\n flash.now[:message]=\"Arquivo de peças importado com sucesso, #{n} registros adicionados à tabela.\"\n end\n end", "def save_csv_to_file(filename = \"resources/validators/csv/#{(URI(url).host + URI(url).path).gsub(%r{[./]}, '_')}.csv\")\n CSV.open(filename, 'wb') do |csv|\n valueset.each do |code|\n csv << [code[:system], code[:code]]\n end\n end\n end", "def get_csv_data(csv_file)\n\t\tcsv_file = File.read(csv_file)\n\t\tcsv = CSV.parse(csv_file, :headers => true)\t\n\t\tcsv\n\tend", "def write_rows file_name, names, values\n header = names.join(',') + \"\\n\"\n body = values.map {|row| row.join(',') }.join($/)\n File.open(file_name + \".csv\", 'w') { |f| f.write(header + body) }\nend", "def write_to_csv (time, platform, browser_name, browser_version, build, counter, num_cases, delay, duration, rate, test_name)\n googledrive_path=\"Google Drive/CODAP @ Concord/Software Development/QA\"\n localdrive_path=\"Documents/CODAP data/\"\n\n if !File.exist?(\"#{Dir.home}/#{$dir_path}/#{$save_filename}\") || $new_file\n CSV.open(\"#{Dir.home}/#{$dir_path}/#{$save_filename}\", \"wb\") do |csv|\n csv<<[\"Time\", \"Platform\", \"Browser\", \"Browser Version\", \"CODAP directory\", \"CODAP Build Num\", \"Test Name\", \"Counter\", \"Num of Cases\", \"Delay (s)\", \"Time Result (ms)\", \"Rate (cases/sec)\"]\n csv << [time, platform, browser_name, browser_version, build, $buildno, test_name, counter, num_cases, delay, duration, rate]\n end\n else\n CSV.open(\"#{Dir.home}/#{$dir_path}/#{$save_filename}\", \"a\") do |csv|\n csv << [time, platform, browser_name, browser_version, build, $buildno, test_name, counter, num_cases, delay, duration, rate]\n end\n end\nend", "def save_students\n puts \"Please enter the name of the file:\"\n filename = STDIN.gets.chomp + \".csv\"\n CSV.open filename , \"a\" do |csv|\n @students.each do |student|\n csv << [student[:name],student[:cohort]]\n end #end of do\n success\n end # end of CSV.open\n #file.close \nend", "def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @data << Employee.new(row)\n end\n end", "def import\n\n output = ''\n\n country_src = 'tmp/Countries.txt'\n \n rs = File.open(country_src)\n rs.gets # <-- remove first line (columns header) \"CountryID:Title\"\n countries = {}\n City.delete_all\n Region.delete_all\n Country.delete_all\n\n while (row = rs.gets) \n row = row.split(':')\n row[0].gsub!(/\\n/, '')\n row[1].gsub!(/\\n/, '')\n countries[row[0]] = {:name => row[1], :regions => {}, :model => nil}\n c = Country.new\n c.iso = row[0]\n c.name = row[1]\n c.save\n countries[row[0]][:model] = c\n end\n\n regions_src = 'tmp/Regions.txt'\n \n rs = File.open(regions_src)\n rs.gets # <-- remove the 1st line (header row) #CountryID:RegionID:Title\n while (row = rs.gets) \n row = row.split(':')\n row[0].gsub!(/\\n/, '')\n row[1].gsub!(/\\n/, '')\n row[2].gsub!(/\\n/, '')\n c = countries[row[0]][:model]\n r = Region.new\n r.iso = row[1]\n r.country_id = c.id\n\n # magic trick to ignore UTF-8 chars for now.\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n r.name = ic.iconv(row[2] + ' ')[0..-2]\n r.save\n countries[row[0]][:regions][row[1]] = r\n\n end\n\n cities_src = 'tmp/Cities.txt'\n \n rs = File.open(cities_src)\n rs.gets # <-- remove 1st row (header) #CountryID:RegionID:Title:Latitude:Longitude\n while(row = rs.gets)\n row = row.split(':')\n row[1].gsub!(/\\n/, '')\n row[2].gsub!(/\\n/, '')\n row[3].gsub!(/\\n/, '')\n row[4].gsub!(/\\n/, '')\n \n r = countries[row[0]][:regions][row[1]]\n if (!r.nil?) \n c = City.new\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n c.name = ic.iconv(row[2] + ' ')[0..-2] \n c.region_id = r.id\n c.lat = row[3]\n c.lng = row[4]\n c.save\n end\n end\n\n output += '<h1>Import complete</h1>'\n render(:text => output, :layout => false)\n end", "def write_to_file(timestamp, csv_record)\n return if storage_dir == File::NULL\n\n filename = filename(timestamp)\n storage_path = Pathname.new(storage_dir).join(filename)\n\n create_file(storage_path, csv_record) unless storage_path.exist?\n write_row(storage_path, csv_record)\n end", "def load_file(model)\n model.delete_all\n record_name = model.to_s.downcase.pluralize\n record_count = 0\n CSV.foreach(\"#{Rails.root}/db/data/#{record_name}.csv\", {headers: true}) do |line|\n model.create(line.to_hash)\n record_count += 1\n end\n puts \"Created #{record_count} #{model.to_s} records.\"\n end", "def open_data_for_write\n @data_file = CSV.open(data_file_full_path,\"w+\", @data_lib.csv_opt)\n @data_stream = @data_file\n end", "def post_csv(path, csv)\n file = Tempfile.new(['dotmailer-contacts', '.csv'])\n file.write csv\n file.rewind\n\n post path, :csv => file\n end", "def save_students\n puts \"Which file do you want to save to?\"\n file = STDIN.gets.chomp\n # open the file for writing\n CSV.open(file, \"wb\") do |csv|\n # iterate over the array of students\n @students.each do |student|\n student_data = [student[:name], student[:cohort]]\n csv_line = student_data\n csv.puts csv_line\n end\n end\nend", "def clean_n_conv csvfile\r\n puts \"Cleaning '\" + csvfile + \"'...\"\r\n tmpfile = csvfile + \".tmp\"\r\n FileUtils.move csvfile, tmpfile\r\n\t\r\n CSV.open(csvfile.downcase,'w',';') do |csv|\r\n CSV.open(tmpfile,'r',';') do |row|\r\n date = row[0]\r\n if /(\\d{2}[\\/-]){2}\\d{4}/.match date\r\n # an alternative format was used by tts in the glostrup files \r\n # for dates - switch day and month\r\n date[0..1],date[3..4] = date[3..4],date[0..1]\r\n date.gsub! '/','-'\r\n end\r\n csv << [date] + row[1..-1]\r\n end\t\r\n end\r\n FileUtils.remove tmpfile\r\nend", "def import_csv\n if current_admin.present? \n updated_user_id = current_admin.id\n create_user_id = current_admin.id\n else\n updated_user_id = current_user.id\n create_user_id = current_user.id\n end\n if (params[:file].nil?)\n redirect_to upload_csv_posts_path, notice: Messages::REQUIRE_FILE_VALIDATION \n elsif !File.extname(params[:file]).eql?(\".csv\")\n redirect_to upload_csv_posts_path, notice: Messages::WRONG_FILE_TYPE \n else\n error_msg = PostsHelper.check_header(Constants::HEADER,params[:file])\n if error_msg.present?\n redirect_to upload_csv_posts_path, notice: error_msg\n else \n Post.import(params[:file],create_user_id,updated_user_id)\n redirect_to posts_path, notice: Messages::UPLOAD_SUCCESSFUL\n end\n end\n end", "def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each, then convert to Entry using 'add_entry' method\r\n csv.each do |row|\r\n row_hash = row.to_hash\r\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\r\n end #end csv.each loop\r\n end" ]
[ "0.7053912", "0.6891978", "0.6891145", "0.6516779", "0.65161276", "0.64820725", "0.6467526", "0.6447237", "0.6437868", "0.6397502", "0.6358854", "0.6310676", "0.62716174", "0.6270609", "0.6258883", "0.6226451", "0.6222196", "0.62037605", "0.62018824", "0.6200083", "0.61763835", "0.6160739", "0.6108492", "0.60955125", "0.60836005", "0.60780203", "0.606555", "0.6056128", "0.60536736", "0.6052066", "0.6050997", "0.6048726", "0.6042967", "0.6041209", "0.60365087", "0.60349995", "0.60337526", "0.60264283", "0.60196537", "0.60056436", "0.6003225", "0.6001467", "0.5987271", "0.59863645", "0.5976416", "0.59750557", "0.5958597", "0.59481937", "0.5944918", "0.5921536", "0.591794", "0.5916406", "0.59120905", "0.59095186", "0.59091145", "0.5909085", "0.5906546", "0.59030294", "0.5902374", "0.5900585", "0.5899204", "0.58959204", "0.58917373", "0.5889446", "0.5888715", "0.58828276", "0.5869928", "0.5868829", "0.5868829", "0.5863299", "0.5857599", "0.58558416", "0.5847732", "0.5838544", "0.5836052", "0.5835852", "0.5835288", "0.5832919", "0.58327985", "0.58270174", "0.5824718", "0.58244896", "0.58211106", "0.58174616", "0.58151", "0.58119553", "0.5807965", "0.58044213", "0.5804184", "0.58033293", "0.57926315", "0.57878256", "0.5786393", "0.57822394", "0.5780537", "0.5777793", "0.5775947", "0.57732505", "0.5769614", "0.57684577", "0.5761928" ]
0.0
-1
Execute a query and create a data frame from the result
def from_sql(db, query) require 'daru/io/sql_data_source' SqlDataSource.make_dataframe(db, query) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(query)\n @query = query\n @conn, @adapter = choose_adapter(@dbh, @query)\n df_hash = result_hash\n Daru::DataFrame.new(df_hash).tap(&:update)\n end", "def execute_query\n the_query = create_query\n\n #to do: start and end offsets\n results = the_query.all.collect { |result|\n the_result = {id: result.id, uuid: result.uuid, start_offset_seconds: nil, end_offset_seconds: nil}\n OpenStruct.new(the_result)\n }\n to_return = {:search => self, :query => the_query, :items => results}\n OpenStruct.new(to_return)\n end", "def execute\n # build the query string\n # run the query\n # return the results\n end", "def query sql\n result = db[sql].all\n return result\n end", "def exec_query(query, conn = ActiveRecord::Base.connection)\n res = conn.exec_query(query)\n puts res.rows.map { |r| r.map(&:inspect).join(\",\") }.join('\\n')\n res.to_a\nend", "def run_query(q)\n return sky_table.query(q)\n end", "def db_query sql\n\n db = SQLite3::Database.new 'database.db'\n db.results_as_hash = true\n # debugging output in the terminal:\n puts '================='\n puts sql\n puts '================='\n results db.execute sql\n db.close might\n\n results # return results as query\nend", "def run(results)\n columns_names = rows.first.inject([]) {|m, kv| m << kv[0]; m}\n row_count = rows.size\n initial_data = results.all.map {|r| columns.map {|c| r[c]}}\n asrecordset = ASRecordset.new(row_count,column_names,initial_data)\n \tresult = asrecordset\n \treturn result\n end", "def exec_raw(sql, options = {})\n cursor = $connection.exec(sql)\n if(options[:return_hash])\n recordset, = pack_cursor(cursor, :return => \"hash\")\n return recordset\n else\n return_data = []\n while current_row = cursor.fetch()\n return_data.push(current_row)\n end\n return return_data\n end\n end", "def execute( sql, backwards_compat=false )\r\n result = @conn.query( sql )\r\n if backwards_compat\r\n return PGresult.new( result )\r\n else\r\n ResultSet.new result\r\n end\r\n rescue Exception => e\r\n raise DataAccessException.new( e.message, e ), $!, caller\r\n end", "def query(sql)\n @dataset = @database[sql] #Take SQL string and connect it to a DB\n #puts(\"Datset\", dataset)\n @fields = Array.new #Create blank array of field/column names\n @fields = @dataset.columns #Gets table field/column names\n #print(\"Fields\", @fields, \"\\n\") #debug \n @fieldCount = @fields.length\n\n begin\n @data = @dataset.all #Executes SQL\n rescue\n @data = Array.new\n end\n end", "def query( sql_string )\n \n # Connect to the Server\n connect\n \n # Bring the Data into a RecordSet\n rs.open( sql_string, cn )\n \n # Get the Headers\n fields = rs.Fields.each.map &:name\n \n # Turn the Data into a 2D Array\n data = rs.GetRows.transpose rescue [[]]\n \n # Load the headers & data into a RubyExcel Sheet\n RubyExcel::Workbook.new.load( [fields] + data )\n\n end", "def oracle_sql_results(sql, conn = VACOLS::Case.connection)\n result = conn.execute(sql)\n output = []\n while r = result.fetch_hash\n output << r\n end\n output\nend", "def result\n ActiveRecord::Base.connection.select_all(sql).entries\n end", "def run(query:)\n Vidalia::log(\"SQL query text: \\\"#{query}\\\"\",:style => :debug)\n open_connection\n result = launch_query_command(query: query)\n if result.size > 0\n count = 1\n result.each do |r|\n Vidalia::log(\"SQL query result (#{count}): \\\"#{r.inspect}\\\"\",:style => :debug)\n count += 1\n end\n else\n Vidalia::log(\"SQL query: NO RESULTS FOUND\",:style => :debug)\n end\n rescue Exception => e\n raise e\n else\n return result\n ensure\n close_connection\n end", "def run_tuples(query, options = {})\n GRel::Debugger.debug \"QUERYING SELECT...\"\n GRel::Debugger.debug query\n GRel::Debugger.debug \"** LIMIT #{@last_query_context.limit}\" if @last_query_context.limit\n GRel::Debugger.debug \"** OFFSET #{@last_query_context.offset}\" if @last_query_context.offset\n GRel::Debugger.debug \"----------------------\"\n args = {}\n args[:accept] = options[:accept] if options[:accept]\n args[:offset] = @last_query_context.offset if @last_query_context.offset\n args[:limit] = @last_query_context.limit if @last_query_context.limit\n @connection.query(@db_name,query, args).body\n end", "def perform_query\n Rails.logger.info queries.to_sql\n queries\n end", "def get_data sql\n #$log.debug \"SQL: #{sql} \"\n columns, *rows = @db.execute2(sql)\n #$log.debug \"XXX COLUMNS #{sql}, #{rows.count} \"\n content = rows\n return content\n end", "def retrieve_data_by_query\n @data_retrieved = nil\n\n # Define query for data retrieve.\n # Query is defined in a way that should be easily execute in an SQL client\n # So meeting_id will be forced in a second step\n data_retrieve_query = \"\n select ms.session_order,\n me.event_order,\n et.code as event_code,\n ht.code as heat_type,\n me.is_out_of_race,\n gt.code as gender_code,\n ct.age_begin,\n ct.code as category_code,\n \tmir.rank,\n mir.is_disqualified,\n mir.minutes,\n mir.seconds,\n mir.hundreds,\n mir.is_personal_best,\n mir.reaction_time,\n mir.standard_points,\n mir.meeting_individual_points,\n mir.goggle_cup_points,\n mir.team_points,\n s.complete_name,\n s.year_of_birth,\n ta.name as team_name,\n mir.updated_at,\n mir.team_id,\n mir.swimmer_id,\n mp.meeting_event_id,\n mir.meeting_program_id\n from meeting_sessions ms\n \tjoin meeting_events me on me.meeting_session_id = ms.id\n join heat_types ht on ht.id = me.heat_type_id\n \tjoin meeting_programs mp on mp.meeting_event_id = me.id\n join meeting_individual_results mir on mir.meeting_program_id = mp.id\n join event_types et on et.id = me.event_type_id\n join gender_types gt on gt.id = mp.gender_type_id\n join category_types ct on ct.id = mp.category_type_id\n join team_affiliations ta on ta.id = mir.team_affiliation_id\n join swimmers s on s.id = mir.swimmer_id\n where ms.meeting_id = VAR_MEETING_ID\n order by ms.session_order, me.event_order, ht.code, gt.code, ct.age_begin, mir.is_disqualified, mir.rank\n \"\n\n # Prepare data retrieve query with swimemr and date inteval as parameters\n data_retrieve_query.gsub!('VAR_MEETING_ID', @meeting.id.to_s)\n\n # Retrieve data\n @data_retrieved = ActiveRecord::Base.connection.exec_query(data_retrieve_query)\n end", "def exec_query(sql, name = nil, binds = [])\n result = without_prepared_statement?(binds) ? exec_no_cache(sql, name, binds) :\n exec_cache(sql, name, binds)\n result_array = result_as_array(result)\n if ArVer::GTEQ_4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end", "def set_values_from(result)\n @arguments = Arguments.new(result[0]['arguments'])\n @return_type = result[0]['return_type']\n @query = \"SELECT * FROM %s.%s(%s)\" % [\n quoted_schema,\n quoted_name,\n @arguments.to_params\n ]\n end", "def execute_query(query)\n ActiveRecord::Base.connection.select_all(query)\n end", "def query(q=\"\")\n if @connection != nil \n @data = MonetDBData.new(@connection)\n @data.execute(q)\n end\n return @data\n end", "def query_db(sql)\n db = SQLite3::Database.new 'database.sqlite3'\n db.results_as_hash = true\n\n puts sql # Optional but nice for debugging.\n\n results = db.execute sql\n db.close\n\n return results\nend", "def query(q=\"\")\n\t\tif @connection != nil\n\t\t\t@data = MonetDBData.new(@connection)\n\t\t\[email protected](q)\n\t\tend\n\t\treturn @data\n\tend", "def get_data()\n db = read_db() # open database for querying\n db.results_as_hash = true # format query results as a hash so columns available as keys\n all_records = db.execute('select * from tokens')\n return all_records # get hash of arrays\nend", "def read(query)\n fields = query.fields\n types = fields.map { |property| property.primitive }\n\n statement, bind_values = select_statement(query)\n\n records = []\n\n with_connection do |connection|\n command = connection.create_command(statement)\n command.set_types(types)\n\n reader = command.execute_reader(*bind_values)\n\n begin\n while reader.next!\n records << fields.zip(reader.values).to_hash\n end\n ensure\n reader.close\n end\n end\n\n records\n end", "def all\n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n results_as_objects(results)\n \n end", "def exec_query(sql, name = 'SQL', binds = [])\n log(sql, name, binds) do\n result = without_prepared_statement?(binds) ? exec_no_cache(sql) :\n exec_cache(sql, binds)\n result_array = result_as_array(result)\n if ActiveRecord::VERSION::MAJOR >= 4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end\n end", "def db_query( sql )\n\n db = SQLite3::Database.new 'database.db'\n db.results_as_hash = true\n # Debugging output in the terminal:\n puts '======================='\n puts sql\n puts '======================='\n results = db.execute sql\n db.close\n\n results # return the result of the query\nend", "def run(result)\r\n\t\t\r\n\t\tcolumn_names = Array.new #store the column names\r\n\t\tfields = result.fetch_fields #get all the fields\r\n\t\tfields.each do |field|\r\n\t\t\tcolumn_names << field.name #push a field into the coumn_names\r\n\t\tend\r\n\t\t\r\n\t\trow_count = result.num_rows #get the number of rows in the Mysql::Result\r\n\t\tinitial_data = Array.new #payload holder\r\n\t\t\r\n\t\tresult.data_seek(0) #Seek the cursor to the beginning of the data\r\n\t\twhile row = result.fetch_row\r\n\t\t\tinitial_data << row # add a row to the payload\r\n\t\tend\r\n\t\t\t\t\r\n\t\tasrecordset = ASRecordset.new(row_count,column_names,initial_data)\r\n\t\tresult = asrecordset\r\n\t\treturn result\r\n\tend", "def create_data_frame_for_returns(column_names_array)\n command = \"return_data=data.frame(\"\n\n column_names_array.each {|name| command << \"#{name.downcase}=#{name},\"}\n\n command.chomp!(\",\")\n command << \")\"\n\n @con.eval(\"#{command};Data = as.timeSeries(return_data)\")\n end", "def sql_query(sql)\n db = PG.connect(:dbname => 'todo_book', :host => 'localhost')\n query_result = db.exec(sql)\n db.close\n\n return query_result\nend", "def query(sql)\n database.execute2(sql)\n end", "def query(sql)\r\n\t\trecordset = WIN32OLE.new('ADODB.Recordset')\r\n\t\trecordset.Open(sql, @connection)\r\n\t\t@fields = []\r\n\t\trecordset.Fields.each do |field|\r\n\t\t\t@fields << field.Name\r\n\t\tend\r\n\r\n\t\tbegin\r\n\t\t\t# Transpose to have array of rows\r\n\t\t\t@data = recordset.GetRows.transpose\r\n\t\trescue\r\n\t\t\t@data = []\r\n\t\tend\r\n\r\n\t\trecordset.Close\r\n\tend", "def query(q)\n gql(prepare: true).query(q)\n end", "def query(query, options = {})\n GRel::Debugger.debug \"QUERYING DESCRIBE...\"\n GRel::Debugger.debug query\n GRel::Debugger.debug \"** LIMIT #{@last_query_context.limit}\" if @last_query_context.limit\n GRel::Debugger.debug \"** OFFSET #{@last_query_context.offset}\" if @last_query_context.offset\n GRel::Debugger.debug \"----------------------\"\n args = {:describe => true}\n #args = {}\n args[:accept] = options[:accept] if options[:accept]\n args[:offset] = @last_query_context.offset if @last_query_context.offset\n args[:limit] = @last_query_context.limit if @last_query_context.limit\n @connection.query(@db_name,query, args).body\n end", "def query_db(sql)\n pp sql\n db = SQLite3::Database.new('database.db')\n db.results_as_hash = true\n data = db.execute(sql)\n db.close\n data\nend", "def exec_query(sql, name = 'SQL', _binds = [], prepare: false)\n log(sql, name) do\n result = @connection.run(sql)\n ActiveRecord::Result.new(result.columns, result.rows)\n end\n end", "def run_query()\n return nil unless @query\n \n gres = @query.execute()\n if @filterClass \n fres = @filterClass.filter(gres)\n res = fres.kind_of?(Array) ? fres.join(\"\\n\") : fres.to_s\n elsif @filterBlock \n fres = @filterBlock.call(gres)\n res = fres.kind_of?(Array) ? fres.join(\"\\n\") : fres.to_s\n else\n res = fres.result_s\n end\n res\n end", "def query(sql)\n path = 'query'\n io = request path, :post, {}, {query: sql}, stream: true\n io.each do |l|\n yield l\n end\n end", "def generate_dataset\n return nil if query.nil?\n # execute the query\n data = Array ActiveRecord::Base.connection.execute(query)\n return [] if data.empty?\n # Convert the query into an easy to read format\n @dataset = [data.first.keys]+data.map{|dd|dd.values}\n return @dataset\n end", "def execute\n results = ResultSet.new( @db, @statement.to_s )\n\n if block_given?\n begin\n yield results\n ensure\n results.close\n end\n else\n return results\n end\n end", "def exec_query(sql, name = 'SQL', binds = [])\n translate(sql) do |sql, args|\n unless binds.empty?\n args = binds.map { |col, val| type_cast(val, col) } + args\n end\n log(expand(sql, args), name) do\n result, rows = @connection.execute(sql, *args) { |cursor| [cursor.fields, cursor.fetchall] }\n if result.respond_to?(:map)\n cols = result.map { |col| col.name } \n ActiveRecord::Result.new(cols, rows)\n else\n result\n end\n end\n end\n end", "def run(result)\t\t\n\t\tcolumn_names = result.fields #store the column names\n\t\trow_count = result.num_tuples #get the number of rows in the result\n\t\tinitial_data = Array.new #payload holder\n result.each do |item|\n intial_data << item.to_ary\n end\t\t\n\t\tasrecordset = ASRecordset.new(row_count,column_names,initial_data)\n\t\tresult = asrecordset\n\t\tresults\n\tend", "def db_query( sql )\n db = SQLite3::Database.new 'database.db'\n db.results_as_hash = true\n puts '==============================='\n puts sql # for debugging our SQL\n puts '==============================='\n result = db.execute sql\n db.close\n result # return the result of the query\nend", "def query(sql, name = nil) #:nodoc:\n log(sql, name) do\n @connection.execute(sql).rows\n end\n end", "def execute!(query)\n http_response = request.post(@url, params: @params, json: { query: query.to_gql })\n\n fail \"Error: #{http_response.reason}\\nBody: #{http_response.body}\" if http_response.status >= 300\n\n parsed_response = JSON.parse(http_response.to_s)\n data = parsed_response['data']\n errors = parsed_response['errors']\n\n Response.new(data, errors, query)\n end", "def query_name(v_quote)\n\n begin\n\n # connect to the database\n conn = PG.connect(dbname: 'test', user: 'something', password: '4321')\n\n # prepare SQL statement\n conn.prepare('q_statement',\n \"select details.id, name, age, quote\n from details\n join quotes on details.id = quotes.details_id\n where quote = $1\")\n\n # execute prepared SQL statement\n rs = conn.exec_prepared('q_statement', [v_quote])\n\n # deallocate prepared statement variable\n conn.exec(\"deallocate q_statement\")\n\n # return array of values returned by SQL statement\n return rs.values[0]\n\n rescue PG::Error => e\n\n puts 'Exception occurred'\n puts e.message\n\n ensure\n\n conn.close if conn\n\n end\n\nend", "def launch_query_command(query:)\n @db.query(query, as: :hash)\n end", "def query(query, values)\n handle.exec(query, values)\n end", "def query(soql)\n response = api_get 'query', :q => soql\n mashify? ? response.body : response.body['records']\n end", "def query_db (sql_statement)\n db = SQLite3::Database.new 'database.sqlite3'\n db.results_as_hash = true\n results = db.execute sql_statement\n db.close\n results\nend", "def query_name(v_name)\n\n begin\n\n # connect to the database\n conn = PG.connect(dbname: 'test', user: 'something', password: '4321')\n\n # prepare SQL statement\n conn.prepare('q_statement',\n \"select details.id, name, age, num_1, num_2, num_3\n from details\n join numbers on details.id = numbers.details_id\n where name = $1\")\n\n # execute prepared SQL statement\n rs = conn.exec_prepared('q_statement', [v_name])\n\n # deallocate prepared statement variable\n conn.exec(\"deallocate q_statement\")\n\n # return array of values returned by SQL statement\n return rs.values[0]\n\n rescue PG::Error => e\n\n puts 'Exception occurred'\n puts e.message\n\n ensure\n\n conn.close if conn\n\n end\n\nend", "def query(db, query, type = \"array\")\n begin\n result = db.query(query)\n return (type == \"hash\" ? result.to_hash : result.to_array)\n rescue Mysql::Error => e\n $stderr.puts \"Error code: #{e.errno}\"\n $stderr.puts \"Error message: #{e.error}\"\n $stderr.puts \"Error SQLSTATE: #{e.sqlstate}\" if e.respond_to?(\"sqlstate\")\n exit\n end\n end", "def execute(query)\n CellSet.new @connection.create_statement.execute_olap_query(query.to_s)\n end", "def query(sql, name = nil) #:nodoc:\n #log(sql, name) do\n #TODO: @async\n select_rows sql, name\n end", "def execute_query(sparql_query)\n puts \"Executing SPARQL Query: #{sparql_query} ...\"\n \n if sparql_query.include? \"DESCRIBE\"\n response = @repository.query(sparql_query, :result_type => RubySesame::DATA_TYPES[:N3]) \n puts response if @verbose\n end\n\n if sparql_query.include? \"SELECT\" \t\n response = @repository.query(sparql_query)\t\n puts response if @verbose\n end\n\n end", "def query_data(base_query)\n query = base_query\n result = Hash.new\n\n # Filters\n query = apply_filters(query, tablesorter_params)\n\n # Calculate row counts\n rec_counts = record_counts(base_query, query)\n result[:filtered_rows] = rec_counts[:filtered_rows]\n result[:total_rows] = rec_counts[:total_rows]\n\n # Handle paging afterwards\n query = handle_pagination(query, tablesorter_params, result)\n\n # Sorting\n query = apply_sorting(query, tablesorter_params)\n\n result[:records] = query\n\n result\n end", "def query(sql)\n res = process_sql(sql.gsub('(', '').gsub(')', ''))\n\n case res\n when Net::HTTPOK\n CSV.parse(res.body.force_encoding(\"UTF-8\"))\n when Net::HTTPFound\n raise Error.new(\"Authentication required. See #{self.class}#authenticate\")\n when Net::HTTPBadRequest\n message = CGI.unescapeHTML(res.body[%r[<title>(.*)</title>]i, 1])\n raise Error.new(\"#{message}. SQL was: #{sql}\")\n else\n raise \"Got #{res.class}: #{res.body}\"\n end\n end", "def query\n rdr = PostgresReader.new(@options)\n query = File.open(@sql_file, 'r', &:read)\n File.open(@output_file, 'w') do |file|\n rdr.query(query, file)\n end\n end", "def run\n _escaped_sql = escaped_sql\n @query_logger << _escaped_sql if @query_logger\n result = @conn.exec_query _escaped_sql\n row_class = OccamsRecord::Results.klass(result.columns, result.column_types, @eager_loaders.names, model: @eager_loaders.model, modules: @use)\n rows = result.rows.map { |row| row_class.new row }\n @eager_loaders.run!(rows, query_logger: @query_logger)\n rows\n end", "def query(sql, limit = 100)\n parse_rest(\n rest_request('SQL', sql_query_body(sql, limit))\n )\n end", "def execute\n render json: Schema.instance.execute(\n params[:query],\n variables: to_hash(params[:variables]),\n context: context\n )\n end", "def query(sql, name, binds)\n \n rs = SA.instance.api.sqlany_execute_direct(@connection, sql)\n raise ActiveRecord::StatementInvalid.new(\"#{SA.instance.api.sqlany_error(@connection)}:#{sql}\") if rs.nil?\n \n max_cols = SA.instance.api.sqlany_num_cols(rs)\n fields = {}\n max_cols.times do |i|\n fields[i] = SA.instance.api.sqlany_get_column_info(rs, i)[2]\n end\n \n rows = []\n while SA.instance.api.sqlany_fetch_next(rs) == 1\n result = Array.new(max_cols)\n max_cols.times do |cols|\n result[cols] = SA.instance.api.sqlany_get_column(rs, cols)[1]\n end\n rows << result\n end\n @affected_rows = SA.instance.api.sqlany_affected_rows(rs)\n SA.instance.api.sqlany_free_stmt(rs)\n\n return rows, fields\n end", "def query(soql_expr)\n result = http_get(\"/services/data/v#{self.version}/query\", :q => soql_expr)\n collection_from(result.body)\n end", "def drillthrough(query)\n RowSet.new @connection.create_statement.execute_query(query.to_s)\n end", "def mqlread(query, options = {})\n cursor = options[:cursor]\n if cursor\n query_result = []\n while cursor\n response = get_query_response(query, cursor)\n query_result += response['result']\n cursor = response['cursor']\n end\n else\n response = get_query_response(query, cursor)\n cursor = response['cursor']\n query_result = response['result']\n end\n query_result\n end", "def reading_data\n result_query = ActiveRecord::Base.connection.execute(\n 'select max, min, avg, reading_type from (' \\\n \" select max(temperature),min(temperature),avg(temperature),'temperature' as reading_type \" \\\n \" from device_readings where device_id = #{device.id} union \" \\\n \" select max(humidity),min(humidity),avg(humidity),'humidity' as reading_type \" \\\n \" from device_readings where device_id = #{device.id} union \" \\\n \" select max(battery_charge),min(battery_charge),avg(battery_charge),'battery_charge' as reading_type \" \\\n \" from device_readings where device_id = #{device.id} )as results\"\n )\n result_query\n end", "def query_db(sql_statement)\n db = SQLite3::Database.new 'database.sqlite3'\n db.results_as_hash = true\n\n puts sql_statement # optional but nice for debugging\n\n results = db.execute sql_statement\n db.close\n results # implicit return\n\nend", "def all\n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n\n results_as_objects(results)\n\n end", "def results_with_rows\n load_from_rows(@dataset.all, true)\n end", "def mqlread(query, options = {})\n Ken.logger.info \">>> Sending Query: #{query.to_json}\"\n cursor = options[:cursor]\n if cursor\n query_result = []\n while cursor\n response = get_query_response(query, cursor)\n query_result += response['result']\n cursor = response['cursor']\n end\n else\n response = get_query_response(query, cursor)\n cursor = response['cursor']\n query_result = response['result']\n end\n query_result\n end", "def ascii_query(sql,*values)\n sth = self.query(sql,*values)\n rows = sth.fetch_all\n col_names = sth.column_names\n sth.finish\n DBI::Utils::TableFormatter.ascii(col_names, rows)\n end", "def query_db(sql_statement)\n db = SQLite3::Database.new 'database.sqlite3'\n db.results_as_hash = true\n\n puts sql_statement\n\n results = db.execute(sql_statement) #action statement\n db.close #close the database\n results #return result\nend", "def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n # TODO put these lines back in and create another method to turn results_as_objects array of \n # objects in to array of hashes!!!!!!!\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end", "def get_data(user_name)\n begin\n conn = open_db()\n conn.prepare('q_statement',\n \"select *\n from details\n join numbers on details.id = numbers.details_id\n join quotes on details.id = quotes.details_id\n where details.name = '#{user_name}'\")\n user_hash = conn.exec_prepared('q_statement')\n conn.exec(\"deallocate q_statement\")\n return user_hash[0]\n rescue PG::Error => e\n puts 'Exception occurred'\n puts e.message\n ensure\n conn.close if conn\n end\nend", "def query_db (sql_statement)\n puts sql_statement # Option feature which will help for debugging\n db = SQLite3::Database.new 'database.sqlite3'\n db.results_as_hash = true\n result = db.execute sql_statement\n db.close\n result #implicitly returned\nend", "def _query(q, params={})\n engine = Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(db)\n result = engine.execute(q, Core::HashWithIndifferentAccess.new(params))\n Neo4j::Cypher::ResultWrapper.new(result)\n end", "def execute_query(options)\n results = solr_select(options)\n Chef::Log.debug(\"Bulk loading from #{@database}:\\n#{results.inspect}\") \n objects = if results[\"response\"][\"docs\"].length > 0\n bulk_objects = @couchdb.bulk_get( results[\"response\"][\"docs\"].collect { |d| d[ID_KEY] } )\n Chef::Log.debug(\"bulk get of objects: #{bulk_objects.inspect}\")\n bulk_objects\n else\n []\n end\n [ objects, results[\"response\"][\"start\"], results[\"response\"][\"numFound\"], results[\"responseHeader\"] ] \n end", "def select(sql)\n raise(ArgumentError, \"Bad sql parameter\") unless sql.kind_of?(String)\n\n client = ensure_connected\n\n Pod4.logger.debug(__FILE__){ \"select: #{sql}\" }\n query = client.execute(sql)\n\n rows = []\n query.each do |r| \n\n if block_given? \n rows << yield(r)\n else\n rows << r\n end\n\n end\n\n query.cancel \n rows\n\n rescue => e\n handle_error(e)\n end", "def query\n end", "def get_results(query, conditions, order)\n query_call = \"select * from #{domain} \"\n query_call << \"where #{conditions.compact.join(' and ')}\" if conditions.length > 0\n query_call << \" #{order}\"\n if query.limit!=nil\n query_limit = query.limit\n query_call << \" limit #{query.limit}\" \n else\n #on large items force the max limit\n query_limit = 999999999 #TODO hack for query.limit being nil\n #query_call << \" limit 2500\" #this doesn't work with continuation keys as it halts at the limit passed not just a limit per query.\n end\n results = sdb.select(query_call)\n \n sdb_continuation_key = results[:next_token]\n while (sdb_continuation_key!=nil && results[:items].length < query_limit)do\n old_results = results\n results = sdb.select(query_call, sdb_continuation_key)\n results[:items] = old_results[:items] + results[:items]\n sdb_continuation_key = results[:next_token]\n end\n\n results = results[:items][0...query_limit]\n end", "def all\n table_name = self.table_name\n \n results = CONNECTION.execute(\"SELECT * FROM '#{table_name}';\")\n\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n \n return results_as_objects\n end", "def run_sql(sql_query)\n\tconn = PG.connect(dbname: 'first_crud_app')\n\tresult = conn.exec(sql_query)\n\tconn.close\n\tresult\nend", "def resultset; end", "def execute_sql(my_sql)\n pg_result = ActiveRecord::Base.connection.execute(my_sql)\n\n # In this example we are just calling #to_a to convert the PG::Result to an\n # Array. PG::Result has a nice API for slicing and dicing itself so you may\n # want to to something clever instead. See\n # https://www.rubydoc.info/gems/pg/PG/Result for details.\n #\n # The important bit here is that we are copying all the data we care about\n # out of the PG::Result in preparation for later clearing the PG::Result\n results = pg_result.to_a\n\n # Calling #clear on the PG::Result is the important bit of cleanup and the\n # whole reason this method exists. See\n # https://www.rubydoc.info/gems/pg/PG/Result#clear-instance_method\n pg_result.clear\n\n yield results if block_given?\n\n results\nend", "def query(query)\n raw_query(query).map do |row|\n row = row.map do |item| \n # If the row entry is a String, it is the result already, and not, as \n # Neo4j.build would expect, the URL of a Neo4j node or relationship. The\n # same is true for all non-hashes.\n next item unless item.is_a?(Hash)\n build_from_hash(item)\n end\n \n row = row.first if row.length == 1\n row\n end\n end", "def query( sql, *bind_vars, &block ) # :yields: result_set\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute( &block )\n end", "def rows\n @rows ||= if ActiveRecord::Base.connection.adapter_name == \"PostgreSQL\"\n result.entries\n else\n [].tap do |row_hashes|\n result.entries.map do |row|\n hash = {}\n result.fields.each do |field|\n hash[field] = row[result.fields.index(field)]\n end\n row_hashes << hash\n end\n end\n end\n end", "def run_sql(sql)\n #connect to the|db|\n conn = PG.connect(:dbname => 'rogbloll')\n\n\n #execute the db in the argument\n res = conn.exec(sql)\n\n #now close the db\n conn.close\n\n #now return the result of the query...\n res\n\n\n \n end", "def execute\n result = nil\n ActiveRecord::Base.connection_pool.with_connection do |con|\n result = con.execute(to_sql)\n end\n if @sql_returning.nil?\n nil\n else\n if @returning_flat\n result.values.map{|r| r.first}\n else\n result\n end\n end\n end", "def query(yql_query, format='json', diagnostics='false')\n # TODO tried to make the necessary parameters more flexibel. failed for now :)\n # format = (hash.nil? or hash[:format.to_s].nil?) ? 'json' : hash[:format.to_s]\n # format = (hash && hash[:format]) || 'json'\n\n @log.info \"SimpleClient query()\"\n\n # try to run YQL query. If an error occures return an empty array\n begin\n\n #\n # Httparty version\n #\n options = {\n :query => {\n :env => SimpleClient.env, #\"store://datatables.org/alltableswithkeys\",\n :diagnostics => diagnostics,\n :format => format,\n :q => yql_query\n }\n }\n\n yahoo_response = self.class.get('/', options)\n\n #\n # Curl Version\n #\n\n # # put together request URL\n # full_request_url = \"#{@@yql_api_url}?diagnostics=#{diagnostics}\"\n # full_request_url += \"&#{@@env}\"\n # full_request_url += \"&format=#{format}\"\n # full_request_url += \"&q=#{CGI.escape(yql_query)}\"\n\n # request = Curl::Easy.http_get(full_request_url)\n # request.perform\n # # pp request.header_str\n # if format == 'json'\n # yahoo_response = JSON.parse(request.body_str)\n # elsif format == 'xml'\n # yahoo_response = Nokogiri::XML(request.body_str)\n # end\n\n rescue Exception => ex\n puts ex\n end\n\n return yahoo_response\n end", "def raw_query(query) #:nodoc:\n logger.benchmark \"cypher: #{query}\" do\n result = connection.execute_query(query)\n if result\n result[\"data\"]\n else\n []\n end\n end\n end", "def execute_query(query)\n dimension_names = query.all_dimensions? ? [] :\n query.referenced_dimensions.dup.\n concat(Wonkavision::Analytics.context.global_filters.\n select{ |f| f.dimension?}.map{ |dim_filter| dim_filter.name }).uniq.\n sort{ |a,b| a.to_s <=> b.to_s }\n\n filters = (query.filters + Wonkavision::Analytics.context.global_filters).compact.uniq\n\n fetch_tuples(dimension_names, filters)\n end", "def fetch_rows(sql)\n execute(sql) do |r|\n i = -1\n cps = db.conversion_procs\n cols = r.fetch_fields.map do |f| \n # Pretend tinyint is another integer type if its length is not 1, to\n # avoid casting to boolean if convert_tinyint_to_bool is set.\n type_proc = f.type == 1 && cast_tinyint_integer?(f) ? cps[2] : cps[f.type]\n [output_identifier(f.name), type_proc, i+=1]\n end\n self.columns = cols.map(&:first)\n if opts[:split_multiple_result_sets]\n s = []\n yield_rows(r, cols){|h| s << h}\n yield s\n else\n yield_rows(r, cols){|h| yield h}\n end\n end\n self\n end", "def all \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_name}\")\n \n return self.results_as_objects(results)\n end", "def run_query(query, server, database = \"postgres\")\n query_command = \"psql -d #{database} -U postgres -c \\\"#{query}\\\"\"\n probe(server, query_command)\n end", "def execute(sql)\n raise(ArgumentError, \"Bad sql parameter\") unless sql.kind_of?(String)\n\n client = ensure_connected\n\n Pod4.logger.debug(__FILE__){ \"execute: #{sql}\" }\n r = client.execute(sql)\n\n r.do\n r\n\n rescue => e\n handle_error(e)\n end" ]
[ "0.7155133", "0.668187", "0.65245724", "0.64619875", "0.6428561", "0.64222574", "0.6419511", "0.64045465", "0.63543665", "0.63390696", "0.63262814", "0.6315325", "0.6311962", "0.6310839", "0.6299909", "0.62983733", "0.6240305", "0.62366605", "0.6219141", "0.6210278", "0.6185919", "0.6162007", "0.61603177", "0.61169964", "0.61153954", "0.6077199", "0.60430264", "0.60124665", "0.60052603", "0.5982123", "0.5981483", "0.59808886", "0.5969777", "0.5953753", "0.5952296", "0.59440905", "0.593398", "0.59331036", "0.59190595", "0.5917712", "0.58942235", "0.5862793", "0.58530885", "0.5852734", "0.58509463", "0.58508694", "0.584936", "0.5848354", "0.5848102", "0.5840088", "0.583423", "0.5821674", "0.5815009", "0.58106554", "0.5809261", "0.5799641", "0.57976365", "0.5796702", "0.57948524", "0.57906413", "0.5787868", "0.5784378", "0.57754713", "0.5766196", "0.5765148", "0.57614", "0.5747694", "0.574621", "0.57396674", "0.57383084", "0.5734948", "0.57211894", "0.57013774", "0.57009697", "0.5698815", "0.56983477", "0.5694557", "0.5693697", "0.56924736", "0.5679557", "0.56672186", "0.56606257", "0.5656965", "0.56516975", "0.56456774", "0.5642838", "0.5637717", "0.56369704", "0.5634157", "0.5631429", "0.5627029", "0.56215906", "0.56145436", "0.56046706", "0.5600704", "0.5592664", "0.55923903", "0.5590778", "0.55848014" ]
0.6906371
1
Load dataframe from AR::Relation
def from_activerecord(relation, *fields) if fields.empty? records = relation.map do |record| record.attributes.symbolize_keys end return Daru::DataFrame.new(records) else fields = fields.map(&:to_sym) end vectors = fields.map { |name| [name, Daru::Vector.new([], name: name)] }.to_h Daru::DataFrame.new(vectors, order: fields).tap do |df| relation.pluck(*fields).each do |record| df.add_row(Array(record)) end df.update end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_activerecord(relation, *fields)\n fields = relation.klass.column_names if fields.empty?\n fields = fields.map(&:to_sym)\n\n result = relation.pluck(*fields).transpose\n Daru::DataFrame.new(result, order: fields).tap(&:update)\n end", "def from_sql(db, query)\n require 'daru/io/sql_data_source'\n SqlDataSource.make_dataframe(db, query)\n end", "def from_sql(db, query)\n require 'daru/io/sql_data_source'\n SqlDataSource.make_dataframe(db, query)\n end", "def results_with_rows\n load_from_rows(@dataset.all, true)\n end", "def transport_dataframe(r_dataframe_name, model, connection)\n\n r = connection\n\n array_of_arrays = eval(model).column_names.map { |column| eval(model).all.order(:id).map(&column.to_sym) }\n # Note: .order(:id) means that if attributes have been edited and the ids are out of order, it will return data in correct orders\n\n column_names = eval(model).column_names\n\n # Transport each column to R interpreter\n array_of_arrays.each_with_index do |column, index|\n puts index\n r.eval Transport.transport_column(column_names[index], column) \n end\n\n # Now create an R dataframe from the columns \n output = r_dataframe_name.to_s + \" <- data.frame(\" + column_names.join(', ') + \", stringsAsFactors=FALSE); print(\" + r_dataframe_name + \")\"\n\n return output\n\nend", "def load\n super\n slice_records!\n\n self\n end", "def wrap_dataset(dataset)\n if relation.is_a?(Relation::Composite)\n relation.new(dataset).to_a\n else\n dataset\n end\n end", "def load\n rows = fire\n columns = rows.shift\n result = []\n rows.map do |el|\n obj = table_name.camelize.singularize.constantize.new\n columns.each_with_index do |column,index|\n obj.instance_variable_set(\"@#{column}\".to_sym, el[index])\n end\n result << obj\n end\n reset\n result\n end", "def convert_input_dataset(ds)\n case ds\n when Symbol, SQL::Identifier, SQL::QualifiedIdentifier, SQL::AliasedExpression, LiteralString\n self.simple_table = db.literal(ds).freeze\n ds = db.from(ds)\n when Dataset\n if ds.joined_dataset?\n # raise Error, \"Using a joined dataset as a model dataset is not support, use from_self on the dataset to wrap it in a subquery\" # SEQUEL5\n Sequel::Deprecation.deprecate(\"Using a joined dataset as a Sequel::Model dataset\", respond_to?(:cti_base_model) ? \"Use the class_table_inheritance plugin :alias option in #{cti_base_model.inspect}\" : \"Call from_self on the dataset to wrap it in a subquery\")\n end\n\n self.simple_table = if ds.send(:simple_select_all?)\n ds.literal(ds.first_source_table).freeze\n end\n @db = ds.db\n else\n raise(Error, \"Model.set_dataset takes one of the following classes as an argument: Symbol, LiteralString, SQL::Identifier, SQL::QualifiedIdentifier, SQL::AliasedExpression, Dataset\")\n end\n\n set_dataset_row_proc(ds.clone(:model=>self))\n end", "def run(results)\n columns_names = rows.first.inject([]) {|m, kv| m << kv[0]; m}\n row_count = rows.size\n initial_data = results.all.map {|r| columns.map {|c| r[c]}}\n asrecordset = ASRecordset.new(row_count,column_names,initial_data)\n \tresult = asrecordset\n \treturn result\n end", "def as_table\n @as_table ||= Arel::Table.new(:authorized_objects_to_hydrate)\n end", "def dataset\n DB[SQL, from: from_truncated, to: to_truncated, tick: tick]\n end", "def convert_input_dataset(ds)\n case ds\n when Symbol, SQL::Identifier, SQL::QualifiedIdentifier, SQL::AliasedExpression, LiteralString\n self.simple_table = db.literal(ds).freeze\n ds = db.from(ds)\n when Dataset\n ds = ds.from_self(:alias=>ds.first_source) if ds.joined_dataset?\n\n self.simple_table = if ds.send(:simple_select_all?)\n ds.literal(ds.first_source_table).freeze\n end\n @db = ds.db\n else\n raise(Error, \"Model.set_dataset takes one of the following classes as an argument: Symbol, LiteralString, SQL::Identifier, SQL::QualifiedIdentifier, SQL::AliasedExpression, Dataset\")\n end\n\n set_dataset_row_proc(ds.clone(:model=>self))\n end", "def eager_loading_dataset(eo=OPTS)\n ds = eo[:dataset] || associated_eager_dataset\n if id_map = eo[:id_map]\n ds = ds.where(eager_loading_predicate_condition(id_map.keys))\n end\n if associations = eo[:associations]\n ds = ds.eager(associations)\n end\n if block = eo[:eager_block]\n ds = block.call(ds)\n end\n if eager_loading_use_associated_key?\n ds = ds.select_append(*associated_key_array)\n end\n if self[:eager_graph]\n raise(Error, \"cannot eagerly load a #{self[:type]} association that uses :eager_graph\") if eager_loading_use_associated_key?\n ds = ds.eager_graph(self[:eager_graph])\n end\n ds\n end", "def dataset(name)\n fetch_or_store(name) { Dataset.new(rql.table(name), rql, self) }\n end", "def lateral\n cached_dataset(:_lateral_ds){clone(:lateral=>true)}\n end", "def load_datasource\n @datasource.write(query.to_json)\n @datasource.rewind # be kind\n @datasource.path\n end", "def load\n query = (arguments or self).info_sql\n Squirm.exec(query, [name, schema]) do |result|\n validate result\n set_values_from result\n end\n self\n end", "def _associated_dataset\n associated_class.dataset.clone\n end", "def prefetch_rows\n raise NoMethodError, \"Not implemented for this raw driver\"\n end", "def residual_load\n render_serializer QueryCurveCSVSerializer.new(\n Etsource::Config.residual_load_csv,\n @scenario.gql,\n 'residual_load'\n )\n end", "def read_all(res, klass, options = nil)\n return [] if res.blank?\n\n if options and join_relations = options[:include]\n join_relations = [join_relations].flatten.collect do |n|\n klass.relation(n)\n end\n end\n\n objects = []\n\n if options and options[:select]\n res.each_row do |res_row, row|\n obj = klass.og_allocate(res_row, row)\n read_row(obj, res, res_row, row)\n objects << obj\n end\n else\n res.each_row do |res_row, row|\n obj = klass.og_allocate(res_row, row)\n obj.og_read(res_row, row)\n read_join_relations(obj, res_row, row, join_relations) if join_relations\n objects << obj\n end\n end\n\n return objects\n\n ensure\n res.close\n end", "def dataset\n database.from(:robots)\n end", "def coerce(object)\n project_relation(Relation.new(header, object))\n end", "def load\n records.load\n end", "def load\n records.__send__(:load)\n end", "def to_a\n return @records if loaded?\n\n load\n end", "def read_join_relations(obj, res_row, row, join_relations)\n offset = obj.class.serializable_attributes.size\n\n for rel in join_relations\n rel_obj = rel[:target_class].og_allocate(res_row, row)\n rel_obj.og_read(res_row, row, offset)\n offset += rel_obj.class.serializable_attributes.size\n obj.instance_variable_set(\"@#{rel[:name]}\", rel_obj)\n end\n end", "def dataset\n database[table_name]\n end", "def load_database(filename)\n \n handle = File.open(filename)\n uncompressed = Zlib::GzipReader.new(handle)\n records = DnaIO.new(uncompressed)\n records.to_a\nend", "def import(points_attrs)\n points = points_attrs.map do |point_attrs|\n r = attrs_to_point(point_attrs)\n r[:series] ||= table_name\n r\n end\n connection.import(points)\n end", "def dataset_from_row(row)\n datasets = Dataset.where(geo_id: row['geo_id'], user: User.robot)\n\n if @create_missing && datasets.none?\n Dataset.create!(\n row.to_h.slice('geo_id', 'name', 'country', 'data_source').merge(user: User.robot)\n )\n else\n datasets.first!\n end\n rescue ActiveRecord::RecordNotFound => ex\n raise ActiveRecord::RecordNotFound,\n \"No dataset exists matching geo ID: #{row['geo_id'].inspect}\",\n ex.backtrace\n end", "def parse_json(csv_file)\n data_frame = Daru::DataFrame.from_csv(csv_file)\n data_frame\nend", "def import\n import_data(load_dataset_hash)\n end", "def get_dataset(table)\n #puts \"converting to a dataset\"\n to_dataset(@datafiles[table].content)\n end", "def from_csv path, opts={}\n daru_options, opts = from_csv_prepare_opts opts\n # Preprocess headers for detecting and correcting repetition in\n # case the :headers option is not specified.\n hsh =\n if opts[:headers]\n from_csv_hash_with_headers(path, opts)\n else\n from_csv_hash(path, opts)\n .tap { |hash| daru_options[:order] = hash.keys }\n end\n Daru::DataFrame.new(hsh,daru_options)\n end", "def load(query)\n raise NotImplementedError, 'Expected adapter to override `load`'\n end", "def load_from_row(row)\n row.each_with_index { |val, i| self[i] = val } # @dbs[i].kind_of?(Numeric) ? val.to_i : val }\n return self\n end", "def load record\n end", "def call(query)\n @query = query\n @conn, @adapter = choose_adapter(@dbh, @query)\n df_hash = result_hash\n Daru::DataFrame.new(df_hash).tap(&:update)\n end", "def dataset(opts=nil)\n Sequel::Swift::Postgres::Dataset.new(self, opts)\n end", "def load_type\n :relation\n end", "def tuples\n relation = self.relation\n return relation if materialized?\n\n adapter.read(relation)\n end", "def load\n csv = csv_data\n @data = TableFu.new(csv_data, @table_opts[:column_options] || {})\n if @table_opts[:faceting]\n @data.col_opts[:ignored] = [@table_opts[:faceting][:facet_by]]\n @facets = @data.faceted_by @table_opts[:faceting][:facet_by]\n end\n @data.delete_rows! @table_opts[:dead_rows] if @table_opts[:dead_rows]\n end", "def from_json_object(json_)\n Table.new(Structure.from_json_array(json_['axes'] || []), :load => json_['values'] || [])\n end", "def to_relation\n scope.where(tree.columns.id => id)\n end", "def all\n @data_adapter.relations\n end", "def associated_dataset\n cached_fetch(:_dataset){apply_dataset_changes(_associated_dataset)}\n end", "def data(opts = {})\n sources = self.attributes[:sources] || []\n seq_opts = {:kind => self.attributes[:kind].to_sym}.merge(opts)\n sequence = SequenceQuery.new(sources, seq_opts)\n seqs = sequence.sequences\n seqs.map do |seq|\n {\n :data => seq[1],\n :start_time => sequence.start_time_epoch,\n :source => seq[0]\n }\n end\n end", "def from_csv path, opts={}\n daru_options, opts = from_csv_prepare_opts opts\n\n # Preprocess headers for detecting and correcting repetition in\n # case the :headers option is not specified.\n hsh =\n if opts[:headers]\n from_csv_hash_with_headers(path, opts)\n else\n from_csv_hash(path, opts)\n .tap { |hash| daru_options[:order] = hash.keys }\n end\n\n Daru::DataFrame.new(hsh,daru_options)\n end", "def rows\n @rows ||= if ActiveRecord::Base.connection.adapter_name == \"PostgreSQL\"\n result.entries\n else\n [].tap do |row_hashes|\n result.entries.map do |row|\n hash = {}\n result.fields.each do |field|\n hash[field] = row[result.fields.index(field)]\n end\n row_hashes << hash\n end\n end\n end\n end", "def _schema_ds\n @_schema_ds ||= begin\n ds = metadata_dataset.select{[\n pg_attribute[:attname].as(:name),\n SQL::Cast.new(pg_attribute[:atttypid], :integer).as(:oid),\n SQL::Cast.new(basetype[:oid], :integer).as(:base_oid),\n SQL::Function.new(:format_type, basetype[:oid], pg_type[:typtypmod]).as(:db_base_type),\n SQL::Function.new(:format_type, pg_type[:oid], pg_attribute[:atttypmod]).as(:db_type),\n SQL::Function.new(:pg_get_expr, pg_attrdef[:adbin], pg_class[:oid]).as(:default),\n SQL::BooleanExpression.new(:NOT, pg_attribute[:attnotnull]).as(:allow_null),\n SQL::Function.new(:COALESCE, SQL::BooleanExpression.from_value_pairs(pg_attribute[:attnum] => SQL::Function.new(:ANY, pg_index[:indkey])), false).as(:primary_key),\n Sequel[:pg_type][:typtype],\n (~Sequel[Sequel[:elementtype][:oid]=>nil]).as(:is_array),\n ]}.\n from(:pg_class).\n join(:pg_attribute, :attrelid=>:oid).\n join(:pg_type, :oid=>:atttypid).\n left_outer_join(Sequel[:pg_type].as(:basetype), :oid=>:typbasetype).\n left_outer_join(Sequel[:pg_type].as(:elementtype), :typarray=>Sequel[:pg_type][:oid]).\n left_outer_join(:pg_attrdef, :adrelid=>Sequel[:pg_class][:oid], :adnum=>Sequel[:pg_attribute][:attnum]).\n left_outer_join(:pg_index, :indrelid=>Sequel[:pg_class][:oid], :indisprimary=>true).\n where{{pg_attribute[:attisdropped]=>false}}.\n where{pg_attribute[:attnum] > 0}.\n order{pg_attribute[:attnum]}\n\n # :nocov:\n if server_version > 100000\n # :nocov:\n ds = ds.select_append{pg_attribute[:attidentity]}\n\n # :nocov:\n if server_version > 120000\n # :nocov:\n ds = ds.select_append{Sequel.~(pg_attribute[:attgenerated]=>'').as(:generated)}\n end\n end\n\n ds\n end\n end", "def dataset(opts=nil)\n Sequel::JDBC::AS400::Dataset.new(self, opts)\n end", "def dataset(opts=nil)\n Sequel::JDBC::AS400::Dataset.new(self, opts)\n end", "def direct_import_from_csv(dataset, opts = {:to => nil, :delimiter => nil, :header => nil})\n delimiter = opts[:delimiter] || \",\"\n header = \"HEADER\" if opts[:header] == true\n table = opts[:to].table_name\n raise TypeError if dataset.class != String\n ActiveRecord::Base.connection.execute(\"COPY #{table} FROM '#{dataset}' DELIMITER \\'#{delimiter}\\' CSV #{header}\")\n end", "def load_records\n native_instance(true)\n native_instance.top(limit) if limit.present?\n Array(service.native_instance.execute)\n end", "def finalize(opts = {})\n # Can we use opts[:from] instead of first_source_table and override?\n model_table_name = opts[:model_table_name] || model.raw_dataset.first_source_table\n sel_col = model.columns.map { |c| Sequel.qualify(model_table_name, c) }\n return select(*sel_col) if opts[:no_finalize]\n extra_columns = [opts[:extra_columns]].flatten.compact\n extra_columns_src = extra_columns.map { |c| c.try(:expression) || c }\n\n ds = select(*sel_col,\n Sequel.function(:rank)\n .over(:partition => @opts[:partition_columns] ||\n (extra_columns_src +\n [last_record_id,\n last_branch_path].compact),\n :order => @opts[:order_columns] ||\n Sequel.qualify(model_table_name,\n :version).desc))\n if last_branch_path_context\n ds = ds.select_append(last_branch_path_context.as(:branch_path_context))\n end\n\n ds = ds.select_append(*extra_columns) unless extra_columns.empty?\n\n if opts[:extra_deleted_column]\n ds = ds.select_append(opts[:extra_deleted_column].as(:extra_deleted))\n end\n\n return ds if opts[:include_all]\n\n ds = ds.from_self.where(:rank => 1)\n unless opts[:include_deleted]\n ds = ds.where(:deleted => false)\n ds = ds.where(:extra_deleted => false) if opts[:extra_deleted_column]\n end\n ds = ds.select(*model.columns)\n ds = ds.select_append(:branch_path_context) if last_branch_path_context\n if opts[:extra_columns]\n ds = ds.select_append(*extra_columns.map { |c| c.try(:aliaz) || c.try(:column) || c })\n end\n ds\n end", "def data(options = {})\n add_required_columns(options[:required_columns])\n @rows ||= aggregate\n end", "def to_csv_data( options={} )\n fields = self.class.to_csv_fields( options ).fields\n data, model_data = [], fields.inject( [] ) { |arr,field| arr << attributes[field].to_s }\n if options[:include]\n to_csv_data_for_included_associations( options[:include ] ).map do |assoc_csv_data|\n data << model_data + assoc_csv_data\n end\n else\n data << model_data\n end\n data\n end", "def active_records(relation)\n ActiveRecordProxy.new(@client, @search_definition, relation)\n end", "def perform_load( _options = {} )\n require 'csv'\n\n raise \"Cannot load - failed to create a #{klass}\" unless load_object\n\n logger.info \"Starting bulk load from CSV : #{file_name}\"\n\n # TODO: - can we abstract out what a 'parsed file' is - headers plus value of each node\n # so a common object can represent excel,csv etc\n # then we can make load() more generic\n\n parsed_file = CSV.read(file_name)\n\n # assume headers are row 0\n header_idx = 0\n header_row = parsed_file.shift\n\n set_headers( DataShift::Headers.new(:csv, header_idx, header_row) )\n\n # maps list of headers into suitable calls on the Active Record class\n bind_headers(headers)\n\n begin\n puts 'Dummy Run - Changes will be rolled back' if(DataShift::Configuration.call.dummy_run)\n\n load_object_class.transaction do\n logger.info \"Processing #{parsed_file.size} rows\"\n\n parsed_file.each_with_index do |row, i|\n\n logger.info \"Processing Row #{i} : #{row}\"\n\n # Iterate over the bindings, creating a context from data in associated Excel column\n\n @binder.bindings.each_with_index do |method_binding, i|\n\n unless method_binding.valid?\n logger.warn(\"No binding was found for column (#{i}) [#{method_binding.pp}]\")\n next\n end\n\n # If binding to a column, get the value from the cell (bindings can be to internal methods)\n value = method_binding.index ? row[method_binding.index] : nil\n\n context = doc_context.create_node_context(method_binding, i, value)\n\n logger.info \"Processing Column #{method_binding.index} (#{method_binding.pp})\"\n\n begin\n context.process\n rescue StandardError => x\n if doc_context.all_or_nothing?\n logger.error(\"ERROR at : #{x.backtrace.first.inspect}\")\n logger.error(x.inspect)\n logger.error('Complete Row aborted - All or nothing set and Current Column failed.')\n doc_context.failed!\n end\n end\n end # end of each column(node)\n\n doc_context.reset and next if doc_context.errors?\n\n doc_context.save_and_monitor_progress\n\n doc_context.reset unless doc_context.node_context.next_update?\n end # all rows processed\n\n if(DataShift::Configuration.call.dummy_run)\n puts 'CSV loading stage done - Dummy run so Rolling Back.'\n raise ActiveRecord::Rollback # Don't actually create/upload to DB if we are doing dummy run\n end\n end # TRANSACTION N.B ActiveRecord::Rollback does not propagate outside of the containing transaction block\n rescue StandardError => e\n puts \"ERROR: CSV loading failed : #{e.inspect}\"\n raise e\n ensure\n report\n end\n\n puts 'CSV loading stage Complete.'\n end", "def dataset\n ds = Sequel::Dataset.new(self)\n end", "def dataset\n ds = Sequel::Dataset.new(self)\n end", "def table(name)\n Arel::Table.new(name, :engine => attribute.relation.engine)\n end", "def post_load(all_records)\n end", "def load_query\n universe.load_query(select_cols)\n end", "def test_arff_parse\n in_file = './test_arff.arff'\n rel = Rarff::Relation.new\n rel.parse(File.open(in_file).read)\n\n assert_equal(rel.instances[2][1], 3.2)\n assert_equal(rel.instances[7][4], 'Iris-setosa')\n end", "def data(options = {})\n sheetname = options[:sheetname]\n column = options[:column]\n filename = options[:filename]\n\n data = []\n\n spreadsheet = Roo::Spreadsheet.open(filename)\n\n csv = CSV.parse(spreadsheet.sheet(sheetname).to_csv, { :headers => true })\n\n csv.each do |row|\n country = Country.find_by_name(row['Region'])\n next unless country\n\n # Get all quarterly cells\n #row.select{|h,v| h.match(/Q\\d \\d{4}/)}.each do |header, value|\n quarter, year = *sheetname.split(' ')\n start_date = Date.new(year.to_i, QUARTER_MAP[quarter][0], QUARTER_MAP[quarter][1])\n\n value = row[ column ].to_f\n if options[ :multiplier ].present?\n value *= options[ :multiplier ]\n end\n\n i = Indicator.new( :start_date => start_date, :original_value => value )\n i.country = country\n data << i\n #end\n end\n data\n end", "def table\n model_class.arel_table\n end", "def coerce_to_relation(summarize_with)\n if summarize_with.kind_of?(Relation)\n summarize_with\n else\n project(Relation::Header.coerce(summarize_with))\n end\n end", "def import_csv_full\n \n end", "def read\n rows = to_a\n if @use_headers\n Table.new(rows)\n else\n rows\n end\n end", "def data\n datacolumns.reduce({}) do |t, col|\n t[col.name] = col.data; t\n end\n end", "def all_as_objects\n table_name = self.to_s.pluralize\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n \n results_as_objects << self.new(result_hash)\n \n end\n \n return results_as_objects\n \n end", "def from(source_data_set)\n if source_data_set.respond_to? :source_data_set\n source_data_set = source_data_set.source_data_set\n elsif source_data_set.kind_of? String\n source_data_set = PublicEarth::Db::DataSet.find_by_id!(source_data_set)\n end\n @history.data_set = @current_source_data_set = source_data_set\n end", "def bt_temporal_attributes\n attributes.slice(*TemporalColumnNames)\n end", "def transpose_hbase_row_to_record_attributes_and_raw_data(row) # :nodoc:\n if field = attributes_schema[inheritance_attribute]\n if cell_with_record_sti_class = row.columns[field.unique_name] and cell_with_record_sti_class.present?\n if klass = field.decode(cell_with_record_sti_class.value) and klass.present?\n ensure_sti_class_is_loaded(klass)\n end\n end\n end\n\n super\n end", "def index\n @table_relations = TableRelation.all\n end", "def table_name\n if qualified? && meta[:qualified].is_a?(Symbol)\n meta[:qualified]\n else\n source.dataset\n end\n end", "def download_raw_data\n sql = \"select \"\n if self.has_regions?\n sql << \"`region`,\"\n end\n sql << \" `district_id`,\"\n if self.has_district_names?\n sql << \"`district_name`,\"\n end\n if self.is_local_majoritarian?\n sql << \"`major_district_id`, \"\n end\n\n sql << \"`precinct_id`,\n `num_possible_voters`,\n `num_special_voters`,\n `num_at_12`,\n `num_at_17`,\n `num_votes`,\n `num_ballots`,\n `num_invalid_votes`,\n `num_valid_votes`,\n `logic_check_fail`,\n `logic_check_difference`,\n `more_ballots_than_votes_flag`,\n `more_ballots_than_votes`,\n `more_votes_than_ballots_flag`,\n `more_votes_than_ballots`,\n `supplemental_documents_flag`,\n `supplemental_document_count`,\n `amendment_flag`,\n `explanatory_note_flag`,\n `is_annulled`, \"\n\n parties = Party.hash_for_analysis(self.id, true)\n if parties.present?\n party_sql = []\n parties.each do |party|\n party_sql << \"`#{party[:id]} - #{party[:name]}`\"\n end\n end\n sql << party_sql.join(', ')\n sql << \" from `#{@@analysis_db}`.`#{self.analysis_table_name} - raw`\n order by district_id, precinct_id \"\n results = @@client.exec_query(sql)\n\n if results.present?\n csv_data = CSV.generate(col_sep: ',', force_quotes: true) do |csv|\n # add header\n csv << results.columns\n\n # data\n # - each row is a hash so just need to get values\n results.each do |row|\n csv << row.values\n end\n end\n end\n\n return csv_data\n end", "def load_data\n raise NotImplementedError\n end", "def generate_dataset\n return nil if query.nil?\n # execute the query\n data = Array ActiveRecord::Base.connection.execute(query)\n return [] if data.empty?\n # Convert the query into an easy to read format\n @dataset = [data.first.keys]+data.map{|dd|dd.values}\n return @dataset\n end", "def loadHistoric()\n\t\treturn @rankedDB.execute(\"SELECT historic FROM ranked WHERE idMap = '#{@idMap}'\").shift.shift\n\tend", "def read_column\n raw = @target_instance.read_attribute(column_name)\n raw ? @serializer.load(raw) : {}\n end", "def sql_load\n row = DBIntf.get_first_row(\"SELECT * FROM #{tbl_name} #{generate_where_on_pk};\")\n return row.nil? ? reset : load_from_row(row)\n end", "def dataset(opts=nil)\n Sequel::JDBC::Oracle::Dataset.new(self, opts)\n end", "def ungraphed\n ds = super.clone(:eager_graph=>nil)\n if (eg = @opts[:eager_graph]) && (rp = eg[:row_proc])\n ds = ds.with_row_proc(rp)\n end\n ds\n end", "def from_self(opts=OPTS)\n fs = {}\n @opts.keys.each{|k| fs[k] = nil unless non_sql_option?(k)}\n pr = proc do\n c = clone(fs).from(opts[:alias] ? as(opts[:alias], opts[:column_aliases]) : self)\n if cols = _columns\n c.send(:columns=, cols)\n end\n c\n end\n\n opts.empty? ? cached_dataset(:_from_self_ds, &pr) : pr.call\n end", "def importDataSource(file, *sync_column)\n\n\nend", "def to_data_array(data_set)\n case\n when data_set.is_a?(Daru::DataFrame)\n return ArgumentError unless data_set.index.is_a?(Daru::Index)\n data_set.access_row_tuples_by_indexs(*data_set.index.to_a)\n when data_set.is_a?(Daru::Vector)\n rows = []\n data_set.to_a.each { |a| rows << [a] }\n rows\n when data_set.is_a?(Array)\n data_set\n else\n raise ArgumentError # TODO: error msg\n end\n end", "def show_dataset\n @dataset = Dataset.find(params[:dataset_id])\n @data = (ActiveRecord::Base.connection.select_all(\"SELECT * from dataset_#{@dataset.id} ORDER BY id ASC\")).to_json\n render :inline => @data\n end", "def _join_table_dataset(opts)\n ds = model.db.from(opts.join_table_source)\n opts[:join_table_block] ? opts[:join_table_block].call(ds) : ds\n end", "def _dataset(opts)\n raise(Sequel::Error, \"model object #{inspect} does not have a primary key\") if opts.dataset_need_primary_key? && !pk\n ds = if opts[:dataset].arity == 1\n instance_exec(opts, &opts[:dataset])\n else\n instance_exec(&opts[:dataset])\n end\n _apply_association_options(opts, ds)\n end", "def rows\n RowCollection.new(@data)\n end", "def load_restaurant_inspection_model(restaurants_csv, locations_csv, restaurant_locations_csv)\n @db.transaction do\n @db.alter_table :restaurant_locations do\n drop_foreign_key [:restaurant_camis]\n drop_foreign_key [:location_id]\n end\n\n @db[:restaurant_locations].truncate\n @db[:restaurants].truncate\n @db[:locations].truncate\n\n @db.alter_table :restaurant_locations do\n add_foreign_key [:restaurant_camis], :restaurants, unique: true\n add_foreign_key [:location_id], :locations\n end\n\n @db.copy_into(:restaurants, data: restaurants_csv, format: :csv, options: 'HEADER true')\n @db.copy_into(:locations, data: locations_csv, format: :csv, options: 'HEADER true')\n @db.copy_into(:restaurant_locations, data: restaurant_locations_csv, format: :csv, options: 'HEADER true')\n end\n end", "def index\n @dataset_data = DatasetDatum.all\n end", "def association_symbol_for_rows\n @importing_reflection ||= self.class.import_into\n end", "def eager_load_results(eo, &block)\n rows = eo[:rows]\n initialize_association_cache(rows) unless eo[:initialize_rows] == false\n if eo[:id_map]\n ids = eo[:id_map].keys\n return ids if ids.empty?\n end\n strategy = eager_limit_strategy\n cascade = eo[:associations]\n eager_limit = nil\n\n if eo[:eager_block] || eo[:loader] == false\n ds = eager_loading_dataset(eo)\n\n strategy = ds.opts[:eager_limit_strategy] || strategy\n\n eager_limit =\n if el = ds.opts[:eager_limit]\n raise Error, \"The :eager_limit dataset option is not supported for associations returning a single record\" unless returns_array?\n strategy ||= true_eager_graph_limit_strategy\n if el.is_a?(Array)\n el\n else\n [el, nil]\n end\n else\n limit_and_offset\n end\n\n strategy = true_eager_graph_limit_strategy if strategy == :union\n # Correlated subqueries are not supported for regular eager loading\n strategy = :ruby if strategy == :correlated_subquery\n strategy = nil if strategy == :ruby && assign_singular?\n objects = apply_eager_limit_strategy(ds, strategy, eager_limit).all\n elsif strategy == :union\n objects = []\n ds = associated_dataset\n loader = union_eager_loader\n joiner = \" UNION ALL \"\n ids.each_slice(subqueries_per_union).each do |slice|\n objects.concat(ds.with_sql(slice.map{|k| loader.sql(*k)}.join(joiner)).to_a)\n end\n ds = ds.eager(cascade) if cascade\n ds.send(:post_load, objects)\n else\n loader = placeholder_eager_loader\n loader = loader.with_dataset{|dataset| dataset.eager(cascade)} if cascade\n objects = loader.all(ids)\n end\n\n objects.each(&block)\n if strategy == :ruby\n apply_ruby_eager_limit_strategy(rows, eager_limit || limit_and_offset)\n end\n end", "def load!\n records_by_identity = index_by { |record| record.key_values }\n\n record_set.find_each_row do |row|\n identity = row.values_at(*record_set.key_column_names)\n records_by_identity[identity].hydrate(row)\n end\n\n loaded_count = count { |record| record.loaded? }\n if loaded_count < count\n raise Cequel::Record::RecordNotFound,\n \"Expected #{count} results; got #{loaded_count}\"\n end\n\n self\n end", "def load(contents, opts={})\n table = infer_csv_contents(contents, opts)\n return nil unless contents\n table.each do |row|\n self.add(*row)\n end\n end" ]
[ "0.6899915", "0.5885378", "0.5885378", "0.5681491", "0.5633544", "0.5607167", "0.5296113", "0.5291698", "0.5078717", "0.5078102", "0.5066383", "0.5064495", "0.50395834", "0.50111485", "0.49696183", "0.4960796", "0.49511477", "0.49497566", "0.48886317", "0.4886219", "0.48663077", "0.4862228", "0.48565587", "0.48542178", "0.4843862", "0.4841473", "0.48378742", "0.4827586", "0.4805606", "0.47704476", "0.47542226", "0.47495", "0.47416338", "0.47372824", "0.47147408", "0.46889746", "0.46784583", "0.46782377", "0.46719944", "0.46659985", "0.46620968", "0.46578074", "0.46568486", "0.46547136", "0.4653771", "0.4651299", "0.46436912", "0.4641519", "0.4640987", "0.46408266", "0.46379492", "0.46365649", "0.46159312", "0.46159312", "0.46097815", "0.46035093", "0.46009925", "0.4595358", "0.45933557", "0.4590608", "0.4571169", "0.4570015", "0.4570015", "0.45696157", "0.45525798", "0.45431978", "0.45376918", "0.45325753", "0.45324937", "0.4530558", "0.45290774", "0.45197463", "0.45192", "0.4517349", "0.4515498", "0.45081595", "0.4507201", "0.4500817", "0.44981676", "0.4493368", "0.44886583", "0.4483585", "0.44747254", "0.4467061", "0.44637376", "0.4457577", "0.44507226", "0.44404095", "0.44386506", "0.4437789", "0.44360986", "0.44357574", "0.44343308", "0.44334555", "0.44220287", "0.4419134", "0.44118476", "0.44036973", "0.4396045", "0.43923238" ]
0.6936078
0
Loading data from plain text files
def from_plaintext filename, fields ds = Daru::DataFrame.new({}, order: fields) fp = File.open(filename,'r') fp.each_line do |line| row = Daru::IOHelpers.process_row(line.strip.split(/\s+/),['']) next if row == ["\x1A"] ds.add_row(row) end ds.update fields.each { |f| ds[f].rename f } ds end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_text(filename); end", "def parse_file\n @file ||= File.open(@file_name) unless @file_name.nil?\n @text = @file.readlines\n @file.close unless @file.nil?\n parse_text\n end", "def fromFile( filename ) \n lines = IO.readlines( filename )\n loadAll( lines )\n end", "def load_english_a\n File.open(\"test/test_files/english_a.txt\", \"r\").read\n end", "def load_file_data(file)\n @data = separate_into_blocks(IO.readlines(file))\n end", "def load_file_contents(filename)\n File.open(filename).readlines\n end", "def load_file(file); end", "def load_file(filename); end", "def load_file(filename); end", "def load(file); end", "def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end", "def load(file_path); end", "def load(file_path); end", "def read_data_file(path); end", "def read_files\r\n @prefixes = IO.read('prefixes.txt').split(' ')\r\n @syllables = IO.read('syllables.txt').split(' ')\r\n @postfixes = IO.read('postfixes.txt').split(' ')\r\n end", "def strings_to_lines_textualed\n strings = File.read(file_name)\n strings.extend Textual\n new = strings.to_textual\n end", "def initialize(options={})\n options = {:file => nil, :text => nil}.merge options\n \n if options[:file]\n @filename = options[:file]\n @text = IO.readlines( @filename ).to_s\n end\n \n if options[:text]\n @text = options[:text]\n @filename = nil\n end\n \n raise( NoTextError, @filename ) if @text == nil\n \n\n \n split\n \n end", "def load_words\n File.read(\"../scrabble word cheat/words.txt\").split(\"\\n\")\nend", "def read_file\n\t\tif @filename == \"\"\n\t\t\t@text = [\"\"]\n\t\t\treturn\n\t\telse\n\t\t\tif File.exists? @filename\n\t\t\t\ttext = IO.read(@filename)\n\t\t\telse\n\t\t\t\t@text = [\"\"]\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t# get rid of crlf\n\t\ttemp = text.gsub!(/\\r\\n/,\"\\n\")\n\t\tif temp == nil\n\t\t\t@eol = \"\\n\"\n\t\telse\n\t\t\t@eol = \"\\r\\n\"\n\t\tend\n\t\ttext.gsub!(/\\r/,\"\\n\")\n\t\t@text = text.split(\"\\n\",-1)\n\tend", "def load(data)\n end", "def read(files); end", "def read(files); end", "def read_data(file_name)\n file = File.open(file_name,\"r\")\n object = eval(file.gets.untaint.encode('UTF-8', :invalid => :replace, :replace => '').gsub('\\n', \"\"))\n file.close()\n return object\nend", "def load_data\n self.open if @io.nil?\n @lines = @io.readlines\n @io.rewind\n @lines.delete_if {|line| line.match(/^\\s*$/)}\n @num_lines = @lines.count\n end", "def load_normal_database\n en_et_dm_lnd\n if FileTest.directory?(\"Data/Text/#{SES::ExternalText::Languages[0]}\")\n create_text\n end\n $game_text = load_data(\"Data/#{check_language}.rvdata2\")\n end", "def import_file(file)\n records = IO.readlines(file)\n Vocabulary::DB.transaction do\n records.each { |record| string_processing record }\n end\n end", "def load(files = T.unsafe(nil), reparse = T.unsafe(nil)); end", "def readFile\r\n\t\tfile = File.open(fileName, \"r\")\r\n\r\n\t\t#Array for partial matches\t\t\r\n\t\t@dictionary = Array.new\r\n\t\tfile.each do |line|\r\n\t\t\tif line != \"\\n\"\r\n\t\t\t\t@dictionary << line.split(/[:;\\n]/)\r\n\t\t\tend\r\n\t\tend\r\n\t\tstartStrategies\r\n\tend", "def LoadFile ()\n\t\n\tinput = \"\"\n\tFile.foreach(\"../Data Files/042-Words.txt\") {|x| input = x }\n\tnames = input.split(\",\")\n\t\n\treturn names;\nend", "def load(filename)\n end", "def read_loaded_txt_file_to_array(file)\n\ttext_array = file.read.split(\",\")\nend", "def load_data(filename=nil)\n filename=data_file(filename)\n return unless File.exist?(filename)\n case File.extname(filename).downcase\n when \".yaml\",\".yml\"\n YAML.load(File.open(filename))\n when \".json\"\n JSON.parse(File.read(filename))\n else\n File.read(filename)\n end\n end", "def readFile()\n\t#This is assuming the file name will be used\n\tfilename = 'names-data.txt'\n\topen(filename, 'r') {|f| f.read}\nend", "def load_file(path)\n file_array = IO.readlines(path)\n file_array.map {|element| element.chomp}\nend", "def load_translations(*filenames); end", "def load_translations(*filenames); end", "def read_data(file_name)\r\n file = File.open(file_name,\"r\")\r\n object = eval(file.gets.untaint.encode('UTF-8', :invalid => :replace))\r\n file.close()\r\n return object\r\nend", "def read_text(name, extension = '.json')\n File.read(\n [\n __FILE__.gsub(%r{(?<=/spec/).*}, ''),\n 'texts/',\n name,\n extension\n ].join\n )\nend", "def read_data(file_name)\n file = File.open(file_name,\"r\")\n object = eval(file.gets)\n file.close()\n return object\nend", "def load(filename)\n\t\tend", "def load_file(f)\n\t\tdata = []\n f.each do |line| \n user_id, movie_id, rating, timestamp = line.split(\"\\t\")\n data.push({\"user_id\"=> user_id.to_i, \"movie_id\"=>movie_id.to_i,\"rating\"=> rating.to_i,\"timestamp\"=>timestamp.to_i})\n\t\tend\n\t\treturn data\n\tend", "def read_post_text_files\n open(MENTION_FILE, 'r:UTF-8') do |file|\n @reply_mention_text = file.readlines.collect{|line| line.strip}\n end\n\n open(NOTMEITAN_FILE, 'r:UTF-8') do |file|\n @notmeitan_text = file.readlines.collect{|line| line.strip}\n end\n\n open(REPLY_CSHARP_FILE, 'r:UTF-8') do |file|\n @reply_csharp_text = file.readlines.collect{|line| line.strip}\n end\n\n open(REPLY_MORNING_FILE, 'r:UTF-8') do |file|\n @reply_morning_text = file.readlines.collect{|line| line.strip}\n end\n\n open(REPLY_SLEEPING_FILE, 'r:UTF-8') do |file|\n @reply_sleeping_text = file.readlines.collect{|line| line.strip}\n end\n\n open(REPLY_DEPARTURE_FILE, 'r:UTF-8') do |file|\n @reply_departure_text = file.readlines.collect{|line| line.strip}\n end\n\n open(REPLY_RETURN_FILE, 'r:UTF-8') do |file|\n @reply_return_text = file.readlines.collect{|line| line.strip}\n end\n\n log 'notmeitan text:'\n for s in @notmeitan_text do\n log ' ' + s\n end\n\n log 'reply text:'\n for s in @reply_mention_text do\n log ' ' + s\n end\n\n log 'reply csharp text:'\n for s in @reply_csharp_text do\n log ' ' + s\n end\n\n log 'reply departure text:'\n for s in @reply_departure_text do\n log ' ' + s\n end\n\n log 'reply returning text:'\n for s in @reply_return_text do\n log ' ' + s\n end\n end", "def load_from_file(file, options = T.unsafe(nil)); end", "def load_used_phrases\n\t@used_phrases = load_collection_from_file(@phrase_file_name, {});\nend", "def load_data\n @data=[]\n marker_found=false\n @file.rewind\n @file.each_line do |line|\n if !marker_found && @sentinel.call(line) then\n marker_found=true\n end\n\n @data << line if marker_found\n end\n end", "def read_word_file\n File.open(\"5desk.txt\").each { |line| @text_file << line }\n end", "def load_source!\n @source = load_file_contents\n end", "def read_data\n @files.each do |file|\n @source.location = file[:location]\n instance_variable_set('@' + file[:var].to_s,\n @source.send(file[:method], file[:klass]))\n end\n end", "def load(path); end", "def load_data\n data = {}.with_indifferent_access\n\n %w[.json .yaml].each do |ext|\n Dir.glob(\"#{DATA_DIR}/*#{ext}\") do |fname|\n key = File.basename(fname, ext).to_sym\n puts \"Loading data[:#{key}] from #{fname}...\"\n data[key] =\n if ext == '.json'\n JSON.parse(File.read(fname))\n else\n Psych.parse(fname)\n end\n end\n end\n\n data\n end", "def load_all_from_files\n\t\tload_hash_from_file($searched, $progDir+'searched.txt')\n\t\tload_hash_from_file($downloaded, $progDir+'downloaded.txt')\n\t\tload_array_from_file($toSearch, $progDir+'toSearch.txt')\n\t\tload_array_from_file($toDownload, $progDir+'toDownload.txt')\n\trescue => e\n\t\t$error.save_error_to_file(__method__, e, $specialErrorTxt)\n\tend", "def load_file!(file)\n if File.file?(file)\n yaml = %w{.yaml .yml}.include?(File.extname(file))\n text = File.read(file)\n if yaml or /\\A---/ =~ text\n #text = ERB.new(text).result(Object.new.instance_eval{binding})\n data = YAML.load(text)\n data.each do |k,v|\n __send__(\"#{k}=\", v)\n end\n else\n # TODO: Should we really do this here?\n instance_eval(text, file, 0)\n end\n end\n end", "def load(filename)\n file_content = File.open(filename).read\n TOMLP::Parser.new(file_content).parse\n end", "def load_data(fileName)\n set = open(fileName, 'r')\n data = []\n set.each_line do |line|\n categories = line.split(' ')\n data.push(categories)\n end\n return data\n end", "def load_data(data_file)\n puts \"FileGenTask: Loading data from YML file [ #{data_file} ]\" if @verbose\n df = DataFile.new\n @data = df.read( data_file )\n end", "def load_data (file, data, k=nil)\n\t\ti=0\n\t\tfile.each_line do |line|\n\t\t\tif i ==k \n\t\t\t\tbreak\n\t\t\tend\n\t\t\twords = line.split(\"\\t\")\n\t\t\tif data.has_key?(words[0].to_i)\n\t\t\t\tdata[words[0].to_i].store_data(words[1].to_i,words[2].to_i)\n\t\t\telse\n\t\t\t\tx = User_data.new\n\t\t\t\tx.store_data(words[1].to_i,words[2].to_i)\n\t\t\t\tdata.store(words[0].to_i, x)\n\t\t\tend\n\t\t\ti+=1\n\t\tend\n\tend", "def parse_txt_file(filename)\n file_lines = []\n File.open(filename).each do |line|\n file_lines << line.chomp\n end\n file_lines\nend", "def load_data\n\t\tFile.open(\"#{@path_to_training}\", \"r\").each_line do |line|\n\t\t\ta = line.split\n\t\t\tadd_movie(a[1].to_i, a[0].to_i, a[2].to_i)\n\t\t\tadd_user(a[0].to_i, a[1].to_i, a[2].to_i)\n\t\tend\n\t\tif File.file?(\"#{@path_to_test}\") then\n\t\t\tFile.open(\"#{@path_to_test}\", \"r\").each_line do |line|\n\t\t\t\ta = line.split\n\t\t\t\t@list_of_test_set << Rating.new(a[0].to_i, a[1].to_i, a[2].to_i)\n\t\t\tend\n\t\tend\n\tend", "def open_data(file)\n @data = JSON.parse(IO.readlines(file).join)\n end", "def load(fn) # :nodoc:\n lines = File.read fn\n lines.gsub!(/\\\\ /, SPACE_MARK)\n lines.gsub!(/#[^\\n]*\\n/m, \"\")\n lines.gsub!(/\\\\\\n/, \" \")\n lines.each_line do |line|\n process_line(line)\n end\n end", "def load(fn)\n return if ! File.exists?(fn)\n lines = File.read fn\n lines.gsub!(/\\\\ /, SPACE_MARK)\n lines.gsub!(/#[^\\n]*\\n/m, \"\")\n lines.gsub!(/\\\\\\n/, ' ')\n lines.each_line do |line|\n process_line(line)\n end\n end", "def load(filename, wrap=false) end", "def initialize(text_file_name)\n @dictionary = Hash.new(0)\n contents = IO.read(text_file_name)\n wordsInFile = words(contents)\n train!(wordsInFile)\n end", "def read\n x = nil\n File.open(@filename, 'r') {|f| x = f.readlines }\n x.each do |line|\n\n line = self.class.remove_comments(line)\n\n if line.present?\n @data << self.class.extract_data_from_line(line)\n # puts self.class.extract_data_from_line(line).to_yaml\n end\n end\n end", "def load_lines file\n\n\t\tlines = Array.new\n\t\tlines = @file.split(\"\\n\")\n\n\t\t#fuck that, i dont like the dyanmic feed, just pre-parse it\n\t\tlines.map! do |line| #map overwrites the old array\n\t\t\tif line.include? '#'\n\t\t\t\tsplit = line.split '#'\n\t\t\t\t#puts split.to_s\n\t\t\t\tsplit.shift\n\t\t\telse\n\t\t\t\tline\n\t\t\tend\n\t\tend\n\n\t\t#removing blank lines\n\t\tlines.delete_if do |line|\n\t\t\ttrue if line.empty?\n\t\tend\n\n\t\tlines.each { |line| line.chomp! }\n\n\t\tlines\n\tend", "def read_languages_from_file(data_file)\n File.open(data_file, 'rb') do |fin|\n until fin.eof\n label, outputs = Marshal.load(fin)\n yield label, outputs\n end\n end\nend", "def load_rb(filename); end", "def load_sample_data\n\tbegin # try to load the file\n\t\t# open the file and create an array to hold it\n\t\tsample_data_file = File.open($sample_data_filename)\n\t\tsample_contents = Array.new{Array.new}\n\t\ti = 0\n\t\t# add the contents of the file to the two-dimensional array\n\t\tsample_data_file.each do |line|\n\t\t\tsample_contents[i] = line.split(\",\").map(&:strip)\n\t\t\ti += 1\n\t\tend\n\t\treturn sample_contents\n\trescue # catch exceptions\n\t\tabort \"Unable to continue - sample data file #{$sample_data_filename} not found.\"\n\tend\nend", "def init_texts\n texts = text_file_get(27)\n with_surface(114, 19, 95) do\n add_line(0, texts[3]) # Type\n add_line(1, texts[36]) # Category\n add_line(0, texts[37], dx: 1) # Power\n add_line(1, texts[39], dx: 1) # Accuracy\n end\n @move_info = SpriteStack.new(@viewport)\n @move_info.with_surface(114, 19, 95) do\n @move_info.add_line(0, :power_text, 2, type: SymText, color: 1, dx: 1)\n @move_info.add_line(1, :accuracy_text, 2, type: SymText, color: 1, dx: 1)\n @move_info.add_line(2, :description, type: SymMultilineText, color: 1).width = 195\n end\n @move_info.push(175, 21, nil, type: TypeSprite)\n @move_info.push(175, 21 + 16, nil, type: CategorySprite)\n end", "def load\n @lines.select! do |line|\n line.strip.length != 0\n end.select! do |line|\n line[0] != '#'\n end.map! do |line|\n line.split(\" \")\n end\n\n self\n end", "def load_dictionary\n @scrubbed_dict = File.readlines(\"dictionary.txt\")\n puts \"Dictionary loaded\"\n end", "def load_file_contents(file)\n File.open(file, 'r').read\n end", "def parsed_file\n data.split(\"\\n\").map do |line|\n line.split(' ')\n end\n end", "def load_words(file_name)\n words_loaded = []\n File.open(file_name).readlines.each do |line|\n words_loaded << line if line.length.between?(5, 12)\n end\n words_loaded\n end", "def parse_translation_file(pattern, model)\n # check if all languages have an associated column name\n Florensia::Language.all.map(&:name).each do |l|\n next if model.columns.map(&:name).include?(l)\n error \"Fatal error: '#{l}' not found in column names of {model.name} but within Florensia::Language\"\n raise \"Translation/Description Language Error\"\n end\n\n batch(Dir[pattern]) do |f|\n data = open(f).read # reading file\n data.encode!('utf-8', 'utf-16') # fix encoding\n data = data.split(\"\\r\\n\") # split into lines\n data.pop # delete __END\n\n # working on header/languages\n header = data.shift.downcase.split(\"\\t\")\n header.shift # 'Code' an identifier, not a language\n #check if we have all languages in our system\n header.delete(\"name\") # that's not a language but is included in Descriptions\n header.each do |l|\n next if model.columns.map(&:name).include?(l)\n error \"Fatal error: '#{l}' not found in column names of #{model.name}\"\n raise \"Translation/Description Language Error\"\n end\n\n # working on the datasets itself\n data.each do |line|\n line = line.split(\"\\t\")\n code = line.shift #first column is the identifier\n line.shift if model == Florensia::Description #second column is unused 'name' in description files\n line.collect!{|text| text.gsub('\\n', \"\\n\")} #fix line breaks\n t = model.where(code: code).first_or_initialize\n t.update_attributes(Hash[header.zip(line)])\n end\n end\n end", "def require_data(*file); end", "def require_data(*file); end", "def read_trees(filename)\n log(\"Reading #{filename}...\")\n File.open(filename, \"r\") do |file|\n file.readlines.collect do |line|\n Tree.from_string(line)\n end\n end\nend", "def file_array_parser\n @array_of_parse_files = []\n file_array.each do |file|\n File.open(\"text_files/#{file}\").readlines.each do |line|\n if line.include?(\"\\n\") # removes '\\n' (line breaker)\n @array_of_parse_files << [line.gsub!(/\\n/, '')]\n else\n @array_of_parse_files << [line]\n end \n end\n @array_of_parse_files \n end\n\nend", "def initialize(file)\n @data = { :students => [] }\n @file = file\n load_data\n end", "def parse_file\n filename = full_path_from_edict_file(@config[\"filename\"])\n ### Get all the line into memory\n file_obj = File.new(filename, \"r\")\n file_obj.each do |line|\n @added_lines.push line\n end\n end", "def load_data (training_set, test_set = :NIL)\n base = training_set + \"/u.data\" if test_set == :NIL\n\t\tbase = training_set + \"/\" + test_set.to_s + \".base\" if test_set != :NIL\n\t\tfile = File.open (base)\n\n\t\ti=0\n\t\tfile.each_line do |line|\n\t\t\t@movieStore[i] = line.split(/\\s/)\n\t\t\ti += 1\n\t\tend\n\t\tif test_set != :NIL then\n\t\t\ttest_set = training_set + \"/\" + test_set.to_s + \".test\"\n\t\t\tfile2 = File.open(test_set)\n\t\t file2.each_line do |line|\n\t\t\t @test_set << line.split(/\\s/)\n\t\t end\n else\n @test_set = @movieStore\n end\n \n\t\tuser_movie_index()\n\tend", "def initialize file\n EasyTranslate.api_key = 'AIzaSyDrbD0AfKHiMZTYoite-ec4byLNlPxoX8k'\n @file = file\n @properties = []\n \n File.open(file, \"r:UTF-8\").each do |line| \n @properties << line \n end\n end", "def load_yml(filename); end", "def all_text\n if(!is_file_open?)\n open_file\n end\n @file_handle.read(self.size)\n end", "def all_text\n if(!is_file_open?)\n open_file\n end\n @file_handle.read(self.size)\n end", "def data\n @data ||= Dir['data/*'].reduce({}) do |data, file|\n raw_data = File.read(file)\n filename = parse_filename(file)\n schema = schemas[filename]\n\n data[filename] = raw_data.split(\"\\n\").map do |row|\n schema.reduce({}) do |object, column|\n # slice from the beginning of the row the relevant number of\n # characters based on the column's attribute length\n raw_value = row.slice!(0, column[:length].to_i)\n\n parsed_value = parse_attribute(raw_value, column[:type])\n object[column[:name]] = parsed_value\n object\n end\n end\n end\n end", "def load_data\n\t\tload_using_arr(train_file,train_hash,0,1)\n\t\tload_using_arr(train_file,movie_hash,1,0)\n\tend", "def file_load(file)\n\t\tresult = \"\"\n\t\tFile.open(file.to_s, 'r') do |f|\n\t\t\twhile l = f.gets \n\t\t\t\tresult << l\n\t\t\tend\n\t\tend\n\t\tresult\n\tend", "def initialize(text_file_name)\n @dictionary = Hash.new 0 \n #read file text_file_name\n #extract words from string (file contents) using method 'words' below.\n #put in dictionary with their frequency (calling train! method)\n File.open(text_file_name) do |f|\n f.each_line do |line|\n words = line.split\n words.each do |word|\n \n train! words word\n\n end\n end\n end\n end", "def read_file(filename); end", "def consume_all(paths)\n lines = []\n paths.each do |path|\n content = File.read(path, :encoding => 'utf-8')\n\n if path.split('.')[-1] == \"json\"\n log \"Reading json corpus from #{path}\"\n l = JSON.parse(content).map do |tweet|\n tweet['text']\n end\n lines.concat(l)\n elsif path.split('.')[-1] == \"csv\"\n log \"Reading CSV corpus from #{path}\"\n content = CSV.parse(content)\n header = content.shift\n text_col = header.index('text')\n l = content.map do |tweet|\n tweet[text_col]\n end\n lines.concat(l)\n else\n log \"Reading plaintext corpus from #{path}\"\n l = content.split(\"\\n\")\n lines.concat(l)\n end\n end\n consume_lines(lines)\n end", "def load_dataE(filename)\r\n Log.ger.debug('Read '+filename)\r\n File.open(filename, \"rb\") { |f|\r\n obj = Marshal.load(f)\r\n }\r\nend", "def load\n eval(@data, TOPLEVEL_BINDING, @filename)\n end", "def initialize(text_file_name)\n text = \"\"\n #read file text_file_name\n File.open(text_file_name, \"r\") do |f|\n f.each_line do |line|\n\ttext << line.chomp << \" \"\n end\n end\n\n #extract words from string (file contents) using method 'words' below.\n word_list = words(text)\n\n #put in dictionary with their frequency (calling train! method)\n train!(word_list)\n end", "def load_hashes(data_set)\n\t\tFile.open(data_set, \"r\") do |f|\n\t\t\tf.each_line do |line|\n\t\t\t\t@@line_array = line.split(' ')\n\t\t\t\tload_user_info\n\t\t\t\tload_movie_viewers\n\t\t\t\tload_movie_ratings\t\n\t\t\tend\n\t\tend\n\tend", "def get_characters\n File.readlines('characters.data').each do |line|\n d = line.split(',').map(&:strip)\n Character.create(name: d[0], publisher: d[1])\n end\nend", "def get_characters\n File.readlines('characters.data').each do |line|\n d = line.split(',').map(&:strip)\n Character.create(name: d[0], publisher: d[1])\n end\nend", "def load_data(file)\n\t\t@user_set = Hash.new\n\t\t@sim_set = Hash.new\n\t\t@movies = Array.new\n\t\tFile.open(file).each do |line|\n\t\t\tline = line.split(\" \")\n\t\t\tgenerate_movies(line[0]) unless file.include? \"test\"\n\t\t\tgenerate_user_pref(line[0], line[1], line[2])\n\t\tend\n\t\t# generate_predictions unless file.include? \"test\"\n\tend" ]
[ "0.7460712", "0.6832215", "0.6684912", "0.6676647", "0.6633156", "0.66077965", "0.6553301", "0.65314525", "0.65314525", "0.65171176", "0.6473957", "0.6458051", "0.6458051", "0.64159524", "0.6412087", "0.63579327", "0.63023347", "0.62768567", "0.6240431", "0.6225768", "0.61964923", "0.61964923", "0.6172801", "0.61597115", "0.6140215", "0.61293346", "0.61055356", "0.6105481", "0.6102472", "0.60874647", "0.6083104", "0.60730714", "0.600223", "0.59944415", "0.59866023", "0.59866023", "0.5966617", "0.59529847", "0.59475774", "0.59399813", "0.59375256", "0.59318775", "0.59312207", "0.5927847", "0.5925051", "0.5923481", "0.5919845", "0.5884508", "0.5883677", "0.5881029", "0.586328", "0.5858801", "0.5854622", "0.585462", "0.5854427", "0.5854278", "0.58288556", "0.58280706", "0.5817118", "0.58149105", "0.5802591", "0.5786146", "0.5780508", "0.57702285", "0.57668614", "0.57573026", "0.57400584", "0.5726572", "0.5719462", "0.57149714", "0.5710068", "0.5699131", "0.56959814", "0.5693522", "0.5691537", "0.56828374", "0.56828374", "0.5679325", "0.5678365", "0.5675829", "0.5672274", "0.5669905", "0.5659814", "0.56597906", "0.5659728", "0.5659728", "0.56595033", "0.5653425", "0.5648249", "0.56469876", "0.5643131", "0.56378025", "0.56348276", "0.5631836", "0.56259257", "0.5623154", "0.5613778", "0.5613778", "0.56074923" ]
0.60467064
32
Loading and writing Marshalled DataFrame/Vector
def save klass, filename fp = File.open(filename, 'w') Marshal.dump(klass, fp) fp.close end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def marshal_load(serialised); end", "def marshal_load(x)\n @table = x\n end", "def marshal\n @data\n end", "def marshal_load(array)\n\t\t@lines, @columns, @stack = array\n\t\treturn self\n\tend", "def marshal_dump\n data\n end", "def marshal_dump\n [@@col_map, @@location_columns, @row]\n end", "def marshal_load(data)\n self.data = data\n end", "def save_dataE(obj, filename) \r\n File.open(filename, \"wb\") { |f|\r\n Marshal.dump(obj, f)\r\n }\r\nend", "def marshal_load(data)\n version, vars, values, obj = data\n if version == :__v2__\n vars.each_with_index {|var, i| instance_variable_set(var, values[i])}\n __setobj__(obj)\n else\n __setobj__(data)\n end\n end", "def marshal_dump\n @table\n end", "def marshal\n Marshal.dump(data)\n end", "def marshall_dump\n end", "def load_dataE(filename)\r\n Log.ger.debug('Read '+filename)\r\n File.open(filename, \"rb\") { |f|\r\n obj = Marshal.load(f)\r\n }\r\nend", "def marshall_dump\n end", "def to_blob; end", "def to_blob; end", "def to_blob; end", "def to_blob; end", "def to_blob; end", "def to_blob; end", "def marshal_dump; end", "def marshal_load( data )\n @value = nil\n @ops = data[0]\n @rel = data[1]\n end", "def _dump(level) # :nodoc:\n Marshal.dump({'rows' => rows, 'cols' => cols, 'data' => to_a})\n end", "def _dump(level) # :nodoc:\n Marshal.dump({'rows' => rows, 'cols' => cols, 'data' => to_a})\n end", "def marshal_load(obj)\r\n @depth, @map_id, @event_id, @list, @index, @branch = obj\r\n create_fiber\r\n end", "def marshal_dump()\n\t\treturn [@lines, @columns, @stack]\n\tend", "def write\n open(@fname,\"wb\") do |file|\n Marshal.dump(@data,file)\n end\n end", "def load_marshal_data object # :nodoc:\n object.load\n rescue NameError, ArgumentError => e\n DRb::DRbUnknown.new e, object.stream\n end", "def marshal_load(s)\n# Unpack coords from unmarshaled string\n@coords = s.unpack(\"w*\") # and use them to initialize the object\nend", "def cast opts={}\n dtype = opts[:dtype]\n raise ArgumentError, \"Unsupported dtype #{opts[:dtype]}\" unless \n dtype == :array or dtype == :nmatrix\n\n @data = cast_vector_to dtype\n end", "def write_blobs\n unless @blobs_to_write.empty?\n @blobs_to_write.each do |blob|\n blob.write_to_column!\n end\n end\n end", "def _serialize_write_data(data, slist)\n bytes = pickle.dumps(data)\n nbytes = len(bytes)\n if not nbytes\n raise Exception(\"write DataObject has no attachment\")\n end\n slist.set_nbytes(nbytes)\n slist.set_bytes(bytes)\n return\nend", "def main\n create_table\n set_timestamp_to_now\n json = fetch_data.to_json\n store json\nend", "def serialize(_object, data); end", "def serialize(_object, data); end", "def to_sequel_blob\n self\n end", "def save_data_matrix_alt(coll, matrix, offset: [0, 0])\n pm = coll.part_matrix\n das = []\n\n uniq_keys = matrix.flatten.map(&:keys).flatten.uniq\n dms_by_key = {}\n uniq_keys.each do |key|\n dms_by_key[key] = coll.data_matrix(key)\n end\n\n coll.each_row_col(matrix, offset: offset) do |x, y, ox, oy|\n next unless !matrix[x][y].nil? && pm[ox][oy] # this part has das\n matrix[x][y].each do |k, v|\n if pm[ox][oy]\n if dms_by_key[k][ox][oy]\n da = dms_by_key[k][ox][oy]\n da.object = { k => v }.to_json\n das << da\n else\n das << pm[ox][oy].lazy_associate(k, v)\n end\n end\n end\n end\n\n das\n end", "def to_file( f )\n buf = [@name, @ref.binary_role(), @ref.binary_type(), @ref.name,\n @type, TYPE_SIZES[@type], \n @data.length()].pack(PFORMAT)\n f.write(buf)\n\n fmt_str = \"%s%d\" % [TYPES[@type], data.length]\n buf = data.pack(fmt_str)\n f.write(buf)\n end", "def serialize(object, data); end", "def serializeDataSMX(ifile,cfile,oPath,doZ,key,var,val,yVar,exposure,verbose,existingVar2vno)\n\twf=MCMD::Mtemp.new(DebugPath)\n\txxrow =wf.file\n\txxcol =wf.file\n\txxval =wf.file\n\txxy =wf.file if cfile\n\txxexposure=wf.file if exposure\n\n\t# preprocessing for x and y variables\n\trowSize,colSize=smatrix(ifile,key,var,val,cfile,false,\"#{oPath}/var2vno.csv\",\"#{oPath}/key2sno.csv\",xxrow,xxcol,xxval,existingVar2vno)\n\tmkYvar(cfile,key,yVar,\"#{oPath}/key2sno.csv\",xxy)\n\tmkExposure(cfile,key,exposure,\"#{oPath}/key2sno.csv\",xxexposure)\n\n\t# csv data => R data.frame\n\tscp1=scpInpSMX(rowSize,colSize,xxrow,xxcol,xxval,\"#{oPath}/var2vno.csv\",\"#{oPath}/key2sno.csv\",xxexposure,doZ,xxy)\n\tscp2=scpSaveData(oPath)\n\n\trunRSCP([scp1,scp2],oPath,\"serializeDataSMX\",verbose)\nend", "def demarshal_object(blob)\n Marshal.load(blob)\n end", "def saveIndex(fileName = \"dataTest.dat\", data)\n\t\tfile = File.new(fileName, \"w+\")\n\t\tserializedData = Marshal.dump(data)\n\t\tfile.write(serializedData)\n\t\tfile.close\n\tend", "def transport_dataframe(r_dataframe_name, model, connection)\n\n r = connection\n\n array_of_arrays = eval(model).column_names.map { |column| eval(model).all.order(:id).map(&column.to_sym) }\n # Note: .order(:id) means that if attributes have been edited and the ids are out of order, it will return data in correct orders\n\n column_names = eval(model).column_names\n\n # Transport each column to R interpreter\n array_of_arrays.each_with_index do |column, index|\n puts index\n r.eval Transport.transport_column(column_names[index], column) \n end\n\n # Now create an R dataframe from the columns \n output = r_dataframe_name.to_s + \" <- data.frame(\" + column_names.join(', ') + \", stringsAsFactors=FALSE); print(\" + r_dataframe_name + \")\"\n\n return output\n\nend", "def unmarshal\n Marshal.restore self\n end", "def dump\n _dump do |row|\n codec.encode( row.values, io ) unless dry_run?\n end\n ensure\n io.flush\n end", "def save_data(data, filename)\n File.binwrite(filename, Marshal.dump(data))\n return nil\nend", "def write_data_provider(asrs)\n\t\twrite_byte(10) #write Array\n\t\twrite_word32_network(asrs.row_count) #array length\n\t\tcolumns = asrs.column_names\n 0.upto(asrs.row_count - 1) do |i|\n h = {}\n 0.upto(columns.length - 1) do |c|\n key = columns[c]\n val = asrs.initial_data[i][c]\n h[key] = val\n end\n write_hash(h)\n end\n end", "def data_frame(name, df, keep=false)\n File.open(\"#{EXCHANGE}\", \"w\") do |f|\n f.puts df.keys*\"\\t\"\n df[df.keys[0]].size.times do |i|\n df.each_key do |k|\n f.print \"#{df[k][i] || 'NA'}\\t\"\n end\n f.puts\n end\n end\n @r.cmd \"#{name}<-read.table('#{EXCHANGE}', h=T)\"\n @r.cmd \"unlink(\\\"#{EXCHANGE}\\\")\" unless keep\n end", "def marshal_dump\n [@lsi_vector, @lsi_norm, @raw_vector, @raw_norm, @categories, @word_hash]\n end", "def write\n write_data\n end", "def serialize_value(column, v)\n return v if v.nil?\n case model.serialization_map[column] \n when :marshal\n [Marshal.dump(v)].pack('m')\n when :yaml\n v.to_yaml\n when :json\n JSON.generate v\n else\n raise Error, \"Bad serialization format (#{model.serialization_map[column].inspect}) for column #{column.inspect}\"\n end\n end", "def postgres_upload_binary_data(data, remote_fname=nil)\n remote_fname ||= Rex::Text::rand_text_alpha(8) + \".dll\"\n\n # From the Postgres documentation:\n # SELECT lo_creat(-1); -- returns OID of new, empty large object\n # Doing it this way instead of calling lo_create with a random number\n # ensures that we don't accidentally hit the id of a real object.\n resp = postgres_query \"select lo_creat(-1)\"\n unless resp and resp[:complete] and resp[:complete].rows[0]\n print_error \"Failed to get a new loid\"\n return\n end\n\n oid = resp[:complete].rows[0][0].to_i\n\n queries = [ \"delete from pg_largeobject where loid=#{oid}\" ]\n\n # Break the data into smaller chunks that can fit in the size allowed in\n # the pg_largeobject data column.\n # From the postgres documentation:\n # \"The amount of data per page is defined to be LOBLKSIZE (which is\n # currently BLCKSZ/4, or typically 2 kB).\"\n # Empirically, it seems that 8kB is fine on 9.x, but we play it safe and\n # stick to 2kB.\n chunks = []\n while ((c = data.slice!(0..2047)) && c.length > 0)\n chunks.push c\n end\n\n chunks.each_with_index do |chunk, pageno|\n b64_data = postgres_base64_data(chunk)\n insert = \"insert into pg_largeobject (loid,pageno,data) values(%d, %d, decode('%s', 'base64'))\"\n queries.push( \"#{insert}\"%[oid, pageno, b64_data] )\n end\n queries.push \"select lo_export(#{oid}, '#{remote_fname}')\"\n\n # Now run each of the queries we just built\n queries.each do |q|\n resp = postgres_query(q)\n if resp && resp[:sql_error]\n print_error \"Could not write the library to disk.\"\n print_error resp[:sql_error]\n # Can't really recover from this, bail\n return nil\n end\n end\n return remote_fname\n end", "def structure_dump() end", "def marshal\n Marshal.dump self\n end", "def marshal\n Marshal.dump self\n end", "def marshal\n Marshal.dump self\n end", "def demarshal\n Marshal.load(decompress)\n end", "def serialize\n @raw_data\n end", "def encode(dataframe)\n logger.info \"Writing CSV file to temporary location #{@working_file}\"\n\n label_columns = self.fields.reduce({}) { |h, (k, v)|\n if v[:label]\n h[k] = v[:label].to_sym\n end\n h\n }\n dataframe.rename_vectors label_columns\n dataframe.write_csv @working_file, @csv_options\n @working_file\n end", "def data\n @data_t\n end", "def stored_data; end", "def write_binary_frame(buffer)\n @j_del.writeBinaryFrame(buffer._to_java_buffer)\n self\n end", "def write object\n if open?\n @reader.close\n @writer.write Marshal.dump(object)\n @writer.close\n end\n end", "def data\n @data ||= load_matrix\n end", "def marshal_load(arg0)\n end", "def data_to_binary(val)\n saved_object_count = @written_object_count\n @written_object_count += 1\n\n bdata = Binary.type_bytes(\"4\", val.bytesize) # a is 1000, type indicator for data\n @object_table[saved_object_count] = bdata + val\n\n return saved_object_count\n end", "def marshal_load(data)\n self.var1 = data['var1']\n self.volatile1 = \"Another value\"\n end", "def data= blob\n $postgres.exec_prepared('wsfile_update', [self.id, {value: blob, format: 1}])\n end", "def marshal_load(variables)#:nodoc:\n fields_to_serialize.each_with_index{|field, index| instance_variable_set_value(field, variables[index])}\n end", "def _dump()\n #This is a stub, used for indexing\n end", "def store_chart_binary(filename) #:nodoc:\n filehandle = File.open(filename, \"rb\")\n # die \"Couldn't open $filename in add_chart_ext(): $!.\\n\";\n\n while tmp = filehandle.read(4096)\n append(tmp)\n end\n end", "def marshal_dump\n dump\n end", "def store_index #:nodoc:\n return if @compatibility == 0\n\n indices = @db_indices\n reserved = 0x00000000\n row_min = @dim_rowmin\n row_max = @dim_rowmax\n\n record = 0x020B # Record identifier\n length = 16 + 4 * indices.size # Bytes to follow\n\n header = [record, length].pack('vv')\n data = [reserved, row_min, row_max, reserved].pack('VVVV')\n\n indices.each do |index|\n data = data + [index + @offset + 20 + length + 4].pack('V')\n end\n\n prepend(header, data)\n end", "def cast opts={}\n dtype = opts[:dtype]\n raise ArgumentError, \"Unsupported dtype #{opts[:dtype]}\" unless \n dtype == :array or dtype == :nmatrix\n\n @vector = cast_vector_to dtype\n end", "def marshal_dump\n format_name_ = Format.canonical_name_for(@_format, true)\n unparsed_data_ = nil\n if @_format.respond_to?(:unparse_for_serialization)\n unparsed_data_ = @_format.unparse_for_serialization(self) rescue nil\n end\n unparsed_data_ ||= @_format.unparse(self) rescue nil\n data_ = [format_name_]\n case unparsed_data_\n when ::Array\n data_ << unparsed_data_[0]\n data_ << unparsed_data_[1] if unparsed_data_[1]\n when ::String\n data_ << unparsed_data_\n else\n data_ << values_array\n data_ << @_unparse_params if @_unparse_params\n end\n data_\n end", "def export\n return if fragments.count.zero?\n File.open(\"#{bin_file_name}.new\", \"wb\") do |f|\n i = 0;\n fragments.order(:order).each do |fr|\n i = export_object f, fr, i\n end\n end\n end", "def dump\r\n @db_mon.synchronize {\r\n File.open(@path,'wt') { |file|\r\n @seek_db.each_value { |x|\r\n file.write(x.to_json)\r\n file.write(\"\\n\")\r\n }\r\n } rescue nil\r\n }\r\n end", "def to_columnar(options = {})\n root = options[:destination] or require_destination!\n @root = must_be_directory!(root)\n @data = @loader.container.sort.map(&:to_h)\n\n column_file(\"content_type\") do |type|\n [type[\"content-type\"], Array(type[\"extensions\"]).join(\" \")]\n .flatten.join(\" \").strip\n end\n\n required_file(\"encoding\")\n optional_file(\"pext\", \"preferred-extension\")\n optional_file(\"docs\")\n bool_file(\"flags\", \"obsolete\", \"registered\", \"signature\", \"provisional\")\n dict_file(\"xrefs\")\n dict_file(\"friendly\")\n optional_file(\"use_instead\", \"use-instead\")\n end", "def blob; end", "def blob; end", "def marshal_load(dump)\n return initialize(dump[:values], dump[:joined], :cached)\n end", "def marshal_load(array)\n self.version = array[0]\n end", "def marshal_save\n donnee_totale.merge!(updated_at: Time.now.to_i)\n # log \"DATA FILM ENREGISTRÉES (film#donnee_totale) :#{RC}#{donnee_totale.inspect}\"\n File.open(marshal_file,'wb'){|f| f.write Marshal.dump(donnee_totale)}\n end", "def from_activerecord(relation, *fields)\n if fields.empty?\n records = relation.map do |record|\n record.attributes.symbolize_keys\n end\n return Daru::DataFrame.new(records)\n else\n fields = fields.map(&:to_sym)\n end\n\n vectors = fields.map { |name| [name, Daru::Vector.new([], name: name)] }.to_h\n\n Daru::DataFrame.new(vectors, order: fields).tap do |df|\n relation.pluck(*fields).each do |record|\n df.add_row(Array(record))\n end\n df.update\n end\n end", "def data\n read_attribute(:data) || write_attribute(:data, (db_file_id ? db_file.data : nil))\n end", "def persist_data(db_columns_and_rows, store)\n store.transaction do\n store['db_columns_and_rows'] = db_columns_and_rows\n end\nend", "def data_file=(name)\n f = File.open(name)\n self.data = Marshal.load(f)\n f.close\n File.delete(name)\n end", "def serialize; end", "def serialize; end", "def serialize(data)\n File.open(\"test/basic_complex_test/ruby_test/bin.babel.rb\", \"w+b\") do |f|\n f.write(data)\n end\n end", "def serialize\n \n end", "def serialized_data\n\t\tdata = strip_hash( @data )\t\t\t\n\t\treturn Marshal.dump( data )\n\tend", "def marshal_load array\n @x, @y, @grid, @generator_pointer = array\n end", "def save\n ole = File.open(@file_name, 'w')\n ole << header\n ole << fat\n @storages.each { |s| ole << s.to_s }\n ole << Array.new((512-(ole.pos % 512)), 0).pack('c*')\n ole << mini_fat\n ole << mini_fat_stream\n ole << fat_stream\n ole.close\n end", "def save_data_to_db(encoded_data)\n return unless encoded_data\n decoded_data = Base64.decode64(encoded_data)\n csv = parse_csv(decoded_data)\n\n csv.each do |data_chunk|\n create(data_chunk.slice(*attribute_names).symbolize_keys)\n end\n end", "def save()\n File.write(@database_file, @data.to_json)\n end", "def data\n raise NotImplementedError.new(\"data() must be implemented by subclasses of AbstractVersionedFile.\")\n end", "def to_file( f )\n size = 0\n @indexes.each { size += Index::FORMAT_SIZE }\n @idata.each do |i| \n size += IntData::FORMAT_SIZE\n size += i.data_size\n end\n\n buf = [@source, @name, @sym, @indexes.length(), @idata.length(), \n size].pack(PFORMAT)\n f.write(buf)\n @indexes.each { |i| i.to_file(f) }\n @idata.each { |i| i.to_file(f) }\n end", "def data\n if @data.nil? && complete_structured_data? then\n @data = Oj.dump(complete_structured_data, mode: :json)\n end\n @data\n end", "def to_ruby(data, columns = nil, buffer = \"\", options = {})\n require 'sbyc/type_system/ruby'\n buffer << \"[\"\n first = true\n data.each{|t| \n buffer << (first ? \"\\n \" : \",\\n \")\n buffer << SByC::TypeSystem::Ruby::to_literal(t)\n first = false\n }\n buffer << \"\\n]\"\n end", "def dump_data(array_of_hashes)\n raise NotImplementedError\n end" ]
[ "0.57836026", "0.5728129", "0.5571151", "0.5559218", "0.55190283", "0.5463519", "0.5440021", "0.53774333", "0.5360353", "0.5355257", "0.5286476", "0.5262109", "0.52498364", "0.52316344", "0.5231279", "0.5231279", "0.5231279", "0.5231279", "0.5231279", "0.5231279", "0.52096295", "0.50807697", "0.5046193", "0.5046193", "0.5028134", "0.5015178", "0.5011428", "0.49849287", "0.4955144", "0.49543542", "0.4941463", "0.49361715", "0.49344867", "0.4920357", "0.4920357", "0.49173668", "0.48951775", "0.48916104", "0.48897302", "0.48784631", "0.4864421", "0.48513356", "0.48320532", "0.48218164", "0.4815575", "0.4814875", "0.48100066", "0.4802947", "0.47964293", "0.47923148", "0.47844672", "0.47790888", "0.47785482", "0.47756845", "0.47756845", "0.47756845", "0.47748974", "0.47728476", "0.47706008", "0.47610185", "0.47581634", "0.47523606", "0.4748201", "0.47472548", "0.4743033", "0.47384727", "0.4735421", "0.47311047", "0.47278398", "0.47256097", "0.4721008", "0.47202677", "0.47150397", "0.47139812", "0.47104126", "0.47071633", "0.47054356", "0.47042122", "0.46906996", "0.46906996", "0.46852538", "0.4683005", "0.4682084", "0.46788415", "0.4674191", "0.46740034", "0.46518132", "0.46368346", "0.46368346", "0.46325478", "0.4627502", "0.4623087", "0.46199957", "0.46132606", "0.46061832", "0.46053538", "0.4603535", "0.45998582", "0.4586456", "0.4581615", "0.4581421" ]
0.0
-1
output integer calculated as sum or product from 1 to input number Ask if they want to calculate product or sum If they enter anything other than 's' or 'p', it should loop again to get correct info 1 to number calculate product or sum
def sum_or_product operation = nil num = nil loop do puts "Enter a number greater than 0." num = gets.chomp.to_i break if num >= 1 puts "Invalid entry, must be greater than 0." end loop do puts "Enter 'p' to calculate the product. Enter 's' to calculate the sum." operation = gets.chomp break if ['p', 's'].include?(operation) puts "Incorrect entry." end if operation == 's' result = (1..num).sum else result = 1 1.upto(num) { |i| result *= i } end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_or_product\n multiply = 1\n p \">> Please enter an integer greater than 0:\"\n number = gets.chomp.to_i\n p \">> Enter 's' to compute the sum, 'p' to compute the product.\"\n operation = gets.chomp\n if operation == \"s\"\n\n puts \"The sum of the integers between 1 and #{number} is #{(1..number).sum}\"\n elsif operation == \"p\"\n (1..number).each { |num| multiply*=num}\n multiply\n puts \"The product of the integers between 1 and #{number} is #{multiply}\"\n end\nend", "def sum_or_product()\n n = 0\n procedure = ''\n loop do\n puts \"Please enter a number greater than 0\"\n response = gets.chomp\n n = response.to_i if response.to_i.to_s == response && response.to_i > 0\n break if n > 0\n end\n loop do\n puts \"Please enter 's' if you would like to calculate the sum, or 'p' if you would like to calculate the product\"\n response = gets.chomp\n procedure = response if %w(s p).include?(response)\n break unless procedure.empty?\n end\n\n range = (1..n).to_a\n if procedure == 's'\n range.reduce(:+)\n else\n range.reduce(:*)\n end\nend", "def sum_or_product\n puts \">> Please enter an integer greater than 0:\"\n integer = gets.chomp.to_i\n\n puts \">> Enter 's' to compute the sum, 'p' to compute the product.\"\n compute = gets.chomp\n\n if compute == 's'\n \"The sum of the integers between 1 and #{integer} is #{(1..integer).reduce(:+)}\"\n else\n \"The product of the integers between 1 and #{integer} is #{(1..integer).reduce(:*)}\"\n end\nend", "def sum_or_product\n puts \"Enter a number greater than zero:\"\n num = gets.chomp.to_i\n\n puts \"Would you like to determine the sum or product of number from 1 to #{num}?\"\n operation = gets.chomp\n\n if operation == 'sum'\n (1..num).inject { |mem, num| mem + num }\n elsif operation == 'product'\n (1..num).inject { |mem, num| mem * num }\n else\n \"Invalid response\"\n end\nend", "def product_sign\n puts \"enter an integer\"\n num1 = gets.to_i\n puts \"enter an integer\"\n num2 = gets.to_i\n puts \"enter an integer\"\n num3 = gets.to_i\n\n product = num1 * num2 * num3\n\n if product > 0\n puts \"product is +\"\n elsif product < 0\n puts \"product is - \"\n else\n puts \"product is zero\"\n end\n\nend", "def mult_operation()\n print_message \"Write number and press ENTER to multiply more or press 'r' to show result\"\n result = 0\n mult = gets.chomp\n if mult != 'r'\n result = mult.to_i\n end\n begin\n begin\n mult = gets.chomp\n if mult != 'r'\n result *= mult.to_i\n end\n rescue StandardError => e\n print_error_message \"Invalid number. Ending Multiplication operation.\\n#{e.message}\"\n mult = 'r'\n end\n end while mult.downcase != 'r'\n print_message \"Result of multiplying: #{result.to_s}\"\n end", "def add_or_multiply\n\tputs \"Select a number between 1 and 25\"\n\tinput = gets.chomp.to_i\n\tputs \"Great, now would you like me to add or multiply?\"\n\tarithmetic = gets.chomp.downcase\n\n\tif arithmetic == \"add\"\n\t\tputs \"Everything added up equals... \" \n\t\tsleep(0.5)\n\t\tputs (1..input).inject(:+)\n\telsif arithmetic == \"multiply\"\n\t\tputs \"Everything multiplied together equals...\"\n\t\tsleep(0.5)\n\t\tputs (1..input).inject(:*)\n\tend\n\tagain\nend", "def option_prod\n input = nil\n while input != \"exit\" do \n puts \"please enter the number of the product you want to see more about\"\n input = gets.strip.downcase\n if input.to_i != 0 \n product = @products[input.to_i-1]\n if product\n puts \"#{product.name} - #{product.price} - #{product.availability}\"\n else\n puts \"There is no Product associate with this number\"\n end\n elsif input == \"back\"\n products_list\n else\n puts \"The system don't understand your input. please tape back or exit\"\n end\n \n\n end\n end", "def consec_ints\n puts \">> Please enter an integer greater than 0:\"\n num = gets.chomp.to_i\n arr = Array.new(num) { |i| i + 1 }\n puts \">> Enter 's' to compute the sum, 'p' to compute the product.\"\n method = gets.chomp.downcase\n if method == 's'\n puts \"#{arr.reduce(&:+)}\"\n else\n puts \"#{arr.reduce(&:*)}\"\n end\nend", "def main()\n puts \"Enter Unit:\"\n consumed_unit = gets.to_i\n return 0 if consumed_unit <= 0\n bill = 0\n unit_details = { 1..50 => 0.5, 51..150 => 0.75, 151..250 => 1.2, 251..Float::INFINITY => 1.5 }\n unit_details.each_pair do |unit, rate|\n break if consumed_unit < 0\n units = unit.max == Float::INFINITY ? consumed_unit : unit.count\n if consumed_unit > units\n bill += rate * units\n else\n bill += rate * consumed_unit\n end\n consumed_unit -= units\n end\n bill += bill * 0.2\n return bill.to_i\nend", "def prompt\n\tputs \"give me a number 1 to 50?\"\n\t@num = gets.chomp.to_i\n\t\n\tif @num < 1 \n\t\tputs \"I told you to give me a number greater than 1\"\n\t\tprompt\n\telsif @num > 50 \n\t\tputs \"I told you to give me a number less than 50\"\n\t \tprompt\n\tend\n\n\tputs \" would you like the sum or the product from 1 to your number?\"\n\t@x = gets.chomp\n\tif @x == \"sum\"\n\t\tsum\n\telsif @x == \"product\"\n\t\tproduct\n\tend\nend", "def sum_difference_product\n\tinput = gets.chomp\n\ti = input.split.collect{|x| x.to_i}\n\tputs (i[0] + i[1])\n\tputs (i[0] - i[1])\n\tputs (i[0] * i[1])\nend", "def input\n\tputs 'What sorta math do ya wanna do?'\n\tputs '1 for addition'\n\tputs '2 for subtraction'\n\tputs '3 for multiplication'\n\tputs '4 for division'\n\tputs '5 for exponent'\n\tputs '6 for squaring'\n\tputs '7 for cubing'\n\tputs '8 for square rooting'\n\tgets.chomp.to_i\nend", "def numSum number\nsum = 0\ncount = 0\nwhile (count < number.to_i)\nputs \"enter num:\"\nnum = gets.chomp\nsum += num.to_i\ncount += 1\nend\nreturn sum\nend", "def sum_difference_product\n puts \"Please enter 2 integers:\"\n input = gets.chomp\n nums = input.split(\" \").map(&:to_i)\n sum = nums.inject(:+)\n difference = nums.inject(:-)\n product = nums.inject(:*)\n puts \"#{sum}\\n#{difference}\\n#{product}\\n\"\nend", "def main\n test_num = gets.chomp.to_i\n test_num.times do |t|\n # input\n s, k = gets.chomp.split(' ')\n k = k.to_i\n\n ans = calc(s, k)\n \n puts \"Case ##{t+1}: #{ans}\"\n end\nend", "def calculator\n\n keep_looping = true\n result = nil\n first_number = nil\n second_number = nil\n \n while keep_looping\n begin\n if result\n puts \"Result: #{result}\"\n first_number = result\n else\n \n puts \"First Number:\"\n first_number = gets.strip.to_f\n end\n puts \"Modifier ( + - * / ) or clear:\"\n modifier = gets.strip\n if modifier == 'clear'\n result = nil\n redo\n end\n \n puts \"Second Number:\"\n second_number = gets.strip.to_f\n end until result = get_result(first_number, modifier, second_number)\n end\n end", "def sum_difference_product\n # your code goes here\n puts \"Enter two numbers seperated by space\"\n arr = gets.split.map(&:to_i)\n puts arr[0] + arr[1]\n puts arr[0] - arr[1]\n puts arr[0] * arr[1]\nend", "def main\n test_num = gets.chomp.to_i\n test_num.times do |t|\n # input\n num = gets.chomp.to_i\n\n ans = calc(num)\n \n puts \"Case ##{t+1}: #{ans}\"\n end\nend", "def sum_difference_product\n\tanswer = \"\"\n \tinput = $stdin.readline\n \tnum = input.split\n \tsum = num[0].to_i + num[1].to_i\n \tdif = num[0].to_i - num[1].to_i\n \tpro = num[0].to_i * num[1].to_i\n\n answer += sum.to_s + \"\\n\" + dif.to_s + \"\\n\" + pro.to_s + \"\\n\"\n $stdout.puts answer\nend", "def basic_calc\n print Rainbow(\"\\n(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \\n\").yellow\n basic_choice = gets.chomp.downcase\n\n print \"\\nEnter your first number: \" \n first_number = gets.to_f\n print \"\\nEnter your second number: \"\n second_number = gets.to_f\n\n\n case basic_choice[0]\n when \"a\"\n print \"\\n\\t#{first_number} + #{second_number} = \", first_number + second_number, \"\\n\"\n when \"s\"\n print \"\\n\\t#{first_number} - #{second_number} = \", first_number - second_number, \"\\n\"\n when \"m\"\n print \"\\n\\t#{first_number} * #{second_number} = \", first_number * second_number, \"\\n\"\n when \"d\"\n print \"\\n\\t#{first_number} / #{second_number} = \", first_number / second_number, \"\\n\"\n else Rainbow(\"\\nYou're doing it wrong!\".upcase).red\n end\n gets\nend", "def sum_difference_product\n\tnums = gets.chomp.split\n\tnums[0] = nums[0].to_i\n\tnums[1] = nums[1].to_i\n\tputs (nums[0]+nums[1]).to_s\n\tputs (nums[0]-nums[1]).to_s\n\tputs (nums[0]*nums[1]).to_s\nend", "def sum_difference_product\n # your code goes here\n\n user_response = gets\n\n puts \"#{user_response}\"\n\na = user_response.split(\" \")[0].to_i\nb = user_response.split(\" \")[1].to_i\n\nputs \"#{a+b}\" + \"\\n\" + \"#{a-b}\" + \"\\n\" + \"#{a*b}\" + \"\\n\"\n\nend", "def output_total_nutritional_content(choices, nutrient_type, total_calories)\n loop do #loop 4 = after seeing cart. This is where the user chooses to finalize transaction, go back\n user_choice4 = gets.chomp.downcase\n if user_choice4 == \"back\"\n puts \"\\n\\n\\n\"\n puts \"More food? Very well then, what would you like to 'add'? You can also 'remove' the last item, 'check' out or 'exit'\"\n return false\n elsif user_choice4 == \"finalize\"\n puts \"\\n\\n\\n\"\n puts \"Your total will be:\"\n 10.times do |j| #nutrient type\n j+=1\n total_nutrient_content = 0\n choices.each do |i|\n total_nutrient_content += i[j].to_f\n end\n puts \"#{nutrient_type.keys[j]}: #{total_nutrient_content}\"\n if nutrient_type.keys[j] == \"Calories\"\n total_calories = total_nutrient_content\n end\n end\n miles = total_calories/100\n puts \"\\nTo burn this off, you would have to run about #{miles} miles\"\n puts \"\\n\\n\\n\"\n puts \"Please pull up to the window to receive your food.\"\n return true\n elsif user_choice4 == \"exit\"\n puts \"\\n\\n\\n\"\n return true\n else\n puts \"\\n\\n\\n\"\n puts \"There are other customers waiting... You can go 'back', 'finalize' or 'exit'\"\n # redo\n end\n end\n end", "def basic_calc\n print Rainbow(\"\\n(a)\").white+Rainbow(\"dd \").green+Rainbow(\"(s)\").white+Rainbow(\"ubtract \").green+Rainbow(\"(m)\").white+Rainbow(\"ultiply \").green+Rainbow(\"(d)\").white+Rainbow(\"ivide \").green\n choice = gets.chomp.to_s\n print Rainbow(\"\\nfirst number: \").blue\n first = gets.chomp.to_f\n print Rainbow(\"second number: \").blue\n second = gets.chomp.to_f\n case choice[0].downcase\n when \"a\"\n print Rainbow(\"\\n#{first} + #{second} = \").blue + Rainbow(\"#{first + second}\\n\\n\").white\n when \"s\"\n print Rainbow(\"\\n#{first} - #{second} = \").blue + Rainbow(\"#{first - second}\\n\\n\").white\n when \"m\"\n print Rainbow(\"\\n#{first} 8 #{second} = \").blue + Rainbow(\"#{first * second}\\n\\n\").white\n when \"d\"\n print Rainbow(\"\\n#{first} / #{second} = \").blue + Rainbow(\"#{(first / second).rounf(5)}\\n\\n\").white\n when \"q\"\n menu\n else \n print Rainbow(\"\\nYou are doing it \").green + Rainbow(\"WRONG\\n\").red\n basic_calc\n end\nend", "def basic_calc\n\tprint \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide:\" \n\tuser_input = gets.chomp\nif user_input == \"a\"\n\tadd\nelsif user_input == \"s\"\n\tsubtract\nelsif user_input == \"m\"\n\tmultiply\nelsif user_input == \"d\"\n\tdivide\n\tend\nend", "def sum_difference_product\n a , b = gets.split.map { |num| num.to_i }\n puts a + b\n puts a - b\n puts a * b\n end", "def sum_difference_product\n input_nums = gets\n a, b = input_nums[/^-?\\d+/].to_i, input_nums[/(?<=\\s)\\d+/].to_i\n \tputs (a+b)\n puts (a-b)\n \tputs (a*b)\nend", "def advanced_calc\n print \"(p)ower, (s)qrt: \"\n option_3 = gets.chomp.downcase\n\n if option_3 == \"p\"\n print \"Please enter a number: \"\n number_1 = gets.chomp.to_i\n print \"Please enter an exponent: \"\n number_2 = gets.chomp.to_i\n puts \"Result: #{number_1} ** #{number_2} = #{number_1 ** number_2}\"\n elsif option_3 == \"s\"\n print \"Please enter a number: \"\n number_1 = gets.chomp.to_i\n puts \"The square root of #{number_1} is #{Math.sqrt(number_1)}\"\n else\n puts \"That is not a valid option. Please try again.\"\n end\n\nend", "def sum_difference_product(input)\n puts \"give me an integer\"\n input= gets.chomp\narray_of_input = input.split(\"\").map {|numb| numb.to_i }\nsum = array_of_input[0]+ array_of_input[2]\nputs \"#{sum}\"\nputs \"#{array_of_input[0] - array_of_input[2]}\"\nputs array_of_input[0] * array_of_input[2]\n\nend", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n operation = gets.chomp.downcase\n print \"first number: \"\n a = gets.to_f\n print \"second number: \"\n b = gets.to_f\n \n case operation\n when 'a'\n puts \"#{a + b}\"\n when 's'\n puts \"#{a - b}\"\n when 'm'\n puts \"#{a * b}\"\n when 'd'\n puts \"#{a / b}\"\n else\n puts \"WRONG!!!!!\"\n basic_calc\n end\n\n gets\nend", "def menu\n puts \"______Calculator_______\"\n puts \"\\t1) Enter first number\"\n puts \"\\t2) Enter modifier\"\n puts \"\\t3) Enter second number\"\n puts \"\\t4) The result is:\"\n return gets.strip.to_i\nend", "def convert_by_total_weight(ingredients)\n puts \"Please input a number for the total target weight of this recipe\"\n input = get_user_integer\n ascii_heading(\"Conversions\")\n ingredients.each do | ingredient |\n ingredient.each do | i,p |\n puts \"#{i}: #{(input*p).to_i} grams\" # iterator formats and calculates input for output.\n end\n end\n puts \"Total Recipe weight = #{input} grams\"\nend", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n function = gets.chomp.downcase\n return 'q' if function == 'q'\n\n print \"Enter first number: \"\n num_1 = gets.chomp.to_i\n\n answer = 0\n\n \n case function \n when \"a\"\n puts \"Enter the second number\"\n add_num = gets.chomp.to_i\n answer = num_1 + add_num\n when \"s\"\n puts \"Enter the second number\"\n sub_num = gets.chomp.to_i\n answer = num_1 - sub_num\n when \"m\"\n puts \"Enter the second number\"\n multi_num = gets.chomp.to_i\n answer = num_1 * multi_num\n when \"d\"\n puts \"Enter the second number \"\n divide_num = gets.chomp.to_i\n answer = num_1 / divide_num\n else\n puts \"Wrong!\"\n end\n\n print \"The answer equals: #{answer}\"\n\nend", "def sum_difference_product\n puts \"Please input a number:\"\n number_string = gets.chomp\n number = number_string.split(' ')\n sum = number[0].to_i + number[1].to_i\n difference = number[0].to_i - number[1].to_i\n product = number[0].to_i * number[1].to_i\n puts sum\n puts difference\n puts product\nend", "def sum_difference_product\n input = gets.split\n numbers = input.map {|num| num.to_i}\n sum = numbers.inject(:+)\n difference = numbers.inject(:-)\n product = numbers.inject(:*)\n\n puts sum\n puts difference\n puts product\n \nend", "def sum_difference_product\n int = gets.chomp\n int_arr = int.split\n int1 = int_arr[0].to_i\n int2 = int_arr[1].to_i\n int_sum = int1 + int2\n int_dif = int1 - int2\n int_prod = int1 * int2\n print \"#{int_sum}\\n#{int_dif}\\n#{int_prod}\\n\"\nend", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n option_2 = gets.chomp.downcase\n\n if option_2 == \"a\"\n print \"Please enter a number: \"\n number_1 = gets.chomp.to_i\n print \"Please enter a second number to add: \"\n number_2 = gets.chomp.to_i\n puts \"Result: #{number_1} + #{number_2} = #{number_1 + number_2}\"\n elsif option_2 == \"s\"\n print \"Please enter a number: \"\n number_1 = gets.chomp.to_i\n print \"Please enter a second number to subtract: \"\n number_2 = gets.chomp.to_i\n puts \"Result: #{number_1} - #{number_2} = #{number_1 - number_2}\"\n elsif option_2 == \"m\"\n print \"Please enter a number: \"\n number_1 = gets.chomp.to_i\n print \"Please enter a second number to multiply: \"\n number_2 = gets.chomp.to_i\n puts \"Result: #{number_1} x #{number_2} = #{number_1 * number_2}\"\n elsif option_2 == \"d\"\n print \"Please enter a number: \"\n number_1 = gets.chomp.to_i\n print \"Please enter a second number to divide: \"\n number_2 = gets.chomp.to_i\n puts \"Result: #{number_1} ÷ #{number_2} = #{number_1 / number_2}\"\n else\n puts \"That is not a valid option. Please try again.\"\n end\n\nend", "def perform\n puts 'Entrez un nombre :'\n print '> '\n nb = gets.chomp.to_i\n\n puts \"La table de multiplication du chiffre #{nb} est :\"\n \n multiplicationTable(nb).each do |result|\n puts result\n end\nend", "def sum_difference_product\n a , b, c = gets.split.map { |num| num.to_i }\n puts a + b + c\n puts a - b - c\n puts a * b * c\nend", "def multiply\n puts \"enter first number \"\n a = gets.to_f\n puts \"enter second numb4\ner\"\n b = gets.to_f\n result = a * b\n puts result\nend", "def number_choice_one\n puts \"Now I need two numbers to use with that operator.\"\n puts \"Type your first number: \"\n gets.chomp.to_i\nend", "def basic_calc\n puts Rainbow(\"(a)dd, (s)ubtract, (m)ultiply, (d)ivide\").yellow.inverse\n arithmetic_type = gets.chomp.downcase\n\n case arithmetic_type\n \n when 'a' \n puts \"whats your first number?\"\n response_1 = gets.strip.to_f \n puts \"whats your second number?\"\n response_2 = gets.strip.to_f\n result = response_1 + response_2\n puts \"#{response_1}+#{response_2} = #{result}\"\n\n when 's' \n puts \"whats your first number?\"\n response_1 = gets.strip.to_f \n puts \"whats your second number?\"\n response_2 = gets.strip.to_f\n result = response_1 - response_2\n puts \"#{response_1}-#{response_2} = #{result}\"\n when 'm' \n puts \"whats your first number?\"\n response_1 = gets.strip.to_f \n puts \"whats your second number?\"\n response_2 = gets.strip.to_f\n result = response_1 * response_2\n puts \"#{response_1}*#{response_2} = #{result}\"\n when 'd' \n puts \"whats your first number?\"\n response_1 = gets.strip.to_f \n puts \"whats your second number?\"\n response_2 = gets.strip.to_f\n result = response_1 / response_2\n puts \"#{response_1}/#{response_2} = #{result}\"\n\nend\nend", "def basic_calc ()\n print \"Please choose from the following options:\n(a)dd, (s)ubtract, (m)ultiply, (d)ivide, (r)eturnt to main menu : \"\n basic_menu_request = gets.chomp.downcase\n case basic_menu_request\n when \"a\"\n print \"What is the first number? \"\n first = gets.chomp.to_f\n print \"What is the second number? \"\n second = gets.chomp.to_f\n answer = first + second\n puts \"The answer is #{answer}\"\n when \"s\"\n print \"What is the first number? \"\n first = gets.chomp.to_f\n print \"What is the second number? \"\n second = gets.chomp.to_f\n answer = first - second\n puts \"The answer is #{answer}\"\n when \"m\"\n print \"What is the first number? \"\n first = gets.chomp.to_f\n print \"What is the second number? \"\n second = gets.chomp.to_f\n answer = first * second\n puts \"The answer is #{answer}\"\n when \"d\"\n print \"What is the first number? \"\n first = gets.chomp.to_f\n print \"What is the second number? \"\n second = gets.chomp.to_f\n answer = first / second\n puts \"The answer is #{answer}\"\n when \"r\"\n puts menu\n else\n print \"That is not a valid command. \"\n puts basic_calc\n end\n\nend", "def sum_difference_product\n # your code goes here\n\tarr = gets.split(\" \") \n\ta = arr[0].to_f\n\tb = arr[1].to_f \n\tprint((a + b),\"\\n\", a - b ,\"\\n\", (a * b),\"\\n\")\nend", "def basic_calc\n puts \"Give me two numbers\"\n print \"> first:\"\n first = gets.chomp.to_i\n print \"> second:\"\n second = gets.chomp.to_i\n\n #print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide:\"\n case $selection\n when \"add\"\n puts \"\\nanswer: #{first + second}\"\n when \"subtract\"\n puts \"\\nanswer: #{first - second}\"\n when \"multiply\"\n puts \"\\nanswer: #{first * second}\"\n when \"divide\"\n puts \"\\nanswer: #{first.to_f / second.to_f} \"\n else\n puts \"\\nOh crap...how'd that happen...\"\n puts \"I guess you never told me what maths to do...EMBARASSING\\n\\n\"\n end\n\nend", "def pets #Method is named pets. There are not parameters\n puts \"How many cats do you have?\" #Prints this string\n cat_total = gets.chomp.to_i #Prompts user for integer input and the integer is stored in cat_total variable\n puts \"I have #{cat_total} cats too!\" #Prints string along with integer in cat_total variable\n puts \"I like to walk my #{cat_total} cats at the park!\" #Prints string with integer in cat_total variable\n puts \"How many dogs do you have?\" #Prints string\n dog_total = gets.chomp.to_i #Prompts user for integer input and stores input in dog_total variable\n puts \"I have #{dog_total} dogs too!\" #Prints string with integer in dog_total\n puts \"What a coincidence!\" #prints string\nend", "def get_requested_amount(type)\n request = prompt_user(\"How much would you like to #{type}?\").to_i\n while request <= 0\n request = prompt_user(\"Please enter an amount greater than $0.\").to_i\n end\n request.to_i\nend", "def user_input(p)\n loop do\n prompt p\n var = gets.chomp\n if number?(var)\n return var\n else\n prompt 'Invalid choice. Please try again.'\n end\n end\nend", "def businesslogic\n\n begin \n #getting user choice according to product id\n print \"\\n Enter your Product Id to purchase:\"\n ch=gets\n \n if (ch=~ /^[0-9]+$/) #check regular expression for correct rating\n \n choice=ch.to_i\n [email protected](\"select * from product_storage where pid=?\")\n res50.execute(choice)\n if (data=res50.fetch).nil? #validation for\n\n puts\"Enter valid product id......\"\n else\n break #break loop if user enter corrcect rating\n end \n else \n\n puts\"Enter only no......\"\n end\n\n end while(ch!=~ /^[0-9]+$/) #@continue until user not enter correct choice \n \n \n [email protected](\"select pname from product_storage where pid=?\")\n name1.execute(choice)\n\n data=name1.fetch\n nm=data[0]\n \n \n puts\"\\n You have selected #{nm}\"\n print\"\\n Enter How many #{nm} do u want:\"\n no=gets.to_i\n #getting quqntity and prize of product \n [email protected](\"select quantity,prize from product_storage where pid=?\")\n res5.execute(choice)\n row3=res5.fetch\n avilable=row3[0].to_i\n prize=row3[1].to_i\n\n #check for avilable stock in store\n if(no<=avilable)\n\n #insert user selected item into inline_item \n [email protected](\"insert into inline_item values(?,?,?)\")\n res6.execute(@cart_no,choice,no)\n tot=prize*no\n\n #create unique bill no each time and store in to bill table\n\n order # call order method to genrate bill no\n \n puts\"\\n #{tot} amount added on your cart..........\"\n puts\"\\n your order no is...............:#{@bill_no}\"\n\n #insert bill no cart no total bill into bill table \n [email protected](\"insert into bill values(?,?,?)\")\n res7.execute(@bill_no,@cart_no,tot)\n\n #calculate remaining product quantity\n totquqntity=avilable-no\n grandtot=totquqntity.to_i\n\n #update quqntity in product table \n [email protected](\"update product_storage set quantity=(?) where pid=(?)\")\n res8.execute(grandtot,choice)\n #call to bill method\n bill\n \n else\n\n puts\"\\n Sorry !!!#{no} are not avilable we have only #{avilable} \"\n end\n end", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n command = gets.chomp.downcase\n case command\n when \"a\"\n puts \"Adding, please provide numbers\"\n first_num = inputs\n answer = inputs + first_num\n when \"s\"\n puts \"Subtracting\"\n first_num = inputs\n answer = first - inputs\n when \"m\"\n puts \"Multiplication\"\n first_num = inputs\n answer = first_num * inputs\n when \"d\"\n puts \"Division\"\n first_num = inputs\n answer = first_num/inputs\n else\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n command = gets.chomp.downcase\n end\n return answer\nend", "def sum_difference_product\n # your code goes here\n a , b = gets.split.map {|x| x.to_i}\n puts a + b\n puts a - b\n puts a * b\nend", "def basic_calc\n puts \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: enter a, s, m, or d; quit to quit\"\n basic_functions = gets.chomp\n while basic_functions != \"quit\"\n if basic_functions == \"a\"\n puts \"Enter first number\"\n add1_int = gets.chomp\n puts \"Enter second number\"\n add2_int = gets.chomp\n puts \"Equals\"\n puts add1_int + add2_int\n puts \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: enter a, s, m, or d; quit to quit\"\n puts basic_functions = gets.chomp\n end\n if basic_functions == \"s\"\n puts \"Enter first integer\"\n sub1_int = gets.chomp.to_i\n puts \"Enter second integer\"\n sub2_int = gets.chomp.to_i\n puts \"Equals\"\n puts sub1_int - sub2_int\n puts \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: enter a, s, m, or d; quit to quit\"\n puts basic_functions = gets.chomp\n end\n if basic_functions == \"m\"\n puts \"Enter first integer\"\n mult1_int = gets.chomp.to_i\n puts \"Enter second integer\"\n mult2_int = gets.chomp.to_i\n puts \"Equals\"\n puts mult1_int * mult2_int\n puts \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: enter a, s, m, or d; quit to quit\"\n puts basic_functions = gets.chomp\n\n end\n if basic_functions == \"d\"\n puts \"Enter first integer\"\n div1_int = gets.chomp.to_i\n puts \"Enter second integer\"\n div2_int = gets.chomp.to_i\n puts \"Equals\"\n puts div1_int / div2_int\n puts \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: enter a, s, m, or d; quit to quit\"\n puts basic_functions = gets.chomp\n\n end\n end\nend", "def Multiplicacion\n print \"Ingrese El numero 1: \"\n numero1 = gets.chomp.to_f\n print \"Ingrese El numeor 2: \"\n numero2 = gets.chomp.to_f\n\n puts \"\\nMultiplicacion: #{numero1 * numero2}\"\n end", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n basic_menu_choice = gets.chomp.downcase\n\n if basic_menu_choice == 'a'\n \tputs \"Enter the first number you want to add:\"\n \tx = gets.chomp.to_i\n \tputs \"Enter the second number you want to add:\"\n \ty = gets.chomp.to_i\n \tputs \"#{x} + #{y} = #{x + y}\"\n\n elsif basic_menu_choice== 's'\n \tputs \"Enter the first number you want to subtract:\"\n \tx = gets.chomp.to_i\n \tputs \"Enter the second number you want to subtract:\"\n \ty = gets.chomp.to_i\n \tputs \"#{x} - #{y} = #{x - y}\"\n\n elsif basic_menu_choice == 'm'\n \tputs \"Enter the first number you want to multiply:\"\n \tx = gets.chomp.to_i\n \tputs \"Enter the second number you want to multiply:\"\n \ty = gets.chomp.to_i\n \tputs \"#{x} x #{y} = #{x * y}\"\n\n elsif basic_menu_choice == 'd'5\n \tputs \"Enter the first number you want to divide:\"\n \tx = gets.chomp.to_i\n \tputs \"Enter the second number you want to divide by:\"\n \ty = gets.chomp.to_i\n \tputs \"#{x} / #{y} = #{x / y}\"\n\n else\n \tputs \"Invalid selection\"\n end\nend", "def calc\n# print \"Please select (a)dd, (s)ubtract, (m)ultiply, (d)ivide, (p)ower, or (s)quare root: \"\n# operation = gets.chomp.downcase\n case response\n when \"a\"\n \tputs \"You have selected addition. Please enter the first number: \"\n \tnum1 = gets.chomp.to_f\n \tputs \"Please enter the second number: \"\n \tnum2 = gets.chomp.to_f\n \tans = num1 + num2\n \tputs \"#{num1} plus #{num2} equals #{ans}.\"\n when \"s\"\n \tputs \"You have selected subtraction. Please enter the first number: \"\n \tnum1 = gets.chomp.to_f\n \tputs \"Please enter the second number: \"\n \tnum2 = gets.chomp.to_f\n \tans = num1 - num2\n \tputs \"#{num1} minus #{num2} equals #{ans}.\"\n when \"m\"\n \tputs \"You have selected multiplication. Please enter the first number: \"\n \tnum1 = gets.chomp.to_f\n \tputs \"Please enter the second number: \"\n \tnum2 = gets.chomp.to_f\n \tans = num1 * num2\n \tputs \"#{num1} multiplied by #{num2} equals #{ans}.\"\n when \"d\"\n \tputs \"You have selected division. Please enter the first number: \"\n \tnum1 = gets.chomp.to_f\n \tputs \"Please enter the second number: \"\n \tnum2 = gets.chomp.to_f\n \tans = num1 / num2\n \tputs \"#{num1} divided by #{num2} equals #{ans}.\"\n when \"p\"\n \tputs \"You have selected power. Please enter the first number: \"\n \tnum1 = gets.chomp.to_f\n \tputs \"Please enter the power which you would like that to be raised: \"\n \tnum2 = gets.chomp.to_f\n \tans = num1**num2\n \tputs \"#{num1} to the power of #{num2} equals #{ans}.\"\n when \"s\"\n \tputs \"You have selected square root. Please enter the number you would like to know the square root of: \"\n \tnum1 = gets.chomp.to_f\n \tans = Math.sqrt(num1)\n \tputs \"The square root of #{num1} equals #{ans}.\"\n else\n \tputs \"Please try again.\"\n \tcalc\n end\nend", "def select_product\n puts Rainbow(' > ').black.underline.bg(:yellow) + 'Type your choice:'\n choice = ''\n coins = false\n while choice\n choice = gets.chomp\n @machine.check_for_product(choice) == 1 ? buy_product(choice, coins) : [intro, menu_setting]\n end\n end", "def insert_coin\n\n loop do\n #入れろお金を選択\n puts \"Please put your money\"\n puts \"01. 1yen\"\n puts \"02. 5yen\"\n puts \"03. 10yen\"\n puts \"04. 50yen\"\n puts \"05. 100yen\"\n puts \"06. 500yen\"\n puts \"07. 1000yen\"\n puts \"08. 2000yen\"\n puts \"09. 5000yen\"\n puts \"10. 10000yen\"\n puts \"11. stop\"\n puts \"money: #{@money}yen\"\n print \"select : \"\n input = Integer(gets)\n\n #10 ~ 1000円 以外の金はお返し\n case input\n when 1 \n then puts \"change : 1\"\n when 2\n then puts \"change : 5\"\n when 3\n then @money += 10\n when 4\n then @money += 50\n when 5\n then @money += 100\n when 6\n then @money += 500\n when 7\n then @money += 1000\n when 8\n then puts \"change : 2000\"\n when 9\n then puts \"change : 5000\"\n when 10\n then puts \"change : 10000\" \n end # end case\n \n #stop\n break if input == 11\n\n end #end loop\n\n end", "def add_to_cart\n puts \"To add product to your cart enter item number. To return to the main menu enter M to return to the main menu.\"\n user_input = gets.strip\n if user_input == \"M\"\n menu\n else\n user_input = user_input.to_i\n @cart << @products[user_input - 1]\n end\n puts \"#{@products[user_input - 1][:product]} added to your cart. If you wish to add more, enter the item number. Or, enter M to return to the main menu.\"\n user_input2 = gets.strip\n if user_input2 == \"M\"\n menu\n else \n add_more(user_input2.to_i)\n end\nend", "def multiplication\n\tputs \"which numbers would you like to multiply\"\n\tmult_number_1 = gets.chomp\n\tmult_number_2 = gets.chomp\n\tputs mult_number_1.to_f * mult_number_2.to_f\nend", "def add_to_cart\n puts \"To add product to your cart enter item number. To return to the main menu enter M to return to the main menu.\"\n user_input = gets.strip\n if user_input == \"M\"\n menu\n else\n user_input = user_input.to_i\n @cart << @products[user_input - 1]\n end\n puts \"#{@products[user_input - 1][:product]} added to your cart. If you wish to add more, enter the item number. Or, enter M to return to the main menu.\"\n user_input2 = gets.strip\n if user_input2 == \"M\"\n menu\n else\n add_more(user_input2.to_i)\n end\nend", "def add_operation()\n print_message \"Write number and press ENTER to add more or press 'r' to show result\"\n result = 0\n add = gets.chomp\n if add != 'r'\n result = add.to_i\n end\n begin\n begin\n add = gets.chomp\n if add != 'r'\n result += add.to_i\n end\n rescue StandardError => e\n print_error_message \"Invalid number. Ending Add operation.\\n#{e.message}\"\n add = 'r'\n end\n end while add.downcase != 'r'\n print_message \"Result of adding: #{result.to_s}\"\n end", "def product(str)\n total_product = 1\n str.split('').each do |num|\n total_product = total_product * num.to_i\n end\n total_product\nend", "def conversion\n kilos_to_pounds = 2.205\n pounds_to_kilos = 0.454\n\n puts \"1. From kilograms to pounds\"\n puts \"2. From pounds to kilograms\"\n print \"Choose the conversion number (1 or 2) you want to make: \"\n response = gets.chomp.to_i\n\n if response == 1\n print \"Enter a number of kilograms: \"\n user_num = gets.chomp.to_i\n result = user_num * kilos_to_pounds\n user_from = \"kilograms\"\n user_to = \"pounds\"\n\n elsif response == 2\n print \"Enter a number of pounds: \"\n user_num = gets.chomp.to_i\n result = user_num * pounds_to_kilos\n user_from = \"pounds\"\n user_to = \"kilograms\"\n end\n\n puts \"There are #{result} #{user_to} in #{user_num} #{user_from}.\"\nend", "def multiplication(input_number1, input_number2)\n\tproduct = input_number1 * input_number2\n\tputs \"The product of #{input_number1} and #{input_number2} is #{product}.\"\n\tputs \"Thank you for using the calculator. Goodbye!\"\nend", "def advanced_calc\n print \"(p)ower, (s)qrt: \"\n gets.chomp.downcase\nend", "def advanced_calculator_type\n print \"What would you like to do? Type 1 to find exponents or 2 to find the square root of a number: \"\n selection = gets.to_i\n # puts \"You chose #{selection}\"\n if selection == 1\n \"exponents\"\n elsif selection == 2\n \"square root\"\n else\n \"error\"\n end\nend", "def ask(order)\r\n input = \"\"\r\n loop do\r\n puts \"What would you like to order? Type finished when order is complete.\"\r\n input = gets.strip.downcase\r\n if input == \"finished\" \r\n break \r\n end\r\n \r\n puts \"How many do you want\"\r\n amount = gets.strip.to_i\r\n \r\n add_order(input, amount, order) \r\n \r\n end\r\n\r\nend", "def calculator\n end_op = \"addition\"\n end_product = 0\n puts \"What is your first number?\"\n numb1 = gets.chomp.to_f\n puts \"What is your operation?\"\n op = gets.chomp\n puts \"What is your second number?\"\n numb2 = gets.chomp.to_f\n puts \"Would you like to add an operation?\"\n add_second = gets.chomp.capitalize\n if add_second.upcase == \"YES\"\n puts \"What is your operation?\"\n op2 = gets.chomp\n puts \"What is your third number?\"\n numb3 = gets.chomp.to_f\n# calculator\n else\n end\n\n # This is normalizing the input, so that the operation is only the lowercase word of the op\n if op == \"+\" || op == \"addition\"\n end_op = \"addition\"\n elsif op == \"-\" || op == \"subtraction\"\n end_op = \"subtraction\"\n elsif op == \"*\" || op == \"multiplication\"\n end_op = \"multiplication\"\n elsif op == \"/\" || op == \"division\"\n end_op = \"division\"\n end\n\n # This does the same as the above section, for the 2nd op\n if op2 == \"+\" || op == \"addition\" || op == \"ADDITION\"\n end_op2 = \"addition\"\n elsif op2 == \"-\" || op == \"subtraction\" || op == \"SUBTRACTION\"\n end_op2 = \"subtraction\"\n elsif op2 == \"*\" || op == \"multiplication\" || op == \"MULTIPLICATION\"\n end_op2 = \"multiplication\"\n elsif op2 == \"/\" || op == \"division\" || op == \"DIVISION\"\n end_op2 = \"division\"\n end\n\n # This operates the first 2 numbers\nif end_op == \"addition\"\n end_product = numb1 + numb2\n elsif end_op == \"subtraction\"\n end_product = numb1 - numb2\n elsif end_op == \"multiplication\"\n end_product = numb1 * numb2\n elsif end_op == \"division\"\n end_product = numb1 / numb2\nend\n\n # This calculates for the 2nd operation and 3rd number\n if add_second.upcase == \"YES\"\n if end_op2 == \"addition\"\n end_product = end_product + numb3\n elsif end_op2 == \"subtraction\"\n end_product = end_product - numb3\n elsif end_op2 == \"multiplication\"\n end_product = end_product * numb3\n elsif end_op2 == \"division\"\n end_product = end_product / numb3\n else\nend\nend\n puts \"Your final answer is #{end_product}.\"\nend", "def sum_difference_product\n puts \"First number: \"\n first_number = gets.chomp.to_i\n puts \"Second number: \"\n second_number = gets.chomp.to_i\n \n puts \"The sum of these two numbers is #{first_number + second_number}.\"\n puts \"The difference between these two numbers is #{(first_number - second_number).abs}.\"\n puts \"The product of these two numbers is #{first_number * second_number}.\"\nend", "def view_cart\n cart_total = 0\n @cart.each_with_index do |product, index|\n print \"#{index + 1}. #{product[:product]} - \"\n puts \"$#{product[:price]}\"\n cart_total += product[:price]\n end\n puts \"---------\"\n puts \"Cart Total: $#{cart_total}\"\n puts \"To remove a product, enter the item number. Or, enter M to return to the Main Menu.\"\n index = gets.strip.to_i\n user_input = gets.strip\n if user_input == \"M\"\n menu\n else \n remove_product(index - 1)\n puts \"Invalid Input. Enter M.\"\n end\nend", "def sum_num\n\t#ask for number\n\tputs \"gimme dat number: make sure its more than 1?\"\n\tnum = gets.chomp.to_i\n\t\n\n\tif num < 1\n\t\tputs \"I told you to put a number greater than 1\"\n\t\tsum_num\n\telse\n\t\t# prints number 1 to num\n\t\tcounter = (1..num)\n\t\tnew_num = 0\n\t\tcounter.each do |num|\n\t\t\tnew_num = new_num + num\n\n\n\t\tend\n\n\tend\n\tputs new_num \nend", "def single_input_calc\n puts \"What would you like to calculate? - enter first number then operator then second number.\"\n to_calc = gets.strip\n arr = to_calc.split\n first_num = arr[0].to_i\n op = arr[1].to_s\n second_num = arr[2].to_i\n string_result = first_num.public_send(op, second_num)\n puts \"The result is: #{string_result}\"\n @arr_results << {first_number: first_num, modifier: op, second_number: second_num, result: string_result}\n end", "def sum_difference_product\n input = gets.chomp \n nums = input.split(' ').map{|x| x.to_i}\n puts nums[0] + nums[1]\n puts nums[0] - nums[1]\n puts nums[0] * nums[1]\n \nend", "def input_process (*args)\n if(args.size == 1)\n input = args[0]\n operation = input.initial\n elsif(args.size == 2)\n input = args[1]\n operation = input[0]\n else\n return\n end\n \n total = get_numbers(input, operation)\n\n if operation == \"+\"\n $totalvalue += addition(*total)\n elsif operation == \"-\"\n $totalvalue += subtraction(*total)\n elsif operation == \"*\"\n $totalvalue = multiplication($totalvalue, *total)\n elsif operation == \"/\"\n $totalvalue = division($totalvalue, *total)\n end\n total.clear\nend", "def Suma\n print \"Ingrese El numero 1: \"\n numero1 = gets.chomp.to_f\n print \"Ingrese El numeor 2: \"\n numero2 = gets.chomp.to_f\n puts \"\\nSuma: #{numero1 + numero2}\"\n end", "def basic_calculator_type\n print \"What would you like to do? Type 1 to add, 2 to subtract, 3 to multiply or 4 to divide: \"\n selection = gets.to_i\n # puts \"You chose #{selection}\"\n if selection == 1\n \"add\"\n elsif selection == 2\n \"subtract\"\n elsif selection == 3\n \"multiply\"\n elsif selection == 4\n \"divide\"\n else\n \"error\"\n end\nend", "def serving_size_calc(item_to_make, order_quantity)#two arguments , item to make order quantity \n library = {\"cookie\" => 1, \"cake\" => 5, \"pie\" => 7}# creating a hash called library, \n #the item to make it's the key and the qty the problem\n error_counter = 3#define a variable cable and set it equal to three.\n\n library.each do |food| #iterating over the hash library \n\n if library[food] != library[item_to_make] #printing error counter - 1\n#we are checking if the library is not equal to the value .\n preturn error_counter += -1 #printing error counter - 1\n end\n end\n\n if error_counter > 0#if error counter is greater than 0 we raise the argument\n raise ArgumentError.new(\"#{item_to_make} is not a valid input\")\n end\n\n \n \n\n serving_size = library.values_at(item_to_make)[0]#set a variable called serving size\n #equal to library.values at to get the values , and get item and index\n serving_size_mod = order_quantity % serving_size#it sets a variable and set it equal to order quantity remainder of serving size.\n\n# case serving_size_mod\n# when 0\n if serving_size_mod == 0#if serving size is equal to 0 then return the calculations complete\n return \"Calculations complete: Make #{order_quantity/serving_size} of #{item_to_make}\"\n else\n return \"Calculations complete: Make #{order_quantity/serving_size} of #{item_to_make}, you have #{serving_size_mod} leftover ingredients. Suggested baking items: #TODO: MAKE THIS FEATURE\"\n end\nend", "def serving_size_calc(item_to_make, order_quantity)#two arguments , item to make order quantity \n library = {\"cookie\" => 1, \"cake\" => 5, \"pie\" => 7}# creating a hash called library, \n #the item to make it's the key and the qty the problem\n error_counter = 3#define a variable cable and set it equal to three.\n\n library.each do |food| #iterating over the hash library \n\n return error_counter -= 1 if library[food] != library[item_to_make] #printing error counter - 1\n#we are checking if the library is not equal to the value .\n #printing error counter - 1\n \n end\n\n if error_counter > 0#if error counter is greater than 0 we raise the argument\n raise ArgumentError.new(\"#{item_to_make} is not a valid input\")\n end\n\n\n serving_size = library.values_at(item_to_make)[0]#set a variable called serving size\n #equal to library.values at to get the values , and get item and index\n serving_size_mod = order_quantity % serving_size#it sets a variable and set it equal to order quantity remainder of serving size.\n\n# case serving_size_mod\n# when 0\n if serving_size_mod == 0 #give me this at position 0\n\n #if serving size is equal to 0 then return the calculations complete\n return \"Calculations complete: Make #{order_quantity/serving_size} of #{item_to_make}\"\n else\n return \"Calculations complete: Make #{order_quantity/serving_size} of #{item_to_make}, you have #{serving_size_mod} leftover ingredients. Suggested baking items: #TODO: MAKE THIS FEATURE\"\n end\nend", "def basic_calc\n\n\n print Rainbow(\"(a)\").green + \"dd, \" + Rainbow(\"(s)\").yellow + \"ubtract, \" + Rainbow(\"(m)\").red + \"ultiply, \" + Rainbow(\"(d)\").cyan + \"ivide: \"\n basic_function = gets.chomp.downcase\n print \"Enter first number: \"\n first_number = gets.chomp.to_f\n print \"Enter second number: \"\n second_number = gets.chomp.to_f\n case basic_function\n when \"a\"\n answer = first_number + second_number\n puts \"Your answer is #{answer}\"\n when \"s\"\n answer = first_number - second_number\n puts \"Your answer is #{answer}\"\n when \"m\"\n answer = first_number * second_number\n puts \"Your answer is #{answer}\"\n when \"d\"\n answer = first_number / second_number\n puts \"Your answer is #{answer}\"\n \n else\n puts \"incorrect\"\n end \n gets\n menu\nend", "def perform\n puts '*' * 40\n puts 'Bienvenue dans le calculateur de poids des mots'\n puts '*' * 40\n puts ' '\n ​\n puts 'Entrez vos mots dans le format suivant : A V E C D E S E S P A C E S'\n print '> ' \n capture = gets.chomp\n ​\n puts '*' * 40\n puts \"Le poid de votre saisie : #{calculateWeight(capture)}\"\n puts '*' * 40\n end", "def add\n #ask for some inputs , after some text\n #turn those inputs into a float, and save it in some variable\n print \"what is your first number? \"\n first_number = gets.to_f\n print \"what is your second number? \"\n second_number = gets.to_f\n # Add the two inputs given togrther and save the result\n result = first_number + second_number\n #print\n puts \"The result is #{result}\"\nend", "def process_orders\n\n\t\tputs ''\n\t\tstill_processing = true\n\n\t\twhile still_processing\n\t\t\tputs \"Enter product type or 'D' (done) to end:\"\n\t\t\tproduct_choice = gets.chomp\n\n\t\t\t# Break out \n\t\t\tif product_choice == 'd' || product_choice == 'done'\n\t\t\t\tstill_processing = false\n\t\t\t\n\t\t\t# Perform each action for the item\n\t\t\telse\n\t\t\t\tif(SkiStore.instance.products.keys.include? product_choice)\n\t\t\t\t\[email protected](product_choice).each{|action| puts \"---- #{action}\"}\n\t\t\t\telse\n\t\t\t\t\t# The assignment says to just 'display an error'\n\t\t\t\t\t# so I didn't display an error here\n\t\t\t\t\tputs \"Error: Product not defined\"\n\t\t\t\tend\n\n\t\t\tend\n\t\tend\n\t\tputs ''\n\tend", "def request_calculation_type\n puts \"Type 1 to add, 2 to subtract, 3 to multiply, 4 to divide, 5 to power to, or 6 for modulus calculation : \"\n operation_selection = gets.to_i\n\n if operation_selection == 1\n \"add\"\n elsif operation_selection == 2\n \"subtract\"\n elsif operation_selection == 3\n \"multiply\"\n elsif operation_selection == 4\n \"divide\"\n elsif operation_selection == 5\n \"exponent\"\n elsif operation_selection == 6\n \"modulus\"\n else\n \"error\"\n end\nend", "def serving_size_calc(item_to_make, order_quantity)\n ##hash called library, \n library = {\"cookie\" => 1, \"cake\" => 5, \"pie\" => 7}\n ##variable called error_counter, set to three\n #error_counter = 3\n #library.each do |food|\n # if library[food] != library[item_to_make]\n ## serving_size_calc(\"pie\", 7)\n ## library[food] != library[\"pie\"]\n # p error_counter += -1\n #end\n # end\n\n #if error_counter > 0\n if library.include?(item_to_make) == false\n raise ArgumentError.new(\"#{item_to_make} is not a valid input\")\n end\n #assign var serving_size to get the value of the key matching item_to_make\n serving_size = library[item_to_make]\n #assign var serving_size_mod to \n serving_size_mod = order_quantity % serving_size\n ## serving_size_calc(\"pie\", 8)\n ## want 8 pies\n ## serving size = 7\n ## 8%7 = 1\n \n\n if serving_size_mod == 0\n return \"Calculations complete: Make #{order_quantity/serving_size} of #{item_to_make}\"\n elsif serving_size_mod.between?(1,4)\n return \"Calculations complete: Make #{order_quantity/serving_size} of #{item_to_make}, you have #{serving_size_mod} leftover ingredients. Suggested baking items: #{serving_size_mod} cookies.\"\n end\n \n # return \"Calculations complete: Make #{order_quantity/serving_size} of #{item_to_make}, you have #{serving_size_mod} leftover ingredients. Suggested baking items: \"\n #end\nend", "def switch\nchoice=gets.chomp.to_s\n@user_choice=choice\n\nif @user_choice==\"douwe egberts\"\n @amount_de-=1\n @total_products+=1\n puts \"You have bought #{choice}\"\n\nelsif @user_choice==\"nespresso\"\n @amount_nes-=1\n @total_products+=1\n puts \"You have bought #{choice}\"\n\n elsif @user_choice==\"senseo\"\n @amount_senseo-=1\n @total_products+=1\n puts \"You have bought #{choice}\"\n\n else\n puts \"wrong\"\n show\n end\n end", "def basic_calc\n\n\n print Rainbow(\"(a)\").green + \"dd, \" + Rainbow(\"(s)\").yellow + \"ubtract, \" + Rainbow(\"(m)\").red + \"ultiply, \" + Rainbow(\"(d)\").cyan + \"ivide: \"\n basic_function = gets.chomp.downcase\n print \"Enter first number: \"\n first_number = gets.chomp.to_f\n print \"Enter second number: \"\n second_number = gets.chomp.to_f\n case basic_function\n when \"a\"\n answer = first_number + second_number\n puts \"Your answer is #{answer}\"\n when \"s\"\n answer = first_number - second_number\n puts \"Your answer is #{answer}\"\n when \"m\"\n answer = first_number * second_number\n puts \"Your answer is #{answer}\"\n when \"d\"\n answer = first_number / second_number\n puts \"Your answer is #{answer}\"\n \n else\n puts \"incorrect\"\n end \ngets\nend", "def get_operator\n begin\n puts \"Please choice the operator:\"\n puts \"1: add \\n2: substract \\n3: multiply \\n4: divide\"\n operator = gets.chomp.to_i\n end while ![1,2,3,4].include?(operator)\n return operator\nend", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n choice = gets.chomp\n case\n when choice == \"a\"\n puts \"What would you like to add?\"\n print \"First number: \"\n num1 = gets.chomp.to_f\n print \"Ok, now the second number: \"\n num2 = gets.chomp.to_f\n puts \"Your maths equal #{num1 + num2}\"\n menu\n when choice == \"s\"\n puts \"What would you like to subtract?\"\n print \"First number: \"\n num1 = gets.chomp.to_f\n print \"Ok, now the second number: \"\n num2 = gets.chomp.to_f\n puts \"Your maths equal #{num1 - num2}\"\n menu\n when choice == \"m\"\n puts \"What would you like to multiply?\"\n print \"First number: \"\n num1 = gets.chomp.to_f\n print \"Ok, now the second number: \"\n num2 = gets.chomp.to_f\n puts \"Your maths equal #{num1 * num2}\"\n menu\n when choice == \"d\"\n puts \"What would you like to divide?\"\n print \"First number: \"\n num1 = gets.chomp.to_f\n print \"Ok, now the second number: \"\n num2 = gets.chomp.to_f\n puts \"Your maths equal #{num1 / num2}\"\n menu\n end\nend", "def theMeat()\n\tprint \"Type the number of what you'd like to buy\"\n\t\t$buy = gets.chomp\n\tif $buy == \"1\" \n\t $soap += 1\n\t $total += 5\n\t\tputs \"Soap X #{$soap}\"\n\t\tputs \"Total $#{$total}\"\n\t\tputs \"Thank you, continue!\"\n\t\tputs \"\"\n\t\tbuyItem()\n\telsif $buy == \"2\" \n\t $bread += 1\n\t $total += 2\n\t\tputs \"Bread X #{$bread}\"\n\t\tputs \"Total $#{$total}\"\n\t\tputs \"Thank you, continue!\"\n\t\tputs \"\"\n\t\tbuyItem()\n\telsif $buy == \"3\" \n\t $cereal += 1\n\t $total += 3\n\t\tputs \"Cereal X #{$cereal}\"\n\t\tputs \"Total $#{$total}\"\n\t\tputs \"Thank you, continue!\"\n\t\tputs \"\"\n\t\tbuyItem()\n\telsif $buy == \"4\" \n\t $dogFood += 1\n\t $total += 5\n\t\tputs \"Dog Food X #{$dogFood}\"\n\t\tputs \"Total $#{$total}\"\n\t\tputs \"Thank you, continue!\"\n\t\tputs \"\"\n\t\tbuyItem()\n\telsif $buy == \"0\"\n\t\tputs \"Soap X #{$soap}\" \n\t\tputs \"Bread X #{$bread}\"\n\t \tputs \"Cereal X #{$cereal}\"\n\t\tputs \"Dog Food X #{$dogFood}\"\n\t\tputs \"Total $#{$total}\"\n\t\tputs \"Thank you for shopping with us!\"\n\t\tputs \"\"\n\telsif $buy > \"4\"\n\t puts \"Sorry, that isn't an option. Try again.\"\n\t buyItem()\n\tend\nend", "def print_choices\n # A user should be able to enter numbers to perform the operation on\n puts \"========================\"\n puts \"Input number 1 please:\"\n @number_one = gets.chomp.to_i\n puts \"Input number 2 please:\"\n @number_two = gets.chomp.to_i\n puts \"\"\n puts \"What do you want to do with the numbers?\"\n # Calculator should be able to do basic arithmetic (+,-, *, /)\n puts \"1 - addition\"\n puts \"2 - subtraction\"\n puts \"3 - division\"\n puts \"4 - multiplication\"\n puts \"5 - quit\"\n gets.chomp.to_i\nend", "def sum_difference_product\n print \"Type two integers separated by a space:\"\n integers = gets.chomp\n arr = integers.split(\" \").map {|s| s.to_i}\n a = arr[0]\n b = arr[1]\n puts \"#{a+b}\\n#{a-b}\\n#{a*b}\"\n \nend", "def rpn_calculator\n operators_list = ['+','-','*','/']\n stack = []\n \n def add(stack)\n stack.push(stack.pop + stack.pop)\n end\n \n def minus(stack)\n var1, var2 = stack.pop, stack.pop\n stack.push(var2 - var1)\n end\n \n def multiply(stack)\n stack.push(stack.pop * stack.pop)\n end\n \n def divide(stack)\n stack.push(stack.pop / stack.pop)\n end\n \n def get_user_input\n puts \"enter number or operator into calculator\"\n\n gets.chomp\n end\n \n puts \"enter 'quit' to quit\"\n loop do\n user_choice = get_user_input\n break if user_choice == \"quit\"\n \n if !(operators_list.include?(user_choice))\n stack << user_choice.to_i\n end\n \n case (user_choice)\n when \"+\"\n add(stack)\n when \"-\"\n minus(stack)\n when \"*\"\n multiply(stack)\n when \"/\"\n divide(stack)\n end \n \n \n p stack\n end \nend", "def sub_operation()\n print_message \"Write number and press ENTER to substract more or press 'r' to show result\"\n result = 0\n sub = gets.chomp\n if sub != 'r'\n result = sub.to_i\n end\n begin\n begin\n sub = gets.chomp\n if sub != 'r'\n result -= sub.to_i\n end\n rescue StandardError => e\n print_error_message \"Invalid number. Ending Substraction operation.\\n#{e.message}\"\n sub = 'r'\n end\n end while sub.downcase != 'r'\n print_message \"Result of substracting: #{result.to_s}\"\n end", "def sum_difference_product\n a = gets.chomp.split' '\n a = a.map{|i| i.to_i}\n sum = a.inject(0, :+)\n diff = a[0] - a[1]\n product = a.inject(1, :*)\n\n puts \"#{sum}\\n#{diff}\\n#{product}\"\nend", "def serving_size_calc(item_to_make, num_of_ingredients)\n library = {\"cookie\" => 1, \"cake\" => 5, \"pie\" => 7} \n \n\nunless library.include?(item_to_make) \n raise ArgumentError.new(\"#{item_to_make} is not a valid input\")\nend\n serving_size = library[item_to_make]\n remaining_ingredients = num_of_ingredients % serving_size\n\n output = \"Calculations complete: Make #{num_of_ingredients / serving_size} of #{item_to_make}\"\n puts remaining_ingredients.zero? ? output : output + \" you have #{remaining_ingredients} leftover ingredients. Suggested baking items: TODO: \"\n while remaining_ingredients > 0\n if remaining_ingredients >= 5\n puts \"we could make a cake\"\n else\n puts \"lets make #{remaining_ingredients} cookies\"\n end\n remaining_ingredients %= remaining_ingredients\n end\nend", "def actualizarStockProducto(pos)\n puts \"1.Incrementar stock\"\n puts \"2.Decrementar stock\"\n op=gets.to_i #op es opcion \n print \"Ingrese cantidad: \"\n cantidad=gets.to_i\n if op==1\n $productos[posicion][5]=$productos[posicion][5] + cantidad\n else\n valor=$productos[posicion][5] * cantidad\n if valor >=0\n $productos[posicion][5]=$productos[posicion][5] - cantidad\n else\n puts \"Debe ingresar una cantidad valida.El stock no puede quedar en negativo\"\n end\n end\n end", "def arithmetic_ops\n puts \"Enter first number:\"\n num1 = gets.to_i\n puts \"Enter the second number:\"\n num2 = gets.to_i\n\n puts \"#{num1} + #{num2} = #{num1 + num2}\" \n puts \"#{num1} - #{num2} = #{num1 - num2}\" \n puts \"#{num1} * #{num2} = #{num1 * num2}\" \n puts \"#{num1} / #{num2} = #{num1 / num2}\" \n puts \"#{num1} % #{num2} = #{num1 % num2}\" \n puts \"#{num1} ** #{num2} = #{num1 ** num2}\"\n \nend", "def sum_difference_product #defines the method\na, b = gets.split #uses the split mehtod to split the input into var a and b\n a = a.to_i #converts a to an int\n b = b.to_i #converts b to an int\n puts a + b #puts the sum of a and b\n puts a - b #puts the difference between a and b\n puts a * b #puts the product of a and b\nend", "def add_function \n\tputs \"Enter the numbers\"\n\tn1 = gets.to_i\n\tn2 = gets.to_i\n\tputs \"The sum is #{n1+n2}\"\nend" ]
[ "0.7865483", "0.77955884", "0.71740174", "0.7131533", "0.6667896", "0.6534447", "0.6484899", "0.64848787", "0.6433163", "0.6341425", "0.6324585", "0.624126", "0.6223523", "0.61402065", "0.6130295", "0.61285204", "0.60888565", "0.60591793", "0.60484135", "0.60353094", "0.60255545", "0.6005131", "0.5994259", "0.5991514", "0.59782195", "0.59434444", "0.59405214", "0.59405166", "0.5940149", "0.5938671", "0.59356916", "0.5933674", "0.5929785", "0.5925685", "0.5925585", "0.5914347", "0.5909803", "0.5908904", "0.5907466", "0.590357", "0.5883123", "0.58801633", "0.58727306", "0.58717376", "0.5856786", "0.5850998", "0.5850701", "0.5849623", "0.5849116", "0.5843217", "0.58310425", "0.58302087", "0.58243126", "0.58186626", "0.58011854", "0.5795009", "0.5792175", "0.57875705", "0.5780235", "0.57784694", "0.5772367", "0.5768939", "0.5768909", "0.576331", "0.57629293", "0.5761844", "0.5757296", "0.57530415", "0.5752897", "0.57441276", "0.5726668", "0.57244444", "0.57213956", "0.5717436", "0.5712858", "0.57109517", "0.5706343", "0.5706293", "0.57023585", "0.5701347", "0.5700083", "0.56973684", "0.5696804", "0.5689688", "0.568947", "0.56798387", "0.56754583", "0.566964", "0.5657188", "0.56454724", "0.5642772", "0.5639828", "0.5637387", "0.56373715", "0.56324005", "0.5632205", "0.56256723", "0.56232697", "0.5611324", "0.5608253" ]
0.77624243
2
TODO, TOFIX validate :material_filename_unique
def save_file if self.file then self.file.save end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_filename(_item)\n nil\n end", "def validate_name_is_unique_among_materials\n return if parent.nil?\n\n # conflicts = parent.materials.where.has { |parent| name =~ parent.name }\n conflicts = parent.materials.where(Course::Material.arel_table[:name].matches(name))\n errors.add(:name, :taken) unless conflicts.empty?\n end", "def filename\n \"#{Digest::SHA1.file(file.file).hexdigest}.png\" if original_filename\n end", "def validate_name_uniqueness\n existing_files = ProjectFile.where(directory_id: directory_id, \n project_id: project_id, name: name)\n unless existing_files.empty? or (existing_files.size == 1 and \n existing_files.first == self)\n errors.add(:name, \"must be unique within a folder; please \"+\n \"change #{project.name}:#{path} to something different.\")\n end\n end", "def ignore_blanks_and_duplicates\n if (self.image_file_name.nil? || self.image_file_name.blank?) && (self.unique_image_file_name.nil? || self.unique_image_file_name.blank?)\n self.errors[:unique_image_file_name].push 'cannot be blank unless uploading from a browser'\n return false\n end\n \n master = self.variant.product.master\n if !master.nil?\n master.variant_images.each do |i|\n if i.unique_image_file_name==self.unique_image_file_name \n self.errors[:unique_image_file_name].push 'is a duplicate with a master image'\n return false\n end\n end\n end\n end", "def path_is_unique\n return true if self.mp3.file.blank?\n\n # Guess what the audio path will be before it's actually saved there.\n # This is predictable for uploaded audio.\n # This could potentially fail if someone was uploading audio at exactly\n # midnight and some audio already existed for the next day.\n path = File.join(\n AUDIO_PATH_ROOT,\n self.store_dir,\n self.filename\n )\n\n if File.exist?(path)\n self.errors.add(:mp3, \"A file with that name already exists; \" \\\n \"please rename your local audio file and try again. \" \\\n \"If you are trying to replace the audio file, first delete the \" \\\n \"old audio.\")\n end\n end", "def clean_file_file_name (d)\n\t\tif ! d\n\t\t\terrors.add('file', 'need to attach a file')\n\t\tend\n\tend", "def filename\n \"vehicle.png\" if original_filename\n end", "def valid_new_filename(file)\n new_file = file\n counter = 0\n while File.exist?(new_file) do\n counter += 1\n ext = File.extname(file)\n basename = file.split(ext).first\n new_file = \"#{basename}_#{counter}#{ext}\"\n end\n new_file\n end", "def generate_file_name\n file_name = attachment.instance_read(:file_name).slugged_filename\n attachment.instance_write :file_name, file_name\n end", "def unique_file_name file_name\n count = 0\n name = file_name\n current_user = User.find(self.user_id)\n while Userfile.find_all_accessible_by_user(current_user).exists?(:name => name)\n count += 1\n extname = File.extname(name)\n name = \"#{File.basename(name,extname)}-#{count}#{extname}\"\n end\n return name\n end", "def filename\n # byebug\n \"#{secure_token}.jpg\" if original_filename.present?\n end", "def file?\n not identifier.blank?\n end", "def filename\n @name ||= \"#{md5}.#{file.extension}\" if original_filename.present?\n end", "def find_free_name(filename); end", "def filename\n \"mp-#{make_stamp}-1024.jpg\" if original_filename\n end", "def valid_filename?(name)\n name.length.positive?\nend", "def validate_file_status(filename)\n raise IconGenerator::Error unless File.exists? filename\n end", "def asset_file_name_formatted\n if self.asset_clone_id.present?\n x = self.asset_clone\n if x.present?\n case self.asset_type\n when TYPE[:section_audio], TYPE[:media_image], TYPE[:media_video], TYPE[:slideshow_image], TYPE[:infographic], TYPE[:infographic_dataset]\n \"#{x.id}__#{x.asset_file_name}\"\n else\n x.asset_file_name\n end\n end\n else\n case self.asset_type\n when TYPE[:section_audio], TYPE[:media_image], TYPE[:media_video], TYPE[:slideshow_image], TYPE[:infographic], TYPE[:infographic_dataset]\n \"#{self.id}__#{self.asset_file_name}\"\n else\n self.asset_file_name\n end\n end\n end", "def validate_and_build_special_images(fileParams,file)\n # if Asset2.is_valid_file?(file)\n @special_image = @special.special_images.build(fileParams)\n # end\n end", "def proper_image_sequence_format\n if not image_sequence =~ /\\.mha\\z/\n errors.add(:image_sequence, \"must be in .mha format currently\")\n end\n end", "def art_file\n \"#{Digest::SHA1.hexdigest(\"#{artist_name}/#{album_name}\")}.png\"\n end", "def original_filename; end", "def filename\n filename = (model.name + '_' + model.artist.name + '_' + model.release.name).downcase.gsub(/\\s/, '-')\n \"#{filename}\" if original_filename \n end", "def filename\n \"something.jpg\" if original_filename\n end", "def filename\n \"something.jpg\" if original_filename\n end", "def file_name\n\t\treturn 'st' + student_id.to_s + 'pr' + problem_id.to_s + 'so' + id.to_s\n\tend", "def fileName\r\n\t\traise NoMethodError\r\n\tend", "def validate_image_name\n name = upload_original_name.to_s\n name = name.sub(/^[a-zA-Z]:/, \"\")\n name = name.sub(%r{^.*[/\\\\]}, \"\")\n # name = '(uploaded at %s)' % Time.now.web_time if name.empty?\n name = name.truncate(120)\n return unless name.present? && User.current &&\n User.current.keep_filenames != \"toss\"\n\n self.original_name = name\n end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename_ok?(src)\n return false if src.nil? or src.empty?\n\n if src.match bad_image_names_regex\n log \"Found bad filename for image: #{src}\"\n false\n else\n true\n end\n end", "def filename\n if original_filename\n var = :\"@#{mounted_as}_unique_file_name\"\n model.instance_variable_get(var) or model.instance_variable_set(var, unique_file_name)\n end\n end", "def file_name\n potential_name = params[:filename] || file.original_name || (asset.respond_to?(:label) && asset.label) || file.id\n potential_name = potential_name.gsub(/[,;]/, '')\n potential_extension = ''\n if file.mime_type == 'image/png'\n potential_extension = '.png'\n elsif file.mime_type == 'image/tiff'\n potential_extension = '.png'\n elsif file.mime_type == 'image/jpeg' || file.mime_type == 'image/jpg'\n potential_extension = '.jpg'\n end\n return potential_name\n #return potential_name + potential_extension\n end", "def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present? \n end", "def generate_uniq_filename_from(data)\n if data.respond_to?(:path)\n Digest::MD5.hexdigest(data.path)\n elsif data.respond_to?(:read)\n chunk = data.read(1024)\n data.rewind\n Digest::MD5.hexdigest(chunk)\n else\n Digest::MD5.hexdigest(data)\n end\n end", "def generate_uniq_filename_from(data)\n if data.respond_to?(:path)\n Digest::MD5.hexdigest(data.path)\n elsif data.respond_to?(:read)\n chunk = data.read(1024)\n data.rewind\n Digest::MD5.hexdigest(chunk)\n else\n Digest::MD5.hexdigest(data)\n end\n end", "def filename\n \"restaurant_thumbnail\" if original_filename\n end", "def filename\r\n \"#{model.user_id.to_s}_#{model.id.to_s}.mov\" if original_filename\r\n end", "def reserved_name?\n !!self[:filename]\n end", "def file_file_name\n f = nil\n if self.asset_clone_id.present?\n x = self.asset_clone\n f = x.asset_file_name if x.present?\n else\n f = self.asset_file_name\n end\n return f\n end", "def valid_file_name\n (@file_name.match(/((\\d)|([a-zA-Z])|(_))*.log/).to_s == @file_name)\n end", "def clean_filename\n if filename.present?\n cleaned_filename = cleaned_basename = basename.gsub(/[^a-z0-9\\-_]/i, '-')\n cleaned_filename = \"#{cleaned_basename}.#{extension.downcase}\" if extension\n self.filename = cleaned_filename\n end\n end", "def original_file_name\r\n file_name_parts = initial_image_name.split('_')\r\n if file_name_parts.length > 0\r\n last_occurrence = nil\r\n first_element = file_name_parts[0]\r\n if Output835.element_duplicates?(first_element, file_name_parts)\r\n last_occurrence = file_name_parts.rindex(first_element)\r\n end\r\n last_occurrence ||= file_name_parts.length\r\n # Fetch the first n ( where n = last_occurrence ) elements of the array, until the first element duplicates.\r\n normalized_file_name_parts = file_name_parts.first(last_occurrence)\r\n normalized_file_name = normalized_file_name_parts.join('_')\r\n if Output835.element_duplicates?(first_element, file_name_parts)\r\n # Only for the duplicating file names, the extension of the file is appended to the normalized_file_name.\r\n # For others, the normalized_file_name itself has the extension.\r\n image_format_extension = batch.facility.image_file_format\r\n normalized_file_name << '.' << image_format_extension.downcase\r\n end\r\n normalized_file_name\r\n else\r\n initial_image_name\r\n end\r\n end", "def file_name?\n !read_attribute('file_name').blank?\n end", "def error_for_new_doc_name(filename, extension)\n full_file_name = filename + \".\" + extension\n if !(1..20).cover?(filename.size)\n return \"File name must be between 1 and 20 characters\"\n elsif find_by_name(full_file_name)\n return \"File name must be unique\"\n elsif (filename =~ /(^[A-Za-z][A-Za-z0-9_]+)$/).nil?\n return \"Invalid file name. File must begin with an alpha character. The rest of the file name can only contain alphanumeric characters and underscores\"\n end\n nil\nend", "def filename=(_); end", "def get_valid_file_name(iFileName)\n if (defined?(prohibited_file_names_chars) != nil)\n return iFileName.gsub(/[#{Regexp.escape(prohibited_file_names_chars)}]/, '_')\n else\n return iFileName\n end\n end", "def filename_for_export\n return \"No file attached to this asset\" if target_item.files.empty?\n target_item.original_file.file_name.first\n end", "def filename\n @filename ||= attached_file&.original_filename&.dup\n end", "def document_media_is_unique\n return if self.documents.count == 0\n\n valid = true\n\n corpus_media = Array.new\n\n self.documents.each { |d| corpus_media.push(:id => d.id, :media => d.media_descriptors) }\n\n last_media_urls = Array.new\n last = self.documents.last\n last.media_descriptors.each { |m| last_media_urls.push(m[:media_url]) }\n\n corpus_media.each do |m|\n if m[:id] != last.id then\n item_media_urls = Array.new\n m[:media].each { |m| item_media_urls.push(m[:media_url]) }\n\n if (last_media_urls == item_media_urls)\n valid = false\n break\n end\n end\n end\n\n errors.add :file, \"contains a media set already in this corpus.\" if valid == false\n end", "def file_name\n @file_name\n end", "def original_filename\n metadata[\"filename\"]\n end", "def bundle_resouce_file_name\n self.title.gsub(/\\s/,\"_\")\n end", "def filename\n @name ||= ActiveSupport::SecureRandom.hex\n\t\"#{@name}#{File.extname(original_filename).downcase}\" if original_filename\n end", "def filename_present_only_if_job_successful\n if state == SUCCESS && filename.blank?\n errors.add :filename, \"can't be blank if the job state is SUCCESS\"\n elsif state != SUCCESS && filename.present?\n errors.add :filename, \"must be blank if the job state is different from SUCCESS\"\n end\n end", "def file_different?\n if @name && File.exist?( @name )\n Digest::MD5.hexdigest(\n @lines.join( \"\\n\" )\n ) != Digest::MD5.hexdigest(\n File.read( @name )\n )\n else\n true\n end\n end", "def get_filename(text)\n if text =~ /[^\\w\\.\\-_]/\n Digest::SHA256.hexdigest(text)\n else\n text\n end\nend", "def filename\n #\"#{original_filename.split('.').first}.png\" if original_filename\n \"img.#{original_filename.split('.').last}\" if original_filename\n #original_filename if original_filename\n end", "def filename\n original_filename.try(:gsub, '+', '-')\n end", "def validate_uniqueness_of_new_image_url\n self.errors[:\"image.url\"] = 'Image url has already been added to this collection' if self.dup_image?\n end", "def file name\n \n end", "def filename\n original_filename\n end", "def filename\n \"passeport_photo.png\" if original_filename\n end", "def file_name\n self.file_file_name\n end", "def file_name\n file_name = (\"tmp/insert_externals.txt\")\n #file_name = (\"tmp/insert_internals.txt\")\n #file_name = (\"./tmp/insert_internals_hash.txt\")\n #file_name = (\"lib/anagrams/anagrams_table_data.txt\")\n #file_name = (\"tmp/insert_anagrams.txt\")\n #file_name = (\"tmp/insert_word_list.txt\")\n #file_name = (\"../../Documents/20110421-research_textualed.txt\")\n #file_name = (\"../consummates/lib/databasers/mysql_database_safe_lines/mysql_database_ready-015.txt\")\n #file_name = (\"../consummates/lib/databasers/mysql_database_safe_lines/mysql_database_ready_hash-015.txt\")\n #file_name = (\"../consummates/lib/databasers/mysql_database_safe_lines/mysql_database_ready_hashlines-015.txt\")\n #file_name = (\"../consummates/lib/databasers/mysql_database_safe_lines/mysql_database_ready_hashlines_sorted_keys-015.txt\")\n #file_name = (\"../consummates/lib/databasers/mysql_database_safe_lines/mysql_database_ready_hashlines_sorted_values-015.txt\")\n end", "def assert_filename_length!(filename)\n name = relative_name = filename.to_s.sub(File.expand_path(@options[:spec_directory]), \"\")\n assert false, \"Filename #{name} must no more than #{256 - GEMFILE_PREFIX_LENGTH} characters long\" if name.size > (256 - GEMFILE_PREFIX_LENGTH)\n\n if name.size <= 100 then\n prefix = \"\"\n else\n parts = name.split(/\\//)\n newname = parts.pop\n nxt = \"\"\n\n loop do\n nxt = parts.pop\n break if newname.size + 1 + nxt.size > 100\n newname = nxt + \"/\" + newname\n end\n\n prefix = (parts + [nxt]).join \"/\"\n name = newname\n\n assert false, \"base name (#{name}) of #{relative_name} must no more than 100 characters long\" if name.size > 100\n assert false, \"prefix (#{prefix}) of #{relative_name} must no more than #{155 - GEMFILE_PREFIX_LENGTH} characters long\" if prefix.size > (155 - GEMFILE_PREFIX_LENGTH)\n end\n return nil\n end", "def generate_unique_filename\n name = options[:file_name] || wrapper.name\n # TODO: Sanitize the file name\n\n filename = \"#{name}.swatches\"\n\n related_files = related_file_indexes(filename)\n\n filename = if related_files.present?\n \"#{name}-#{related_files.max + 1}#{SWATCHES_EXTENSION}\"\n else\n \"#{name}#{SWATCHES_EXTENSION}\"\n end\n\n @swatches_path = File.join(options[:export_directory], filename)\n end", "def filename() @fn.dup end", "def randomize_filename\n extension = File.extname(asset_file_name).downcase\n self.asset.instance_write(:file_name, \"#{SecureRandom.hex.first(16)}#{extension}\")\n end", "def original_file # Accessor for probably protected value original_filename\r\n original_filename\r\n end", "def asset_file_id_to_copy; @asset_file_id_to_copy; end", "def filename\n raise\n end", "def access_file_name\n end", "def filename\n if original_filename\n md5 = Digest::MD5.hexdigest(\"#{model.imagenable.friendly_id}_#{Time.now}\")\n \"#{md5}.#{file.extension}\"\n end\n end", "def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end", "def filename()\n @name ||= \"#{SecureRandom.hex()}.png\"\n end", "def filename\n sanitize(original_filename) if original_filename\n end", "def filename\n \"#{original_filename_without_extension.parameterize}_#{model.filename_token}#{original_extension}\" if original_filename\n end", "def full_filename(for_file)\n # 兼容 #{mounted_as}_fingerprint\n if version_name.present? && model.try(:\"#{mounted_as}_fingerprint\")\n [version_name, model.send(:\"#{mounted_as}_fingerprint\"), for_file].compact.join('_')\n elsif version_name.present?\n [version_name, model.send(:\"#{mounted_as}_identifier\")].compact.join('_')\n else\n super\n end\n end", "def file_name\n \"images/#{@name}.msf\"\n end", "def update_from_filename filename\n self.original_filename = filename\n self.valid?\n end", "def checkForFileExistence(fileName)\n raise \"#{fileName} file already exists\" if File.exist?(fileName);\nend", "def validate_file(file)\n end", "def search_file_name\n file_name = ''\n if @artist_id && @artist_id != 0\n artist_name = ARUtils.field( Artist , @artist_id , :name )\n file_name = artist_name if artist_name\n end\n if @album_id && @album_id != 0\n album_name = ARUtils.field( Album , @album_id , :name )\n file_name += ' - ' if ! file_name.empty?\n if album_name\n file_name += album_name\n end\n end\n file_name = 'songs' if file_name.empty?\n return ImagesModule.safe_file_name(file_name, true)\n end", "def make_file\n\t\t$filename = params.find(:disname)\n\t\t`rm #$filename`\n\tend", "def filename\n \"application_#{model.hash}.#{file.extension}\" if original_filename.present?\n end", "def create\n puts params\n\n\n puts params\n #params.permit(:file,:semester, :branch, :subject, :category, :title)\n @material = Material.new(material_params)\n filename=params[:material][:file]\n File.open(Rails.root.join('public','uploadedfiles',filename.original_filename), 'wb') do |file|\n file.write(filename.read)\n end\n # uploaded_file = material_params[:file]\n # filepath = Dir.pwd + \"/public/uploadedfiles/\" + filename\n # File.open(filepath,'wb') do |file|\n # file.write(uploaded_file.read())\n # end\n\n @material.file=filename.original_filename\n @material.user_id=current_user.id\n respond_to do |format|\n if @material.save\n Newcourse.detail(@material).deliver_later\n format.html { redirect_to @material, notice: 'Material was successfully created.' }\n format.json { render :show, status: :created, location: @material }\n else\n format.html { render :new }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end", "def filename\n if super.present?\n @name ||=\"#{SecureRandom.hex}.#{file.extension.downcase}\" if original_filename\n Rails.logger.debug(\"(BaseUploader.filename) #{@name}\")\n @name\n end\n end" ]
[ "0.66475046", "0.64454967", "0.6224993", "0.61269563", "0.61181873", "0.6076486", "0.60676926", "0.59852904", "0.59082043", "0.5894987", "0.5885921", "0.5846301", "0.5832198", "0.5815858", "0.5813129", "0.5791955", "0.57732606", "0.5768478", "0.5761662", "0.57595706", "0.57593215", "0.57441753", "0.57426155", "0.5732152", "0.5727643", "0.5727643", "0.5719481", "0.5687469", "0.56783223", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.5669873", "0.56660414", "0.5658623", "0.5650159", "0.56468976", "0.5628929", "0.5628929", "0.5623579", "0.5623057", "0.5621786", "0.56204516", "0.5613007", "0.5612163", "0.560535", "0.5595388", "0.55857843", "0.55778104", "0.55642134", "0.5563947", "0.55615675", "0.5547686", "0.554748", "0.5541848", "0.5533361", "0.55313724", "0.5528782", "0.5521496", "0.5520421", "0.55182683", "0.5508672", "0.55078244", "0.5505621", "0.55028546", "0.54884535", "0.54853624", "0.5484977", "0.54725987", "0.5471527", "0.5469387", "0.5468193", "0.54676944", "0.5464838", "0.5461582", "0.5458443", "0.5456403", "0.54554975", "0.5436003", "0.5428034", "0.542759", "0.542314", "0.5420854", "0.5416705", "0.54120857", "0.5408588", "0.5407776", "0.54067975", "0.54064286", "0.53990644", "0.53943866" ]
0.0
-1
Attaches the given file to this material; if an existing file is linked, the link is broken.
def attach(file) existing_file = self.file file.owner = self file.display_filename = existing_file.display_filename if existing_file if file.save and existing_file then existing_file.owner_type = nil existing_file.owner_id = nil existing_file.save end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attach_file(input, file)\n path = File.expand_path(File.join(SUPPORT_DIR,\"attachments/#{file}\"))\n\n raise RuntimeError, \"file '#{path}' does not exists\" unless File.exists?(path)\n\n input.set(path)\n end", "def link_file(filename, title = T.unsafe(nil), anchor = T.unsafe(nil)); end", "def link_file(filename, title = T.unsafe(nil), anchor = T.unsafe(nil)); end", "def make_link(old) File.link(old, path) end", "def attaches_file(id_or_name_or_label, path)\n field = find_field(id_or_name_or_label, FileField)\n field.set(path)\n end", "def add_file_reference_to_target(_file_reference, _target)\n end", "def link(file_name, dest_file)\n log \"Linking file #{file_name} to #{dest_file}\"\n File.link(file_name, dest_file)\n end", "def link(file_name, dest_file)\n log \"Linking file #{file_name} to #{dest_file}\"\n File.link(file_name, dest_file)\n end", "def attach(attachable)\n # Moving the file to some safe place; as tmp files will be flushed timely\n blob_was = attached? ? read_file(attachable) : nil\n blob = create_file_from(attachable)\n\n unless blob == blob_was\n detach\n write_attachment build_attachment(attachable)\n end\n end", "def file=(file)\n self.fileRef = file.uuid\n end", "def file=(file)\n self.name = filename(file)\n self.attachment = Attachment.find_or_initialize_by(file: file)\n end", "def attach_file(book, field,field_name)\n book.send(field_name).attach(io: open_file(book[field]), filename: field)\n url_for(book[field_name])\n end", "def add_file(file_name, data, flags)\n data = filter \"decode\", file_name, data\n path = working_join file_name\n \n File.unlink path rescue nil\n \n if flags.include? 'l' # if it's a link\n @file_opener.symlink path, data\n else\n @file_opener.open(path, 'w') {|f| f.write data }\n File.set_flag path, false, true if flags.include? 'x'\n end\n end", "def update_attachment(args={})\n raise ArgumentError unless args[:file] && args[:name]\n return unless has_attachment?(args[:name])\n delete_attachment(args[:name])\n set_attachment_attr(args)\n rescue ArgumentError => e\n raise ArgumentError, 'You must specify :file and :name'\n end", "def file=(file)\n raise ArgumentError, 'Embeds and files are mutually exclusive!' unless @embeds.empty?\n\n @file = file\n end", "def make_link( old ) File.link( old, expand_tilde ) end", "def attach_file_to_work(work, file_set, file_set_params)\n acquire_lock_for(work.id) do\n # Ensure we have an up-to-date copy of the members association, so\n # that we append to the end of the list.\n work.reload unless work.new_record?\n unless assign_visibility?(file_set_params)\n copy_visibility(work, file_set)\n end\n work.ordered_members << file_set\n set_representative(work, file_set)\n set_thumbnail(work, file_set)\n\n # Save the work so the association between the work and the file_set is persisted (head_id)\n work.save\n end\n end", "def attach_file_to_work(work, file_set_params = {})\n acquire_lock_for(work.id) do\n # Ensure we have an up-to-date copy of the members association, so that we append to the end of the list.\n work.reload unless work.new_record?\n ## move next four statements to update_work_with_file_set\n #copy_visibility(work, file_set) unless assign_visibility?(file_set_params)\n #work.ordered_members << file_set\n #set_representative(work, file_set)\n #set_thumbnail(work, file_set)\n update_work_with_file_set( work, file_set, file_set_params )\n # Save the work so the association between the work and the file_set is persisted (head_id)\n # NOTE: the work may not be valid, in which case this save doesn't do anything.\n work.save\n end\n end", "def link(old)\n warn 'Path::Name#link is obsoleted. Use Path::Name#make_link.'\n File.link(old, path)\n end", "def link fn,linkname\n\t\tif File.symlink?(linkname) and !Cfruby::FileOps::SymlinkHandler.points_to?(linkname,fn)\n\t\t\tCfruby.controller.inform('verbose', \"Existing #{linkname} is not pointing to #{fn}\")\n\t\t\tprint \"Existing #{linkname} is not pointing to #{fn}\\n\"\n\t\t\tCfruby::FileOps.delete linkname\n\t\tend\n\t\tif @cf.strict\n\t\t\tCfruby::FileOps.link fn,linkname\n\t\telse\n\t\t\tbegin\n\t\t\t\tCfruby::FileOps.link fn,linkname\n\t\t\trescue\n\t\t\t\tCfruby.controller.inform('verbose', \"Problem linking #{linkname} -> #{fn}\")\n\t\t\tend\n\t\tend\n\tend", "def add_file(file)\n @files[file.name] = file\n file.parent = self\n end", "def linkfile\n curfile = File.last_added(\"#{Downloads_path}/*.pdf\")\n unless curfile # no last file found\n growl(\"Sorry, no PDFs found in that directory\")\n exit(0)\n end\n\n f = MacTypes::FileURL.path(curfile)\n Selection[0].linked_files.add(f,{:to =>Selection[0]})\n Selection[0].auto_file\n\n growl(\"PDF added\", \"File added successfully to #{Selection[0].cite_key.get}\")\nend", "def add_external(original_filename, remote_file_name)\n externals.create!(url: '#', original_filename: original_filename, remote_file_name: remote_file_name)\n end", "def attach(attachment)\n if new_attlink(attachment).save\n increment_attachments_count\n reload_attachments_with attachment\n attachment.increment_masters_count\n end\n end", "def set_file\n if have_file?\n begin\n set_file_for_remote_storage\n rescue Errno::ENOENT\n set_file_for_local_storage\n rescue NoMethodError\n raise \"Original resource has no File\"\n end\n else\n raise \"Original resource has no File\"\n end\n end", "def add_file(attrs)\n return if search(\"//ovf:References/ovf:File[@ovf:href='#{attrs[:href]}']\").count == 1\n file = Nokogiri::XML::Node.new 'File', self\n file['ovf:href'] = attrs[:href] if attrs[:href]\n if attrs[:id]\n file['ovf:id'] = attrs[:id]\n else\n n = filecount + 1\n file['ovf:id'] = \"file#{n}\"\n end\n at('//ovf:References').add_child file\n end", "def add file\n file.download unless file.downloaded?\n @files << file\n end", "def file=(f)\n @file = f\n @internal = nil # force reload\n @file\n end", "def add_file(file, dsid, file_name) \n return add_external_file(file, dsid, file_name) if dsid == 'content'\n super\n end", "def file= file\n unless file.size == 0\n picture = Attachment.new :content => file.read\n picture.save\n write_attribute 'picture_id', picture.id\n end\n end", "def replace_file(file, target)\n LOGGER.info \"Replacing #{file}\".blue\n system %(rm -rf \"#{target}\")\n link_file(file, target)\nend", "def attach_file(field_locator, path, content_type = nil)\n locate_field(field_locator, FileField).set(path, content_type)\n end", "def append(filename)\n return @filemgr.append(filename, @contents)\n end", "def set_file_for_remote_storage\n set_resource_mounter_file open(original_resource_mounter.url)\n end", "def set_link_attachment\n @link_attachment = LinkAttachment.find(params[:id])\n end", "def add_file(file, dsid, file_name) \n return add_external_file(file, file_name) if dsid == 'content'\n super\n end", "def add_attachment(summary, file, **kwargs)\n @client.add_attachment(summary, file, id, **kwargs).first\n end", "def _set_file(name, contents)\n File.open(\"%s/%s\" % [uri, name], \"w\") { |io| io.write contents }\n end", "def add_hardlink(uri, targeturi)\n @hardlinks[uri] = targeturi\n end", "def government_file=(file)\n government_issue_id.attach(io: file, filename: File.basename(file.path))\n end", "def assign(file, identifier = Identifier.generate)\n self.file = file\n\n if file\n extension ||= file.extension if file.respond_to? :extension\n extension ||= File.extname(file.original_filename) if file.respond_to? :original_filename\n extension ||= File.extname(file.path) if file.respond_to? :path\n size ||= file.size if file.respond_to? :size\n size ||= File.size(file.path) if file.respond_to? :path\n end\n\n @purge = [self.path, *self.styles.map { |style, options| self.path(style) }] if attached?\n\n self.size = file ? size : nil\n self.extension = file ? extension : nil\n self.identifier = file ? identifier : nil\n\n process if file\n end", "def attach(attachment)\n if attachment_ids\n self.attachment_ids |= [attachment.id] if attachment_ids.size < MAX_ATTACHMENTS\n else\n self.attachment_ids = [attachment.id]\n end\n self.joined_attachments << attachment\n end", "def attach_audio_file(path)\n AttachAudioService.call(self, path)\n end", "def link_file(source, *args)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source\n source = File.expand_path(find_in_source_paths(source.to_s))\n\n create_link destination, source, config\n end", "def set(file)\n self.file = file\n end", "def imported_attachment=(attachment)\n self.attachment = attachment\n clear_attachment_change\n end", "def attach( file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,\n type = nil, headers = nil)\n @mailer.attach(file_or_files, filename, type, headers)\n end", "def add_attachment_link(name, attachment_name, attachment_model_name)\n link_to_function name do |page|\n page.insert_html :bottom, attachment_name.pluralize.to_sym, :partial => attachments_name, :object => Run.attachment_model_name.to_model.new\n end\n end", "def handle(path)\n File.exist?(path) ? attach(path) : failed!\n end", "def handle(path)\n File.exist?(path) ? attach(path) : failed!\n end", "def handle(path)\n File.exist?(path) ? attach(path) : failed!\n end", "def CreateLinkFile(linkfile)\n\t file=File.open(linkfile, \"w\")\n\n\t @links.each do |link|\n\n\t file.write(\"L #{link.from.id} #{link.to.id} #{@rate}\\n\")\n\t \n\t end\n\t \n\t file.close\n\n\tend", "def file=(file)\n @prerequisites << file\n @queue << \"file #{file}\"\n @file = file\n end", "def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end", "def add_file(file)\n setup_file_tailer file\n self\n end", "def link_file(file, target = File.join(ENV['HOME'], \".#{file.sub(/\\.erb$/, '')}\"))\n if file =~ /.erb$/\n LOGGER.info \"generating #{target.replace_home}\".blue\n File.open(target, 'w') do |new_file|\n new_file.write ERB.new(File.read(file)).result(binding)\n end\n else\n LOGGER.info \"linking #{target.replace_home}\".blue\n File.symlink(File.join(Dir.pwd, file), target)\n end\nend", "def add_file_attachment(new_attachments)\n attachments = @task.attachments\n attachments += new_attachments\n @task.attachments = attachments\n end", "def append_line_to_file(filename, line)\n FileUtils.touch(filename)\n File.open(filename, 'a') do |f|\n f.puts line\n end\nend", "def replace_with_file(blob, attributes = {})\n File.binwrite(self.file_path, blob)\n\n pdf = CombinePDF.parse blob\n self.update(num_pages: pdf.pages.length, filename: attributes[:new_filename])\n self.save_cover\n end", "def add_file (file)\n @files[file.path] = file\n end", "def create\n\n @link = Link.new(params[:link])\n @link.resource_id = @resource.id\n \n if [email protected]? \"http://\"\n @link.link = \"http://\" + @link.link\n end\n\n\n @resource.attachment = @link\n @resource.save\n\n @link.save\n\n\n\n respond_to do |format|\n if @link.update_attributes(params[:text]) && @resource.update_attributes(params[:resource])\n format.js\n end\n end \n end", "def add_file(name)\n @files[name] = nil unless @files.has_key?(name)\n end", "def file=(new_file)\n @file = File.open(new_file.path, 'rb')\n @filename = new_file.original_filename || 'No file' rescue 'No file'\n @bibtex_source = @file.read.force_encoding(\"UTF-8\")\n end", "def attach_to_work(work, file_set_params = {})\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"work.id=#{work.id}\",\n \"file_set_params=#{file_set_params}\",\n \"\" ] if file_set_ordered_ordered_members_actor_debug_verbose\n file_set.visibility = work.visibility unless assign_visibility?(file_set_params)\n work.representative = file_set if work.representative_id.blank?\n work.thumbnail = file_set if work.thumbnail_id.blank?\n end", "def link!(resource, uuid)\n build_link(resource, uuid).save!\n end", "def add_rpm_ghost_file(file)\n @ghost_files.add file\n end", "def link\n display_change\n begin\n File.symlink(@real_path, new_path)\n rescue NotImplemented\n puts \"Error: cannot create symlinks\"\n end\n end", "def file=(a)\n @file = a\n @real_fname = a\n end", "def setup_file\n unless File.exists?('link_db.txt')\n File.open('link_db.txt', 'a+') do |link_database|\n link_database.write(\"[]\") \n end\n end\nend", "def setup_file\n unless File.exists?('link_db.txt')\n File.open('link_db.txt', 'a+') do |link_database|\n link_database.write(\"[]\")\n end\n end\nend", "def set_from_file(model_image_attr, full_path)\n model_image_attr.store!(File.open(full_path))\n send(\"write_#{model_image_attr.mounted_as}_identifier\")\n model_image_attr\n end", "def add_file (file)\n @files[file.path] = file\n end", "def attachment=(params)\n super params\n import_attachment if persisted? && attachment.try(:valid?)\n end", "def link_file( src, dest )\n if File.symlink?( dest )\n puts \"#{dest} is already a symlink, ignoring\"\n else\n puts \"ln -s #{src} #{dest} \"\n File.symlink( src, dest )\n end\nend", "def attach_file(user_id:, file_path:)\n warn caller.first + \" DEPRECATION WARNING: #{self.class}##{__method__} is deprecated. Use #update with encode_attachment instead.\"\n\n file_contents = open(file_path) { |f| f.read }\n content_types = MIME::Types.type_for(file_path)\n file_type = content_types.first.content_type if content_types.any?\n if file_type.nil?\n raise('File type not found. Use attach_file_with_file_type(user_id: <user_id>, file_path: <file_path>, file_type: <file_type>)')\n else\n attach_file_with_file_type(user_id: user_id, file_path: file_path, file_type: file_type)\n end\n end", "def AddLinksFromFile(linkfile)\t\t\n\t\tfile=File.new(linkfile, \"r\")\n\t\t# reading nodes information\n \n\t\twhile (line = file.gets)\n \t\t\tline.chomp!(\"\\n\")\n \t\t\t\n\t\t\tif (line.size==0 or line.strip[0].chr=='#')\n\t\t\t\tnext\n \t\t\tend\n\n\t\n\t\t \ta=line.split(\" \")\n \t\t\t\n\t\t\tif a.size > 0\n\t\t\t if a[0] == \"L\"\n\t\t\t link = Link.new(@nodes[Integer(a[1])], @nodes[Integer(a[2])], Integer(a[3]) )\n\t\t\t revLink = Link.new(@nodes[Integer(a[2])], @nodes[Integer(a[1])], Integer(a[3]) )\n\t\t\t puts(\"Adding link between node #{a[1]} and node #{a[2]}\")\n \t\t\t puts(\"Adding link between node #{a[2]} and node #{a[1]}\")\n\t\t\t @links << link\n\t\t\t @links << revLink\n\t\t\t elsif a[0] == \"WL\"\n\t\t\t if @nodes[Integer(a[2])].type==\"R\"\n\t\t\t link = Link.new(@nodes[Integer(a[1])], @nodes[Integer(a[2])], @nodes[Integer(a[3])] )\n\t\t\t\tputs(\"Adding wired link between node #{a[1]} and node #{a[2]}\")\n\t\t\t\t@wired_links << link\n\t\t\t else\n\t\t\t link = Link.new(@nodes[Integer(a[2])], @nodes[Integer(a[1])], @nodes[Integer(a[3])] )\n\t\t\t\tputs(\"Adding wired link between node #{a[2]} and node #{a[1]}\")\n\t\t\t\t@wired_links << link\n\t\t\t end\n\n\t\t\t else\n\t\t\t $stderr.puts(\"Wrong link type: #{a[0]}\")\n\t\t\t end\n\t\t\tend\n\t\tend\n\t\n\t\tfile.close\n\n\t\t@linksFile=linkfile\n\tend", "def activation_resource(sapi_name, sapi_file = nil)\n sapi_file ||= sapi_file_path(sapi_name, new_resource.priority)\n link sapi_file do\n to new_resource.path\n action :nothing\n end\n end", "def attach_report_file(file_name, file_data)\n unless (@user.report_files.blobs.find {|blob| blob.filename === file_name}).nil?\n raise ::Rbt::User::Document::Error::DuplicateDocumentError.new(\"File with name: #{file_name} already exists for user: #{@user.id}\")\n end\n\n @user.report_files.attach(io: StringIO.new(file_data), filename: file_name)\n return @user.report_files.blobs.find {|blob| blob.filename === file_name}\n end", "def file!\n file or fail Error, \"no file is attached\"\n end", "def add_attachment(project_id, story_id, file, options = {})\n options.merge!(:payload => file)\n post(\"projects/#{project_id}/stories/#{story_id}/attachments\", options).attachment\n end", "def neofiles_link(file, tag_content = nil, html_attrs = {})\n html_attrs[:href] = neofiles_file_url file unless html_attrs[:href]\n content_tag(:a, tag_content.presence || file.description.presence || file.filename, html_attrs)\n end", "def add(filename)\n not_implemented('add')\n end", "def add_file file, opts={}\n opts[:mime_type] ||= Ddr::Utils.mime_type_for(file)\n opts[:original_name] ||= Ddr::Utils.file_name_for(file)\n\n # @file_to_add is set for callbacks to access the data\n self.file_to_add = file\n\n run_callbacks(:add_file) do\n super\n end\n\n # clear the instance data\n self.file_to_add = nil\n end", "def attach_cached\n return file_attacher.file if file_attacher.cached?\n return if file_attacher.stored? || file_data.blank?\n=begin # TODO: remove when :json resolved\n file_attacher.load_data(file_data)\n=end\n file_attacher_load\n file_attacher.set(nil) unless file_attacher.cached?\n file_attacher.file\n end", "def attach_file_with_file_type(user_id:, file_path:, file_type:)\n warn caller.first + \" DEPRECATION WARNING: #{self.class}##{__method__} is deprecated. Use #update with encode_attachment instead.\"\n\n path = user_path(user_id: user_id)\n file_contents = open(file_path) { |f| f.read }\n encoded = Base64.encode64(file_contents)\n mime_padding = \"data:#{file_type};base64,\"\n base64_attachment = mime_padding + encoded\n\n payload = {\n 'doc' => {\n 'attachment' => base64_attachment\n }\n }\n client.patch(path, payload)\n end", "def attach(source); end", "def add_line_to_file(file, line)\n File.open(file, \"a\") {|f| f.puts(\"#{line}\")}\n end", "def write_to_external_datastore file, file_name\n external_file_path = File.join external_file_dirname, file_name\n\n if file.respond_to? :read\n File.open(external_file_path, \"wb\") do |f|\n f.write(file.read(CHUNK)) until file.eof?\n file.rewind\n end\n elsif File.exists? file # raises TypeError\n FileUtils.mv file, external_file_path\n else\n raise ArgumentError, \"File not found: #{file.inspect}\"\n end\n\n external_file_uri external_file_path\n end", "def symlink(file_name, dest_file)\n log \"Symlinking file #{file_name} to #{dest_file}\"\n File.symlink(file_name, dest_file)\n end", "def symlink(file_name, dest_file)\n log \"Symlinking file #{file_name} to #{dest_file}\"\n File.symlink(file_name, dest_file)\n end", "def fix\n path = Rails.root.join(\"public/system/files/#{self.id}/original/#{self.file_file_name}\")\n Formatador.display_line(\"Uploading file at: [green]#{path}[/]\")\n if File.exists?(path)\n self.attached_file.store!(File.open(path))\n self.update_attribute(:attached_file, self.file_file_name)\n Formatador.display_line(\"[yellow]Done![/]\")\n else\n Formatador.display_line(\"[red]ERROR: [/]File does not exist!\")\n end\n end", "def update_attachment_data_file(attachment)\n corrected_tmp_file = repaired_file_for(attachment)\n logger.info(\"\\tAttachment #{attachment.filename} (#{attachment.id}) being updated to #{File.basename(corrected_tmp_file.path)}\")\n\n attachment.attachment_data.file = corrected_tmp_file\n attachment.attachment_data.save!\n ensure\n FileUtils.rm(corrected_tmp_file.path)\n end", "def ensure_line_appended_to_file(path, line)\n remove_line_from_file(path, line)\n append_line_to_file(path, line)\n end", "def attach_schema_file(file_name, file_data)\n unless (@user.schema_files.blobs.find {|blob| blob.filename === file_name}).nil?\n raise ::Rbt::User::Document::Error::DuplicateDocumentError.new(\"File with name: #{file_name} already exists for user: #{@user.id}\")\n end\n\n @user.schema_files.attach(io: StringIO.new(file_data), filename: file_name)\n return @user.schema_files.blobs.find {|blob| blob.filename === file_name}\n end", "def insert_link (fileArray, linkName, utilHash)\n\nend", "def attach_file(card_id, url, mime_type = nil, options = {})\n options = mime_type if mime_type.is_a?(Hash)\n\n uri = URI.parse(url)\n\n if uri.scheme =~ %r{https?}\n options.update url: uri.to_s, mime_type: mime_type\n else\n file = Faraday::UploadIO.new(uri.to_s, mime_type)\n options.update file: file, mime_type: file.content_type\n end\n\n create_card_resource card_id, \"attachments\", options\n end", "def add_file(file_params)\n # append a new file to our the current identity's list of bruse_files\n\n file = BruseFile.new(file_params)\n\n if bruse_files << file\n # return file\n file\n else\n # could not append file!\n file.destroy\n nil\n end\n end", "def link *args\n self.destination_and_options( args ) do |lnk, opts|\n symlink_requested = self.directory? || opts[:symbolic] || opts[:sym] || opts[:soft]\n \n if symlink_requested\n self.symlink lnk, opts\n else\n FileUtils.ln self, lnk, ** Utils::Opts.narrow_file_utils_options( opts, :ln )\n end\n \n lnk.fwf_filepath\n end\n end", "def record(filename)\n contents = File.read(filename) rescue nil\n files[filename] = contents unless files.has_key? filename\n end", "def update!\n open(link)\n end" ]
[ "0.6643031", "0.6198407", "0.6198303", "0.6148004", "0.6042394", "0.60200536", "0.5954688", "0.5954688", "0.5878957", "0.5841446", "0.58389527", "0.5785293", "0.5784163", "0.5738983", "0.56813246", "0.562604", "0.5610538", "0.5571698", "0.55579466", "0.5551819", "0.55406654", "0.5504398", "0.549286", "0.5472602", "0.5471688", "0.54614645", "0.54337543", "0.5408288", "0.53947103", "0.5365448", "0.5365352", "0.53648466", "0.5364233", "0.5360356", "0.53417885", "0.5339813", "0.53213143", "0.5308725", "0.5298425", "0.5295291", "0.52947813", "0.52914274", "0.5283781", "0.5275876", "0.5272685", "0.5259733", "0.52530664", "0.52483845", "0.52390474", "0.52390474", "0.52390474", "0.52277446", "0.52249354", "0.5194544", "0.5192704", "0.5187948", "0.5181382", "0.515533", "0.5151136", "0.51468545", "0.51314443", "0.51310664", "0.5130451", "0.512957", "0.5119487", "0.51119304", "0.5106391", "0.5104428", "0.5099527", "0.5098769", "0.50972223", "0.50959486", "0.5086783", "0.50639415", "0.50538176", "0.50431085", "0.5038816", "0.5034639", "0.5022186", "0.50138533", "0.50038797", "0.5001234", "0.49970275", "0.49957085", "0.49918613", "0.49893466", "0.4987612", "0.49840003", "0.49838296", "0.49838296", "0.49798137", "0.4979355", "0.49667636", "0.49634644", "0.49545732", "0.494363", "0.4943555", "0.49389482", "0.49347997", "0.49322712" ]
0.7131582
0
_store_chart_type() Implementation of the abstract method from the specific chart class. Write the Pie chart BIFF record.
def store_chart_type # :nodoc: record = 0x1019 # Record identifier. length = 0x0006 # Number of bytes to follow. angle = 0x0000 # Angle. donut = 0x0000 # Donut hole size. grbit = 0x0002 # Option flags. store_simple(record, length, angle, donut, grbit) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_chart_type # :nodoc:\n end", "def write_chart_type; end", "def write_chart_type(params = {})\n # Write the c:areaChart element.\n write_pie_chart\n end", "def write_chart_type\n # Write the c:barChart element.\n write_line_chart\n end", "def write_chart_type(params)\n # Write the c:areaChart element.\n write_area_chart(params)\n end", "def chart_data(chart_type)\n Chart::Data.const_get(chart_type).new(data)\n end", "def write_pie_chart\n @writer.tag_elements('c:pieChart') do\n # Write the c:varyColors element.\n write_vary_colors\n # Write the series elements.\n @series.each {|s| write_series(s)}\n # Write the c:firstSliceAng element.\n write_first_slice_ang\n end\n end", "def add_chart(params = {})\n # Type must be specified so we can create the required chart instance.\n type = params[:type]\n embedded = params[:embedded]\n name = params[:name]\n raise \"Must define chart type in add_chart()\" unless type\n\n chart = Chart.factory(type, params[:subtype])\n chart.palette = @palette\n\n # If the chart isn't embedded let the workbook control it.\n if ptrue?(embedded)\n chart.name = name if name\n\n # Set index to 0 so that the activate() and set_first_sheet() methods\n # point back to the first worksheet if used for embedded charts.\n chart.index = 0\n chart.set_embedded_config_data\n else\n # Check the worksheet name for non-embedded charts.\n sheetname = check_chart_sheetname(name)\n chartsheet = Chartsheet.new(self, @worksheets.size, sheetname)\n chartsheet.chart = chart\n @worksheets << chartsheet\n end\n @charts << chart\n ptrue?(embedded) ? chart : chartsheet\n end", "def store_charts #:nodoc:\n record = 0x00EC # Record identifier\n length = 0x0000 # Bytes to follow\n \n ids = @object_ids.dup\n spid = ids.shift\n \n charts = @charts_array\n num_charts = charts.size\n \n num_filters = @filter_count\n num_comments = @comments_array\n \n # Number of objects written so far.\n num_objects = @images_array.size\n \n # Skip this if there aren't any charts.\n return if num_charts == 0\n \n (0 .. num_charts-1 ).each do |i|\n row = charts[i][0]\n col = charts[i][1]\n name = charts[i][2]\n x_offset = charts[i][3]\n y_offset = charts[i][4]\n scale_x = charts[i][5]\n scale_y = charts[i][6]\n width = 526\n height = 319\n \n width *= scale_x if scale_x.kind_of?(Numeric) && scale_x != 0\n height *= scale_y if scale_y.kind_of?(Numeric) && scale_y != 0\n \n # Calculate the positions of chart object.\n vertices = position_object( col,\n row,\n x_offset,\n y_offset,\n width,\n height\n )\n\n if (i == 0 and num_objects != 0)\n # Write the parent MSODRAWIING record.\n dg_length = 192 + 120*(num_charts -1)\n spgr_length = 168 + 120*(num_charts -1)\n \n dg_length += 96 *num_filters\n spgr_length += 96 *num_filters\n \n dg_length += 128 *num_comments\n spgr_length += 128 *num_comments\n \n \n data = store_mso_dg_container(dg_length) +\n store_mso_dg(*ids) +\n store_mso_spgr_container(spgr_length) +\n store_mso_sp_container(40) +\n store_mso_spgr() +\n store_mso_sp(0x0, spid, 0x0005)\n spid += 1\n data = data + store_mso_sp_container(112) +\n store_mso_sp(201, spid, 0x0A00)\n spid += 1\n data = data + store_mso_opt_chart() +\n store_mso_client_anchor(0, *vertices) +\n store_mso_client_data()\n else\n # Write the child MSODRAWIING record.\n data = store_mso_sp_container(112) +\n store_mso_sp(201, spid, 0x0A00)\n spid += 1\n data = data + store_mso_opt_chart() +\n store_mso_client_anchor(0, *vertices) +\n store_mso_client_data()\n end\n length = data.length\n header = [record, length].pack(\"vv\")\n append(header, data)\n \n store_obj_chart(num_objects+i+1)\n store_chart_binary(name)\n end\n\n\n # Simulate the EXTERNSHEET link between the chart and data using a formula\n # such as '=Sheet1!A1'.\n # TODO. Won't work for external data refs. Also should use a more direct\n # method.\n #\n formula = \"='#{@name}'!A1\"\n store_formula(formula)\n \n @object_ids[0] = spid\n end", "def add_chart(chartType, upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn)\n begin\n if(@filename=='')\n raise \"Base file not specified\"\n end\n if(@worksheetname=='')\n raise \"Worksheet is not specified\"\n end\n str_uri = $productURI + \"/cells/\" + @filename + \"/worksheets/\" + @worksheetname + \"/charts?chartType=\" +\n chartType.to_s + \"&upperLeftRow=\" + upperLeftRow.to_s + \"&upperLeftColumn=\" +\n upperLeftColumn.to_s + \"&lowerRightRow=\" + lowerRightRow.to_s + \n \"&lowerRightColumn=\" + lowerRightColumn.to_s\n signed_uri = Common::Utils.sign(str_uri)\n \n response = RestClient.put signed_uri,'', {:accept => 'application/json'}\n v_output = Common::Utils.validate_output(response)\n if(v_output==nil || v_output=='')\n folder = SaasposeStorage::Folder.new\n outputstream = folder.getfile(@filename)\n outputstream\n outputpath = $OutPutLocation + @filename\n Common::Utils.saveFile(outputstream, outputpath)\n return \"Chart added\"\n else\n return v_output\n end\n rescue Exception=>e\n print e\n end\n end", "def store_obj_chart(obj_id) #:nodoc:\n record = 0x005D # Record identifier\n length = 0x001A # Bytes to follow\n\n obj_type = 0x0005 # Object type (chart).\n data = '' # Record data.\n\n sub_record = 0x0000 # Sub-record identifier.\n sub_length = 0x0000 # Length of sub-record.\n sub_data = '' # Data of sub-record.\n options = 0x6011\n reserved = 0x0000\n\n # Add ftCmo (common object data) subobject\n sub_record = 0x0015 # ftCmo\n sub_length = 0x0012\n sub_data = [obj_type, obj_id, options, reserved, reserved, reserved].pack('vvvVVV')\n data = [sub_record, sub_length].pack('vv') + sub_data\n\n # Add ftEnd (end of object) subobject\n sub_record = 0x0000 # ftNts\n sub_length = 0x0000\n data = data + [sub_record, sub_length].pack('vv')\n\n # Pack the record.\n header = [record, length].pack('vv')\n\n append(header, data)\n\n end", "def make_pie_chart\n\t\trequire 'gruff'\n \t\ta = Sha.group(\"filetype\").count\n\n \t\tg = Gruff::Pie.new\n \t\tg.title = 'Filetypes'\n \n \t\ta.each do |key, value|\n \t\t puts g.data(key, a[key])\n \t\tend\n\n\t\t g.write('app/assets/images/pie.png')\n\tend", "def chart_type\n @chart_type ||= self.class.name.split('::').last.downcase\n end", "def store_chart_binary(filename) #:nodoc:\n filehandle = File.open(filename, \"rb\")\n # die \"Couldn't open $filename in add_chart_ext(): $!.\\n\";\n\n while tmp = filehandle.read(4096)\n append(tmp)\n end\n end", "def add_chart(chart_type, options) \n @object = GraphicFrame.new(self, chart_type, options)\n @object.chart\n end", "def chart=(v) DataTypeValidator.validate \"Series.chart\", Chart, v; @chart = v; end", "def add_chart(chart_type, options)\n @object = GraphicFrame.new(self, chart_type, options)\n @object.chart\n end", "def save\n result = Base.redis.hset(:charts, self.name, Marshal.dump(self))\n Log.debug \"Saving Chart object to Redis: #{self.name}\"\n result\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', ['BarOfPieChart', 'PieOfPieChart', 'DoughnutChart', 'PieChart', 'AreaChartArea', 'AreaChartPercentsStackedArea', 'AreaChartStackedArea', 'BarChartHorizClustered', 'BarChartHorizStacked', 'BarChartHorizPercentsStacked', 'BarChartVertClustered', 'BarChartVertStacked', 'BarChartVertPercentsStacked', 'LineChartLine', 'LineChartStackedLine', 'LineChartPercentsStackedLine', 'RadarChart', 'FilledRadarChart', 'StockHighLowClose', 'StockOpenHighLowClose', 'StockVolumeHighLowClose', 'StockVolumeOpenHighLowClose', 'ScatterStraightMarker', 'ScatterSmoothMarker', 'AreaChartArea3D', 'AreaChartStackedArea3D', 'AreaChartPercentsStackedArea3D', 'Line3DChart', 'Pie3DChart', 'Bar3DChartVert', 'Bar3DChartVertClustered', 'Bar3DChartVertPercentsStackedColumn3D', 'Bar3DChartVertPercentsStackedCone', 'Bar3DChartVertPercentsStackedCylinder', 'Bar3DChartVertPercentsStackedPyramid', 'Bar3DChartVertStackedColumn3D', 'Bar3DChartVertStackedCone', 'Bar3DChartVertStackedCylinder', 'Bar3DChartVertStackedPyramid', 'Bar3DChartHorizClustered', 'Bar3DChartHorizStackedBar3D', 'Bar3DChartHorizStackedCone', 'Bar3DChartHorizStackedCylinder', 'Bar3DChartHorizStackedPyramid', 'Bar3DChartHorizPercentsStackedBar3D', 'Bar3DChartHorizPercentsStackedCone', 'Bar3DChartHorizPercentsStackedCylinder', 'Bar3DChartHorizPercentsStackedPyramid', 'SurfaceChartContour', 'SurfaceChartWireframeContour', 'SurfaceChartSurface3D', 'SurfaceChartWireframeSurface3D', 'BubbleChart', 'HistogramChart', 'ParetoLineChart', 'BoxAndWhiskerChart', 'WaterfallChart', 'FunnelChart', 'TreemapChart', 'MapChart', 'SunburstChart'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end", "def getchart()\n # The data for the pie chart\n data = [25, 18, 15, 12, 8, 30, 35]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Insurance\", \"Facilities\",\n \"Production\"]\n\n # Create a PieChart object of size 360 x 300 pixels\n c = ChartDirector::PieChart.new(360, 300)\n\n # Set the center of the pie at (180, 140) and the radius to 100 pixels\n c.setPieSize(180, 140, 100)\n\n # Add a title to the pie chart\n c.addTitle(\"Project Cost Breakdown\")\n\n # Draw the pie in 3D\n c.set3D()\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Explode the 1st sector (index = 0)\n c.setExplode(0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 320 pixels. Use a vertical gradient color\n # from light blue (99ccff) to white (ffffff) spanning the top 100 pixels as\n # background. Set border to grey (888888). Use rounded corners. Enable soft drop\n # shadow.\n c = ChartDirector::PieChart.new(600, 320)\n c.setBackground(c.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff), 0x888888)\n c.setRoundedFrame()\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Pie Chart With Legend Demonstration\", \"timesbi.ttf\", 18).setMargin2(0,\n 0, 16, 0)\n\n # Set the center of the pie at (160, 165) and the radius to 110 pixels\n c.setPieSize(160, 165, 110)\n\n # Draw the pie in 3D with a pie thickness of 25 pixels\n c.set3D(25)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors\n c.setSectorStyle(ChartDirector::LocalGradientShading)\n\n # Use the side label layout method, with the labels positioned 16 pixels from the\n # pie bounding box\n c.setLabelLayout(ChartDirector::SideLayout, 16)\n\n # Show only the sector number as the sector label\n c.setLabelFormat(\"{={sector}+1}\")\n\n # Set the sector label style to Arial Bold 10pt, with a dark grey (444444) border\n c.setLabelStyle(\"arialbd.ttf\", 10).setBackground(ChartDirector::Transparent,\n 0x444444)\n\n # Add a legend box, with the center of the left side anchored at (330, 175), and\n # using 10 pts Arial Bold Italic font\n b = c.addLegend(330, 175, true, \"arialbi.ttf\", 10)\n b.setAlignment(ChartDirector::Left)\n\n # Set the legend box border to dark grey (444444), and with rounded conerns\n b.setBackground(ChartDirector::Transparent, 0x444444)\n b.setRoundedCorners()\n\n # Set the legend box margin to 16 pixels, and the extra line spacing between the\n # legend entries as 5 pixels\n b.setMargin(16)\n b.setKeySpacing(0, 5)\n\n # Set the legend box icon to have no border (border color same as fill color)\n b.setKeyBorder(ChartDirector::SameAsMainColor)\n\n # Set the legend text to show the sector number, followed by a 120 pixels wide\n # block showing the sector label, and a 40 pixels wide block showing the\n # percentage\n b.setText(\n \"<*block,valign=top*>{={sector}+1}.<*advanceTo=22*><*block,width=120*>\" \\\n \"{label}<*/*><*block,width=40,halign=right*>{percent}<*/*>%\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def chart(type, x_column, y_column, name)\n\n prepare_dimension(x_column, x_column) if (@base_dimensions[x_column + \"Dimension\"] == nil)\n\n chart = Sol::Chart.build(type, x_column, y_column, name)\n\n # Set chart defaults. Should preferably be read from a config file \n chart.elastic_y(true)\n chart.x_axis_label(x_column)\n chart.y_axis_label(y_column)\n chart.group(:reduce_sum)\n\n @charts[name] = chart\n chart\n\n end", "def series_type\n end", "def basic_chart\n \n end", "def export(plot, export_type='png', file_name='chart')\n raise NotImplementedError, 'Not yet implemented!' unless\n export_type == 'png'\n\n plot.export_iruby(export_type, file_name) if defined? IRuby\n rescue NameError\n plot.export(export_type, file_name)\n end", "def draw_google_chart(type, which_chart, data, chart_string, chart_values,\n chart_title, chart_div, width, height)\n %(\n function drawChart#{which_chart}() {\n // Create the data table.\n var data = new google.visualization.DataTable();\n data.addColumn(\"string\", \"#{escape(chart_string)}\");\n data.addColumn(\"number\", \"#{chart_values}\");\n data.addRows(#{data});\n // Set chart options\n var options = {\"title\": \"#{escape(chart_title)}\",\n is3D: #{type.zero?},\n pieHole: #{type},\n \"pieSliceText\": \"value\",\n \"width\": #{width},\n \"height\": #{height},\n \"titleTextStyle\": {\"color\": \"black\"}};\n // Instantiate and draw our chart, passing in some options.\n var chart = new google.visualization.PieChart(document.getElementById(\"chart_div_#{chart_div}\"));\n chart.draw(data, options);\n }\\n)\nend", "def getchart()\n # The data for the pie chart\n data = [72, 18, 15, 12]\n\n # The depths for the sectors\n depths = [30, 20, 10, 10]\n\n # The labels for the pie chart\n labels = [\"Sunny\", \"Cloudy\", \"Rainy\", \"Snowy\"]\n\n # The icons for the sectors\n icons = [\"sun.png\", \"cloud.png\", \"rain.png\", \"snowy.png\"]\n\n # Create a PieChart object of size 400 x 310 pixels, with a blue (CCCCFF) vertical\n # metal gradient background, black border, 1 pixel 3D border effect and rounded\n # corners\n c = ChartDirector::PieChart.new(400, 310, ChartDirector::metalColor(0xccccff, 0),\n 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the center of the pie at (200, 180) and the radius to 100 pixels\n c.setPieSize(200, 180, 100)\n\n # Add a title box using 15 pts Times Bold Italic font, on a blue (CCCCFF)\n # background with glass effect\n c.addTitle(\"Weather Profile in Wonderland\", \"timesbi.ttf\", 15).setBackground(\n 0xccccff, 0x000000, ChartDirector::glassEffect())\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Add icons to the chart as a custom field\n c.addExtraField(icons)\n\n # Configure the sector labels using CDML to include the icon images\n c.setLabelFormat(\n \"<*block,valign=absmiddle*><*img={field0}*> <*block*>{label}\\n{percent}%\" \\\n \"<*/*><*/*>\")\n\n # Draw the pie in 3D with variable 3D depths\n c.set3D2(depths)\n\n # Set the start angle to 225 degrees may improve layout when the depths of the\n # sector are sorted in descending order, because it ensures the tallest sector is\n # at the back.\n c.setStartAngle(225)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 360 pixels.\n c = ChartDirector::PieChart.new(600, 360)\n\n # Use the white on black palette, which means the default text and line colors are\n # white\n c.setColors(ChartDirector::whiteOnBlackPalette)\n\n # Use a vertical gradient color from deep blue (000066) to blue (0000cc) as\n # background. Use rounded corners of 20 pixels radius. Enable soft drop shadow.\n c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x000066, 0x0000cc))\n c.setRoundedFrame(0xffffff, 20)\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Exploded Pie Chart Demonstration\", \"timesbi.ttf\", 18).setMargin2(0, 0,\n 16, 0)\n\n # Set the center of the pie at (300, 195) and the radius to 110 pixels\n c.setPieSize(300, 195, 110)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors, with 5 pixels wide semi-transparent\n # white (bbffffff) borders\n c.setSectorStyle(ChartDirector::LocalGradientShading, 0xbbffffff, 5)\n\n # Use the side label layout method\n c.setLabelLayout(ChartDirector::SideLayout)\n\n # Use 10pt Arial Bold as the default label font. Set the label box background\n # color the same as the sector color. Use soft lighting effect with light\n # direction from right. Use 8 pixels rounded corners.\n t = c.setLabelStyle(\"arialbd.ttf\", 10, 0x000000)\n t.setBackground(ChartDirector::SameAsMainColor, ChartDirector::Transparent,\n ChartDirector::softLighting(ChartDirector::Right, 0))\n t.setRoundedCorners(8)\n\n # Set the sector label format. The label is centered in a 110 pixels wide bounding\n # box. It consists of two lines. The first line is the sector name. The second\n # line shows the data value and percentage.\n c.setLabelFormat(\n \"<*block,halign=center,width=110*>{label}\\n<*font=arial.ttf,size=8*>US$ \" \\\n \"{value}M ({percent}%)<*/*>\")\n\n # Explode all sectors 10 pixels from the center\n c.setExplode(-1, 10)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def draw_d3pie_chart(type, which, data, num, colors, title, width, height,\n mainlabelsize, titlesize, valuesize, tooltipsize,\n segmentsize, pieouterradius, pieinnerradius, piedistance, linesenabled,\n pulloutsegmentsize, titlefont, footerfont, footerfontsize, backgroundcolor,\n footercolor)\n high = 1; seen = []; element = ''\n data.map do |x|\n if x[1] > high\n high = x[1]\n element = x[0]\n end\n seen << x[1]\n end\n footertext = if high > 1 && seen.size > 1 && seen.count(high) == 1\n if type.zero?\n \"#{high} \\\"#{element}\\\"#{element == 'folders' ? '' : ' files'} occurred most frequently\"\n elsif type == 1\n \"#{high} maximum occurrences in file \\\"#{element}\\\"\"\n else\n \"#{high} maximum occurrences for the word \\\"#{element}\\\"\"\n end\n end\n\n s = \"\n var pie = new d3pie('d3pie_chart_div_#{which}', {\n 'header': {\n 'title': {\n 'text': '#{chart_title(title, num)}',\n 'fontSize': #{titlesize},\n 'font': '#{titlefont}'\n }\n },\n 'footer': {\n 'text': '#{footertext}',\n 'color': '##{footercolor}',\n 'fontSize': #{footerfontsize},\n 'font': '#{footerfont}',\n 'location': 'bottom-center'\n },\n 'size': {\n 'canvasWidth': #{width},\n 'canvasHeight': #{height},\n 'pieOuterRadius': '#{pieouterradius}',\n 'pieInnerRadius': '#{pieinnerradius}'\n },\n\n 'data': {\n 'sortOrder': 'value-desc',\n 'smallSegmentGrouping': {\n 'enabled': true,\n 'value': #{segmentsize}\n },\n 'content': [\"\n data.each do |x|\n if x[0].include?('.') || type != 2\n s += \"{'label':'#{x[0].split('.').first}','value':#{x[1]},'color':'#{colors[:\"#{x[0]}\"]}'},\"\n else\n s += \"{'label':'#{x[0]}','value':#{x[1]},'color':'black'},\"\n end\n end\n s.chop!\n s + \"\n ]\n },\n callbacks: {\n onMouseoverSegment: function(info) {\n console.log('mouseover:', info);\n },\n onMouseoutSegment: function(info) {\n console.log('mouseout:', info);\n }\n },\n 'labels': {\n 'outer': {\n 'pieDistance': #{piedistance}\n },\n 'inner': {\n 'format': 'value',\n 'hideWhenLessThanPercentage': 3\n },\n 'mainLabel': {\n 'fontSize': #{mainlabelsize}\n },\n 'percentage': {\n 'color': '#ffffff',\n 'decimalPlaces': 0\n },\n 'value': {\n 'color': '#ffffff',\n 'fontSize': #{valuesize}\n },\n 'lines': {\n 'enabled': #{linesenabled}\n },\n 'truncation': {\n 'enabled': true\n }\n },\n 'tooltips': {\n 'enabled': true,\n 'type': 'placeholder',\n 'string': '{label}: {value}, {percentage}%',\n 'styles': {\n 'fadeInSpeed': 586,\n 'backgroundOpacity': 0.7,\n 'color': '#ffffff',\n 'fontSize': #{tooltipsize}\n }\n },\n 'effects': {\n 'pullOutSegmentOnClick': {\n 'effect': 'linear',\n 'speed': 400,\n 'size': #{pulloutsegmentsize}\n }\n },\n 'misc': {\n 'colors': {\n 'background': '##{backgroundcolor}'\n },\n 'gradient': {\n 'enabled': true,\n 'percentage': 100\n }\n }\n });\\n\"\nend", "def piechart (synonym_id, type)\n synonym = Synonym.find(synonym_id)\n if type == @@GENDER\n stats = synonym.get_visual_stats_gender\n header = t(:stats_gender)\n elsif type == @@COUNTRY\n stats = synonym.get_visual_stats_country\n header = t(:stats_country)\n elsif type == @@AGE\n stats = synonym.get_visual_stats_age\n header = t(:stats_age)\n else\n stats = synonym.get_visual_stats_education\n header = t(:stats_education)\n end\n chart = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [0, 10, 150,25], :width => 157, :hieght => 50} )\n series = {\n :type=> 'pie',\n :name=> 'Browser share',\n :borderWidth => 0.7,\n :data=> stats\n\n }\n f.series(series)\n f.options[:title][:text] = header\n f.options[:title][:x] = 0\n\n f.legend(:layout=> 'vertical',:style=> {:left=> '0px', :bottom=> '0px',:right=> '0px',:top=> '0px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" ,\n :size =>'100%', \n :dataLabels=>{\n :enabled=>false,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end", "def data type\n if type == :roc\n fpr_axis.zip(tpr_axis)\n elsif type == :precision_recall\n tpr_axis.zip(precision_axis)\n else\n raise ArgumentError, \"Unrecognized plot type: #{type.to_s}\"\n end\n end", "def add_chart(chart_type, options={})\n TwoCellAnchor.new(self, options)\n @anchors.last.add_chart(chart_type, options)\n end", "def getchart()\n # The data for the pie chart\n data = [18, 45, 28]\n\n # The labels for the pie chart\n labels = [\"Marble\", \"Wood\", \"Granite\"]\n\n # The icons for the sectors\n texture = [\"marble3.png\", \"wood.png\", \"rock.png\"]\n\n # Create a PieChart object of size 400 x 330 pixels, with a metallic green\n # (88EE88) background, black border and 1 pixel 3D border effect\n c = ChartDirector::PieChart.new(400, 330, ChartDirector::metalColor(0x88ee88),\n 0x000000, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set donut center at (200, 160), and outer/inner radii as 120/60 pixels\n c.setDonutSize(200, 160, 120, 60)\n\n # Add a title box using 15 pts Times Bold Italic font and metallic deep green\n # (008000) background color\n c.addTitle(\"Material Composition\", \"timesbi.ttf\", 15).setBackground(\n ChartDirector::metalColor(0x008000))\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the colors of the sectors to the 3 texture patterns\n c.setColor(ChartDirector::DataColor + 0, c.patternColor2(texture[0]))\n c.setColor(ChartDirector::DataColor + 1, c.patternColor2(texture[1]))\n c.setColor(ChartDirector::DataColor + 2, c.patternColor2(texture[2]))\n\n # Draw the pie in 3D with a 3D depth of 30 pixels\n c.set3D(30)\n\n # Use 12 pts Arial Bold Italic as the sector label font\n c.setLabelStyle(\"arialbi.ttf\", 12)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def store_mso_opt_chart #:nodoc:\n type = 0xF00B\n version = 3\n instance = 9\n data = ''\n length = nil\n\n data = [0x007F].pack('v') + # Protection -> fLockAgainstGrouping\n [0x01040104].pack('V') +\n [0x00BF].pack('v') + # Text -> fFitTextToShape\n [0x00080008].pack('V') +\n [0x0181].pack('v') + # Fill Style -> fillColor\n [0x0800004E].pack('V') +\n [0x0183].pack('v') + # Fill Style -> fillBackColor\n [0x0800004D].pack('V') +\n\n [0x01BF].pack('v') + # Fill Style -> fNoFillHitTest\n [0x00110010].pack('V') +\n [0x01C0].pack('v') + # Line Style -> lineColor\n [0x0800004D].pack('V') +\n [0x01FF].pack('v') + # Line Style -> fNoLineDrawDash\n [0x00080008].pack('V') +\n [0x023F].pack('v') + # Shadow Style -> fshadowObscured\n [0x00020000].pack('V') +\n [0x03BF].pack('v') + # Group Shape -> fPrint\n [0x00080000].pack('V')\n\n return add_mso_generic(type, version, instance, data, length)\n end", "def export(plot, export_type='png', file_name='chart')\n plot.export_iruby(export_type, file_name) if defined? IRuby\n rescue NameError\n plot.export(export_type, file_name)\n end", "def get_form_chart_types\n # Each element has format [<Display Name>, <Value>]\n [\n [\"Bar\", \"bar_chart\"],\n [\"Column\", \"column_chart\"],\n [\"Pie\", \"pie_chart\"],\n [\"Line\", \"line_chart\"]\n ]\n end", "def simple_chart\n \n end", "def getchart()\n # The data for the bar chart\n data0 = [100, 125, 245, 147, 67]\n data1 = [85, 156, 179, 211, 123]\n data2 = [97, 87, 56, 267, 157]\n\n # The labels for the bar chart\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 500 x 320 pixels\n c = ChartDirector::XYChart.new(500, 320)\n\n # Set the plotarea at (100, 40) and of size 280 x 240 pixels\n c.setPlotArea(100, 40, 280, 240)\n\n # Add a legend box at (400, 100)\n c.addLegend(400, 100)\n\n # Add a title to the chart using 14 points Times Bold Itatic font\n c.addTitle(\"Weekday Network Load\", \"timesbi.ttf\", 14)\n\n # Add a title to the y axis. Draw the title upright (font angle = 0)\n c.yAxis().setTitle(\"Average\\nWorkload\\n(MBytes\\nPer Hour)\").setFontAngle(0)\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a stacked bar layer and set the layer 3D depth to 8 pixels\n layer = c.addBarLayer2(ChartDirector::Stack, 8)\n\n # Add the three data sets to the bar layer\n layer.addDataSet(data0, 0xff8080, \"Server # 1\")\n layer.addDataSet(data1, 0x80ff80, \"Server # 2\")\n layer.addDataSet(data2, 0x8080ff, \"Server # 3\")\n\n # Enable bar label for the whole bar\n layer.setAggregateLabelStyle()\n\n # Enable bar label for each segment of the stacked bar\n layer.setDataLabelStyle()\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the bar chart\n data0 = [100, 125, 245, 147, 67]\n data1 = [85, 156, 179, 211, 123]\n data2 = [97, 87, 56, 267, 157]\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 400 x 240 pixels\n c = ChartDirector::XYChart.new(400, 240)\n\n # Add a title to the chart using 10 pt Arial font\n c.addTitle(\" Average Weekday Network Load\", \"\", 10)\n\n # Set the plot area at (50, 25) and of size 320 x 180. Use two alternative\n # background colors (0xffffc0 and 0xffffe0)\n c.setPlotArea(50, 25, 320, 180, 0xffffc0, 0xffffe0)\n\n # Add a legend box at (55, 18) using horizontal layout. Use 8 pt Arial font, with\n # transparent background\n c.addLegend(55, 18, false, \"\", 8).setBackground(ChartDirector::Transparent)\n\n # Add a title to the y-axis\n c.yAxis().setTitle(\"Throughput (MBytes Per Hour)\")\n\n # Reserve 20 pixels at the top of the y-axis for the legend box\n c.yAxis().setTopMargin(20)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Add a multi-bar layer with 3 data sets and 3 pixels 3D depth\n layer = c.addBarLayer2(ChartDirector::Side, 3)\n layer.addDataSet(data0, 0xff8080, \"Server #1\")\n layer.addDataSet(data1, 0x80ff80, \"Server #2\")\n layer.addDataSet(data2, 0x8080ff, \"Server #3\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def chart\n @chart ||= Chart.new(settings)\n end", "def getchart()\n # The data for the bar chart\n data = [85, 156, 179.5, 211, 123]\n\n # The labels for the bar chart\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # The colors for the bar chart\n colors = [0xb8bc9c, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6]\n\n # Create a XYChart object of size 300 x 220 pixels. Use golden background color.\n # Use a 2 pixel 3D border.\n c = ChartDirector::XYChart.new(300, 220, ChartDirector::goldColor(), -1, 2)\n\n # Add a title box using 10 point Arial Bold font. Set the background color to\n # metallic blue (9999FF) Use a 1 pixel 3D border.\n c.addTitle(\"Daily Network Load\", \"arialbd.ttf\", 10).setBackground(\n ChartDirector::metalColor(0x9999ff), -1, 1)\n\n # Set the plotarea at (40, 40) and of 240 x 150 pixels in size\n c.setPlotArea(40, 40, 240, 150)\n\n # Add a multi-color bar chart layer using the given data and colors. Use a 1 pixel\n # 3D border for the bars.\n c.addBarLayer3(data, colors).setBorderColor(-1, 1)\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n data0 = [100, 100, 100, 100, 100]\n data1 = [90, 85, 85, 80, 70]\n data2 = [80, 65, 65, 75, 45]\n\n # The labels for the chart\n labels = [\"Population<*br*><*font=arial.ttf*>6 millions\",\n \"GDP<*br*><*font=arial.ttf*>120 billions\",\n \"Export<*br*><*font=arial.ttf*>25 billions\",\n \"Import<*br*><*font=arial.ttf*>24 billions\",\n \"Investments<*br*><*font=arial.ttf*>20 billions\"]\n\n # Create a PolarChart object of size 480 x 460 pixels. Set background color to\n # silver, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 460, ChartDirector::silverColor(),\n 0x000000, 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep green (008000) background\n c.addTitle(\"Economic Growth\", \"timesbi.ttf\", 15, 0xffffff).setBackground(0x008000)\n\n # Set plot area center at (240, 270), with 150 pixels radius\n c.setPlotArea(240, 270, 150)\n\n # Use 1 pixel width semi-transparent black (c0000000) lines as grid lines\n c.setGridColor(0xc0000000, 1, 0xc0000000, 1)\n\n # Add a legend box at top-center of plot area (240, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with silver background and 1 pixel 3D border effect.\n b = c.addLegend(240, 35, false, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add area layers of different colors to represent the data\n c.addAreaLayer(data0, 0xcc8880, \"Year 2004\")\n c.addAreaLayer(data1, 0xffd080, \"Year 1994\")\n c.addAreaLayer(data2, 0xa0bce0, \"Year 1984\")\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Set radial axis from 0 - 100 with a tick every 20 units\n c.radialAxis().setLinearScale(0, 100, 20)\n\n # Just show the radial axis as a grid line. Hide the axis labels by setting the\n # label color to Transparent\n c.radialAxis().setColors(0xc0000000, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n data0 = [90, 60, 85, 75, 55]\n data1 = [60, 80, 70, 80, 85]\n\n # The labels for the chart\n labels = [\"Speed\", \"Reliability\", \"Comfort\", \"Safety\", \"Efficiency\"]\n\n # Create a PolarChart object of size 480 x 380 pixels. Set background color to\n # gold, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 380, ChartDirector::goldColor(), 0x000000,\n 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep blue (000080) background\n c.addTitle(\"Space Travel Vehicles Compared\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x000080)\n\n # Set plot area center at (240, 210), with 150 pixels radius, and a white (ffffff)\n # background.\n c.setPlotArea(240, 210, 150, 0xffffff)\n\n # Add a legend box at top right corner (470, 35) using 10 pts Arial Bold font. Set\n # the background to silver, with 1 pixel 3D border effect.\n b = c.addLegend(470, 35, true, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopRight)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add an area layer to the chart using semi-transparent blue (0x806666cc). Add a\n # blue (0x6666cc) line layer using the same data with 3 pixel line width to\n # highlight the border of the area.\n c.addAreaLayer(data0, 0x806666cc, \"Model Saturn\")\n c.addLineLayer(data0, 0x6666cc).setLineWidth(3)\n\n # Add an area layer to the chart using semi-transparent red (0x80cc6666). Add a\n # red (0xcc6666) line layer using the same data with 3 pixel line width to\n # highlight the border of the area.\n c.addAreaLayer(data1, 0x80cc6666, \"Model Jupiter\")\n c.addLineLayer(data1, 0xcc6666).setLineWidth(3)\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_object_value(\"axes\", @axes)\n writer.write_object_value(\"dataLabels\", @data_labels)\n writer.write_object_value(\"format\", @format)\n writer.write_object_value(\"height\", @height)\n writer.write_object_value(\"left\", @left)\n writer.write_object_value(\"legend\", @legend)\n writer.write_string_value(\"name\", @name)\n writer.write_collection_of_object_values(\"series\", @series)\n writer.write_object_value(\"title\", @title)\n writer.write_object_value(\"top\", @top)\n writer.write_object_value(\"width\", @width)\n writer.write_object_value(\"worksheet\", @worksheet)\n end", "def bake_pie\n chart = PiCharts::Pie.new\n chart.add_dataset(label: \"cats\", data: 80)\n chart.add_dataset(label: \"dogs\", data: 50)\n chart.hover\n chart.responsive\n \"<head>\" + chart.cdn + \"</head>\" + \"<body>\" + chart.html(width: 100) + \"</body>\"\nend", "def series_json(params={})\n # Create data for charts\n color = params[:color] ||= 'AA4643'\n color = '#' + color\n series = []\n data = []\n\n data << [self.baseline_date, (self.baseline.round*100).round / 100.0]\n # For ideal data\n self.progresses.each{|progress| \n data << [progress.due_date, (progress.accuracy*100).round / 100.0]\n }\n data << [self.due_date, (self.accuracy*100).round / 100.0]\n #Sort data by due date\n data = data.sort_by { |hsh| hsh[0] }\n \n series << {\n :type => 'line',\n :name => \"Ideal chart\",\n :data => data\n }\n if color && color == '#4572A7'\n series[0][:color] = \"#AA4643\"\n end\n # For add grade \n data = []\n self.grades.find_each{|grade| \n data << [grade.due_date, (grade.accuracy*100).round / 100.0]\n }\n data = data.sort_by { |hsh| hsh[0] }\n series << {\n :name => self.name,\n :data => data,\n :color => color \n }\n series.to_json\n end", "def generate_piechartXML(*args)\n begin\n #color_hash is used to store default colors for pie-chart\n @aes = AESSecurity.new()\n @color_hash=Hash.new\n @keywordcolor_hash=Hash.new\n @pieRadius=\"pieRadius='100'\"\n @color_hash={\"0\"=>\"0C95BF\",\"1\"=>\"12C400\",\"2\"=>\"ECB800\",\"3\"=>\"EB2300\",\"4\"=>\"70808F\",\"5\"=>\"000000\",\"6\"=>\"800080\",\"7\"=>\"FFFF00\",\"8\"=>\"0377CA\"}\n if @@flag==true #checks whether the flag is true to add root xml element.\n @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' plotGradientColor='' showShadow='0' showLabels='#{args[3]}' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='#{args[3]}' decimals='0' isSliced='0' enableSmartLabels='#{args[3]}' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' showPercentageValues='1' #{args[3].to_i==1 ? @pieRadius : \"\"} >\" if args[2]!='keywords'&& args[2]!='url' # this root xml element is used only for channel and handset pie-chart.\n @@flag=false #set flag as false\n end\n \n key='rh21nr8e0vav0h0v'\n iv='1pnee1ng36nuare8'\n getsymbol={\"&\"=>\"%7E\",\"%\"=>\"%25\"}\n args[0]=(args[0]=='' || args[0]==nil) ? 'Unknown' : args[0]\n #url_model=(args[2]=='handset') ? (args[0]!='Others' && args[0]!='Unknown') ? \"link='/#{args[4]}/publisher_handset_model%3Fhandset=#{args[0].to_s.gsub(/([&%])/) do|s| getsymbol[\"#{s}\"] end}'\" : \"\" : \"\"\n colour=@color_hash[\"#{@@color_count}\"] #get the color \n @@strXML+=\"<set label='#{args[0].to_s.gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end}' value='#{args[1].to_s}' color='#{colour.to_s}'/>\" if args[2]!='url'\n @@date_count+=args[1].to_i #increment the counter value\n @@XML_array[@@color_count]=[\"#{args[0]}\",args[1].to_i,colour,@@date_count] if args[2]!='handset_model' #store the label,value and color in the array \n @@color_count+=1\n \n rescue Exception=>e\n puts \"ERROR :: in ReportGenerator Component and generate_piechartXML method. The Error is #{e.to_s}\"\n end\n end", "def getchart()\n # The data for the chart\n data0 = [32, 39, 23, 28, 41, 38, 26, 35, 29]\n data1 = [50, 55, 47, 34, 47, 53, 38, 40, 51]\n\n # The labels for the chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"]\n\n # Create a XYChart object of size 600 x 300 pixels, with a pale red (ffdddd)\n # background, black border, 1 pixel 3D border effect and rounded corners.\n c = ChartDirector::XYChart.new(600, 300, 0xffdddd, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is white (ffffff)\n # on a dark red (880000) background, with soft lighting effect from the right\n # side.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance \" \\\n \"Enhancer <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x880000, -1, ChartDirector::softLighting(ChartDirector::Right\n ))\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Energy Concentration (KJ per liter)\")\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a spline layer to the chart\n layer = c.addSplineLayer()\n\n # Set the default line width to 2 pixels\n layer.setLineWidth(2)\n\n # Add a data set to the spline layer, using blue (0000c0) as the line color, with\n # yellow (ffff00) circle symbols.\n layer.addDataSet(data1, 0x0000c0, \"Target Group\").setDataSymbol(\n ChartDirector::CircleSymbol, 9, 0xffff00)\n\n # Add a data set to the spline layer, using brown (982810) as the line color, with\n # pink (f040f0) diamond symbols.\n layer.addDataSet(data0, 0x982810, \"Control Group\").setDataSymbol(\n ChartDirector::DiamondSymbol, 11, 0xf040f0)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 250,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def generate_piechartXML(*args)\n begin\n @color_hash=Hash.new\n @color_hash={\"0\"=>\"0C95BF\",\"1\"=>\"12C400\",\"2\"=>\"ECB800\",\"3\"=>\"EB2300\",\"4\"=>\"70808F\",\"5\"=>\"000000\",\"6\"=>\"800080\",\"7\"=>\"FFFF00\",\"8\"=>\"7FFFD4\",\"9\"=>\"0377CA\",\"10\"=>\"15C2F7\"}\n if @@flag==true\n #~ @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' showShadow='0' plotGradientColor='0' showLabels='1' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='0' baseFontSize='12' isSliced='1' enableSmartLabels='1' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' startingAngle='80' canvasBorderColor ='cccccc' canvasBorderAlpha='0' canvasBorderThickness='0' showPercentageValues='1' pieRadious='100'>\" if args[2]=='Device_Summary' or args[2]==\"Carrier_Traffic\" \n puts \"hello\"\n p @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' showShadow='0' plotGradientColor='0' showLabels='1' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='0' baseFontSize='12' isSliced='1' enableSmartLabels='1' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' startingAngle='80' canvasBorderColor ='cccccc' canvasBorderAlpha='0' canvasBorderThickness='0' showPercentageValues='1' pieRadious='100'>\" \n #~ @@strXML = \"<chart decimals='2' yAxisName='#{args[3].to_s=='ecpm' ? 'eCPM' : (args[3].to_s).upcase}' divLineColor='CCCCCC' numDivLines='2' alternateHGridColor='FFFFFF' anchorBorderColor='FFFFFF' defaultAnimation='0' use3DLighting='0' alternateVGridColor='FFFFFF' showPlotBorder='0' showShadow='0' plotGradientColor='' showLabels='1' chartTopMargin='10' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='10' showValues='0' canvasBorderColor ='FFFFFF' formatNumberScale='0' canvasBorderAlpha='0' canvasBorderThickness='0' pieRadious='100' baseFontSize='12' showBorder='0' plotBorderThickness='0' bgColor='FFFFFF' showPercentageValues='1' > \" if args[3]=='ctr' || args[3]=='ecpm'\n @@flag=false\n end\n colour=@color_hash[\"#{@@color_count}\"]\n limit = (args[3]=='ctr' || args[3]=='ecpm') ? 10 : 15\n args[0]=(args[0]=='' || args[0]==nil) ? 'could not detect' : args[0]\n puts \"---------------------34----------\"\n p @@strXML=@@strXML+ \"<set label='#{args[0]!=nil ? (truncate(args[0].split(\"'\")[0].to_s,limit)).gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end : 'NA' }' value='#{args[1].to_s}' color='#{(args[0].to_s=='Others') ? '000000' : colour.to_s}' />\" if args[3]!='ctr' and args[2]!='URL' and args[3]!='ecpm'\n puts \"---------------------35----------\"\n #~ @@strXML+=\"<set label='#{args[0].to_s.gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end}' value='#{args[1].to_s}' color='176D94'/>\" if args[3]=='ctr' || args[3]=='ecpm'\n @@color_count+=1\n rescue Exception=>e\n puts \"DEBUGGER :: ERROR :: in AdminXmlBuilder Component under generate_piechartXML method. The Error is #{e.to_s}\"\n end\n end", "def getchart()\n # Data for outer ring\n data = [88, 124, 96]\n\n # Data for inner ring\n data2 = [77, 87, 45]\n\n # Labels for the sectors\n labels = [\"Hardware\", \"Software\", \"Services\"]\n\n # Colors for the sectors\n colors = [0xff9999, 0x9999ff, 0x66ff66]\n\n #\n # Create the main chart, which contains the chart title, the outer ring, and the\n # legend box\n #\n\n # Create a PieChart object of size 450 x 360 pixels, with transparent background\n c = ChartDirector::PieChart.new(450, 360)\n\n # Add a title to the chart with 18pts Times Bold Italic font\n c.addTitle(\"Concentric Donut Chart\", \"timesbi.ttf\", 18)\n\n # Set donut center at (160, 200), and outer/inner radii as 150/100 pixels\n c.setDonutSize(160, 200, 150, 100)\n\n # Add a label at the bottom-right corner of the ring to label the outer ring Use\n # 12pts Arial Bold Italic font in white (ffffff) color, on a green (008800)\n # background, with soft lighting effect and 5 pixels rounded corners\n t = c.addText(260, 300, \" Year 2006 \", \"arialbi.ttf\", 12, 0xffffff)\n t.setBackground(0x008800, ChartDirector::Transparent, ChartDirector::softLighting(\n ))\n t.setRoundedCorners(5)\n\n # Set the legend box at (320, 50) with 12 pts Arial Bold Italic font, with no\n # border\n c.addLegend(320, 50, true, \"arialbi.ttf\", 13).setBackground(\n ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the pie colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Set pie border color to white (ffffff)\n c.setLineColor(0xffffff)\n\n # Set pie label to value in $###M format, percentage in (##.#%) format, in two\n # lines.\n c.setLabelFormat(\"${value}M<*br*>({percent|1}%)\")\n\n # Use 10pts Airal Bold for the sector labels\n c.setLabelStyle(\"arialbd.ttf\", 10)\n\n # Set the label position to -25 pixels from the sector (which would be internal to\n # the sector)\n c.setLabelPos(-25)\n\n #\n # Create the inner ring.\n #\n\n # Create a PieChart object of size 280 x 320 pixels, with transparent background\n c2 = ChartDirector::PieChart.new(280, 320, ChartDirector::Transparent)\n\n # Set donut center at (110, 110), and outer/inner radii as 100/50 pixels\n c2.setDonutSize(110, 110, 100, 50)\n\n # Add a label at the center of the ring to label the inner ring. Use 12pts Arial\n # Bold Italic font in white (ffffff) color, on a deep blue (0000cc) background,\n # with soft lighting effect and 5 pixels rounded corners\n t2 = c2.addText(110, 110, \" Year 2005 \", \"arialbi.ttf\", 12, 0xffffff,\n ChartDirector::Center)\n t2.setBackground(0x0000cc, ChartDirector::Transparent,\n ChartDirector::softLighting())\n t2.setRoundedCorners(5)\n\n # Set the pie data and the pie labels\n c2.setData(data2, labels)\n\n # Set the pie colors\n c2.setColors2(ChartDirector::DataColor, colors)\n\n # Set pie border color to white (ffffff)\n c2.setLineColor(0xffffff)\n\n # Set pie label to value in $###M format, percentage in (##.#%) format, in two\n # lines.\n c2.setLabelFormat(\"${value}M<*br*>({percent|1}%)\")\n\n # Use 10pts Airal Bold for the sector labels\n c2.setLabelStyle(\"arialbd.ttf\", 10)\n\n # Set the label position to -25 pixels from the sector (which would be internal to\n # the sector)\n c2.setLabelPos(-25)\n\n # merge the inner ring into the outer ring at (50, 90)\n c.makeChart3().merge(c2.makeChart3(), 50, 90, ChartDirector::TopLeft, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n data = [100, 125, 260, 147, 67]\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 200 x 180 pixels\n c = ChartDirector::XYChart.new(200, 180)\n\n # Set the plot area at (30, 10) and of size 140 x 130 pixels\n c.setPlotArea(30, 10, 140, 130)\n\n # Ise log scale axis if required\n if params[\"img\"] == \"1\"\n c.yAxis().setLogScale3()\n end\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a color bar layer using the given data. Use a 1 pixel 3D border for the\n # bars.\n c.addBarLayer3(data).setBorderColor(-1, 1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def piechart(*args)\n Pie.new(self, *args)\n end", "def getchart()\n # The data for the bar chart\n data0 = [44, 55, 100]\n data1 = [97, 87, 167]\n data2 = [156, 78, 147]\n data3 = [125, 118, 211]\n\n # The labels for the bar chart. The labels contains embedded images as icons.\n labels = [\"<*img=service.png*><*br*>Service\",\n \"<*img=software.png*><*br*>Software\", \"<*img=computer.png*><*br*>Hardware\"]\n\n # Create a XYChart object of size 600 x 350 pixels, using 0xe0e0ff as the\n # background color, 0xccccff as the border color, with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(600, 350, 0xe0e0ff, 0xccccff, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Add a title to the chart using 14 points Times Bold Itatic font and light blue\n # (0x9999ff) as the background color\n c.addTitle(\"Business Results 2001 vs 2002\", \"timesbi.ttf\", 14).setBackground(\n 0x9999ff)\n\n # Set the plotarea at (60, 45) and of size 500 x 210 pixels, using white\n # (0xffffff) as the background\n c.setPlotArea(60, 45, 500, 210, 0xffffff)\n\n # Swap the x and y axes to create a horizontal bar chart\n c.swapXY()\n\n # Add a title to the y axis using 11 pt Times Bold Italic as font\n c.yAxis().setTitle(\"Revenue (millions)\", \"timesbi.ttf\", 11)\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Disable x-axis ticks by setting the tick length to 0\n c.xAxis().setTickLength(0)\n\n # Add a stacked bar layer to the chart\n layer = c.addBarLayer2(ChartDirector::Stack)\n\n # Add the first two data sets to the chart as a stacked bar group\n layer.addDataGroup(\"2001\")\n layer.addDataSet(data0, 0xaaaaff, \"Local\")\n layer.addDataSet(data1, 0x6666ff, \"International\")\n\n # Add the remaining data sets to the chart as another stacked bar group\n layer.addDataGroup(\"2002\")\n layer.addDataSet(data2, 0xffaaaa, \"Local\")\n layer.addDataSet(data3, 0xff6666, \"International\")\n\n # Set the sub-bar gap to 0, so there is no gap between stacked bars with a group\n layer.setBarGap(0.2, 0)\n\n # Set the bar border to transparent\n layer.setBorderColor(ChartDirector::Transparent)\n\n # Set the aggregate label format\n layer.setAggregateLabelFormat(\"Year {dataGroupName}\\n{value} millions\")\n\n # Set the aggregate label font to 8 point Arial Bold Italic\n layer.setAggregateLabelStyle(\"arialbi.ttf\", 8)\n\n # Reverse 20% space at the right during auto-scaling to allow space for the\n # aggregate bar labels\n c.yAxis().setAutoScale(0.2)\n\n # Add a legend box at (310, 300) using TopCenter alignment, with 2 column grid\n # layout, and use 8 pts Arial Bold Italic as font\n legendBox = c.addLegend2(310, 300, 2, \"arialbi.ttf\", 8)\n legendBox.setAlignment(ChartDirector::TopCenter)\n\n # Set the format of the text displayed in the legend box\n legendBox.setText(\"Year {dataGroupName} {dataSetName} Revenue\")\n\n # Set the background and border of the legend box to transparent\n legendBox.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def export_highchart(id, chart, data, is_donation, file_type = \"png\", return_url = true)\n ok = true\n image_stream = nil\n file_type = \"png\" if [\"png\",\"jpeg\",\"svg\",\"pdf\"].index(file_type).nil?\n is_pdf = file_type == \"pdf\"\n is_base64 = file_type != \"svg\"\n image_name = \"#{id}#{chart}.#{file_type}\"\n image_rel_dir = \"/system/share_images/#{is_donation ? 'donation' : 'finance'}/#{I18n.locale}\"\n image_abs_dir = \"#{Rails.root}/public#{image_rel_dir}\"\n image_rel_path = \"#{image_rel_dir}/#{image_name}\"\n image_abs_path = \"#{image_abs_dir}/#{image_name}\"\n\n\n uri = URI.parse(\"http://127.0.0.1:3003/\")\n headers = { 'Content-Type' => 'application/json' }\n\n jsn = highchart_options_by_type(is_donation ? :bar : :column, file_type)\n k = (\"c#{chart}\").to_sym\n jsn[\"infile\"].gsub!(\"_title_\", data[k][:title])\n if is_donation\n jsn[\"infile\"].gsub!(\"_bg_\", chart == \"a\" ? \"#EBE187\" : \"#B8E8AD\")\n jsn[\"infile\"].gsub!(\"_subtitle_\", data[k][:subtitle])\n jsn[\"infile\"].gsub!(\"_series_\", data[k][:series].to_s)\n jsn[\"infile\"].gsub!(\"_width_\", \"1200\")\n jsn[\"infile\"].gsub!(\"_height_\", \"628\")\n else\n cats = data[k][:categories]\n\n jsn[\"infile\"].gsub!(\"_categories_\", cats.to_json.to_s)\n jsn[\"infile\"].gsub!(\"_series_\", data[k][:series].to_json.to_s)\n rotated = cats[0].class == Hash && cats[0].dig(:categories).present? && cats[0].dig(:categories).length > 1\n\n cat_max_len = 0\n if rotated\n cats[0].dig(:categories).each { |cat|\n cat_max_len = cat.length if cat_max_len < cat.length\n }\n end\n\n jsn[\"infile\"].gsub!(\"_grouped_options_\", !rotated ? \"[]\" : \"[{ \\\"rotation\\\": 0 }, { \\\"rotation\\\": -90 }]\")\n jsn[\"infile\"].gsub!(\"_rotation_\", (!rotated ? \"0\" : \"-90\"))\n jsn[\"infile\"].gsub!(\"_width_\", rotated && cats[0].dig(:categories).length > 6 ? \"2400\" : \"1200\")\n jsn[\"infile\"].gsub!(\"_height_\", (628 + cat_max_len*9).to_s)\n end\n tmp_path = \"#{Rails.root}/tmp/assets/#{image_name}\"\n jsn[\"outfile\"] = tmp_path if is_pdf\n\n # Rails.logger.fatal(\"fatal----------------------#{jsn}\")\n # jsn[\"width\"] = 1200 if return_url\n # FileUtils.mkdir_p(image_abs_dir) unless File.directory?(image_abs_dir)\n\n http = Net::HTTP.new(uri.host, uri.port)\n\n http.request_post(uri.path, jsn.to_json, headers) {|response|\n if is_pdf\n if File.file?(tmp_path)\n image_stream = IO.read(tmp_path)\n File.unlink(tmp_path)\n end\n\n else\n image_stream = is_base64 ? Base64.urlsafe_decode64(response.body) : response.body\n end\n }\n\n\n rescue => e\n # Rails.logger.fatal(\"fatal----------------------#{e}\")\n ok = false\n image_stream = nil\n ensure\n return { ok: ok, data: image_stream }\n end", "def render\n labels = []\n values = []\n @data.each do |label, value|\n labels << CGI::escape(label)\n values << (value > 0 ? value * 100 / @max : value).round.to_s\n end\n params = {:cht => 'p', :chs => \"#{width}x#{height}\", :chd => \"t:#{values.join(',')}\", :chl => labels.join('|') }\n params['chco'] = color if color\n\n url = \"http://chart.apis.google.com/chart?#{to_query(params)}\"\n\n alt_msg = \"This pie chart is generated by Google Charts. You must be connected to the Internet to view this chart.\"\n html = \"<img id=\\\"pie_chart_image\\\" src=\\\"#{url}\\\" alt=\\\"#{alt_msg}\\\"/>\"\n return html\n end", "def chart_data\n chart_data = {}\n if @issue_max_date < @basis_date && complete_ev < 100.0\n @ev[@basis_date] = @ev[@ev.keys.max]\n @ac[@basis_date] = @ac[@ac.keys.max]\n end\n chart_data[:planned_value] = convert_to_chart(@pv_actual)\n chart_data[:actual_cost] = convert_to_chart(@ac)\n chart_data[:earned_value] = convert_to_chart(@ev)\n chart_data[:baseline_value] = convert_to_chart(@pv_baseline)\n if @forecast\n bac_top_line = { chart_minimum_date => bac,\n chart_maximum_date => bac }\n chart_data[:bac_top_line] = convert_to_chart(bac_top_line)\n eac_top_line = { chart_minimum_date => eac,\n chart_maximum_date => eac }\n chart_data[:eac_top_line] = convert_to_chart(eac_top_line)\n actual_cost_forecast = { @basis_date => today_ac,\n forecast_finish_date(@basis_hours) => eac }\n chart_data[:actual_cost_forecast] = convert_to_chart(actual_cost_forecast)\n earned_value_forecast = { @basis_date => today_ev,\n forecast_finish_date(@basis_hours) => bac }\n chart_data[:earned_value_forecast] = convert_to_chart(earned_value_forecast)\n end\n chart_data\n end", "def create\n @chart = Chart.new(params[:chart])\n\n respond_to do |format|\n if @chart.save\n format.html { redirect_to(@chart, :notice => 'Chart was successfully created.') }\n format.xml { render :xml => @chart, :status => :created, :location => @chart }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @chart.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @chart = Chart.new(params[:chart])\n\n respond_to do |format|\n if @chart.save\n format.html { redirect_to(@chart, :notice => 'Chart was successfully created.') }\n format.xml { render :xml => @chart, :status => :created, :location => @chart }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @chart.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @chart = Chart.new(params[:chart])\n\n respond_to do |format|\n if @chart.save\n format.html { redirect_to(@chart, :notice => 'Chart was successfully created.') }\n format.xml { render :xml => @chart, :status => :created, :location => @chart }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @chart.errors, :status => :unprocessable_entity }\n end\n end\n end", "def getchart()\n # The data for the chart\n data0 = [42, 49, ChartDirector::NoValue, 38, 64, 56, 29, 41, 44, 57]\n data1 = [65, 75, 47, 34, 42, 49, 73, ChartDirector::NoValue, 90, 69, 66, 78]\n data2 = [ChartDirector::NoValue, ChartDirector::NoValue, 25, 28, 38, 20, 22,\n ChartDirector::NoValue, 25, 33, 30, 24]\n labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\",\n \"Nov\", \"Dec\"]\n\n # Create a XYChart object of size 600 x 360 pixels. Set background color to\n # brushed silver, with a 2 pixel 3D border. Use rounded corners.\n c = ChartDirector::XYChart.new(600, 360, ChartDirector::brushedSilverColor(),\n ChartDirector::Transparent, 2)\n c.setRoundedFrame()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. #Set top/bottom\n # margins to 6 pixels.\n title = c.addTitle(\"Product Line Global Revenue\", \"timesbi.ttf\", 18)\n title.setMargin2(0, 0, 6, 6)\n\n # Add a separator line just under the title\n c.addLine(10, title.getHeight(), c.getWidth() - 11, title.getHeight(),\n ChartDirector::LineColor)\n\n # Add a legend box where the top-center is anchored to the horizontal center of\n # the chart, just under the title. Use horizontal layout and 10 points Arial Bold\n # font, and transparent background and border.\n legendBox = c.addLegend(c.getWidth() / 2, title.getHeight(), false, \"arialbd.ttf\",\n 10)\n legendBox.setAlignment(ChartDirector::TopCenter)\n legendBox.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Tentatively set the plotarea at (70, 75) and of 460 x 240 pixels in size. Use\n # transparent border and black (000000) grid lines\n c.setPlotArea(70, 75, 460, 240, -1, -1, ChartDirector::Transparent, 0x000000, -1)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Show the same scale on the left and right y-axes\n c.syncYAxis()\n\n # Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this\n # as the guideline when putting ticks on the y-axis.\n c.yAxis().setTickDensity(30)\n\n # Set all axes to transparent\n c.xAxis().setColors(ChartDirector::Transparent)\n c.yAxis().setColors(ChartDirector::Transparent)\n c.yAxis2().setColors(ChartDirector::Transparent)\n\n # Set the x-axis margins to 15 pixels, so that the horizontal grid lines can\n # extend beyond the leftmost and rightmost vertical grid lines\n c.xAxis().setMargin(15, 15)\n\n # Set axis label style to 8pts Arial Bold\n c.xAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis2().setLabelStyle(\"arialbd.ttf\", 8)\n\n # Add axis title using 10pts Arial Bold Italic font\n c.yAxis().setTitle(\"Revenue in USD millions\", \"arialbi.ttf\", 10)\n c.yAxis2().setTitle(\"Revenue in USD millions\", \"arialbi.ttf\", 10)\n\n # Add the first line. The missing data will be represented as gaps in the line\n # (the default behaviour)\n layer0 = c.addLineLayer2()\n layer0.addDataSet(data0, 0xff0000, \"Quantum Computer\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer0.setLineWidth(3)\n\n # Add the second line. The missing data will be represented by using dash lines to\n # bridge the gap\n layer1 = c.addLineLayer2()\n layer1.addDataSet(data1, 0x00ff00, \"Atom Synthesizer\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer1.setLineWidth(3)\n layer1.setGapColor(c.dashLineColor(0x00ff00))\n\n # Add the third line. The missing data will be ignored - just join the gap with\n # the original line style.\n layer2 = c.addLineLayer2()\n layer2.addDataSet(data2, 0xff6600, \"Proton Cannon\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer2.setLineWidth(3)\n layer2.setGapColor(ChartDirector::SameAsMainColor)\n\n # layout the legend so we can get the height of the legend box\n c.layoutLegend()\n\n # Adjust the plot area size, such that the bounding box (inclusive of axes) is 15\n # pixels from the left edge, just under the legend box, 16 pixels from the right\n # edge, and 25 pixels from the bottom edge.\n c.packPlotArea(15, legendBox.getTopY() + legendBox.getHeight(), c.getWidth() - 16,\n c.getHeight() - 25)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the bar chart\n data = [450, 560, 630, 800, 1100, 1350, 1600, 1950, 2300, 2700]\n\n # The labels for the bar chart\n labels = [\"1996\", \"1997\", \"1998\", \"1999\", \"2000\", \"2001\", \"2002\", \"2003\", \"2004\",\n \"2005\"]\n\n # Create a XYChart object of size 600 x 360 pixels\n c = ChartDirector::XYChart.new(600, 360)\n\n # Add a title to the chart using 18pts Times Bold Italic font\n c.addTitle(\"Annual Revenue for Star Tech\", \"timesbi.ttf\", 18)\n\n # Set the plotarea at (60, 40) and of size 500 x 280 pixels. Use a vertical\n # gradient color from light blue (eeeeff) to deep blue (0000cc) as background. Set\n # border and grid lines to white (ffffff).\n c.setPlotArea(60, 40, 500, 280, c.linearGradientColor(60, 40, 60, 280, 0xeeeeff,\n 0x0000cc), -1, 0xffffff, 0xffffff)\n\n # Add a multi-color bar chart layer using the supplied data. Use soft lighting\n # effect with light direction from left.\n c.addBarLayer3(data).setBorderColor(ChartDirector::Transparent,\n ChartDirector::softLighting(ChartDirector::Left))\n\n # Set x axis labels using the given labels\n c.xAxis().setLabels(labels)\n\n # Draw the ticks between label positions (instead of at label positions)\n c.xAxis().setTickOffset(0.5)\n\n # Add a title to the y axis with 10pts Arial Bold font\n c.yAxis().setTitle(\"USD (millions)\", \"arialbd.ttf\", 10)\n\n # Set axis label style to 8pts Arial Bold\n c.xAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 8)\n\n # Set axis line width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def get_grafico(obj,tipo_grafico)\n\n return @h = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>tipo_grafico , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> tipo_grafico,\n :name=> 'Media de precos dos anuncios',\n :data=> obj,\n\n }\n f.series(series)\n\n f.options[:title][:text] = \"Preco por categoria\"\n\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"white\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end", "def getchart()\n # The data for the bar chart\n data0 = [100, 125, 156, 147, 87, 124, 178, 109, 140, 106, 192, 122]\n data1 = [122, 156, 179, 211, 198, 177, 160, 220, 190, 188, 220, 270]\n data2 = [167, 190, 213, 267, 250, 320, 212, 199, 245, 267, 240, 310]\n labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sept\", \"Oct\",\n \"Nov\", \"Dec\"]\n\n # Create a XYChart object of size 580 x 280 pixels\n c = ChartDirector::XYChart.new(580, 280)\n\n # Add a title to the chart using 14 pts Arial Bold Italic font\n c.addTitle(\"Product Revenue For Last 3 Years\", \"arialbi.ttf\", 14)\n\n # Set the plot area at (50, 50) and of size 500 x 200. Use two alternative\n # background colors (f8f8f8 and ffffff)\n c.setPlotArea(50, 50, 500, 200, 0xf8f8f8, 0xffffff)\n\n # Add a legend box at (50, 25) using horizontal layout. Use 8pts Arial as font,\n # with transparent background.\n c.addLegend(50, 25, false, \"arial.ttf\", 8).setBackground(\n ChartDirector::Transparent)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Draw the ticks between label positions (instead of at label positions)\n c.xAxis().setTickOffset(0.5)\n\n # Add a multi-bar layer with 3 data sets\n layer = c.addBarLayer2(ChartDirector::Side)\n layer.addDataSet(data0, 0xff8080, \"Year 2003\")\n layer.addDataSet(data1, 0x80ff80, \"Year 2004\")\n layer.addDataSet(data2, 0x8080ff, \"Year 2005\")\n\n # Set 50% overlap between bars\n layer.setOverlapRatio(0.5)\n\n # Add a title to the y-axis\n c.yAxis().setTitle(\"Revenue (USD in millions)\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def create\n @chart = Chart.new(params[:chart])\n\n respond_to do |format|\n if @chart.save\n format.html { redirect_to @chart, notice: 'Chart was successfully created.' }\n format.json { render json: @chart, status: :created, location: @chart }\n else\n format.html { render action: \"new\" }\n format.json { render json: @chart.errors, status: :unprocessable_entity }\n end\n end\n end", "def request_type_volume_chart\n require 'gruff'\n\n g = Gruff::Bar.new\n g.title = 'Bytes Transferred per Request Type'\n group_by { |e| e.request_type }.each { |request_type, entries|\n g.data(request_type, [entries.map { |e| e.bytes }.reduce(:+)])\n }\n g\n end", "def create\n @chart = Chart.new(chart_params)\n @chart.BMI = @chart.set_information[:BMI]\n @chart.Proper = @chart.set_information[:Proper]\n @chart.metabolism = @chart.basal_metabolism(current_user.age)\n\n respond_to do |format|\n if @chart.save\n format.html { redirect_to @chart, notice: '編集しました' }\n format.json { render :show, status: :created, location: @chart }\n else\n format.html { render :new }\n format.json { render json: @chart.errors, status: :unprocessable_entity }\n end\n end\n end", "def axis_type_label\n raise NotImplementedError.new(\"Method must be overridden in a subclass of this abstract base class.\")\n end", "def chart\n case param_context(:chart_type)\n when 'cities' then\n @cities = city_count_data.to_a # build the data here, or pull it from an endpoint in the JS, but not both\n render 'cities_chart'\n when 'countries' then\n @countries = country_count_data.to_a # build the data here, or pull it from an endpoint in the JS, but not both\n render 'countries_chart'\n when 'years' then\n @years = year_count_data.to_a\n render 'years_chart'\n else\n flash[:error] = 'Unknown chart type'\n redirect_to events_path\n end\n end", "def build_graph_generally(chart_type, categories, series, colors)\n graph = get_graph(chart_type)\n graph.add(:axis_category_text, categories)\n graph.add(:series, \"series legend label\", series)\n graph.add(:theme, \"vote\")\n graph.add(:user_data, :colors, colors.join(\",\"))\n graph.add(:user_data, :delay_count, series.size - 1)\n graph\n end", "def data\n chart =OpenFlashChart.new\n\n data = get_data\n\n get_converter.convert(chart, data)\n \n if show_y_axis\n y = YAxis.new\n y.set_range(0,(data[:max]*1.2).round,(data[:max]/get_y_axis_labels).round) if data[:max]\n chart.y_axis = y\n end\n\n if show_x_axis\n x = XAxis.new\n x.set_range(0,data[:count] > 1 ? data[:count] - 1 : 1,1) if data[:count]\n if data[:labels]\n labels = []\n if get_x_axis_labels > 0\n step = (data[:labels].size/get_y_axis_labels).to_i\n step = 1 if step == 0\n else\n step = 1\n end\n data[:labels].each_with_index do |l,i|\n if i % step == 0\n labels << l\n else\n labels << \"\"\n end\n end\n x.set_labels(labels)\n end\n chart.x_axis = x\n else\n x = XAxis.new\n x.set_labels([\"\"])\n chart.x_axis = x\n end\n\n unless get_x_legend.nil?\n legend = XLegend.new(get_x_legend)\n legend.set_style('{font-size: 12px}')\n chart.set_x_legend(legend)\n end\n\n unless get_x_legend.nil?\n legend = YLegend.new(get_y_legend)\n legend.set_style('{font-size: 12px}')\n chart.set_y_legend(legend)\n end\n\n chart.set_bg_colour('#ffffff');\n\n chart.to_s\n end", "def getchart()\n # Data for the chart\n data0 = [5, 3, 10, 4, 3, 5, 2, 5]\n data1 = [12, 6, 17, 6, 7, 9, 4, 7]\n data2 = [17, 7, 22, 7, 18, 13, 5, 11]\n\n labels = [\"North\", \"North<*br*>East\", \"East\", \"South<*br*>East\", \"South\",\n \"South<*br*>West\", \"West\", \"North<*br*>West\"]\n\n # Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0)\n # background and 1 pixel 3D border\n c = ChartDirector::PolarChart.new(460, 500, 0xe0e0e0, 0x000000, 1)\n\n # Add a title to the chart at the top left corner using 15pts Arial Bold Italic\n # font. Use a wood pattern as the title background.\n c.addTitle(\"Polar Area Chart Demo\", \"arialbi.ttf\", 15).setBackground(\n c.patternColor(File.dirname(__FILE__) + \"/wood.png\"))\n\n # Set center of plot area at (230, 280) with radius 180 pixels, and white (ffffff)\n # background.\n c.setPlotArea(230, 280, 180, 0xffffff)\n\n # Set the grid style to circular grid\n c.setGridStyle(false)\n\n # Add a legend box at top-center of plot area (230, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with 1 pixel 3D border effect.\n b = c.addLegend(230, 35, false, \"arialbd.ttf\", 9)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::Transparent, ChartDirector::Transparent, 1)\n\n # Set angular axis using the given labels\n c.angularAxis().setLabels(labels)\n\n # Specify the label format for the radial axis\n c.radialAxis().setLabelFormat(\"{value}%\")\n\n # Set radial axis label background to semi-transparent grey (40cccccc)\n c.radialAxis().setLabelStyle().setBackground(0x40cccccc, 0)\n\n # Add the data as area layers\n c.addAreaLayer(data2, -1, \"5 m/s or above\")\n c.addAreaLayer(data1, -1, \"1 - 5 m/s\")\n c.addAreaLayer(data0, -1, \"less than 1 m/s\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def pcharts?\n self.charts == CHARTS_PCHART\n end", "def create\n @chart = Chart.new(params[:chart])\n flash[:notice] = 'Chart was successfully created.' if @chart.save\n respond_with(@chart)\n end", "def valid?\n type_validator = EnumAttributeValidator.new('String', ['BarOfPieChart', 'PieOfPieChart', 'DoughnutChart', 'PieChart', 'AreaChartArea', 'AreaChartPercentsStackedArea', 'AreaChartStackedArea', 'BarChartHorizClustered', 'BarChartHorizStacked', 'BarChartHorizPercentsStacked', 'BarChartVertClustered', 'BarChartVertStacked', 'BarChartVertPercentsStacked', 'LineChartLine', 'LineChartStackedLine', 'LineChartPercentsStackedLine', 'RadarChart', 'FilledRadarChart', 'StockHighLowClose', 'StockOpenHighLowClose', 'StockVolumeHighLowClose', 'StockVolumeOpenHighLowClose', 'ScatterStraightMarker', 'ScatterSmoothMarker', 'AreaChartArea3D', 'AreaChartStackedArea3D', 'AreaChartPercentsStackedArea3D', 'Line3DChart', 'Pie3DChart', 'Bar3DChartVert', 'Bar3DChartVertClustered', 'Bar3DChartVertPercentsStackedColumn3D', 'Bar3DChartVertPercentsStackedCone', 'Bar3DChartVertPercentsStackedCylinder', 'Bar3DChartVertPercentsStackedPyramid', 'Bar3DChartVertStackedColumn3D', 'Bar3DChartVertStackedCone', 'Bar3DChartVertStackedCylinder', 'Bar3DChartVertStackedPyramid', 'Bar3DChartHorizClustered', 'Bar3DChartHorizStackedBar3D', 'Bar3DChartHorizStackedCone', 'Bar3DChartHorizStackedCylinder', 'Bar3DChartHorizStackedPyramid', 'Bar3DChartHorizPercentsStackedBar3D', 'Bar3DChartHorizPercentsStackedCone', 'Bar3DChartHorizPercentsStackedCylinder', 'Bar3DChartHorizPercentsStackedPyramid', 'SurfaceChartContour', 'SurfaceChartWireframeContour', 'SurfaceChartSurface3D', 'SurfaceChartWireframeSurface3D', 'BubbleChart', 'HistogramChart', 'ParetoLineChart', 'BoxAndWhiskerChart', 'WaterfallChart', 'FunnelChart', 'TreemapChart', 'MapChart', 'SunburstChart'])\n return false unless type_validator.valid?(@type)\n pie_split_by_validator = EnumAttributeValidator.new('String', ['Default', 'Custom', 'ByPercentage', 'ByPos', 'ByValue'])\n return false unless pie_split_by_validator.valid?(@pie_split_by)\n bubble_size_representation_validator = EnumAttributeValidator.new('String', ['Area', 'Width'])\n return false unless bubble_size_representation_validator.valid?(@bubble_size_representation)\n true\n end", "def series_type(field = nil)\n find_record_value(field) if field\n end", "def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [150, 300, 1000, 1700]\n dataY0 = [12, 60, 25, 65]\n dataZ0 = [20, 50, 50, 85]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [35, 50, 75]\n dataZ1 = [30, 55, 95]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add a title to the y axis using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with semi-transparent red (0x80ff3333)\n # circle symbols, where the circle size is modulated by dataZ0. This creates a\n # bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\", ChartDirector::CircleSymbol,\n 9, 0x80ff3333, 0x80ff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with semi-transparent green (0x803333ff)\n # circle symbols, where the circle size is modulated by dataZ1. This creates a\n # bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\", ChartDirector::CircleSymbol,\n 9, 0x803333ff, 0x803333ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def write(io_or_file=\"chart.png\")\n return io_or_file.write(fetch) if io_or_file.respond_to?(:write)\n open(io_or_file, \"w+\") { |io| io.write(fetch) }\n end", "def load_weekly_chart\n if params[:date]\n @e_date_str = params[:date]\n e_date = Date.parse(@e_date_str)\n @week_number = e_date.cweek-0\n else\n @week_number = params[:week].to_i\n# if params[:week] then\n# @week_number = params[:week].to_i\n# else\n# @week_number = (Date.today.cweek - 0)\n# end\n end\n\n if @week_number < 0 then\n @week_number = 1\n end\n if @week_number >52 then\n @week_number = @week_number - 52\n end\n\n logger.debug \"load weekly chart called\"\n @date_range_start = Date.commercial(Date.today.cwyear, @week_number, 1).strftime \"%m/%d/%y\" # 1/19/09 (Monday)\n @date_range_end = Date.commercial(Date.today.cwyear, @week_number, 7).strftime \"%m/%d/%y\" # 1/25/09 (Sunday)\n\n reports = EffortLog.find_by_sql([\"SELECT task_types.name, users.human_name, effort_log_line_items.sum FROM effort_log_line_items inner join effort_logs on effort_log_line_items.effort_log_id = effort_logs.id inner join users on users.id = person_id inner join task_types on task_type_id = task_types.id where course_id = ? and effort_logs.week_number = ? order by name, human_name\", params[:id], @week_number])\n\n @labels_array = []\n labels_index_hash = {}\n\n reports.each do |line|\n l_human_name = line.human_name\n if !labels_index_hash.has_key?(l_human_name)\n @labels_array << l_human_name\n labels_index_hash[l_human_name] = @labels_array.size\n end\n end\n\n #unless the user is a student, move them to be the first column of data\n unless current_user && (!current_user.is_staff? && !current_user.is_admin?) then\n @labels_array.each_index do |i|\n if @labels_array[i] == current_user.human_name then\n labels_index_hash[@labels_array[0]] = i+1\n labels_index_hash[current_user.human_name] = 1\n @labels_array[i] = @labels_array[0]\n @labels_array[0] = current_user.human_name\n end\n end\n @labels_array.each_index do |i|\n if @labels_array[i] != current_user.login then\n @labels_array[i] = 'anonymous'\n end\n end\n end\n\n if request.env[\"Anonymous\"] then\n @labels_array.each_index do |i|\n @labels_array[i] = 'anonymous'\n end\n end\n\n row_width = @labels_array.size + 1 #Plus one is the for an additional first column, the \"type\" label.\n current_task = \"\"\n current_task_chart_data_row = Array.new(row_width) { |i| \"0.0\" }\n @chart_data = []\n reports.each do |line|\n if line.name == current_task\n current_task_chart_data_row[labels_index_hash[line.human_name]] = line.sum\n else\n if current_task != \"\" then\n @chart_data << current_task_chart_data_row\n current_task_chart_data_row = Array.new(row_width) { |i| \"0.0\" }\n end\n current_task = line.name\n current_task_chart_data_row[0] = line.name\n current_task_chart_data_row[labels_index_hash[line.human_name]] = line.sum\n end\n end\n @chart_data << current_task_chart_data_row\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :layout => false }\n end\n end", "def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [170, 300, 1000, 1700]\n dataY0 = [16, 69, 16, 75]\n dataZ0 = [52, 105, 88, 140]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [40, 58, 85]\n dataZ1 = [140, 202, 84]\n\n # Create a XYChart object of size 540 x 480 pixels\n c = ChartDirector::XYChart.new(540, 480)\n\n # Set the plotarea at (70, 65) and of size 400 x 350 pixels. Turn on both\n # horizontal and vertical grid lines with light grey color (0xc0c0c0)\n c.setPlotArea(70, 65, 400, 350, -1, -1, ChartDirector::Transparent, 0xc0c0c0, -1)\n\n # Add a legend box at (70, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(70, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add titles to the axes using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with red (ff3333) glass spheres, where\n # the sphere size is modulated by dataZ0. This creates a bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\",\n ChartDirector::GlassSphere2Shape, 15, 0xff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with blue (0000ff) glass spheres, where\n # the sphere size is modulated by dataZ1. This creates a bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\",\n ChartDirector::GlassSphere2Shape, 15, 0x0000ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def draw_plotly_chart(chart_div, data, title, height, width, type)\n %(\n var data = [{\n values: #{data.map(&:last)},\n labels: #{data.map{|x| fir(x)}},\n hole: #{type},\n type: 'pie'\n }];\n\n var layout = {\n title: '#{title}',\n titlefont: {\n size: 12,\n color: 'black'\n },\n height: #{height + data.size * 15}, // Each legend entry is 15 high.\n width: #{width},\n showlegend: true,\n\t legend: {\n \"orientation\": \"h\"\n }\n };\n\n Plotly.newPlot('plotly_chart_div_#{chart_div}', data, layout);\n )\nend", "def set_chart\n @chart = Chart.first\n end", "def save_report\n report = Report.create(name: @name, start_date: @start_date,\n end_date: @end_date, type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end", "def getchart()\n # Some ChartDirector built-in symbols\n symbols = [ChartDirector::CircleShape, ChartDirector::GlassSphereShape,\n ChartDirector::GlassSphere2Shape, ChartDirector::SolidSphereShape,\n ChartDirector::SquareShape, ChartDirector::DiamondShape,\n ChartDirector::TriangleShape, ChartDirector::RightTriangleShape,\n ChartDirector::LeftTriangleShape, ChartDirector::InvertedTriangleShape,\n ChartDirector::StarShape(3), ChartDirector::StarShape(4),\n ChartDirector::StarShape(5), ChartDirector::StarShape(6),\n ChartDirector::StarShape(7), ChartDirector::StarShape(8),\n ChartDirector::StarShape(9), ChartDirector::StarShape(10),\n ChartDirector::PolygonShape(5), ChartDirector::Polygon2Shape(5),\n ChartDirector::PolygonShape(6), ChartDirector::Polygon2Shape(6),\n ChartDirector::CrossShape(0.1), ChartDirector::CrossShape(0.2),\n ChartDirector::CrossShape(0.3), ChartDirector::CrossShape(0.4),\n ChartDirector::CrossShape(0.5), ChartDirector::CrossShape(0.6),\n ChartDirector::CrossShape(0.7), ChartDirector::Cross2Shape(0.1),\n ChartDirector::Cross2Shape(0.2), ChartDirector::Cross2Shape(0.3),\n ChartDirector::Cross2Shape(0.4), ChartDirector::Cross2Shape(0.5),\n ChartDirector::Cross2Shape(0.6), ChartDirector::Cross2Shape(0.7)]\n\n # Create a XYChart object of size 450 x 400 pixels\n c = ChartDirector::XYChart.new(450, 400)\n\n # Set the plotarea at (55, 40) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 40, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Built-in Symbols\", \"timesbi.ttf\", 18)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Ensure the ticks are at least 1 unit part (integer ticks)\n c.xAxis().setMinTickInc(1)\n c.yAxis().setMinTickInc(1)\n\n # Add each symbol as a separate scatter layer.\n 0.upto(symbols.length - 1) do |i|\n c.addScatterLayer([i % 6 + 1], [(i / 6 + 1).to_i], \"\", symbols[i], 15)\n end\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def bar_type=(s)\n self[:type] = s\n end", "def getPieChartDetails\r\n \t\r\n \t # Query the Table to perform the average netscore calcuations based on selections in combobox\r\n \r\n \tsentimentarray=[1,2]\r\n\t\t\t\t@piechartPositive =Feedback.count(:all, :conditions => [\"created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)\",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray]) \t\r\n\tsentimentarray=[4,5]\r\n\t\t\t\t@piechartNegative =Feedback.count(:all, :conditions => [\"created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)\",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray])\t\t\t\r\n sentimentarray=[3]\r\n\t\t\t\t@piechartNeutral =Feedback.count(:all, :conditions => [\"created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)\",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray])\t\t\t\t\r\n \r\n \t\r\n \t\r\n end", "def create\n @performance_chart = PerformanceChart.new(performance_chart_params)\n\n respond_to do |format|\n if @performance_chart.save\n format.html { redirect_to @performance_chart, notice: 'Performance chart was successfully created.' }\n format.json { render :show, status: :created, location: @performance_chart }\n else\n format.html { render :new }\n format.json { render json: @performance_chart.errors, status: :unprocessable_entity }\n end\n end\n end", "def draw_data(data_type)\n @maqj_font_data_type = data_type\n reset_font_settings\n send(:\"draw_#{data_type}\") if self.class.method_defined?(:\"draw_#{data_type}\")\n @draw_y += data_height(data_type)\n end", "def chart(reload_cache = false)\n return body.html_safe if body? && !reload_cache\n \n chart_code = nil\n \n opts = {\n :title => legend,\n :renderTo => \"chart-#{(0...16).map{65.+(rand(25)).chr}.join}\"\n }\n \n hc = Highchart.new(opts, csv)\n hc.transpose = transpose\n \n chart_code = \"<div id=\\\"#{opts[:renderTo]}\\\" style=\\\"height:#{height}px;width:#{width}px;\\\"></div>\"\n chart_code << hc.render\n\n if new_record?\n self.body = chart_code\n else\n update_attributes(:body => chart_code)\n end\n return body.html_safe\n end", "def add_series(params)\n # Check that the required input has been specified.\n raise \"Must specify ':values' in add_series\" unless params.has_key?(:values)\n\n raise \"Must specify ':categories' in add_series for this chart type\" if @requires_category != 0 && !params.has_key?(:categories)\n\n raise \"The maximum number of series that can be added to an Excel Chart is 255.\" if @series.size == 255\n\n @series << Series.new(self, params)\n\n # Set the secondary axis properties.\n x2_axis = params[:x2_axis]\n y2_axis = params[:y2_axis]\n\n # Store secondary status for combined charts.\n @is_secondary = true if ptrue?(x2_axis) || ptrue?(y2_axis)\n\n # Set the gap and overlap for Bar/Column charts.\n if params[:gap]\n if ptrue?(y2_axis)\n @series_gap_2 = params[:gap]\n else\n @series_gap_1 = params[:gap]\n end\n end\n\n # Set the overlap for Bar/Column charts.\n if params[:overlap]\n if ptrue?(y2_axis)\n @series_overlap_2 = params[:overlap]\n else\n @series_overlap_1 = params[:overlap]\n end\n end\n end", "def export_iruby(export_type='png', file_name='chart')\n IRuby.html(export(export_type, file_name))\n end", "def getchart()\n #\n # We use a random number generator to simulate the data from 9:30am to 4:30pm\n # with one data point every 4 minutes. The total number of points during that\n # period is 106. (7 hours x 15 points/hour + 1)\n #\n noOfPoints = 106\n\n # Assume we have not reached the end of the day yet, and only 85 points are\n # available. Create a random table object of 1 col x 85 rows, using 9 as seed.\n rantable = ChartDirector::RanTable.new(9, 1, 85)\n\n # Set the 1st column to start with 1800 and with random delta from -5 to 5.\n rantable.setCol(0, 1800, -5, 5)\n\n # Get the data as the 1st column of the random table\n data = rantable.getCol(0)\n\n # The x-axis labels for the chart\n labels = [\"-\", \"10am\", \"-\", \" \", \"-\", \"12am\", \"-\", \" \", \"-\", \"2pm\", \"-\", \" \", \"-\",\n \"4pm\", \"-\"]\n\n #\n # Now we obtain the data into arrays, we can start to draw the chart using\n # ChartDirector\n #\n\n # Create a XYChart object of size 180 x 180 pixels with a blue background\n # (0x9c9cce)\n c = ChartDirector::XYChart.new(180, 180, 0x9c9cce)\n\n # Add titles to the top and bottom of the chart using 7.5pt Arial font. The text\n # is white 0xffffff on a deep blue 0x31319C background.\n c.addTitle2(ChartDirector::Top, \"STAR TECH INDEX 2003-01-28\", \"arial.ttf\", 7.5,\n 0xffffff, 0x31319c)\n c.addTitle2(ChartDirector::Bottom, \"LATEST STI:1809.41 (+14.51)\", \"arial.ttf\",\n 7.5, 0xffffff, 0x31319c)\n\n # Set the plotarea at (31, 21) and of size 145 x 124 pixels, with a pale yellow\n # (0xffffc8) background.\n c.setPlotArea(31, 21, 145, 124, 0xffffc8)\n\n # Add custom text at (176, 21) (top right corner of plotarea) using 11pt Times\n # Bold Italic font/red (0xc09090) color\n c.addText(176, 21, \"Chart Demo\", \"timesbi.ttf\", 11, 0xc09090).setAlignment(\n ChartDirector::TopRight)\n\n # Use 7.5 pts Arial as the y axis label font\n c.yAxis().setLabelStyle(\"\", 7.5)\n\n # Set the labels on the x axis by spreading the labels evenly between the first\n # point (index = 0) and the last point (index = noOfPoints - 1)\n c.xAxis().setLinearScale(0, noOfPoints - 1, labels)\n\n # Use 7.5 pts Arial as the x axis label font\n c.xAxis().setLabelStyle(\"\", 7.5)\n\n # Add a deep blue (0x000080) line layer to the chart\n c.addLineLayer(data, 0x000080)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def bar_type\n self[:type]\n end", "def prepare_piechart_json(utilization_date, record, key)\n titles, ids, data, links = [], [], [], []\n involved, total = 0, 0\n if key == 'team'\n # employees = Employee.where(team_id: id)\n # FIXME_AB: avoid using unless statements unless you really need it, as discussed\n # Fixed\n record.team_leads.active_on(utilization_date).each do |team_lead| \n #FIXME_AB: avoid using unless statements unless you really need it, as discussed\n titles << team_lead.name\n total, involved = find_involvement( team_lead, utilization_date )\n data = push_data( data, total, involved )\n ids << team_lead.id \n links << view_context.link_to(team_lead.name, employee_path(team_lead) )\n end\n elsif key == 'emp'\n record.subordinates.active_on(utilization_date).each do |employee|\n titles << employee.name\n total, involved = find_involvement(employee, utilization_date)\n data = push_data(data, total, involved)\n ids << employee.id\n links << view_context.link_to(employee.name, employee_path(employee))\n end\n end\n pie_report_hash = {'ids' => ids, 'data' => data, 'titles' => titles, 'links' => links}\n return pie_report_hash\n end", "def performance_chart_data\n chart_data = {}\n new_ev = complement_evm_value @ev\n new_ac = complement_evm_value @ac\n new_pv = complement_evm_value @pv\n performance_min_date = [new_ev.keys.min,\n new_ac.keys.min,\n new_pv.keys.min].max\n performance_max_date = [new_ev.keys.max,\n new_ac.keys.max,\n new_pv.keys.max].min\n spi = {}\n cpi = {}\n cr = {}\n (performance_min_date..performance_max_date).each do |date|\n spi[date] = (new_ev[date] / new_pv[date]).round(2)\n cpi[date] = (new_ev[date] / new_ac[date]).round(2)\n cr[date] = (spi[date] * cpi[date]).round(2)\n end\n chart_data[:spi] = convert_to_chart(spi)\n chart_data[:cpi] = convert_to_chart(cpi)\n chart_data[:cr] = convert_to_chart(cr)\n chart_data\n end", "def draw(metric, *args)\n draw = chart.draw(*args)\n self.send(metric).each do |metric|\n draw.data(position: metric.first, value: metric.last)\n end\n draw.store\n end", "def chart_params\n params.require(:chart).permit(:patient_id, :doctor_id, :pages, :chart, :filename)\n end", "def get_grafico_anuncio_categoria\n\n obj1 = categoria_percent\n\n return @h = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [30, 70, 0, 70]} )\n series = {\n :type=> \"pie\",\n :name=> 'Percentagem de Anuncios por categoria',\n :data=> obj1\n }\n f.series(series)\n f.options[:title][:text] = \"Percentagem de anuncios por categoria\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"white\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\",\n :width => \"50px\",\n :height => \"50px\" \n }\n }\n })\n end\n end", "def plot(opts = {}, &block)\n\t\t\tdefault_opts = {:type => DOMAIN_COLORED_PLOT, :color => ChunkyPNG::Color::BLACK,\n\t\t\t\t:vert => DLINES, :horz => DLINES}\n\t\t\topts = default_opts.merge(opts)\n\t\t\tif opts[:type] == DOMAIN_COLORED_PLOT and @size > 0\n\t\t\t\twarn \"Warning in #{self.class}::plot: DOMAIN_COLORED_PLOT will overdraw existing #{@size} plots. Draw 1st for correct behavior.\"\n\t\t\tend\n\t\t\tcase opts[:type]\n\t\t\t\twhen DOMAIN_COLORED_PLOT then plotDCPlot(opts, &block)\n\t\t\t\twhen COMPLEX_CONTOUR_PLOT then plotCCPlot(opts, &block)\n\t\t\t\telse raise RangeError, \"Invalid plot type #{opts[:type]}.\"\n\t\t\tend\n\t\t\t@size += 1\n\t\tend", "def makeChart(*options)\n\ndisplay = \"\n<div class='charts last'>\n\n<div class='left'>\n\n\n<div id='placeholder' style='width:400px;height:200px;'></div>\n<div id='overview' style='width:400px;height:50px'></div>\n<p id='overviewLegend' style='margin-left:10px'></p>\n\n<p> Try zooming. Click and drag to select a zone.</p>\n</div>\n\n<div class='right'>\n\nWeight Chart<br/>\n<div id='miniWeight' style='width:350px;height:100px;'></div>\nWater Chart<br/>\n<div id='miniWater' style='width:350px;height:100px;'></div>\n\n\nCalories Eaten<br/>\n<div id='miniCalorie' style='width:350px;height:100px;'></div>\nFitness (Calories burned not to include resting metabolism)<br/>\n<div id='miniFitness' style='width:350px;height:100px;'></div><br/>\n\nMeasurements (Total inches)<br/>\n<div id='miniMeasures' style='width:350px;height:100px;'></div>\n\n\n</div>\n\n\n\n\n<div class='last'></div>\n<script id='source' language='javascript' type='text/javascript'>\n\n\n$(function () {\nvar options = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { \n show: true, \n container: $('#overviewLegend'),\n noColumns: 2,\n }\n};\n\nvar options_overview = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { show: false}\n};\n\n\nvar plot = $.plot($('#placeholder'), \n[ #{@chartable.to_chart } ], options);\n\n\n\n\nvar overview = $.plot($('#overview'), \n[ #{@chartable.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n\n\n\n\nvar overview_1 = $.plot($('#miniWeight'), \n[ #{@miniWeight.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_2 = $.plot($('#miniWater'), \n[ #{@miniWater.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_3 = $.plot($('#miniCalorie'), \n[ #{@miniCalorie.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_4 = $.plot($('#miniFitness'), \n[ #{@miniFitness.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_5 = $.plot($('#miniMeasures'), \n[ #{@miniMeasures.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n// now connect the two\nvar internalSelection = false;\n\n$('#placeholder').bind('selected', function (event, area) {\n // do the zooming\n plot = $.plot($('#placeholder'), \n [#{@chartable.to_chart}],\n $.extend(true, {}, options, {\n xaxis: { min: area.x1, max: area.x2 }\n }));\n \n if (internalSelection)\n return; // prevent eternal loop\n internalSelection = true;\n overview.setSelection(area);\n internalSelection = false;\n});\n\n$('#overview').bind('selected', function (event, area) {\n if (internalSelection)\n return;\n internalSelection = true;\n plot.setSelection(area);\n internalSelection = false;\n});\n\n\n});\n</script>\n\"\n\nend", "def render_chart\n assert_privileges(\"view_graph\")\n\n if params[:report]\n rpt = MiqReport.for_user(current_user).find_by(:name => params[:report])\n rpt.generate_table(:userid => session[:userid])\n else\n rpt = if session[:report_result_id]\n MiqReportResult.for_user(current_user).find(session[:report_result_id]).report_results\n elsif session[:rpt_task_id].present?\n MiqTask.find(session[:rpt_task_id]).task_results\n else\n @report\n end\n end\n\n rpt.to_chart(settings(:display, :reporttheme), true, MiqReport.graph_options)\n rpt.chart\n end" ]
[ "0.7705244", "0.76917017", "0.7567402", "0.7402535", "0.7053944", "0.63243276", "0.6097914", "0.59807354", "0.59499574", "0.5917845", "0.5887035", "0.58339185", "0.5806949", "0.57968646", "0.56917995", "0.56241626", "0.5588128", "0.5586219", "0.5519601", "0.54627264", "0.5443057", "0.5442153", "0.54142416", "0.54000956", "0.53751266", "0.53642625", "0.53611314", "0.5358646", "0.5343491", "0.53349364", "0.5291411", "0.52864164", "0.5281529", "0.5261994", "0.5224528", "0.5180921", "0.5087059", "0.5082239", "0.5045856", "0.50323606", "0.5016144", "0.49908772", "0.49782112", "0.4937857", "0.4915315", "0.4906283", "0.48938596", "0.48720402", "0.48709223", "0.4866457", "0.48625362", "0.48536742", "0.48531017", "0.48505762", "0.48447275", "0.4830677", "0.48129404", "0.48129404", "0.48129404", "0.47977203", "0.4793344", "0.4787426", "0.47779784", "0.4771709", "0.47709247", "0.47625878", "0.47537956", "0.47512916", "0.47458717", "0.4738754", "0.47166455", "0.47111416", "0.4706799", "0.47045368", "0.47034046", "0.47027972", "0.47020307", "0.470146", "0.46978238", "0.46965927", "0.46905938", "0.46835378", "0.46758613", "0.4673533", "0.46729723", "0.46679378", "0.46655634", "0.4659298", "0.46462706", "0.46184447", "0.4616895", "0.4608291", "0.46063873", "0.46017045", "0.4600565", "0.45955634", "0.45933628", "0.4592237", "0.45886177", "0.45642656" ]
0.7689753
2
_store_axisparent_stream(). Overridden. Write the AXISPARENT chart substream. A Pie chart has no X or Y axis so we override this method to remove them.
def store_axisparent_stream # :nodoc: store_axisparent(*@config[:axisparent]) store_begin store_pos(*@config[:axisparent_pos]) store_chartformat_stream store_end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_xml\n builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|\n xml.send('c:chartSpace', :'xmlns:c' => XML_NS_C, :'xmlns:a' => XML_NS_A) {\n xml[:c].date1904 :val => Axlsx::Workbook.date1904\n xml[:c].style :val=>style\n xml[:c].chart {\n @title.to_xml(xml)\n xml.autoTitleDeleted :val=>0\n @view3D.to_xml(xml) unless @view3D.nil?\n \n xml.floor { xml.thickness(:val=>0) }\n xml.sideWall { xml.thickness(:val=>0) }\n xml.backWall { xml.thickness(:val=>0) }\n xml.plotArea {\n xml.layout\n yield xml if block_given?\n }\n if @show_legend\n xml.legend {\n xml.legendPos :val => \"r\"\n xml.layout\n xml.overlay :val => 0 \n }\n end\n xml.plotVisOnly :val => 1\n xml.dispBlanksAs :val => :zero\n xml.showDLblsOverMax :val => 1\n }\n \n }\n end\n builder.to_xml(:save_with => 0)\n end", "def get_primary_axes_series\n @series.reject { |s| s.y2_axis }\n end", "def store_charts #:nodoc:\n record = 0x00EC # Record identifier\n length = 0x0000 # Bytes to follow\n \n ids = @object_ids.dup\n spid = ids.shift\n \n charts = @charts_array\n num_charts = charts.size\n \n num_filters = @filter_count\n num_comments = @comments_array\n \n # Number of objects written so far.\n num_objects = @images_array.size\n \n # Skip this if there aren't any charts.\n return if num_charts == 0\n \n (0 .. num_charts-1 ).each do |i|\n row = charts[i][0]\n col = charts[i][1]\n name = charts[i][2]\n x_offset = charts[i][3]\n y_offset = charts[i][4]\n scale_x = charts[i][5]\n scale_y = charts[i][6]\n width = 526\n height = 319\n \n width *= scale_x if scale_x.kind_of?(Numeric) && scale_x != 0\n height *= scale_y if scale_y.kind_of?(Numeric) && scale_y != 0\n \n # Calculate the positions of chart object.\n vertices = position_object( col,\n row,\n x_offset,\n y_offset,\n width,\n height\n )\n\n if (i == 0 and num_objects != 0)\n # Write the parent MSODRAWIING record.\n dg_length = 192 + 120*(num_charts -1)\n spgr_length = 168 + 120*(num_charts -1)\n \n dg_length += 96 *num_filters\n spgr_length += 96 *num_filters\n \n dg_length += 128 *num_comments\n spgr_length += 128 *num_comments\n \n \n data = store_mso_dg_container(dg_length) +\n store_mso_dg(*ids) +\n store_mso_spgr_container(spgr_length) +\n store_mso_sp_container(40) +\n store_mso_spgr() +\n store_mso_sp(0x0, spid, 0x0005)\n spid += 1\n data = data + store_mso_sp_container(112) +\n store_mso_sp(201, spid, 0x0A00)\n spid += 1\n data = data + store_mso_opt_chart() +\n store_mso_client_anchor(0, *vertices) +\n store_mso_client_data()\n else\n # Write the child MSODRAWIING record.\n data = store_mso_sp_container(112) +\n store_mso_sp(201, spid, 0x0A00)\n spid += 1\n data = data + store_mso_opt_chart() +\n store_mso_client_anchor(0, *vertices) +\n store_mso_client_data()\n end\n length = data.length\n header = [record, length].pack(\"vv\")\n append(header, data)\n \n store_obj_chart(num_objects+i+1)\n store_chart_binary(name)\n end\n\n\n # Simulate the EXTERNSHEET link between the chart and data using a formula\n # such as '=Sheet1!A1'.\n # TODO. Won't work for external data refs. Also should use a more direct\n # method.\n #\n formula = \"='#{@name}'!A1\"\n store_formula(formula)\n \n @object_ids[0] = spid\n end", "def get_primary_axes_series\n @series.reject {|s| s[:_y2_axis]}\n end", "def write_pie_chart\n @writer.tag_elements('c:pieChart') do\n # Write the c:varyColors element.\n write_vary_colors\n # Write the series elements.\n @series.each {|s| write_series(s)}\n # Write the c:firstSliceAng element.\n write_first_slice_ang\n end\n end", "def axes\n if @axes.nil? then\n # add the normal axes\n @axes = Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)\n\n # add the secondary axes if needed\n if @series.any? {|s| !s.on_primary_axis} then\n if @axes[:sec_cat_axis].nil? then\n @axes.add_axis(:sec_cat_axis, Axlsx::CatAxis)\n sec_cat_axis = @axes[:sec_cat_axis]\n sec_cat_axis.ax_pos = :b\n sec_cat_axis.delete = 1\n sec_cat_axis.gridlines = false\n end\n if @axes[:sec_val_axis].nil? then\n @axes.add_axis(:sec_val_axis, Axlsx::ValAxis)\n sec_val_axis = @axes[:sec_val_axis]\n sec_val_axis.ax_pos = :r\n sec_val_axis.gridlines = false\n sec_val_axis.crosses = :max\n end\n end\n end\n\n # return\n @axes\n end", "def added_signal_parent(parent, info) # :nodoc:\n super\n parent.if_unreachable(cancel_at_emission: true) do |reason, event|\n if !emitted? && each_parent_object(EventStructure::Signal).all?(&:unreachable?)\n unreachable!(reason || parent)\n end\n end\n end", "def to_xml(xml)\n xml[:c].serAx {\n super(xml)\n xml[:c].tickLblSkip :val=>@tickLblSkip unless @tickLblSkip.nil?\n xml[:c].tickMarkSkip :val=>@tickMarkSkip unless @tickMarkSkip.nil?\n }\n end", "def serie\n Allocine::Serie.new(document[\"parentSeries\"][\"code\"])\n end", "def axes_series(params)\n if params[:primary_axes] == 0\n secondary_axes_series\n else\n primary_axes_series\n end\n end", "def axes_series(params)\n if params[:primary_axes] != 0\n primary_axes_series\n else\n secondary_axes_series\n end\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_object_value(\"axes\", @axes)\n writer.write_object_value(\"dataLabels\", @data_labels)\n writer.write_object_value(\"format\", @format)\n writer.write_object_value(\"height\", @height)\n writer.write_object_value(\"left\", @left)\n writer.write_object_value(\"legend\", @legend)\n writer.write_string_value(\"name\", @name)\n writer.write_collection_of_object_values(\"series\", @series)\n writer.write_object_value(\"title\", @title)\n writer.write_object_value(\"top\", @top)\n writer.write_object_value(\"width\", @width)\n writer.write_object_value(\"worksheet\", @worksheet)\n end", "def sub_charts\n @sub_charts\n end", "def write_chart_type\n # Write the c:barChart element.\n write_line_chart\n end", "def _UNDO_setParent(iParentTag)\n @Parent = iParentTag\n end", "def to_xml\n inner = String.new\n inner_builder = Builder::XmlMarkup.new(:target => inner, :indent => 2)\n \n # create the XML for the inner \"categories\" element(s)\n inner_builder.tag!(\"categories\") do\n categories.each do |category|\n inner_builder << category.to_xml\n end\n end\n \n # create the XML for the inner \"dataset\" element(s)\n inner_builder.tag!(\"dataset\") do\n dataSets.each do |dataset|\n inner_builder << dataset.to_xml\n end\n end\n \n # create the XML for this chart, including attributes defined in the Base chart type\n result = super(nil, inner)\n \n result\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_object_value(\"parentNotebook\", @parent_notebook)\n writer.write_object_value(\"parentSectionGroup\", @parent_section_group)\n writer.write_collection_of_object_values(\"sectionGroups\", @section_groups)\n writer.write_string_value(\"sectionGroupsUrl\", @section_groups_url)\n writer.write_collection_of_object_values(\"sections\", @sections)\n writer.write_string_value(\"sectionsUrl\", @sections_url)\n end", "def write_plot_area\n @writer.tag_elements('c:plotArea') do\n # Write the c:layout element.\n write_layout\n # Write the subclass chart type element.\n write_chart_type\n end\n end", "def clear!\n @active_subplot.clear!\n end", "def delete_x_axis\n self.GetXaxis.SetLabelOffset(999)\n self.GetXaxis.SetTitleOffset(999)\n end", "def atfork_parent # :nodoc:\n @to_io = @to_io.close\n end", "def write_chart_type(params = {})\n # Write the c:areaChart element.\n write_pie_chart\n end", "def delete_chart(chart_index)\n begin\n if(@filename=='')\n raise \"Base file not specified\"\n end\n if(@worksheetname=='')\n raise \"Worksheet is not specified\"\n end\n str_uri = $productURI + \"/cells/\" + @filename + \"/worksheets/\" + @worksheetname + \"/charts/\" + chart_index.to_s\n signed_uri = Common::Utils.sign(str_uri)\n \n response = RestClient.delete signed_uri, {:accept => 'application/json'}\n v_output = Common::Utils.validate_output(response)\n if(v_output==nil || v_output=='')\n folder = SaasposeStorage::Folder.new\n outputstream = folder.getfile(@filename)\n outputstream\n outputpath = $OutPutLocation + @filename\n Common::Utils.saveFile(outputstream, outputpath)\n return \"Chart deleted\"\n else\n return v_output\n end\n rescue Exception=>e\n print e\n end\n end", "def parent_shape_containers\n if @parent_shape_containers.nil?\n if parent.is_a?(Drawable)\n @parent_shape_containers = []\n elsif !parent.container?\n @parent_shape_containers = parent.parent_shape_containers\n else\n @parent_shape_containers = parent.parent_shape_containers + [parent]\n end\n end\n @parent_shape_containers\n end", "def draw_child(page, prefix, parent_is_tail)\n connecting_pipe = parent_is_tail ? SPACE_PIPE : VERTICAL_PIPE\n draw(page, \"#{prefix}#{connecting_pipe}\", false)\n end", "def parent_shape_composites\n if @parent_shape_composites.nil?\n if parent.is_a?(Drawable)\n @parent_shape_composites = []\n elsif !parent.container?\n @parent_shape_composites = parent.parent_shape_composites\n else\n @parent_shape_composites = parent.parent_shape_composites + [parent]\n end\n end\n @parent_shape_composites\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_object_value(\"format\", @format)\n writer.write_string_value(\"position\", @position)\n writer.write_string_value(\"separator\", @separator)\n writer.write_boolean_value(\"showBubbleSize\", @show_bubble_size)\n writer.write_boolean_value(\"showCategoryName\", @show_category_name)\n writer.write_boolean_value(\"showLegendKey\", @show_legend_key)\n writer.write_boolean_value(\"showPercentage\", @show_percentage)\n writer.write_boolean_value(\"showSeriesName\", @show_series_name)\n writer.write_boolean_value(\"showValue\", @show_value)\n end", "def write_cat_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n\n # if there are no axis_ids then we don't need to write this element\n return unless axis_ids\n return if axis_ids.empty?\n\n position = @cat_axis_position\n horiz = @horiz_cat_axis\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis[:_position] || position\n\n @writer.tag_elements('c:catAx') do\n write_axis_id(axis_ids[0])\n # Write the c:scaling element.\n write_scaling(x_axis[:_reverse])\n\n write_delete(1) unless ptrue?(x_axis[:_visible])\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis[:_reverse])\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis[:_major_gridlines])\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis[:_minor_gridlines])\n\n # Write the axis title elements.\n if title = x_axis[:_formula]\n write_title_formula(title, @x_axis[:_data_id], horiz, @x_axis[:_name_font])\n elsif title = x_axis[:_name]\n write_title_rich(title, horiz, x_axis[:_name_font])\n end\n\n # Write the c:numFmt element.\n write_cat_number_format(x_axis)\n\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis[:_major_tick_mark])\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis[:_label_position])\n\n # Write the axis font elements.\n write_axis_font(x_axis[:_num_font])\n\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n if @show_crosses || ptrue?(x_axis[:_visible])\n write_crossing(y_axis[:_crossing])\n end\n # Write the c:auto element.\n write_auto(1)\n # Write the c:labelAlign element.\n write_label_align('ctr')\n # Write the c:labelOffset element.\n write_label_offset(100)\n end\n end", "def draw(stream)\n @xml = Builder::XmlMarkup.new(:target=>stream, :indent=>2)\n @xml.instruct!\n @xml.declare! :DOCTYPE, :svg, :PUBLIC, \"-//W3C//DTD SVG 1.1//EN\", \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"\n @xml.svg(:width=>\"#{PHYSICAL_WIDTH}#{PHYSICAL_UNITS}\",\n :height=>\"#{PHYSICAL_HEIGHT}#{PHYSICAL_UNITS}\",\n :viewBox=>\"#{MIN_X} #{MIN_Y} #{WIDTH} #{HEIGHT}\",\n :xmlns=>NAMESPACE,\n :version=>VERSION) do |page|\n @slist.each_with_index do |series, i|\n page.g(:transform=>\"translate(#{MARGIN}, #{i * @spacing})\") do |panel|\n panel.g(:transform=>\"scale(#{@yscale})\") do |caption|\n caption.text(:x=>\"-#{TSIZE}\",\n :y=>\"#{MARGIN}\",\n :'font-size'=>\"#{TSIZE}\",\n :'font-family'=>\"Verdana\",\n :'text-anchor'=>\"end\") do |textlabel|\n textlabel.text! series.name\n end\n end\n widthscale = Float(WIDTH - MARGIN)/series.total\n boxdepth = DEPTH/widthscale\n panel.g(:transform=>\"scale(#{widthscale})\") do |core|\n core.rect(:x=>\"0\", :y=>\"0\", :width=>\"#{series.total}\", :height=>\"#{boxdepth}\", :fill=>\"goldenrod\")\n cx = (-series.offset).to_s\n series.rings.inject(0) do |x, ring|\n ring_width, ring_start = ring\n ew_width = 0.75 * ring_width\n r_e, r_w = ring_start + ew_width, ring_start + ring_width\n p_a_x, p_b_x = x + ew_width, x + ring_width\n data = \"M#{p_a_x},0 H#{p_b_x} A#{r_w},#{r_w} 0 0,1 \"\n data << case\n when r_w <= boxdepth\n p_c_y, p_d_y = Math.sqrt(r_w**2 - series.offset**2), Math.sqrt(r_e**2 - series.offset**2)\n \"0,#{p_c_y} V#{p_d_y} A#{r_e},#{r_e} 0 0,0 \"\n when r_e > boxdepth && Math.sqrt(r_e**2 - boxdepth**2) > series.offset\n p_c_x, p_d_x = Math.sqrt(r_w**2 - boxdepth**2) - series.offset, Math.sqrt(r_e**2 - boxdepth**2) - series.offset\n \"#{p_c_x},#{boxdepth} H#{p_d_x} A#{r_e},#{r_e} 0 0,0 \"\n when Math.sqrt(r_w**2 - boxdepth**2) <= series.offset\n p_c_y, p_d_y = Math.sqrt(r_w**2 - series.offset**2), Math.sqrt(r_e**2 - series.offset**2)\n \"0,#{p_c_y} V#{p_d_y} A#{r_e},#{r_e} 0 0,0 \"\n else\n p_c_x, = Math.sqrt(r_w**2 - boxdepth**2) - series.offset\n p_d_y = Math.sqrt(r_e**2 - series.offset**2)\n \"#{p_c_x},#{boxdepth} H0 V#{p_d_y} A#{r_e},#{r_e} 0 0,0 \"\n end\n data << \"#{p_a_x},0 Z\"\n core.path(:d=>data, :'stroke'=>\"none\", :fill=>\"saddlebrown\")\n p_b_x\n end\n end\n end\n end\n end\n end", "def use_axes=(pagesettings)\n end", "def parent_shapes\n if @parent_shapes.nil?\n if parent.is_a?(Drawable)\n @parent_shapes = []\n else\n @parent_shapes = parent.parent_shapes + [parent]\n end\n end\n @parent_shapes\n end", "def write_chart_type # :nodoc:\n end", "def write_chart_type; end", "def axes=(value)\n @axes = value\n end", "def add_frame_output(parent, property, output)\n if parent.is_a?(Hash)\n parent[property] ||= []\n parent[property] << output\n else\n parent << output\n end\n end", "def write_cat_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n\n # if there are no axis_ids then we don't need to write this element\n return unless axis_ids\n return if axis_ids.empty?\n\n position = @cat_axis_position\n is_y_axis = @horiz_cat_axis\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis.position || position\n\n @writer.tag_elements('c:catAx') do\n write_axis_id(axis_ids[0])\n # Write the c:scaling element.\n write_scaling(x_axis.reverse)\n\n write_delete(1) unless ptrue?(x_axis.visible)\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis.reverse)\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis.major_gridlines)\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis.minor_gridlines)\n\n # Write the axis title elements.\n if x_axis.formula\n write_title_formula(x_axis, is_y_axis, @x_axis, x_axis.layout)\n elsif x_axis.name\n write_title_rich(x_axis, is_y_axis, x_axis.name_font, x_axis.layout)\n end\n\n # Write the c:numFmt element.\n write_cat_number_format(x_axis)\n\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis.major_tick_mark)\n\n # Write the c:minorTickMark element.\n write_minor_tick_mark(x_axis.minor_tick_mark)\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis.label_position)\n\n # Write the c:spPr element for the axis line.\n write_sp_pr(x_axis)\n\n # Write the axis font elements.\n write_axis_font(x_axis.num_font)\n\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n write_crossing(y_axis.crossing) if @show_crosses || ptrue?(x_axis.visible)\n # Write the c:auto element.\n write_auto(1) unless x_axis.text_axis\n # Write the c:labelAlign element.\n write_label_align(x_axis.label_align)\n # Write the c:labelOffset element.\n write_label_offset(100)\n # Write the c:tickLblSkip element.\n write_tick_lbl_skip(x_axis.interval_unit)\n # Write the c:tickMarkSkip element.\n write_tick_mark_skip(x_axis.interval_tick)\n end\n end", "def axes(*)\n super\n end", "def on_axis_parent(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |context_node|\n next unless has_parent?(context_node)\n\n parent = context_node.parent\n\n nodes << parent if node_matches?(parent, ast_node)\n end\n\n return nodes\n end", "def set_pseudo_parent_if_applicable\n if custom_slideshow?\n # NOTE inherited_resources default #parent? looks at @parent_type to determine if there is a parent\n @parent_type = :slideshow\n @slideshow = Slideshow.new(:title => custom_slideshow_title, :pseudo_slides => collection)\n end\n end", "def assemble_xml_file # :nodoc:\n @writer.xml_decl\n\n # Write the c:chartSpace element.\n write_chart_space do\n\n # Write the c:lang element.\n write_lang\n\n # Write the c:style element.\n write_style\n\n # Write the c:protection element.\n write_protection\n\n # Write the c:chart element.\n write_chart\n\n # Write the c:spPr element for the chartarea formatting.\n write_sp_pr(@chartarea)\n\n # Write the c:printSettings element.\n write_print_settings if @embedded && @embedded != 0\n end\n\n # Close the XML writer object and filehandle.\n @writer.crlf\n @writer.close\n end", "def write_container_xml\n File.write(path('epub/META-INF/container.xml'), container_xml)\n end", "def save\n result = Base.redis.hset(:charts, self.name, Marshal.dump(self))\n Log.debug \"Saving Chart object to Redis: #{self.name}\"\n result\n end", "def add_chart(chartType, upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn)\n begin\n if(@filename=='')\n raise \"Base file not specified\"\n end\n if(@worksheetname=='')\n raise \"Worksheet is not specified\"\n end\n str_uri = $productURI + \"/cells/\" + @filename + \"/worksheets/\" + @worksheetname + \"/charts?chartType=\" +\n chartType.to_s + \"&upperLeftRow=\" + upperLeftRow.to_s + \"&upperLeftColumn=\" +\n upperLeftColumn.to_s + \"&lowerRightRow=\" + lowerRightRow.to_s + \n \"&lowerRightColumn=\" + lowerRightColumn.to_s\n signed_uri = Common::Utils.sign(str_uri)\n \n response = RestClient.put signed_uri,'', {:accept => 'application/json'}\n v_output = Common::Utils.validate_output(response)\n if(v_output==nil || v_output=='')\n folder = SaasposeStorage::Folder.new\n outputstream = folder.getfile(@filename)\n outputstream\n outputpath = $OutPutLocation + @filename\n Common::Utils.saveFile(outputstream, outputpath)\n return \"Chart added\"\n else\n return v_output\n end\n rescue Exception=>e\n print e\n end\n end", "def delete_orphan_spektrix_events\n @spektrix_event_ids = @spektrix_events.collect {|e| e.id.to_i}\n @rooftop_event_ids = @rooftop_events.inject({}) do |hash, e|\n hash[e.id] = e.meta_attributes[:spektrix_id].to_i\n hash\n end\n @rooftop_event_ids.reject! {|k,v| v == 0} #remove events with no spektrix ID; we don't want to remove them.\n spektrix_ids_to_delete = (@rooftop_event_ids.values - (@rooftop_event_ids.values & @spektrix_event_ids))\n rooftop_ids_to_delete = @rooftop_event_ids.select {|k,v| spektrix_ids_to_delete.include?(v)}.keys\n Rooftop::Events::Event.where(post__in: rooftop_ids_to_delete).each do |rooftop_event|\n title = rooftop_event.title\n if rooftop_event.destroy\n @logger.info(\"[spektrix] Removed Rooftop event #{title} which doesn't exist in Spektrix\")\n end\n end\n end", "def clear_figure!\n @subplots_list = [Rubyplot::SubPlot.new(1, 1, 1)]\n @no_subplot = true\n @tasks = []\n @x_title = ''\n @y_title = ''\n @x_range = [0, 0]\n @y_range = [0, 0]\n @origin = [0, 0]\n @x_tick_count = :default\n @y_tick_count = :default\n @title = nil\n @title_shift = 0\n @text_font = :default\n @grid = true\n @bounding_box = true\n @x_axis_padding = :default\n @y_axis_padding = :default\n @active_subplot = @subplots_list[0]\n end", "def generate_piechartXML(*args)\n begin\n #color_hash is used to store default colors for pie-chart\n @aes = AESSecurity.new()\n @color_hash=Hash.new\n @keywordcolor_hash=Hash.new\n @pieRadius=\"pieRadius='100'\"\n @color_hash={\"0\"=>\"0C95BF\",\"1\"=>\"12C400\",\"2\"=>\"ECB800\",\"3\"=>\"EB2300\",\"4\"=>\"70808F\",\"5\"=>\"000000\",\"6\"=>\"800080\",\"7\"=>\"FFFF00\",\"8\"=>\"0377CA\"}\n if @@flag==true #checks whether the flag is true to add root xml element.\n @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' plotGradientColor='' showShadow='0' showLabels='#{args[3]}' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='#{args[3]}' decimals='0' isSliced='0' enableSmartLabels='#{args[3]}' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' showPercentageValues='1' #{args[3].to_i==1 ? @pieRadius : \"\"} >\" if args[2]!='keywords'&& args[2]!='url' # this root xml element is used only for channel and handset pie-chart.\n @@flag=false #set flag as false\n end\n \n key='rh21nr8e0vav0h0v'\n iv='1pnee1ng36nuare8'\n getsymbol={\"&\"=>\"%7E\",\"%\"=>\"%25\"}\n args[0]=(args[0]=='' || args[0]==nil) ? 'Unknown' : args[0]\n #url_model=(args[2]=='handset') ? (args[0]!='Others' && args[0]!='Unknown') ? \"link='/#{args[4]}/publisher_handset_model%3Fhandset=#{args[0].to_s.gsub(/([&%])/) do|s| getsymbol[\"#{s}\"] end}'\" : \"\" : \"\"\n colour=@color_hash[\"#{@@color_count}\"] #get the color \n @@strXML+=\"<set label='#{args[0].to_s.gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end}' value='#{args[1].to_s}' color='#{colour.to_s}'/>\" if args[2]!='url'\n @@date_count+=args[1].to_i #increment the counter value\n @@XML_array[@@color_count]=[\"#{args[0]}\",args[1].to_i,colour,@@date_count] if args[2]!='handset_model' #store the label,value and color in the array \n @@color_count+=1\n \n rescue Exception=>e\n puts \"ERROR :: in ReportGenerator Component and generate_piechartXML method. The Error is #{e.to_s}\"\n end\n end", "def write_epilogue\n @max_depth = @options[:max_depth] || 3\n\n self.reset\n\n log_debug(\"\\nserialize: repo:\") {repo.size}\n\n preprocess\n\n start_document\n\n @formula_names = repo.graph_names(unique: true)\n\n with_graph(nil) do\n count = 0\n order_subjects.each do |subject|\n unless is_done?(subject)\n statement(subject, count)\n count += 1\n end\n end\n\n # Output any formulae not already serialized using owl:sameAs\n formula_names.each do |graph_name|\n next if graph_done?(graph_name)\n\n # Add graph_name to @formulae\n @formulae[graph_name] = true\n\n log_debug {\"formula(#{graph_name})\"}\n @output.write(\"\\n#{indent}\")\n p_term(graph_name, :subject)\n @output.write(\" \")\n predicate(RDF::OWL.sameAs)\n @output.write(\" \")\n formula(graph_name, :graph_name)\n @output.write(\" .\\n\")\n end\n end\n\n super\n end", "def set_fedora_obsolete_parent_digital_object_pid_relationships\n # This method also ensures that we only save pids for Objects that actually exist. Invalid pids will cause it to fail.\n values = @parent_digital_object_pids.map { |object_pid| ActiveFedora::Base.find(object_pid).internal_uri }\n set_fedora_object_relationship(:cul_obsolete_from, values)\n end", "def getchart()\n # Sample data for the Box-Whisker chart. Represents the minimum, 1st quartile,\n # medium, 3rd quartile and maximum values of some quantities\n q0Data = [40, 45, 40, 30, 20, 50, 25, 44]\n q1Data = [55, 60, 50, 40, 38, 60, 51, 60]\n q2Data = [62, 70, 60, 50, 48, 70, 62, 70]\n q3Data = [70, 80, 65, 60, 53, 78, 69, 76]\n q4Data = [80, 90, 75, 70, 60, 85, 80, 84]\n\n # The labels for the chart\n labels = [\"Group A\", \"Group B\", \"Group C\", \"Group D\", \"Group E\", \"Group F\",\n \"Group G\", \"Group H\"]\n\n # Create a XYChart object of size 550 x 250 pixels\n c = ChartDirector::XYChart.new(550, 250)\n\n # Set the plotarea at (50, 25) and of size 450 x 200 pixels. Enable both\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 25, 450, 200).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart\n c.addTitle(\"Computer Vision Test Scores\")\n\n # Set the labels on the x axis and the font to Arial Bold\n c.xAxis().setLabels(labels).setFontStyle(\"arialbd.ttf\")\n\n # Set the font for the y axis labels to Arial Bold\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # Add a Box Whisker layer using light blue 0x9999ff as the fill color and blue\n # (0xcc) as the line color. Set the line width to 2 pixels\n c.addBoxWhiskerLayer(q3Data, q1Data, q4Data, q0Data, q2Data, 0x9999ff, 0x0000cc\n ).setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def suppress_parents container, ancestor # :nodoc:\n while container and container != ancestor do\n container.suppress unless container.documented?\n container = container.parent\n end\n end", "def write_date_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n\n return unless axis_ids && !axis_ids.empty?\n\n position = @cat_axis_position\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis[:_position] || position\n\n @writer.tag_elements('c:dateAx') do\n write_axis_id(axis_ids[0])\n # Write the c:scaling element.\n write_scaling_with_param(x_axis)\n\n write_delete(1) unless ptrue?(x_axis[:_visible])\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis[:reverse])\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis[:_major_gridlines])\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis[:_minor_gridlines])\n\n # Write the axis title elements.\n if title = x_axis[:_formula]\n write_title_formula(title, x_axis[:_data_id], nil, x_axis[:_name_font])\n elsif title = x_axis[:_name]\n write_title_rich(title, nil, x_axis[:_name_font])\n end\n # Write the c:numFmt element.\n write_number_format(x_axis)\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis[:_major_tick_mark])\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis[:_label_position])\n # Write the font elements.\n write_axis_font(x_axis[:_num_font])\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n if @show_crosses || ptrue?(x_axis[:_visible])\n write_crossing(y_axis[:_crossing])\n end\n\n # Write the c:auto element.\n write_auto(1)\n # Write the c:labelOffset element.\n write_label_offset(100)\n # Write the c:majorUnit element.\n write_c_major_unit(x_axis[:_major_unit])\n # Write the c:majorTimeUnit element.\n if !x_axis[:_major_unit].nil?\n write_c_major_time_unit(x_axis[:_major_unit_type])\n end\n # Write the c:minorUnit element.\n write_c_minor_unit(x_axis[:_minor_unit])\n # Write the c:minorTimeUnit element.\n if !x_axis[:_minor_unit].nil?\n write_c_minor_time_unit(x_axis[:_minor_unit_type])\n end\n end\n end", "def active_charts\n @@active_charts\n end", "def write_date_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n\n return unless axis_ids && !axis_ids.empty?\n\n position = @cat_axis_position\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis.position || position\n\n @writer.tag_elements('c:dateAx') do\n write_axis_id(axis_ids[0])\n # Write the c:scaling element.\n write_scaling_with_param(x_axis)\n\n write_delete(1) unless ptrue?(x_axis.visible)\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis.reverse)\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis.major_gridlines)\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis.minor_gridlines)\n\n # Write the axis title elements.\n if x_axis.formula\n write_title_formula(x_axis, nil, nil, x_axis.layout)\n elsif x_axis.name\n write_title_rich(x_axis, nil, x_axis.name_font, x_axis.layout)\n end\n # Write the c:numFmt element.\n write_number_format(x_axis)\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis.major_tick_mark)\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis.label_position)\n # Write the c:spPr element for the axis line.\n write_sp_pr(x_axis)\n # Write the font elements.\n write_axis_font(x_axis.num_font)\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n write_crossing(y_axis.crossing) if @show_crosses || ptrue?(x_axis.visible)\n\n # Write the c:auto element.\n write_auto(1)\n # Write the c:labelOffset element.\n write_label_offset(100)\n # Write the c:tickLblSkip element.\n write_tick_lbl_skip(x_axis.interval_unit)\n # Write the c:tickMarkSkip element.\n write_tick_mark_skip(x_axis.interval_tick)\n # Write the c:majorUnit element.\n write_c_major_unit(x_axis.major_unit)\n # Write the c:majorTimeUnit element.\n write_c_major_time_unit(x_axis.major_unit_type) if x_axis.major_unit\n # Write the c:minorUnit element.\n write_c_minor_unit(x_axis.minor_unit)\n # Write the c:minorTimeUnit element.\n write_c_minor_time_unit(x_axis.minor_unit_type) if x_axis.minor_unit\n end\n end", "def write(io_handle, indent=-1, transitive=false, ie_hack=false)\n options = {:indent => (indent >= 0 ? indent : 0)}\n\n if String === io_handle\n io_handle.replace(self.to_xml(options))\n else\n io_handle << self.to_xml(options)\n end\n end", "def visit(sc, suppress_transform = false)\n sc.slices << self unless suppress_transform\n end", "def plot_visible_only=(v) Axlsx.validate_boolean(v); @plot_visible_only = v; end", "def test_flatten\r\n ax = Ziya::Components::ChartPref.new\r\n ax.point_shape = \"circle\"\r\n ax.fill_shape = true\r\n ax.reverse = true\r\n ax.type = \"body\"\r\n ax.line_thickness = 10\r\n ax.bull_color = \"ff0000\"\r\n ax.bear_color = \"00ff00\"\r\n ax.point_size = 5\r\n ax.point_shape = \"square\"\r\n ax.trend_thickness = 10\r\n ax.trend_alpha = 50\r\n ax.line_alpha = 100\r\n ax.rotation_x = 90\r\n ax.rotation_y = -90\r\n ax.grid = \"linear\"\r\n \r\n xml = Builder::XmlMarkup.new\r\n ax.flatten( xml )\r\n result = xml.to_s\r\n check_results( result.gsub( /<to_s\\/>/, ''), \r\n File.join( File.expand_path( \".\" ), \"/test/xmls/chart_pref.xml\" ) )\r\n end", "def parent=(new_parent_node)\n orphan_me\n @parent = new_parent_node\n unless @parent.nil?\n siblings = @parent.children\n siblings << self unless siblings.include?(self)\n end\n end", "def gen_xml \n @xml = Builder::XmlMarkup.new\n @parent_categories = CptCategory.find(:all, :conditions => [\"parent_id = 1002795\"])\n render :layout => false\n end", "def show_x_axis\n false\n end", "def child_objects\n charts + images + hyperlinks\n end", "def subfigure_cleanup(xmldoc)\n xmldoc.xpath(\"//example[figure]\").each do |e|\n next unless e.elements.map(&:name).reject do |m|\n %w(name figure).include? m\n end.empty?\n\n e.name = \"figure\"\n end\n end", "def add_chart(params = {})\n # Type must be specified so we can create the required chart instance.\n type = params[:type]\n embedded = params[:embedded]\n name = params[:name]\n raise \"Must define chart type in add_chart()\" unless type\n\n chart = Chart.factory(type, params[:subtype])\n chart.palette = @palette\n\n # If the chart isn't embedded let the workbook control it.\n if ptrue?(embedded)\n chart.name = name if name\n\n # Set index to 0 so that the activate() and set_first_sheet() methods\n # point back to the first worksheet if used for embedded charts.\n chart.index = 0\n chart.set_embedded_config_data\n else\n # Check the worksheet name for non-embedded charts.\n sheetname = check_chart_sheetname(name)\n chartsheet = Chartsheet.new(self, @worksheets.size, sheetname)\n chartsheet.chart = chart\n @worksheets << chartsheet\n end\n @charts << chart\n ptrue?(embedded) ? chart : chartsheet\n end", "def display_charts(is_reload)\n @entries.each_with_index do |entry, i|\n break if i == Cfg.max_items\n iter = is_reload ? @lsc.get_iter(i.to_s) : @lsc.append\n iter[COL_RANK] = entry.rank #.to_s\n if @count_type == COUNT_PLAYED\n iter[COL_PLAYED] = entry.played.to_s\n else\n if view_tracks_or_records?\n iter[COL_PLAYED] = entry.played.to_hr_length\n else\n iter[COL_PLAYED] = entry.played.to_day_length\n end\n end\n iter[COL_REF] = entry.ref\n iter[COL_PIX] = entry.pix\n iter[COL_TEXT] = entry.title\n end\n end", "def destroy\n super do\n graph.delete [source.to_term, nil, nil]\n parent.delete [parent, nil, source.to_term]\n end\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_object_value(\"cumulative\", @cumulative)\n writer.write_object_value(\"z\", @z)\n writer.write_additional_data(@additional_data)\n end", "def clear\n super\n __wx_item_data.clear\n end", "def assemble_xml_file # :nodoc:\n write_xml_declaration do\n # Write the c:chartSpace element.\n write_chart_space do\n # Write the c:lang element.\n write_lang\n # Write the c:style element.\n write_style\n # Write the c:protection element.\n write_protection\n # Write the c:chart element.\n write_chart\n # Write the c:spPr element for the chartarea formatting.\n write_sp_pr(@chartarea)\n # Write the c:printSettings element.\n write_print_settings if @embedded && @embedded != 0\n end\n end\n end", "def axes\n @axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)\n end", "def show\n unless parent.chart\n parent.update_attributes chart: Chart.find_or_create(parent.dob)\n end\n @chart = parent.chart\n @name = parent.full_name\n\n @chart = Chart.find(params[:id])\n respond_with(@chart)\n \n respond_to do |format|\n format.html\n # format.html { render :layout => 'chart' }\n format.pdf {\n pdf = ChartPdf.new(@chart, @name, view_context)\n send_data pdf.render, filename: \"#{parent.friendly_id}-natal-chart.pdf\", type: \"application/pdf\", disposition: 'inline'\n }\n end\n end", "def index\n @graphic_frame.anchor.drawing.worksheet.workbook.charts.index(self)\n end", "def index\n @graphic_frame.anchor.drawing.worksheet.workbook.charts.index(self)\n end", "def drawChart()\n # The moving average periods selected by the user.\n avgPeriod1 = 0\n avgPeriod1 = params[\"movAvg1\"].to_i\n avgPeriod2 = 0\n avgPeriod2 = params[\"movAvg2\"].to_i\n\n if avgPeriod1 < 0\n avgPeriod1 = 0\n elsif avgPeriod1 > 300\n avgPeriod1 = 300\n end\n\n if avgPeriod2 < 0\n avgPeriod2 = 0\n elsif avgPeriod2 > 300\n avgPeriod2 = 300\n end\n\n # We need extra leading data points in order to compute moving averages.\n extraPoints = 20\n if avgPeriod1 > extraPoints\n extraPoints = avgPeriod1\n end\n if avgPeriod2 > extraPoints\n extraPoints = avgPeriod2\n end\n\n # Get the data series to compare with, if any.\n compareKey = (params[\"CompareWith\"] || \"\").strip\n @compareData = nil\n if getData(compareKey, extraPoints)\n @compareData = @closeData\n end\n\n # The data series we want to get.\n tickerKey = (params[\"TickerSymbol\"] || \"\").strip\n if !getData(tickerKey, extraPoints)\n return errMsg(\"Please enter a valid ticker symbol\")\n end\n\n \n\n # Check if there is any valid data\n if extraPoints >= @timeStamps.length\n # No data - just display the no data message.\n return errMsg(\"No data available for the specified time period\")\n end\n\n # In some finance chart presentation style, even if the data for the latest day is\n # not fully available, the axis for the entire day will still be drawn, where no\n # data will appear near the end of the axis.\n # if @resolution < 86400\n # # Add extra points to the axis until it reaches the end of the day. The end of\n # # day is assumed to be 16:00 (it depends on the stock exchange).\n # lastTime = @timeStamps[@timeStamps.length - 1]\n # extraTrailingPoints = ((16 * 3600 - lastTime % 86400) / @resolution).to_i\n # 0.upto(extraTrailingPoints - 1) do |i|\n # @timeStamps.push(lastTime + @resolution * (i + 1))\n # end\n # end\n\n #\n # At this stage, all data are available. We can draw the chart as according to\n # user input.\n #\n\n #\n # Determine the chart size. In this demo, user can select 4 different chart sizes.\n # Default is the large chart size.\n #\n width = 780\n mainHeight = 255\n indicatorHeight = 80\n\n size = params[\"ChartSize\"]\n if size == \"S\"\n # Small chart size\n width = 450\n mainHeight = 160\n indicatorHeight = 60\n elsif size == \"M\"\n # Medium chart size\n width = 620\n mainHeight = 215\n indicatorHeight = 70\n elsif size == \"H\"\n # Huge chart size\n width = 1000\n mainHeight = 320\n indicatorHeight = 90\n end\n\n # Create the chart object using the selected size\n m = ChartDirector::FinanceChart.new(width)\n\n # Set the data into the chart object\n m.setData(@timeStamps, @highData, @lowData, @openData, @closeData, @volData,\n extraPoints)\n #debugger\n #\n # We configure the title of the chart. In this demo chart design, we put the\n # company name as the top line of the title with left alignment.\n #\n m.addPlotAreaTitle(ChartDirector::TopLeft, tickerKey)\n\n # We displays the current date as well as the data resolution on the next line.\n resolutionText = \"\"\n if @resolution == 30 * 86400\n resolutionText = \"Monthly\"\n elsif @resolution == 7 * 86400\n resolutionText = \"Weekly\"\n elsif @resolution == 86400\n resolutionText = \"Daily\"\n elsif @resolution == 900\n resolutionText = \"15-min\"\n end\n\n m.addPlotAreaTitle(ChartDirector::BottomLeft, sprintf(\n \"<*font=arial.ttf,size=8*>%s - %s chart\", m.formatValue(Time.new,\n \"mmm dd, yyyy\"), resolutionText))\n\n # A copyright message at the bottom left corner the title area\n m.addPlotAreaTitle(ChartDirector::BottomRight,\n \"<*font=arial.ttf,size=8*>(c) Advanced Software Engineering\")\n\n #\n # Add the first techical indicator according. In this demo, we draw the first\n # indicator on top of the main chart.\n #\n addIndicator(m, params[\"Indicator1\"], indicatorHeight)\n\n #\n # Add the main chart\n #\n m.addMainChart(mainHeight)\n\n #\n # Set log or linear scale according to user preference\n #\n if params[\"LogScale\"] == \"1\"\n m.setLogScale(true)\n end\n\n #\n # Set axis labels to show data values or percentage change to user preference\n #\n if params[\"PercentageScale\"] == \"1\"\n m.setPercentageAxis()\n end\n\n #\n # Draw any price line the user has selected\n #\n mainType = params[\"ChartType\"]\n if mainType == \"Close\"\n m.addCloseLine(0x000040)\n elsif mainType == \"TP\"\n m.addTypicalPrice(0x000040)\n elsif mainType == \"WC\"\n m.addWeightedClose(0x000040)\n elsif mainType == \"Median\"\n m.addMedianPrice(0x000040)\n end\n\n #\n # Add comparison line if there is data for comparison\n #\n if @compareData != nil\n if @compareData.length > extraPoints\n m.addComparison(@compareData, 0x0000ff, compareKey)\n end\n end\n\n #\n # Add moving average lines.\n #\n addMovingAvg(m, params[\"avgType1\"], avgPeriod1, 0x663300)\n addMovingAvg(m, params[\"avgType2\"], avgPeriod2, 0x9900ff)\n\n #\n # Draw candlesticks or OHLC symbols if the user has selected them.\n #\n if mainType == \"CandleStick\"\n m.addCandleStick(0x33ff33, 0xff3333)\n elsif mainType == \"OHLC\"\n m.addHLOC(0x008800, 0xcc0000)\n end\n\n #\n # Add parabolic SAR if necessary\n #\n if params[\"ParabolicSAR\"] == \"1\"\n m.addParabolicSAR(0.02, 0.02, 0.2, ChartDirector::DiamondShape, 5, 0x008800,\n 0x000000)\n end\n\n #\n # Add price band/channel/envelop to the chart according to user selection\n #\n bandType = params[\"Band\"]\n if bandType == \"BB\"\n m.addBollingerBand(20, 2, 0x9999ff, 0xc06666ff)\n elsif bandType == \"DC\"\n m.addDonchianChannel(20, 0x9999ff, 0xc06666ff)\n elsif bandType == \"Envelop\"\n m.addEnvelop(20, 0.1, 0x9999ff, 0xc06666ff)\n end\n\n #\n # Add volume bars to the main chart if necessary\n #\n if params[\"Volume\"] == \"1\"\n m.addVolBars(indicatorHeight, 0x99ff99, 0xff9999, 0xc0c0c0)\n end\n\n #\n # Add additional indicators as according to user selection.\n #\n addIndicator(m, params[\"Indicator2\"], indicatorHeight)\n addIndicator(m, params[\"Indicator3\"], indicatorHeight)\n addIndicator(m, params[\"Indicator4\"], indicatorHeight)\n\n return m\n end", "def load_charts\n @entries.clear\n i = rank = 0\n last_played = -1\n DBIntf.execute(generate_sql) do |row|\n entry = ChartEntry.new\n entry.played = row[0].to_i\n entry.ref = row[1]\n i += 1\n if entry.played != last_played\n rank = i\n last_played = entry.played\n end\n entry.rank = rank\n\n # If view is other than tracks or record, the entry is fully loaded in this loop\n unless view_tracks_or_records?\n entry.title = row[2].to_html_bold\n entry.pix = XIntf::Image::Cache.get_flag(row[3]) if @view_type == VIEW_ARTISTS\n entry.pix = XIntf::Image::Cache.get_flag(row[1]) if @view_type == VIEW_COUNTRIES\n end\n\n @entries << entry\n end\n\n # Done if not tracks or records charts\n return unless view_tracks_or_records?\n\n # Pix and title loading are in another loop because making db accesses while reading\n # the result set of the query greatly speeds the things down...\n @entries.each do |entry|\n if @view_type == VIEW_TRACKS\n entry.xlink = XIntf::Link.new.set_track_ref(entry.ref)\n entry.pix = entry.xlink.small_track_cover\n entry.title = entry.xlink.html_track_title_no_track_num(@mc.show_segment_title?)\n else\n entry.xlink = XIntf::Link.new.set_record_ref(entry.ref)\n entry.pix = entry.xlink.small_record_cover\n entry.title = entry.xlink.html_record_title\n end\n end\n end", "def use_axes?\n end", "def parent=(other)\n raise 'Cannot set parent of root namespace' if root?\n @parent = other\n @registry = nil\n end", "def export\n figure_node\n end", "def write_cat_val_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n position = params[:position] || @val_axis_position\n horiz = @horiz_val_axis\n\n return unless axis_ids && !axis_ids.empty?\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis[:_position] || position\n\n @writer.tag_elements('c:valAx') do\n write_axis_id(axis_ids[0])\n\n # Write the c:scaling element.\n write_scaling_with_param(x_axis)\n\n write_delete(1) unless ptrue?(x_axis[:_visible])\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis[:_reverse])\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis[:_major_gridlines])\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis[:_minor_gridlines])\n\n # Write the axis title elements.\n if title = x_axis[:_formula]\n write_title_formula(title, y_axis[:_data_id], horiz, x_axis[:_name_font])\n elsif title = x_axis[:_name]\n write_title_rich(title, horiz, x_axis[:_name_font])\n end\n\n # Write the c:numberFormat element.\n write_number_format(x_axis)\n\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis[:_major_tick_mark])\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis[:_label_position])\n\n # Write the axis font elements.\n write_axis_font(x_axis[:_num_font])\n\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n write_crossing(y_axis[:_crossing])\n\n # Write the c:crossBetween element.\n write_cross_between\n\n # Write the c:majorUnit element.\n write_c_major_unit(x_axis[:_major_unit])\n\n # Write the c:minorunit element.\n write_c_minor_unit(x_axis[:_minor_unit])\n end\n end", "def do_not_save_chart!\n @do_not_save_chart = true\n end", "def parent=(parent)\n raise UnmutableParentError unless parent.is_a? RDF::Mutable\n raise UnmutableParentError unless parent.mutable?\n @parent = parent\n end", "def getchart()\n # Sample data for the Box-Whisker chart. Represents the minimum, 1st quartile,\n # medium, 3rd quartile and maximum values of some quantities\n q0Data = [40, 45, 35]\n q1Data = [55, 60, 50]\n q2Data = [62, 70, 60]\n q3Data = [70, 80, 65]\n q4Data = [80, 90, 75]\n\n # The labels for the chart\n labels = [\"<*img=robot1.png*><*br*>Bipedal Type\",\n \"<*img=robot2.png*><*br*>Wolf Type\", \"<*img=robot5.png*><*br*>Bird Type\"]\n\n # Create a XYChart object of size 540 x 320 pixels\n c = ChartDirector::XYChart.new(540, 320)\n\n # swap the x and y axes to create a horizontal box-whisker chart\n c.swapXY()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (75, 25) and of size 440 x 270 pixels. Enable both\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(75, 25, 440, 270).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart\n c.addTitle(\" Robot Shooting Accuracy Scores\")\n\n # Set the labels on the x axis and the font to Arial Bold\n c.xAxis().setLabels(labels).setFontStyle(\"arialbd.ttf\")\n\n # Disable x axis ticks by setting the length to 0\n c.xAxis().setTickLength(0)\n\n # Set the font for the y axis labels to Arial Bold\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # Add a Box Whisker layer using light blue 0x9999ff as the fill color and blue\n # (0xcc) as the line color. Set the line width to 2 pixels\n c.addBoxWhiskerLayer2(q3Data, q1Data, q4Data, q0Data, q2Data).setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def all_axes\n @structure.all_axes\n end", "def store_filters #:nodoc:\n record = 0x00EC # Record identifier\n length = 0x0000 # Bytes to follow\n\n ids = @object_ids.dup\n spid = ids.shift\n\n filter_area = @filter_area\n num_filters = @filter_count\n\n num_comments = @comments_array.size\n\n # Number of objects written so far.\n num_objects = @images_array.size + @charts_array.size\n\n # Skip this if there aren't any filters.\n return if num_filters == 0\n\n row1, row2, col1, col2 = @filter_area\n\n (0 .. num_filters-1).each do |i|\n vertices = [ col1 +i, 0, row1 , 0,\n col1 +i +1, 0, row1 +1, 0]\n\n if i == 0 and !num_objects.nil?\n # Write the parent MSODRAWIING record.\n dg_length = 168 + 96*(num_filters -1)\n spgr_length = 144 + 96*(num_filters -1)\n\n dg_length = dg_length + 128 *num_comments\n spgr_length = spgr_length + 128 *num_comments\n\n data = store_mso_dg_container(dg_length) +\n store_mso_dg(*ids) +\n store_mso_spgr_container(spgr_length) +\n store_mso_sp_container(40) +\n store_mso_spgr() +\n store_mso_sp(0x0, spid, 0x0005)\n spid = spid + 1\n data = data + store_mso_sp_container(88) +\n store_mso_sp(201, spid, 0x0A00) +\n store_mso_opt_filter() +\n store_mso_client_anchor(1, *vertices) +\n store_mso_client_data()\n spid = spid + 1\n\n else\n # Write the child MSODRAWIING record.\n data = store_mso_sp_container(88) +\n store_mso_sp(201, spid, 0x0A00) +\n store_mso_opt_filter() +\n store_mso_client_anchor(1, *vertices) +\n store_mso_client_data()\n spid = spid + 1\n end\n length = data.length\n header = [record, length].pack(\"vv\")\n append(header, data)\n\n store_obj_filter(num_objects+i+1, col1 +i)\n end\n\n # Simulate the EXTERNSHEET link between the filter and data using a formula\n # such as '=Sheet1!A1'.\n # TODO. Won't work for external data refs. Also should use a more direct\n # method.\n #\n formula = \"=#{@name}!A1\"\n store_formula(formula)\n\n @object_ids[0] = spid\n end", "def prepare_charts #:nodoc:\n count = 0\n charts = []\n\n # We sort the charts by row and column but that isn't strictly required.\n #\n rows = @charts.keys.sort\n rows.each do |row|\n cols = @charts[row].keys.sort\n cols.each do |col|\n charts.push(@charts[row][col])\n count += 1\n end\n end\n\n @charts = {}\n @charts_array = charts\n count\n end", "def multiple_series\n render :layout => false\n end", "def all_axes\n @indexes.dup\n end", "def to_ax\n klass = self.class\n ptr = Pointer.new klass.type\n ptr.assign self\n AXValueCreate(klass.ax_value, ptr)\n end", "def update_visualization(point)\n\t\tsuper(point)\n\tend", "def parent=(a_parent)\n if parent \n parent.children.delete(self)\n end \n \n if a_parent.nil? \n @parent = a_parent\n return\n else\n a_parent.children << self unless a_parent.children.include?(self)\n @parent = a_parent\n end \n end", "def write_chart_type(params)\n # Write the c:areaChart element.\n write_area_chart(params)\n end", "def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 360 pixels.\n c = ChartDirector::PieChart.new(600, 360)\n\n # Use the white on black palette, which means the default text and line colors are\n # white\n c.setColors(ChartDirector::whiteOnBlackPalette)\n\n # Use a vertical gradient color from deep blue (000066) to blue (0000cc) as\n # background. Use rounded corners of 20 pixels radius. Enable soft drop shadow.\n c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x000066, 0x0000cc))\n c.setRoundedFrame(0xffffff, 20)\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Exploded Pie Chart Demonstration\", \"timesbi.ttf\", 18).setMargin2(0, 0,\n 16, 0)\n\n # Set the center of the pie at (300, 195) and the radius to 110 pixels\n c.setPieSize(300, 195, 110)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors, with 5 pixels wide semi-transparent\n # white (bbffffff) borders\n c.setSectorStyle(ChartDirector::LocalGradientShading, 0xbbffffff, 5)\n\n # Use the side label layout method\n c.setLabelLayout(ChartDirector::SideLayout)\n\n # Use 10pt Arial Bold as the default label font. Set the label box background\n # color the same as the sector color. Use soft lighting effect with light\n # direction from right. Use 8 pixels rounded corners.\n t = c.setLabelStyle(\"arialbd.ttf\", 10, 0x000000)\n t.setBackground(ChartDirector::SameAsMainColor, ChartDirector::Transparent,\n ChartDirector::softLighting(ChartDirector::Right, 0))\n t.setRoundedCorners(8)\n\n # Set the sector label format. The label is centered in a 110 pixels wide bounding\n # box. It consists of two lines. The first line is the sector name. The second\n # line shows the data value and percentage.\n c.setLabelFormat(\n \"<*block,halign=center,width=110*>{label}\\n<*font=arial.ttf,size=8*>US$ \" \\\n \"{value}M ({percent}%)<*/*>\")\n\n # Explode all sectors 10 pixels from the center\n c.setExplode(-1, 10)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n dataY0 = [4, 4.5, 5, 5.25, 5.75, 5.25, 5, 4.5, 4, 3, 2.5, 2.5]\n dataX0 = [Time.mktime(1997, 1, 1), Time.mktime(1998, 6, 25), Time.mktime(1999, 9,\n 6), Time.mktime(2000, 2, 6), Time.mktime(2000, 9, 21), Time.mktime(2001, 3, 4\n ), Time.mktime(2001, 6, 8), Time.mktime(2002, 2, 4), Time.mktime(2002, 5, 19),\n Time.mktime(2002, 8, 16), Time.mktime(2002, 12, 1), Time.mktime(2003, 1, 1)]\n\n dataY1 = [7, 6.5, 6, 5, 6.5, 7, 6, 5.5, 5, 4, 3.5, 3.5]\n dataX1 = [Time.mktime(1997, 1, 1), Time.mktime(1997, 7, 1), Time.mktime(1997, 12,\n 1), Time.mktime(1999, 1, 15), Time.mktime(1999, 6, 9), Time.mktime(2000, 3, 3\n ), Time.mktime(2000, 8, 13), Time.mktime(2001, 5, 5), Time.mktime(2001, 9, 16\n ), Time.mktime(2002, 3, 16), Time.mktime(2002, 6, 1), Time.mktime(2003, 1, 1)]\n\n # Create a XYChart object of size 500 x 270 pixels, with a pale blue (e0e0ff)\n # background, black border, 1 pixel 3D border effect and rounded corners\n c = ChartDirector::XYChart.new(600, 300, 0xe0e0ff, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set the plotarea at (55, 60) and of size 520 x 200 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(50, 60, 525, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The text is\n # white (ffffff) on a deep blue (000088) background, with soft lighting effect\n # from the right side.\n c.addTitle(\"Long Term Interest Rates\", \"timesbi.ttf\", 15, 0xffffff).setBackground(\n 0x000088, -1, ChartDirector::softLighting(ChartDirector::Right))\n\n # Set the y axis label format to display a percentage sign\n c.yAxis().setLabelFormat(\"{value}%\")\n\n # Add a red (ff0000) step line layer to the chart and set the line width to 2\n # pixels\n layer0 = c.addStepLineLayer(dataY0, 0xff0000, \"Country AAA\")\n layer0.setXData(dataX0)\n layer0.setLineWidth(2)\n\n # Add a blue (0000ff) step line layer to the chart and set the line width to 2\n # pixels\n layer1 = c.addStepLineLayer(dataY1, 0x0000ff, \"Country BBB\")\n layer1.setXData(dataX1)\n layer1.setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def axes\n end", "def parent=(parent)\n raise NilParentError if parent.nil?\n raise UnmutableParentError unless parent.is_a? RDF::Mutable\n raise UnmutableParentError unless parent.mutable?\n\n @parent = parent\n reload\n end", "def before_validate\n self.previous_output :alias => 'PREVOUT' unless self.previous_output\n self.outputs<< output(0) if self.outputs.empty?\n super\n end", "def eliminate_duplicate_parent_child_additions!\n parents_to_add.uniq!\n children_to_add.uniq!\n parents_to_remove.uniq!\n children_to_remove.uniq!\n end", "def to_xml(builder)\n builder.series type: type do\n builder.title { title.to_xml builder } if title\n builder.place place if place\n builder.organization organization if organization\n builder.abbreviation { abbreviation.to_xml builder } if abbreviation\n builder.from from if from\n builder.to to if to\n builder.number number if number\n builder.part_number part_number if part_number\n end\n end", "def clean\n @scene = Bootstrap.new\n @charts = Hash.new\n end", "def parent=(new_parent)\n if parent != new_parent\n p = position\n remove_from_list if (p && valid?)\n super\n add_to_list_bottom if (p && valid?)\n else\n super\n end\n end", "def generate_piechartXML(*args)\n begin\n @color_hash=Hash.new\n @color_hash={\"0\"=>\"0C95BF\",\"1\"=>\"12C400\",\"2\"=>\"ECB800\",\"3\"=>\"EB2300\",\"4\"=>\"70808F\",\"5\"=>\"000000\",\"6\"=>\"800080\",\"7\"=>\"FFFF00\",\"8\"=>\"7FFFD4\",\"9\"=>\"0377CA\",\"10\"=>\"15C2F7\"}\n if @@flag==true\n #~ @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' showShadow='0' plotGradientColor='0' showLabels='1' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='0' baseFontSize='12' isSliced='1' enableSmartLabels='1' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' startingAngle='80' canvasBorderColor ='cccccc' canvasBorderAlpha='0' canvasBorderThickness='0' showPercentageValues='1' pieRadious='100'>\" if args[2]=='Device_Summary' or args[2]==\"Carrier_Traffic\" \n puts \"hello\"\n p @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' showShadow='0' plotGradientColor='0' showLabels='1' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='0' baseFontSize='12' isSliced='1' enableSmartLabels='1' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' startingAngle='80' canvasBorderColor ='cccccc' canvasBorderAlpha='0' canvasBorderThickness='0' showPercentageValues='1' pieRadious='100'>\" \n #~ @@strXML = \"<chart decimals='2' yAxisName='#{args[3].to_s=='ecpm' ? 'eCPM' : (args[3].to_s).upcase}' divLineColor='CCCCCC' numDivLines='2' alternateHGridColor='FFFFFF' anchorBorderColor='FFFFFF' defaultAnimation='0' use3DLighting='0' alternateVGridColor='FFFFFF' showPlotBorder='0' showShadow='0' plotGradientColor='' showLabels='1' chartTopMargin='10' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='10' showValues='0' canvasBorderColor ='FFFFFF' formatNumberScale='0' canvasBorderAlpha='0' canvasBorderThickness='0' pieRadious='100' baseFontSize='12' showBorder='0' plotBorderThickness='0' bgColor='FFFFFF' showPercentageValues='1' > \" if args[3]=='ctr' || args[3]=='ecpm'\n @@flag=false\n end\n colour=@color_hash[\"#{@@color_count}\"]\n limit = (args[3]=='ctr' || args[3]=='ecpm') ? 10 : 15\n args[0]=(args[0]=='' || args[0]==nil) ? 'could not detect' : args[0]\n puts \"---------------------34----------\"\n p @@strXML=@@strXML+ \"<set label='#{args[0]!=nil ? (truncate(args[0].split(\"'\")[0].to_s,limit)).gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end : 'NA' }' value='#{args[1].to_s}' color='#{(args[0].to_s=='Others') ? '000000' : colour.to_s}' />\" if args[3]!='ctr' and args[2]!='URL' and args[3]!='ecpm'\n puts \"---------------------35----------\"\n #~ @@strXML+=\"<set label='#{args[0].to_s.gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end}' value='#{args[1].to_s}' color='176D94'/>\" if args[3]=='ctr' || args[3]=='ecpm'\n @@color_count+=1\n rescue Exception=>e\n puts \"DEBUGGER :: ERROR :: in AdminXmlBuilder Component under generate_piechartXML method. The Error is #{e.to_s}\"\n end\n end" ]
[ "0.5174809", "0.49344313", "0.49333224", "0.48437437", "0.47048783", "0.4627388", "0.46055394", "0.45998502", "0.45729837", "0.45229915", "0.45184213", "0.44338074", "0.4426349", "0.43217492", "0.43202817", "0.4269759", "0.4257218", "0.42558557", "0.42374235", "0.41882733", "0.41696447", "0.41636357", "0.41621038", "0.4157495", "0.41205144", "0.41064537", "0.4096813", "0.40950197", "0.40855995", "0.4079037", "0.40769467", "0.40696558", "0.40528756", "0.4038632", "0.40356374", "0.40325218", "0.40323725", "0.40295222", "0.40117133", "0.40081096", "0.39970538", "0.3985223", "0.39763626", "0.3975075", "0.39733753", "0.39704832", "0.39552984", "0.39356038", "0.393218", "0.3928863", "0.39256853", "0.39043644", "0.39004973", "0.38997963", "0.38886285", "0.38880327", "0.3887405", "0.3885885", "0.38822418", "0.38819736", "0.38788056", "0.3859361", "0.385589", "0.3849333", "0.38391852", "0.38223335", "0.3819398", "0.381887", "0.38134643", "0.38103828", "0.38100153", "0.38100153", "0.38072258", "0.3806855", "0.38044268", "0.38010517", "0.37981144", "0.37977841", "0.37974975", "0.37935752", "0.37883407", "0.37733188", "0.37732056", "0.37667674", "0.37662217", "0.3765674", "0.37654173", "0.37598172", "0.3758559", "0.3753382", "0.3750221", "0.37498093", "0.37430608", "0.3741974", "0.37340236", "0.3732834", "0.37325203", "0.37322575", "0.37290064", "0.37260285" ]
0.8029582
0
Converts one filetype to the other
def filetype_conversion(options) @transform_tasks.push( add_transform_task('output', options) ) self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_type_class\n self.file_type.downcase.split.join('-') + '-file'\n end", "def type t\n @files = @files.select { |file| File.exist?(file) && File.ftype(file) == t}\n self\n end", "def update_content_type\n if file.present? && file_changed?\n self.content_type = file.file.content_type\n end\n end", "def conversion_type(filepath,mimetype)\n Log.log.debug(\"conversion_type(#{filepath},m=#{mimetype},t=#{@use_mimemagic})\")\n # 1- get type from provided mime type, using local mapping\n conv_type=SUPPORTED_MIME_TYPES[mimetype] if ! mimetype.nil?\n # 2- else, from computed mime type (if available)\n if conv_type.nil? and @use_mimemagic\n detected_mime=mime_from_file(filepath)\n if ! detected_mime.nil?\n conv_type=SUPPORTED_MIME_TYPES[detected_mime]\n if ! mimetype.nil?\n if mimetype.eql?(detected_mime)\n Log.log.debug(\"matching mime type per magic number\")\n else\n # note: detected can be nil\n Log.log.debug(\"non matching mime types: node=[#{mimetype}], magic=[#{detected_mime}]\")\n end\n end\n end\n end\n # 3- else, from extensions, using local mapping\n extension = File.extname(filepath.downcase)[1..-1]\n conv_type=SUPPORTED_EXTENSIONS[extension] if conv_type.nil?\n Log.log.debug(\"conversion_type(#{extension}): #{conv_type.class.name} [#{conv_type}]\")\n return conv_type\n end", "def set_file_type\n if self.is_local?\n if self.attachment_content_type.blank?\n self.file_type = \"misc\"\n elsif self.attachment_content_type == 'application/pdf'\n self.file_type = \"pdf\"\n elsif self.attachment_content_type.include?('powerpoint')\n self.file_type = \"presentation\"\n elsif self.attachment_content_type == 'application/zip'\n self.file_type = \"zip\"\n elsif self.attachment_content_type == \"application/rtf\" || self.attachment_content_type == 'text/plain' || self.attachment_content_type == 'application/msword' || self.attachment_content_type.include?('wordprocessing')\n self.file_type = \"document\"\n elsif self.attachment_content_type.include?('spreadsheet') || self.attachment_content_type == 'ms-excel'\n self.file_type = \"spreadsheet\"\n elsif self.attachment_content_type.include?('image')\n self.file_type = \"image\"\n else\n self.file_type = \"misc\"\n end\n end\n end", "def file_type(file_name)\n @file_class.extname(file_name).gsub( /^\\./, '' ).downcase \n end", "def convert_file(file_name, from_format, to_format)\n begin\n from_file_name = Rails.root.join('public', 'uploads', request.remote_ip, file_name)\n to_file_name = Rails.root.join('public', 'uploads', request.remote_ip, file_name.gsub(from_format, to_format))\n #Read the uploaded image from the disk\n from_image = Image.read(from_file_name).first\n #Copy the image into a new variable\n to_image = from_image.copy\n #Change the format for the selected by user\n to_image.format = to_format[1..3].upcase\n #Write the copied image with the new format into the user temporal folder\n to_image.write(to_file_name)\n rescue Exception => e\n raise\n end\n end", "def get_file_type\n\n @image.uploads.each do |upload|\n filename_arr = upload.content_type.to_s.split('/')\n @image.file_type = filename_arr[1].upcase\n end\n\n end", "def file_type(file_name)\n File.exname( file_name ).gsub( /^\\./, '').downcase\n end", "def maybe_convert_extension(ext); end", "def file_type file_name\n File.extname(file_name).gsub(/^\\./, '').downcase\n end", "def file_type file_name \n\t\tFile.extname( file_name ).gsub /^\\./, '' \n\tend", "def file_type file_name \n File.extname( file_name ).gsub /^\\./, '' \n end", "def file_type( file_name )\n File.extname( file_name ).gsub( /^./, '' ).downcase\n end", "def override_content_type_and_save_info\n case File.extname(file.file).delete('.').downcase.to_sym\n when :xlsx\n file.content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n when :docx\n file.content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n when :pptx\n file.content_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\n when :rar\n file.content_type = 'application/vnd.rar'\n when :zip\n file.content_type = 'application/zip'\n when :bat\n file.content_type = 'application/x-msdos-program'\n when :cmd\n file.content_type = 'application/cmd'\n when :exe\n file.content_type = 'application/x-msdownload'\n when :msi\n file.content_type = 'application/x-msi'\n when :php\n file.content_type = 'application/x-php'\n when :py\n file.content_type = 'application/x-python'\n when :vbs\n file.content_type = 'application/x-vbs'\n end\n\n model.file_content_type = file.content_type if file.content_type\n model.file_size = number_to_human_size(file.size) if file.size\n end", "def file_type\n FILE_TYPES[@file_type]\n end", "def file_type\r\n\t\t@file_type\r\n\tend", "def file_type\n if is_ography?\n :ography\n else\n :tei_content\n end\n end", "def type\n stype = \"file\"\n stype = \"atom\" if @filepath.nil? and [email protected]?\n stype = \"multipart\" if [email protected]? and [email protected]?\n stype\n end", "def mime_type\n term = format_controlled_vocabulary.all.find { |x| x.definition == info_service.driver }\n term ? term.value : original_file.mime_type\n end", "def filetype\n `file --mime-type -b #{@file_path}`.chomp\n end", "def update_last_known_file_type\n self.last_known_file_type = Constants::FILE_TYPES_BY_EXTENSION[pathname.extname[1..-1]]\n end", "def update!(**args)\n @file_type = args[:file_type] if args.key?(:file_type)\n end", "def file_type\n case raw_file_type\n when 'f'\n :file\n when 'd'\n :directory\n when 'L'\n :symlink\n when 'D'\n :device\n when 'S'\n :special\n end\n end", "def file_type\n self['fileRef']['explicitFileType'] || self['fileRef']['lastKnownFileType']\n end", "def override_content_type_and_save_info\n case File.extname(file.file).delete('.').to_sym\n when :xlsx\n file.content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n when :docx\n file.content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n when :pptx\n file.content_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\n end\n\n # if File.extname(file.file).delete('.').to_sym == :xlsx\n # file.content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n # end\n # if File.extname(file.file).delete('.').to_sym == :docx\n # file.content_type='application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n # end\n # if File.extname(file.file).delete('.').to_sym == :pptx\n # file.content_type='application/vnd.openxmlformats-officedocument.presentationml.presentation'\n # end\n\n model.file_content_type = file.content_type if file.content_type\n model.file_size = number_to_human_size(file.size) if file.size\n\n tmp_file = file.path\n photo = MiniExiftool.new \"#{tmp_file}\"\n\n model.latitude = dms_to_float(photo.gpslatitude) if photo && photo.gpslatitude\n model.longitude = dms_to_float(photo.gpslongitude) if photo && photo.gpslongitude\n model.photo_created_at = photo.createdate if photo && photo.createdate\n end", "def categorize filename\n [filetype(filename), fileclass(filename)]\nend", "def file_type(file_name)\n return file_name[file_name.rindex(\".\") + 1, file_name.size]\n end", "def filetype(path)\n path = File.extname(path)\n if Audio::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'audio'\n elsif Video::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'video'\n elsif Image::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'image'\n else\n return nil\n end\n end", "def filename_to_mimetype(filename)\n if !filename\n return nil\n end\n if filename.match(/\\.([^.]+)$/i)\n lext = $1.downcase\n if $file_extension_to_mime_type.include?(lext)\n return $file_extension_to_mime_type[lext]\n end\n end\n return nil\nend", "def rename_with_file_type(ori, nam)\n s = ori.split('.')\n nam + '.' + s[s.length - 1]\n end", "def initialize\n TYPES.each do |type|\n transform_files!(Files.type_files(type), type)\n end\n end", "def mimetype; @mimetype ||= `file -b --mime-type '#@fname'`.strip; end", "def ftype() File.ftype(path) end", "def preferred_file_format\n ''\n end", "def filetype f\n return nil unless f\n\n f = Shellwords.escape(f)\n s = `file #{f}`\n return :text if s.index 'text'\n return :zip if s.index(/[Zz]ip/)\n return :zip if s.index('archive')\n return :image if s.index 'image'\n return :sqlite if s.index 'SQLite'\n # return :db if s.index 'database'\n return :text if s.index 'data'\n\n nil\nend", "def content_type\n self.file_content_type\n end", "def convert_file2(file_path)\n @ole.ConvertFile2(file_path)\n end", "def mime_type\n term = format_controlled_vocabulary.all.find { |x| x.definition == info_service.driver }\n term ? term.value : primary_file.mime_type\n end", "def convert\n puts \"\\n--------------------------------\"\n puts \"Transforming #{File.extname(@file)} file to .#{@type} format...\"\n \n runHardklor if @hardklor && @file.downcase.include?(\".mzxml\")\n \n if @type == \"mgf\" || @type == \"ms2\"\n Ms::Msrun.open(@file) do |ms|\n file = @file.chomp(File.extname(@file)) + \"_#{@run}.#{@type}\"\n File.open(file, 'w') do |f|\n f.puts eval(\"ms.to_#{@type}\")\n end\n end\n else\n # If ms-msrun can't do it, then this might. Do something here to include run number. Doesn't work with Refiner, so\n # this is probably pointless to even have.\n #\n # And why do we run our own code to transform mzML instead of TPP?\n # 1) Prince said so\n # 2) I hate the TPP. The people who put that together don't deserve to be called programmers. I mean, come on! Methods\n # should never be longer than 100 lines of code, yet they've got methods that are over 1000 lines of code! Ack! It\n # just makes my skin crawl!\n system(\"/usr/local/src/tpp-4.3.1/build/linux/MzXML2Search -#{@type} #{@file}\")\n end\n end", "def transform_files!(files, type) \n files.each do |file|\n @file = file\n @type = type\n parsed = \"\"\n @dirnames = Base.get_namespace(file,type) # directories after the app/type/ directory\n \n namespaces = LANGUAGES.collect do |lang|\n if type == 'views'\n namespace = [lang] + @dirnames\n else\n namespace = [lang, type] + @dirnames\n end\n \n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n Namespace.new(namespace,lang)\n end\n\n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, namespaces, type)\n \n # write the app/type/file with new i18n format instead of gettext\n File.open(file, 'w') { |file| file.write(parsed)}\n \n namespaces.each do |ns|\n new_file_handler(ns)\n end\n end\n end", "def set_filetypes\n #unless params[:id] == 'download' || params == :file\n @filetype = Filetype.find(params[:id])\n # end\n end", "def filetype\n if options.filetype.to_sym == :dot then :none else options.filetype.to_sym end\n end", "def _extract_mime_type_with_mime_types(io)\n if filename = extract_filename(io)\n mime_type = MIME::Types.of(filename).first\n mime_type.to_s if mime_type\n end\n end", "def map_type_to_mime(type)\n case type\n when \"photo\"\n return AppConstants.mime_remote_image\n when \"video\"\n return AppConstants.mime_remote_video\n when \"music\"\n return AppConstants.mime_remote_music\n when \"link\"\n return AppConstants.mime_remote_link\n else\n return AppConstants.mime_remote_link\n end\n rescue => e\n Rails.logger.error(\"[LIB] [API] [HELPERS] [PARSER] [map_type_to_mime] **** RESCUE **** => #{e.message} for #{type}\")\n AppConstants.mime_remote_link\n end", "def extract_content_type\n if image_content_type == \"application/octet-stream\" && !image_file_name.blank?\n content_types = MIME::Types.type_for(image_file_name)\n self.image_content_type = content_types.first.to_s unless content_types.empty?\n end\n end", "def normalize(file_type)\n return @img_data if file_type == 'pdf'\n\n label_image = MiniMagick::Image.read(@img_data)\n label_image.combine_options do |img|\n img.rotate(90) if label_image.width > label_image.height\n img.rotate(180) if [:fedex].include?(@carrier)\n img.bordercolor('#ffffff')\n img.border('1x1')\n img.trim\n end\n\n @img_data = label_image.to_blob\n end", "def getFiletype filename\n extension = filename.split(\".\")[1]\n case extension\n when \"wav\" then\t\"audio/wav\"\n when \"amr\" then\t\"audio/amr\"\n when \"amr-wb\" then \"audio/amr-wb\"\n when \"x-speex\" then \"audio/x-speex\"\n when \"spx\" then\t\"audio/x-speex\"\n else \n end\n end", "def file_type(file_path)\n return 'file' if File.file? file_path\n return 'directory' if File.directory? file_path\n return 'unknown'\n end", "def parser_type_for_filename(filename); end", "def type_for(filename, platform = false)\r\n # call the original method\r\n type = mime_type_for(filename, platform)\r\n \r\n if type.empty? then\r\n case File.extname(filename)\r\n when '.cod'\r\n type = MIME::Type.from_array('application/vnd.rim.cod', 'cod', '8bit', 'linux')\r\n when '.apk'\r\n type = MIME::Type.from_array('application/vnd.android.package-archive', 'apk', '8bit', 'linux')\r\n when '.aetx'\r\n type = MIME::Type.from_array('application/x-aetx', 'aetx', '8bit', 'linux')\r\n when '.xap'\r\n type = MIME::Type.from_array('application/x-silverlight-app', 'xap', '8bit', 'linux')\r\n end\r\n end\r\n return type\r\n end", "def check_file_type\n if self.is_image?\n {\n :thumb => \"200x200>\",\n :medium => \"500x500>\"\n }\n elsif self.is_pdf?\n {\n :thumb => [\"200x200>\", :png],\n :medium => [\"500x500>\", :png]\n }\n\n elsif self.is_video?\n {\n :thumb => {\n :geometry => \"200x200>\",\n :format => 'jpg',\n :time => 0\n },\n :medium => {\n :geometry => \"500x500>\",\n :format => 'jpg',\n :time => 0\n }\n }\n elsif self.is_audio?\n {\n :audio => {\n :format => \"mp3\"\n }\n }\n else\n {}\n end\n end", "def mime_type=(_); end", "def set_content_type(override=false)\n if override || file.content_type.blank? || generic_content_type?\n new_content_type = ::MIME::Types.type_for(current_path).first.to_s\n if file.respond_to?(:content_type=)\n file.content_type = new_content_type\n else\n file.instance_variable_set(:@content_type, new_content_type)\n end\n end\n rescue ::MIME::InvalidContentType => e\n raise CarrierWave::ProcessingError, I18n.translate(:\"errors.messages.mime_types_processing_error\", :e => e)\n end", "def save_content_type_and_size\n model.content_type = file.content_type if model.respond_to?(:content_type) && file.content_type\n model.file_size = file.size if model.respond_to?(:file_size)\n end", "def check_file_type\n if image_type? || gif_type?\n {\n thumb: '200x200>',\n medium: '500x500>'\n }\n elsif video_type?\n {\n thumb: { geometry: '200x200>' , format: 'jpg', frame_index: 2 },\n medium: { geometry: '500x500>' , format: 'jpg', frame_index: 2 }\n }\n elsif pdf_type?\n {\n thumb: ['200x200>', :png],\n medium: ['500x500>', :png]\n }\n else\n {}\n end\n end", "def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n target_file = @file_set.try(type)\n next unless target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: target_file.file_identifiers[0])\n new_file = target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end", "def convert_files2(file_paths)\n @ole.ConvertFiles2(file_paths)\n end", "def set_content_type(override=false)\n if override || file.content_type.blank?\n File.open(file.path) do |fd|\n data = fd.read(1024) || \"\"\n new_content_type = filemagic.buffer(data)\n if file.respond_to?(:content_type=)\n file.content_type = new_content_type\n else\n file.instance_variable_set(:@content_type, new_content_type)\n end\n end\n end\n end", "def detect_file_type(tempfile)\n tempfile.rewind\n MagicBytes.read_and_detect(tempfile).tap { tempfile.rewind }\n end", "def check_file_type\n if is_image_type?\n {\n thumb: '100x100>',\n medium: '640x360>',\n large: '1920x1080>'\n }\n elsif is_video_type?\n {\n thumb: { :geometry => \"100x100#\", format: 'jpg', :time => 5 },\n mp4_sd: { :geometry => \"640x360#\", format: 'mp4', :processors => [:transcoder] },\n mp4_hd: { :geometry => \"1920x1080#\", format: 'mp4', :processors => [:transcoder] },\n #webm_sd: { :geometry => \"640x360#\", format: 'webm', :processors => [:transcoder] },\n webm_hd: { :geometry => \"1920x1080#\", format: 'webm', :processors => [:transcoder] }\n }\n else\n {}\n end\n end", "def check_file_type\n if self.is_pdf?\n {\n :square_thumb => ['200x200#', :png],\n :annotation_thumb => ['300x200#', :png],\n :medium => ['500x500>', :png]\n }\n\n elsif self.is_video?\n {\n :square_thumb => { \n :geometry => '200x200!',\n :format => 'jpg',\n :time => 1\n }, \n :annotation_thumb => {\n :geometry => '300x200!',\n :format => 'jpg',\n :time => 1\n },\n :medium => { \n :geometry => '500x500>',\n :format => 'jpg',\n :time => 1\n },\n :transcoded_video => {\n :geometry => '300x200!',\n :format => 'mp4'\n }\n }\n elsif self.is_audio?\n {\n :audio => {\n :format => 'mp3'\n }\n }\n elsif self.is_image?\n {\n :square_thumb => '200x200#', \n :annotation_thumb => '300x200#',\n :medium => '500x500>'\n }\n else\n {}\n end\n end", "def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n target_file = @file_set.try(type)\n next unless target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: target_file.file_identifiers[0])\n next unless image_valid?\n new_file = target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end", "def extract_content_type(new_file)\n content_type = nil\n\n File.open(new_file.path) do |fd|\n data = fd.read(1024) || \"\"\n content_type = filemagic.buffer(data)\n end\n\n content_type\n end", "def file_base_type(path)\r\n \t\tfile_name = File.basename(path)\r\n \t\textension = File.extname(file_name)\r\n \t\tfile_name = file_name[0, file_name.length - extension.length]\r\n \t\t(File.extname(file_name)[1..-1]).to_sym\r\n end", "def convert_one(*args)\n raise \"x2t file is not found in #{@bin_path} path\" unless x2t_exist?\n output_file_path = \"#{@convert_to}/#{File.basename(args.first[:input_file], '.*')}.\" + args.first[:format_to]\n convert_file(args.first[:input_file], output_file_path, false)\n output_file_path\n end", "def document_type\n FileUtility.get_file_type(@file_name)\n end", "def file_mimetype\n if file_formats.first\n file_formats.first.mimetype\n end\n end", "def mime_type_for(filename, override = nil)\n override || Mime.type_for(filename)\n end", "def newfiletype(name, &block)\n return if @filetypes&.key?(name)\n\n base_newfiletype(name, &block)\n end", "def remap_resource_type\n return unless is_a?(Bulkrax::CsvFileSetEntry)\n\n parsed_metadata.delete('resourceType_attributes')\n parsed_metadata['resource_type'] = raw_metadata['resourcetype']&.split(/\\s*[|]\\s*/)\n end", "def mimetype\n mtype = MIME::Types.of(@filename).first\n if (mtype)\n mimetype = MIME::Type.simplified(mtype)\n end\n mimetype\n end", "def write_temp_content_type(parameters)\n eachImageField(parameters) do |image|\n if image.present? and image[:assets].present? and image[:assets_content_type].present?\n UploadedFile.temp_content_type = image[:assets_content_type]\n end\n end\n end", "def ftype\n :file\n end", "def mime_type=(_arg0); end", "def mime_type=(_arg0); end", "def mime_type=(_arg0); end", "def file_type\n attachments.order(position: 'asc').first.file_type\n rescue StandardError => exc\n logger.error(\"Message for the log file #{exc.message}\")\n 'application/pdf'\n end", "def transform_files\n extract\n reorder_files\n transform @attendance_file, 'att' unless @attendance_file.blank?\n transform @enroll_file, 'enroll' unless @enroll_file.blank?\n transform @ili_file, 'ili' unless @ili_file.blank?\n end", "def new_ending(sourcefile, type)\n #sourcefile.sub(/\\.[^.]+$/, \".#{type.to_s}\")\n \"#{sourcefile}.#{type.to_s}\"\nend", "def convert_file tempfile\n path = tempfile.path\n filetype = get_mime_type(path)\n\n if filetype == 'application/pdf'\n convert_pdf_to_html(path)\n elsif filetype == 'text/html'\n File.read(path)\n else\n convert_document_to_html(path)\n end\n end", "def related_mimetype(extension)\n if extension == \".gif\"\n \"image/gif\"\n elsif extension == \".png\"\n \"image/png\"\n else\n \"image/jpeg\"\n end\nend", "def determine_file_type\n return \"pfile\" if image? and (@filename =~ /^P.....\\.7/) != nil\n return \"pfile\" if (@filename =~ /^P.....\\.7\\.summary/) != nil\n return \"geifile\" if image? and (@filename =~ /^I\\.\\d*/) != nil\n return \"scan_archive_h5_json\" if (@filename =~ /^ScanArchive_.{10,}.h5.json/) != nil\n return \"dicom\" if image? and (@filename =~ /^P.....\\.7/) == nil\n return nil\n end", "def _mime_type\n if defined? @_mime_type\n @_mime_type\n else\n guesses = ::MIME::Types.type_for(extname.to_s)\n\n # Prefer text mime types over binary\n @_mime_type = guesses.detect { |type| type.ascii? } || guesses.first\n end\n end", "def convert(type)\n case type\n when 'tests' then @test_tool.convert\n when 'coverage' then @coverage_tool.convert\n when 'all'\n @test_tool.convert\n @coverage_tool.convert\n end\n end", "def image_type\n ImageScience.fif_to_string(@file_type)\n end", "def file_set_mime_type\n file_set.mime_type.first\n end", "def type\n @type ||= File.extname(path)[1..-1]\n end", "def file_type\n\t\tline = @file_desc.gets\n\t\t@file_desc.pos = 0 # Reset our location within the file\n\t\t\t\t\n\t\ttype = case line[line.rindex(' ')-1].chr\n\t\t\twhen ',' then :comma\n\t\t\twhen '|' then :pipe\n\t\t\telse :space\n\t\tend\n\tend", "def attachment_content_type_for(joint)\n case File.extname(joint).downcase\n when '.txt' then 'text/plain'\n when '.html' then 'plain/html'\n when '.pdf' then 'application/octet-stream' #'application/x-pdf'\n when '.jpg', '.jpeg' then 'image/jpeg'\n when '.png' then 'image/png'\n when '.gif' then 'image/gif'\n when '.doc', '.docx' then 'application/msword'\n else \n 'plain/text' # par défaut\n end\nend", "def mimetype\n process_upload\n return @file.file.file.content_type\n end", "def ftype() File.ftype( expand_tilde ) end", "def mime_type_for(format, temp_object=nil)\n registered_mime_types[file_ext_string(format)] || (temp_object.mime_type if temp_object.respond_to?(:mime_type)) || fallback_mime_type\n end", "def set_file_type(file_type)\n @file_type = file_type\n init_data_arrays\n end", "def check_file_type\n `file #{@desktop_image}`.sub(/^.*: /,'').split.first.downcase\n end", "def default_mime_type=(value); end", "def file_content_type\n types = MIME::Types.type_for(original_filename)\n types.first\n end", "def normalize(type); end", "def files_of_type_diff(of_type, but_not_of_type)\n result = []\n talia_files.each do |talia_file|\n found_good = false; found_bad = false\n for data_record in talia_file.data_records\n found_good = true if data_record.is_a? of_type\n found_bad = true if data_record.is_a? but_not_of_type\n end\n result << data_record if found_good and !found_bad\n end\n result\n end", "def photo__mime_type\r\nif !self.photo__name.blank?\r\n mt = MIME::Types.of(File.extname(self.photo__name)).first\r\n return mt ? mt.content_type : \"application/octet-stream\"\r\nend\r\nend" ]
[ "0.6699641", "0.66246897", "0.6442772", "0.64404196", "0.64225304", "0.64192474", "0.6317206", "0.6238761", "0.6227111", "0.61857367", "0.6141491", "0.6133514", "0.60959435", "0.6025811", "0.5969169", "0.58836544", "0.5876826", "0.5872552", "0.582588", "0.5819007", "0.5809501", "0.5804888", "0.58025557", "0.57975787", "0.57635933", "0.574006", "0.5725342", "0.57174426", "0.5713163", "0.5697293", "0.56971955", "0.5688018", "0.56581753", "0.5644978", "0.5643158", "0.56404376", "0.56347144", "0.56201214", "0.5618423", "0.56049335", "0.5584398", "0.557926", "0.55761325", "0.55721647", "0.55569357", "0.55535525", "0.55514026", "0.55458736", "0.5525734", "0.5513072", "0.5500823", "0.5498483", "0.54971856", "0.54964745", "0.5487316", "0.5484738", "0.54816735", "0.54813105", "0.54635537", "0.54607135", "0.54485774", "0.54376644", "0.54352254", "0.54327464", "0.542564", "0.541959", "0.5418454", "0.54154587", "0.54142725", "0.54117364", "0.5407522", "0.54051703", "0.5396747", "0.53871363", "0.53870666", "0.53870666", "0.53870666", "0.5384544", "0.53792155", "0.536986", "0.5367338", "0.5364949", "0.536478", "0.5359282", "0.53529954", "0.5352479", "0.5347315", "0.5342288", "0.5333709", "0.53301936", "0.5327851", "0.5313963", "0.5298972", "0.5296417", "0.52948946", "0.5290103", "0.52873427", "0.52853876", "0.52747667", "0.5269129" ]
0.614568
10
Converts video or audio based on userprovided parameters
def av_convert(options) if @external_url return 'av_convert does not support external URLs. Please upload file first.' end @transform_tasks.push( add_transform_task('video_convert', options) ) response = UploadUtils.make_call(url, 'post') if response.code == 200 return AV.new(url, apikey: @apikey, security: @security) end JSON.parse(response.body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert(file_info)\n input_name = Shellwords.escape(file_info[:filename])\n input_suffix = File.extname input_name\n output_name = File.basename input_name, input_suffix\n output_suffix = \"mp4\"\n command = [ \"ffmpeg\", \"-y\", \"-i #{input_name}\", \"-max_muxing_queue_size 9999\", \"-map_chapters -1\" ]\n\n if (file_info[:video].empty? && !file_info[:audio].empty?) || input_suffix == '.flac' || input_suffix == '.mp3' || input_suffix == '.aiff'\n #\n # Audio-only files are converted to either ALAC if the source was FLAC, or\n # AAC for all other formats.\n #\n stream = file_info[:audio][0]\n case stream[:codec]\n when \"alac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a copy\"\n when \"flac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n when \"mp3\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n else\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a aac\" << \"-ar:a:0 48k\" << \"-ab:a 256k\"\n end\n output_suffix = \"m4a\"\n elsif !file_info[:video].empty? && !file_info[:audio].empty?\n # Removes all of the default metadata that junks up the final file.\n command << \"-map_metadata -1\"\n \n # Maps the video track\n command << \"-map 0:v:0\" << \"-metadata:s:v:0 language=und\" << \"-metadata:s:v:0 title='Video Track'\"\n\n #\n # The video track is copied if the codec is h265 (hevc) and a video tag\n # is added so that Apple products understand the format. Otherwise, the\n # video track is copied if it's in h264 format and the frame size is\n # to remain the same, or it's converted to h264 using high-quality\n # settings.\n #\n if \"hevc\" == file_info[:video][:codec]\n command << \"-codec:v copy -vtag hvc1\"\n elsif \"h264\" == file_info[:video][:codec] && !Options.options[:P480] && !Options.options[:P720]\n command << \"-codec:v copy\"\n else\n # This converts the video using settings that provide nearly visual\n # lossless results.\n output_suffix = \"mp4\"\n command << \"-codec:v libx265\" << \"-vtag hvc1\" << \"-preset:v slow\" << \"-profile:v main\" << \"-crf:v 18\" << \"-threads:v 0\"\n\n # Converts HD video to wide-screen 720P if necessary.\n command << \"-vf:v scale=1280:-1\" if Options.options[:P720]\n\n # Converts HD video to wide-screen 480P if necessary.\n command << \"-vf:v scale=854:-1\" if Options.options[:P480]\n end\n\n # Convert all of the audio tracks to AAC (stereo) and AC3 (multi-channel)\n index = 0\n file_info[:audio].each do |stream|\n index, c = convert_audio(stream, index)\n command << c\n end\n\n if file_info.key?(:subtitle) && !file_info[:subtitle].nil? && !file_info[:subtitle].empty?\n command << \"-map 0:s:#{file_info[:subtitle][:index]}\" << \"-metadata:s:s:0 language=eng\" << \"-metadata:s:s:0 title='Subtitle Track'\"\n command << ('dvd_subtitle' == file_info[:subtitle][:codec] ? \"-codec:s:0 copy\" : \"-codec:s:0 mov_text\")\n end\n\n end\n\n command << \"#{output_name}.#{output_suffix}\"\n\n if Options.options[:dump]\n puts command.join(' ')\n exit\n end\n\n #\n # Starts the transcoding process.\n #\n puts file_info[:filename]\n progress = ProgressBar.create(:format => \"%t |%B| %e\",\n :total => file_info[:duration] + 1,\n :title => \"Encoding Progress\")\n execute(command, true) do |line|\n begin\n line.match /time=(\\d\\d):(\\d\\d):(\\d\\d)/ do |match|\n if match.length == 4\n time = match[1].to_i * 3600 + match[2].to_i * 60 + match[3].to_i\n progress.progress = time\n end\n end\n rescue\n # Some UTF-8 characters can cause match to throw, but these characters are not used by this script.\n end\n end\n progress.finish\nend", "def convert_video(params = {}, options = {}, converter = Conversion::VideoConverter)\n convert_file(params, converter, options)\n end", "def convert_header_file_audio\n self.convert_header_file_audio_or_video('audio')\n end", "def video_convert_to_mp4_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_mp4 ...'\n end\n # resource path\n local_var_path = '/video/convert/to/mp4'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_mp4\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def convert\n\t\tif self.video.file?\n\t\t\tself.convert!\n\n\t\t\tsuccess = system(convert_command)\n\t\t\tif success && $?.exitstatus == 0\n\t\t\t\tself.converted!\n\t\t\telse\n\t\t\t\tself.failed!\n\t\t\tend\n\t\tend\n\tend", "def video_gen(slide)\n term = slide['term']\n kind = slide['kind']\n index = slide['index']\n audio = slide['audio']\n image = slide['image']\n raise \"audio is required fof #{term}\" unless audio\n raise \"image is required fof #{term}\" unless image\n file_name = file_name_gen(slide, \".mpg\")\n audio = command_arg(slide['audio'])\n image = command_arg(slide['image'])\n video = command_arg(file_name)\n `ffmpeg -loop 1 -y -i #{image} -i #{audio} -acodec libmp3lame -vcodec mpeg4 -shortest -qscale:v 1 #{video}`\n slide['video'] = file_name\nend", "def url_to_video(source, options = T.unsafe(nil)); end", "def preview_type\n return \"video\" if %w(mp4 m4v mov flv avi asf).include?(format)\n return \"audio\" if !format.blank?\n return nil\n end", "def run\n\n @options = @video.convert_options\n @output_file = \"#{generate_path @video.name}/#{@video.name}#{@options[:postfix]}.#{@options[:extension]}\"\n\n command = \"#{CONFIG[:ffmpeg_binary]} -y -i '#{@video.path}' #{@options} '#{@output_file}'\"\n output = \"\"\n convert_error = true\n\n # before convert callbacks\n Hook.exec :before_convert, @video, command\n\n # process video\n Open3.popen3(command) do |stdin, stdout, stderr|\n stderr.each \"r\" do |line|\n VTools.fix_encoding line\n output << line\n\n # we know, that all is not so bad, if \"time=\" at least once met\n if line.include? \"time=\"\n\n convert_error = false # that is why, we say \"generally it's OK\"\n\n if line =~ /time=(\\d+):(\\d+):(\\d+.\\d+)/ # ffmpeg 0.8 and above style\n time = ($1.to_i * 3600) + ($2.to_i * 60) + $3.to_f\n elsif line =~ /time=(\\d+.\\d+)/ # ffmpeg 0.7 and below style\n time = $1.to_f\n else # in case of unexpected output\n time = 0.0\n end\n progress = time / @video.duration\n Hook.exec :in_convert, @video, progress # callbacks\n end\n end\n end\n\n raise ProcessError, output.split(\"\\n\").last if convert_error # exit on error\n\n # callbacks\n unless error = encoding_invalid?\n Hook.exec :convert_success, @video, @output_file\n else\n Hook.exec :convert_error, @video, error, output\n raise ProcessError, error # raise exception in error\n end\n\n encoded\n end", "def codec\n if RAILS_ENV == 'development'\n \"-ar 22050 -ab 32 -f flv -y\"\n else\n \"-vcodec libx264 -vpre hq -ar 22050 -ab 32 -crf 15\"\n end\n end", "def convert_command\n @original_video_filename = compute_original_local_filename\n @flv_filename = \"#{@original_video_filename}.flv\"\n @flv_url = \"#{public_filename}.flv\"\n \n if is_mov?\n command = \"/opt/ffmpeg/ffmpeg -y -i #{@original_video_filename} -target ntsc-dvd #{@flv_filename}\" \n else\n command = \"/opt/ffmpeg/ffmpeg -y -i #{@original_video_filename} #{@flv_filename}\"\n end\n command.gsub!(/\\s+/, \" \")\n end", "def video_codec\n @video_codec ||= begin\n case self[:video_codec]\n when \"h264\"\n 'H264'\n when \"mpeg4\"\n 'MP4'\n when 'hevc'\n \"HEVC\"\n else\n nil\n end\n end \n end", "def path_to_video(source, options = T.unsafe(nil)); end", "def convert\n success = true\n inputs.each { |input| success &&= Ffmpeg.new(input, outputs).run }\n success\n end", "def update_after_conversion\n #update_attribute(:filename, \"#{filename}.flv\")\n #update_attribute(:content_type,\"video/x-flv\")\n end", "def quick_transcode(input, options={})\n quality = options[:quality] || 19\n log = options[:log]\n output = input.gsub(/\\.[^.]*$/, '.m4v')\n\n # TODO Next time this is needed, make the options below detect its use.\n pcm_input = nil\n # extract the audio to PCM with ffmpeg first because sometimes HandBrakeCLI has problems\n # pcm_input = \"#{input}-temp.avi\"\n # command = <<-EOS\n # nice -n 19 ffmpeg -i \"#{input}\" -acodec adpcm_ms -vcodec copy \"#{pcm_input}\"\n # EOS\n # input = pcm_input # we no longer care about the original.\n # command = command.strip\n # # log.info \"Extracting audio to PCM with ffmpeg...\"\n # puts \"Prepping with ffmpeg using: #{command}\"\n # system(command)\n\n # x264opts will be passed to the '-x' argument of HandBrakeCLI\n # I took these from the advanced tab of the HandBrake 0.9.5 x86_64 (2011010300) GUI for the AppleTV preset\n x264opts = {\n :'cabac' => '0',\n :'ref' => '2',\n :'me' => 'umh',\n :'b-pyramid' => 'none',\n :'b-adapt' => '2',\n :'weightb' => '0',\n :'trellis' => '0',\n :'weightp' => '0',\n :'vbv-maxrate' => '9500',\n :'vbv-bufsize' => '9500' }\n\n options = {\n :'-i' => %{\"#{input}\"},\n :'-o' => %{\"#{output}\"},\n :'--crop' => '0:0:0:0',\n :'-X' => '1280',\n :'-Y' => '720',\n :'-e' => 'x264',\n :'-q' => quality,\n :'--loose-anamorphic' => nil,\n :'--markers' => nil, # chapter markers\n :'-x' => x264opts.map{|k,v| \"#{k}=#{v}\"}.join(':') }\n\n # Now transcode the video and re-mux / transcode in the audio extracted by ffmpeg\n command = \"nice -n 19 HandBrakeCLI #{options.map{|k,v| \"#{k} #{v}\"}.join(\" \")}\"\n command = command.gsub(/ +/, ' ').strip\n # puts \"doing it!: #{command}\"\n system(command) # backticks wont work here.\n\n # if we're using the intermediate pcm-audio step, clean up after ourselves.\n if pcm_input\n # log.info \"Cleaning up ffmpeg intermediate step...\"\n File.delete(pcm_input)\n end\n\n if options[:source_type] == \"mkv\"\n mkv_options = []\n mkvoptions[:log] = log if log\n mkv_file = MkvFile.new(source_file, mkv_options)\n ##### TODO extract any chapter info and import it\n\n if mkv_file.subtitles?\n srt_file = mkv_file.export_subtitles_as_srt\n\n ##### Mux the M4V and SRT files\n log.info \"Muxing subtitles into .M4V file '#{m4v_file}' ...\" if log\n `SublerCLI -i \"#{m4v_file}\" -s \"#{srt_file}\"`\n\n mkv_file.cleanup_subtitle_files\n end\n end\nend", "def video_convert_to_mov_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_mov ...'\n end\n # resource path\n local_var_path = '/video/convert/to/mov'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_mov\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def convert_video_to_AVI(filename, path, content, url)\n logger.debug \"Convert the video ( #{filename} ) path ( #{path}) from content type of #{content} to H264\"\n File.new(File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.avi\"), File::CREAT | File::TRUNC| File::RDWR, 0644)\n videoavi = File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.avi\")\n system(\"ffmpeg -i #{url} -acodec copy -vcodec copy #{videoavi} -y\")\n return videoavi\n end", "def audio_convert_to_m4a_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AudioApi.audio_convert_to_m4a ...'\n end\n # resource path\n local_var_path = '/video/convert/to/m4a'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'bitRate'] = opts[:'bit_rate'] if !opts[:'bit_rate'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AudioApi#audio_convert_to_m4a\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def video_convert_to_webm_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_webm ...'\n end\n # resource path\n local_var_path = '/video/convert/to/webm'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_webm\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def mux(options={})\n if File.file?(options[:output])\n File.delete(options[:output])\n end\n\n create do |mp4creator|\n mp4creator.create = options[:audio]\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.create = options[:video]\n mp4creator.rate = options[:frame_rate].to_f\n mp4creator.file = options[:output]\n end\n\n if options[:hint]\n create do |mp4creator|\n mp4creator.hint = 1\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.hint = 2\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.optimize = true\n mp4creator.file = options[:output]\n end\n end\n end", "def ffmpeg\n @log.info \"Running ffmpeg to convert to MP4\"\n ffmpegOutOptions = \"-strict experimental -vcodec copy -acodec aac\"\n if @remux\n ffmpegOutOptions = \"-vcodec copy -acodec copy\"\n end \n ffmpeg_command =\"ffmpeg -y -i \\\"#{@out_file}.flv\\\" #{ffmpegOutOptions} \\\"#{@out_file}.mp4\\\"\"\n success = system(ffmpeg_command)\n\n if not success\n raise \"Something went wrong running ffmpeg :(. Your file may not have converted properly.\"\n end\n\n @log.info \"File converted\"\n end", "def transcode!\n raise PaperclipError, 'The attachment is not a video' unless video?\n original_file = Paperclip.io_adapters.for(asset)\n asset.queued_for_write[:transcoded] = Paperclip.processor(:video_transcode).make(original_file, { :whiny => true, :geometry => '480x360' }, asset)\n asset.save\n ensure\n original_file.close if original_file.respond_to?(:close)\n end", "def create\n audio_types = [\"audio/vnd.wave\", \"audio/mpeg\", \"audio/mp3\", \"audio/mp4\", \"audio/wav\"]\n video_types = [\"application/mp4\", \"video/mpeg\", \"video/mpeg2\", \"video/mp4\", \"video/quicktime\"]\n unknown_types = [\"application/octet-stream\"]\n \n wrong_format = false \n @upload_format = 'other'\n \n if params.has_key?(:Filedata) and params.has_key?(:original)\n @video_assets = []\n \t\tparams[:Filedata].each do |file|\n puts \"<< MIME type is #{file.content_type} >>\"\n \t\t @upload_format = 'video' if video_types.include?(file.content_type)\n \t\t @upload_format = 'audio' if audio_types.include?(file.content_type)\n \t\t \n \t\t # If the content type cannot be inferred from the MIME type fall back on the\n \t\t # list of unknown types. This is different than a generic fallback because it\n \t\t # is skipped for known invalid extensions like application/pdf\n \t\t @upload_format = determine_format_by_extension(file) if unknown_types.include?(file.content_type)\n \t\t puts \"<< Uploaded file appears to be #{@upload_format} >>\"\n \t\t \n \t\t if 'unknown' == @upload_format\n \t wrong_format = true\n \t break\n \t \n \t\t end\n \t\t \n \t\t\t@video_assets << video_asset = saveOriginalToHydrant(file)\n \t\t\tif video_asset.save\n \t\t\tvideo_asset = sendOriginalToMatterhorn(video_asset, file)\n \t\t\tvideo_asset.save\n\t\t\t end\n \t\t\t#TODO store Workflow instance id and/or MediaPackage in VideoDCDatastream so we can show processing status on edit page later\n \t\tend\n else\n flash[:notice] = \"You must specify a file to upload.\"\n end\n \n respond_to do |format|\n flash[:upload] = create_upload_notice(@upload_format)\n puts \"<< #{flash[:upload]} >>\"\n \n unless params[:container_id].nil?\n \tformat.html { \n redirect_to :controller => \"catalog\", :action => \"edit\", :id => params[:container_id] }\n \tformat.js { }\n else \n format.html { \n redirect_to :controller => \"catalog\", :action => \"index\"}\n format.js { }\n end\n end\n end", "def audio_convert_to_mp3_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AudioApi.audio_convert_to_mp3 ...'\n end\n # resource path\n local_var_path = '/video/convert/to/mp3'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'bitRate'] = opts[:'bit_rate'] if !opts[:'bit_rate'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AudioApi#audio_convert_to_mp3\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def convert_command\n\t\t\tflv = File.join(File.dirname(self.video.path), \"#{self.video_file_name}.flv\")\n\t\t\tmpeg4 = File.join(File.dirname(self.video.path), \"#{self.video_file_name}.mp4\")\n\t\t\tFile.open(flv, 'w')\n\t\t\tFile.open(mpeg4, 'w')\n\t\t\t#command = \"cd log/ && ffmpeg -i #{ self.video.path } -ar 22050 -ab 32 -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y #{ flv }; ffmpeg -i #{ self.video.path } -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 1024k -bt 1024k -threads 0 -y #{ mpeg4 }\"\n\t\t\tcommand = \"cd log/ && ffmpeg -i '#{ self.video.path }' -ar 22050 -ab 32 -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y '#{ flv }'; ffmpeg -threads 4 -i '#{ self.video.path }' -r 29.97 -vcodec libx264 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 24 -bt 256k -refs 1 -coder 0 -subq 5 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -sc_threshold 40 -i_qfactor 0.71 -acodec libfaac -ab 128k -ar 48000 -ac 2 '#{ mpeg4 }'\"\n\n\t\t\tcommand.gsub!(/\\s+/, \" \")\n\t\t\tlogger.debug command\n\t\tend", "def url_to_audio(source, options = T.unsafe(nil)); end", "def run\n begin\n prepare_for_conversion\n\n Queue.run *FORMATS.map{ |format| proc{ convert_to(format) } }, close_connection_before_execution: true\n \n mp4_file_info = Info.new output_path(:mp4)\n webm_file_info = Info.new output_path(:webm)\n \n unless similar_durations?(mp4_file_info.duration, webm_file_info.duration) \n raise Error.new( 'output videos have different duration', \n model_id: model_id, mp4_duration: mp4_file_info.duration, webm_duration: webm_file_info.duration )\n end\n \n cover_path = File.join output_folder, COVER_FORMAT % output_filename_without_extension\n extract_cover output_path(:mp4), cover_path, mp4_file_info.duration\n \n thumb_path = File.join output_folder, THUMB_FORMAT % output_filename_without_extension\n extract_thumb cover_path, thumb_path, *THUMB_SIZES\n \n rescue StandardError => e\n FileUtils.rm_rf output_folder\n \n input_path = \n if File.exists? temp_path\n temp_path\n elsif File.exists? uploaded_path\n uploaded_path\n end\n FileUtils.cp input_path, create_log_folder if input_path\n\n if model.present? and model.user_id.present?\n Notification.send_to(\n model.user_id,\n I18n.t('notifications.video.upload.failed.title'),\n I18n.t('notifications.video.upload.failed.message', :item => model.title),\n ''\n )\n model.destroyable_even_if_not_converted = true\n model.destroy\n end\n\n raise e\n end\n \n model.converted = true\n model.rename_media = true\n model.mp4_duration = mp4_file_info.duration\n model.webm_duration = webm_file_info.duration\n model.media = output_filename_without_extension\n model[:media] = output_filename_without_extension\n model.save!\n\n #FileUtils.rm temp_path\n FileUtils.rm_r temp_folder\n\n Notification.send_to(\n model.user_id,\n I18n.t('notifications.video.upload.ok.title'),\n I18n.t('notifications.video.upload.ok.message', :item => model.title),\n ''\n )\n end", "def process_video(options = {})\n vzaar_video_id = nil\n request_xml = %{\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <vzaar-api>\n <video>\n <guid>#{options[:guid]}</guid>\n <title>#{options[:title]}</title>\n <description>#{options[:description]}</description>\n <profile>#{options[:profile]}</profile>\n }\n if !options[:transcoding].nil?\n request_xml += %{\n <transcoding>#{options[:transcoding]}</transcoding>\n }\n end\n request_xml += %{ \n </video>\n </vzaar-api>\n }\n auth_connection HTTP_POST, '/api/videos', request_xml do |response_body|\n vzaar_video_id = get_video_id_from_response_body(response_body)\n end\n vzaar_video_id\n end", "def decide_interested_video_type\n \n end", "def convert(force = false)\n return false if !force && STATUS_CONVERSION_PENDNG != status\n update_attribute(:status, STATUS_PROCESSING)\n # convert to flv\n flv_path = \"#{AppConfig.tmp_dir}/video-#{id}.flv\"\n File.delete flv_path if File.exists? flv_path\n\n # get an image from the video after 4 seconds \n img_path = \"#{AppConfig.tmp_dir}/video-#{id}-%d.jpg\"\n img_path2 = \"#{AppConfig.tmp_dir}/video-#{id}-1.jpg\"\n File.delete img_path2 if File.exists? img_path2\n\n begin\n system(\"#{AppConfig.video_conversion_command} -i #{File.expand_path(RAILS_ROOT)}/#{original_file} -ar 44100 #{flv_path}\")\n raise \"Failed to convert '#{File.expand_path(RAILS_ROOT)}/#{original_file}' to flv!\" unless $? == 0\n self.stream_file = File.new(flv_path)\n if image.blank?\n system(\"#{AppConfig.video_conversion_command} -i #{File.expand_path(RAILS_ROOT)}/#{original_file} -an -ss 00:00:04 -an -r 1 -vframes 1 -y #{img_path}\")\n unless File.exists? img_path2\n system(\"#{AppConfig.video_conversion_command} -i #{File.expand_path(RAILS_ROOT)}/#{original_file} -an -ss 00:00:00 -an -r 1 -vframes 1 -y #{img_path}\")\n end\n p \"tmp img - #{img_path2}\"\n self.image = File.new(img_path2) if File.exists? img_path2\n end\n\n self.status = STATUS_LIVE\n self.save!\n watermark_image(\"#{RAILS_ROOT}/#{image('thumb')}\") unless image.blank?\n FileUtils.rm_rf(self.original_file_dir)\n return true\n rescue\n update_attribute(:status, STATUS_ERROR)\n logger.error \"ERROR:#{Time.now.iso8601}: #{$!}\"\n return false\n ensure\n File.delete flv_path if File.exists? flv_path\n File.delete img_path2 if File.exists? img_path2\n end\n end", "def convert\n success = system(convert_command + \" > conversion.log\")\n if success && $?.exitstatus == 0\n local_path_util = LocalMediaPathUtil.new \n file_dir = local_path_util.local_media_complete_dir(id)\n t_local_path = file_dir + \"/\" + filename + \".flv\"\n update_attribute(:converted_media_local_path,t_local_path)\n end\n end", "def make\n src = @file\n dst = Tempfile.new([@basename, @format ? \".#{@format}\" : ''])\n dst.binmode\n \n\n parameters = []\n \n # Add source\n parameters << @convert_options[:input].map { |k,v| \"-#{k.to_s} #{v} \"}\n parameters << \"-f --quiet :source\"\n parameters << @convert_options[:output].map { |k,v| \"-#{k.to_s} #{v} \"}\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n \n Paperclip.log(\"[lame] #{parameters}\")\n begin\n success = Paperclip.run(\"lame\", parameters, :source => \"#{File.expand_path(src.path)}\", :dest => File.expand_path(dst.path))\n rescue Cocaine::ExitStatusError => e\n raise PaperclipError, \"error while processing video for #{@basename}: #{e}\" if @whiny\n end\n\n dst\n end", "def convert_video_to_H264(filename, path, content, url)\n logger.debug \"Convert the video ( #{filename} ) path ( #{path}) from content type of #{content} to H264\"\n File.new(File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.h264\"), File::CREAT | File::TRUNC| File::RDWR, 0644)\n videoh264 = File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.h264\")\n system(\"ffmpeg -i #{url} -an -vcodec libx264 -crf 23 #{videoh264} -y\")\n return videoh264\n end", "def to_m4a(options={})\n options[:quality] ||= 320\n options[:output] ||= self.basename_with_path + '.m4a'\n cmd = \"afconvert -v \\\"#{self.path}\\\" -o \\\"#{options[:output]}\\\" -f m4af -d aac -b #{options[:quality]}000 -s 0\"\n system(cmd)\n end", "def create\n\n @video = Video.new(video_params)\n file = @video.video.tempfile\n\n video = Panda::Video.create(:file => file)\n # binding.pry\n video.encodings['h264'].reload\n\n until video.encodings['h264'].status == 'success'\n video.encodings['h264'].reload\n end\n\n video.encodings['h264'].encoding_progress\n @video.video = video.encodings['h264'].url\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to @video, notice: 'video was successfully created.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def to_mp3(filename, params={})\n text = params[:text] || self\n raise \"to_mp3 language option still not implemented\" if params[:language]\n #system(\"echo \\\"#{text.to_s}\\\" | text2wave | lame --alt-preset cbr 16 -a --resample 11 --lowpass 5 --athtype 2 -X3 - > #{filename} 2> /dev/null\")\n system(\"echo \\\"#{text.to_s}\\\" | text2wave -eval \\\"(voice_nitech_us_slt_arctic_hts)\\\" | lame --alt-preset cbr 16 -a --resample 11 --lowpass 5 -X3 - > #{filename} 2> /dev/null\")\n end", "def select_streams(info)\n unless info[:video].empty?\n # There can be only one (video stream).\n info[:video] = info[:video].first\n end\n\n unless info[:audio].empty?\n audio_streams = []\n audio_stream = nil\n\n # Finds the highest quality English audio stream available\n info[:audio].each do |s|\n if s[:language] == 'eng'\n # Surround tracks\n audio_stream ||= s if s[:codec] == 'dts' # DTS\n audio_stream ||= s if s[:codec] == 'dca' # DTS (older ffmpeg)\n audio_stream ||= s if s[:codec] == 'eac3' # Dolby Digital Plus\n audio_stream ||= s if s[:codec] == 'ac3' # Dolby Digital\n # Stereo tracks\n audio_stream ||= s if s[:codec] == 'alac' # Apple lossless\n audio_stream ||= s if s[:codec] == 'flac' # Open-source lossless\n audio_stream ||= s if s[:codec] == 'opus' # Open-source lossy\n audio_stream ||= s if s[:codec] == 'aac' # AAC\n audio_stream ||= s if s[:codec] == 'vorbis' # OGG Vorbis\n audio_stream ||= s if s[:codec] == 'mp3' # MP3\n end\n end\n\n audio_streams << audio_stream if audio_stream != nil\n\n # Adds all of the non-English audio streams.\n info[:audio].each do |s|\n if s[:language] != 'eng'\n audio_streams << s\n end\n end\n\n info[:audio] = audio_streams\n end\n \n unless info[:subtitle].empty?\n # Removes all non-english subtitle streams.\n info[:subtitle].delete_if { |s| s[:language] != 'eng' }\n\n # Removes Bluray PGS subtitles because ffmpeg doesn't have encoding nor OCR support.\n info[:subtitle].delete_if { |s| s[:codec] == 'hdmv_pgs_subtitle' }\n\n # Removes subtitles marked as \"signs and songs\" which are usually forced.\n info[:subtitle].delete_if { |s| s[:title].downcase.include? 'sign' }\n\n # Default to the last subtitle stream (first one is usually forced subs)\n info[:subtitle] = info[:subtitle].last unless info[:subtitle].empty?\n end\n\n return info\nend", "def audio_convert_to_aac_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AudioApi.audio_convert_to_aac ...'\n end\n # resource path\n local_var_path = '/video/convert/to/aac'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'bitRate'] = opts[:'bit_rate'] if !opts[:'bit_rate'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AudioApi#audio_convert_to_aac\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def combine_video(presentation)\n term = presentation['term']\n args = []\n for slide in presentation['slides']\n args.push command_arg(slide['video'])\n end\n args = args.join(' ')\n combined_arg = command_arg(\"#{BUILD_DIR}/#{term}/#{term}-combined.mpg\")\n final = \"#{DIST_DIR}/#{term}/#{term}.avi\"\n final_arg = command_arg(final)\n `cat #{args} > #{combined_arg}`\n `ffmpeg -y -i #{combined_arg} -r 25 -qscale:v 1 #{final_arg}`\n presentation['video'] = final\nend", "def options\n {\n # audio_sample_rate: 44100,\n # audio_channels: 2,\n audio_bitrate: AUDIO_BITRATE,\n video_max_bitrate: new_bitrate,\n buffer_size: new_bitrate,\n # video_bitrate: new_bitrate,\n # FIXME: `-fs` doesn't work as inteded. it just stops encoding when file got bigger.\n # http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2141\n # custom: \"-fs #{FILESIZE_BOUND}\"\n }\n end", "def perform(video_id)\n video = Video.get(video_id)\n flv_video = FFMPEG::Movie.new(video.flv)\n options = {\n resolution: flv_video.resolution,\n video_bitrate: flv_video.video_bitrate,\n audio_bitrate: flv_video.audio_bitrate\n }\n mp4_video = flv_video.transcode('uploads/' + video.id.to_s + '.mp4', options)\n video.update(mp4: mp4_video.path)\n end", "def audio_convert_to_wav_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AudioApi.audio_convert_to_wav ...'\n end\n # resource path\n local_var_path = '/video/convert/to/wav'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'sampleRate'] = opts[:'sample_rate'] if !opts[:'sample_rate'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AudioApi#audio_convert_to_wav\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def convert_to_mp3\n\t\tputs \"\\n=> look for m4a files and convert it to mp3\\n\"\n\t\t\n\t\t# grab directory names.\n\t\tdir_names = Dir.entries @@dir_temp\n\t\t# remove .prefixes\n\t\tdir_names = self.remove_hidden_files dir_names\n\t\t\n\t\t# go thru each sub directories.\n\t\tdir_names.each do |current_dir|\n\t\t\tputs \"\\n=> at \" + @@dir_temp + current_dir + \"\\n\"\n\t\t\t\n\t\t\t# grabs the files in the directory\n\t\t\tcurrent_files = Dir.entries(@@dir_temp + \"/\" + current_dir)\n\t\t\t\n\t\t\t# remove the . prefixes.\n\t\t\tcurrent_files = self.remove_hidden_files current_files\n\t\t\t\n\t\t\t# cycle thru the file\n\t\t\tcurrent_files.each do |current_file|\n\t\t\t\t# file names\n\t\t\t\tsrc_file = \"\"\n\t\t\t\tdest_file = \"\"\n\t\t\t\n\t\t\t\t# checks if it has a m4a extension\n\t\t\t\tif self.is_m4a? current_file\t\t\n\t\t\t\t\tputs \"\\n=> encoding \" + current_file\n\t\t\t\t\t\n\t\t\t\t\t# creating src and dest files.\n\t\t\t\t\tsrc_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + self.ext_to_mp3(current_file)\n\t\t\t\t\t\n\t\t\t\t\t#src_file = \"'\" + src_file + \"'\" \n\t\t\t\t\t#dest_file = \"'\" + dest_file + \"'\" \n\t\t\t\t\t\n\t\t\t\t\t# escape the names.\n\t\t\t\t\tsrc_file = self.escaped_file_name(src_file)\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\t\t\n\t\t\t\t\tputs \"=> src \" + src_file \n\t\t\t\t\tputs \"=> dest \" + dest_file\n\t\t\t\t\t\n\t\t\t\t\t# lame encoding.\n\t\t\t\t\tself.lame_str(@@opt_lame, src_file, dest_file)\n\t\t\t\telse\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# split the mp3...\n\t\t\t\tself.mp3splt_str(@@opt_mp3splt, dest_file)\n\t\t\t\t\n\t\t\t\t# delete the source file.\n\t\t\t\t# only want the split files.\n\t\t\t\tself.rm_str(\"\", dest_file)\n\t\t\t\tif (src_file != \"\")\n\t\t\t\t\tself.rm_str(\"\", src_file)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def path_to_audio(source, options = T.unsafe(nil)); end", "def convertSlidesToVideo(presentationSlidesStart)\n presentationSlidesStart.each do |item|\n # Path to original svg\n originalLocation = File.join(item[\"filepath\"], item[\"filename\"])\n # Save conversion with similar path in tmp\n dirname = File.join(TMP_PATH, item[\"presentationName\"], \"svgs\")\n finalLocation = File.join(dirname, changeFileExtensionTo(item[\"filename\"], \"mp4\"))\n\n if (!File.exists?(finalLocation))\n # Create path to save conversion to\n unless File.directory?(dirname)\n FileUtils.mkdir_p(dirname)\n end\n\n # Convert to png\n image = MiniMagick::Image.open(originalLocation)\n image.format 'png'\n pathToImage = File.join(dirname, changeFileExtensionTo(item[\"filename\"], \"png\"))\n image.write pathToImage\n\n # Convert to video\n # Scales the output to be divisible by 2\n system \"ffmpeg -loglevel quiet -nostdin -nostats -y -r 30 -i #{pathToImage} -vf crop='trunc(iw/2)*2:trunc(ih/2)*2' #{finalLocation}\"\n end\n\n item[\"filepath\"] = dirname\n item[\"filename\"] = finalLocation.split('/').last\n end\n\n return presentationSlidesStart\nend", "def create\n @video = Video.new(event_id: params[:event_id], has_youtube: params[:has_youtube], video: params[:video], youtube: params[:youtube], default: params[:default])\n\n if params[:has_youtube] == 'false'\n image = StringIO.new(Base64.decode64(params[:poster]))\n image.class.class_eval { attr_accessor :original_filename, :content_type }\n image.original_filename = 'tester.jpg'\n image.content_type = 'image/jpeg'\n @video.poster = image\n end\n\n respond_to do |format|\n if @video.save\n unless @video.has_youtube\n transcode_flv(opentok_flv_url(@video.video), @video.video)\n end\n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n format.json { render json: @video, status: :created, location: @video }\n else\n format.html { render action: \"new\" }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def physical_video_params\n params.require(:physical_video).permit(:physical_item_id, :is_3d, :format, :resolution, :sound, :dubbed, :other_information)\n end", "def update!(**args)\n @audio_bitrate = args[:audio_bitrate] if args.key?(:audio_bitrate)\n @audio_channels = args[:audio_channels] if args.key?(:audio_channels)\n @audio_codec_id = args[:audio_codec_id] if args.key?(:audio_codec_id)\n @audio_end_timestamp = args[:audio_end_timestamp] if args.key?(:audio_end_timestamp)\n @audio_frame_size = args[:audio_frame_size] if args.key?(:audio_frame_size)\n @audio_length = args[:audio_length] if args.key?(:audio_length)\n @audio_number_of_frames = args[:audio_number_of_frames] if args.key?(:audio_number_of_frames)\n @audio_sample_rate = args[:audio_sample_rate] if args.key?(:audio_sample_rate)\n @audio_sample_size = args[:audio_sample_size] if args.key?(:audio_sample_size)\n @audio_start_timestamp = args[:audio_start_timestamp] if args.key?(:audio_start_timestamp)\n @audio_stream = args[:audio_stream] if args.key?(:audio_stream)\n @audio_stream_codec_tag = args[:audio_stream_codec_tag] if args.key?(:audio_stream_codec_tag)\n @av_distance = args[:av_distance] if args.key?(:av_distance)\n @av_length = args[:av_length] if args.key?(:av_length)\n @average_video_fps = args[:average_video_fps] if args.key?(:average_video_fps)\n @build_label = args[:build_label] if args.key?(:build_label)\n @container_id = args[:container_id] if args.key?(:container_id)\n @container_type = args[:container_type] if args.key?(:container_type)\n @contains_chapters = args[:contains_chapters] if args.key?(:contains_chapters)\n @data_stream = args[:data_stream] if args.key?(:data_stream)\n @display_height = args[:display_height] if args.key?(:display_height)\n @display_width = args[:display_width] if args.key?(:display_width)\n @file_header_fingerprint = args[:file_header_fingerprint] if args.key?(:file_header_fingerprint)\n @file_magic = args[:file_magic] if args.key?(:file_magic)\n @file_modified_time = args[:file_modified_time] if args.key?(:file_modified_time)\n @file_name = args[:file_name] if args.key?(:file_name)\n @file_size = args[:file_size] if args.key?(:file_size)\n @file_type = args[:file_type] if args.key?(:file_type)\n @google_video_clip_info = args[:google_video_clip_info] if args.key?(:google_video_clip_info)\n @image_stream = args[:image_stream] if args.key?(:image_stream)\n @is_asf = args[:is_asf] if args.key?(:is_asf)\n @is_image_file = args[:is_image_file] if args.key?(:is_image_file)\n @is_video_insane_size = args[:is_video_insane_size] if args.key?(:is_video_insane_size)\n @level = args[:level] if args.key?(:level)\n @metadata = args[:metadata] if args.key?(:metadata)\n @num_audio_streams = args[:num_audio_streams] if args.key?(:num_audio_streams)\n @num_data_streams = args[:num_data_streams] if args.key?(:num_data_streams)\n @num_image_streams = args[:num_image_streams] if args.key?(:num_image_streams)\n @num_timedtext_streams = args[:num_timedtext_streams] if args.key?(:num_timedtext_streams)\n @num_video_streams = args[:num_video_streams] if args.key?(:num_video_streams)\n @parsed_by_ffmpeg = args[:parsed_by_ffmpeg] if args.key?(:parsed_by_ffmpeg)\n @partial_file = args[:partial_file] if args.key?(:partial_file)\n @pix_fmt = args[:pix_fmt] if args.key?(:pix_fmt)\n @profile = args[:profile] if args.key?(:profile)\n @timedtext_stream = args[:timedtext_stream] if args.key?(:timedtext_stream)\n @video_bitrate = args[:video_bitrate] if args.key?(:video_bitrate)\n @video_clip_info = args[:video_clip_info] if args.key?(:video_clip_info)\n @video_codec_id = args[:video_codec_id] if args.key?(:video_codec_id)\n @video_end_timestamp = args[:video_end_timestamp] if args.key?(:video_end_timestamp)\n @video_fps = args[:video_fps] if args.key?(:video_fps)\n @video_frame_size = args[:video_frame_size] if args.key?(:video_frame_size)\n @video_has_b_frames = args[:video_has_b_frames] if args.key?(:video_has_b_frames)\n @video_has_fragments = args[:video_has_fragments] if args.key?(:video_has_fragments)\n @video_has_leading_moov_atom = args[:video_has_leading_moov_atom] if args.key?(:video_has_leading_moov_atom)\n @video_has_non_monotonic_dts = args[:video_has_non_monotonic_dts] if args.key?(:video_has_non_monotonic_dts)\n @video_has_non_monotonic_pts = args[:video_has_non_monotonic_pts] if args.key?(:video_has_non_monotonic_pts)\n @video_has_non_zero_start_edit_list = args[:video_has_non_zero_start_edit_list] if args.key?(:video_has_non_zero_start_edit_list)\n @video_has_possible_open_gop = args[:video_has_possible_open_gop] if args.key?(:video_has_possible_open_gop)\n @video_has_variable_aspect_ratio = args[:video_has_variable_aspect_ratio] if args.key?(:video_has_variable_aspect_ratio)\n @video_height = args[:video_height] if args.key?(:video_height)\n @video_interlace = args[:video_interlace] if args.key?(:video_interlace)\n @video_length = args[:video_length] if args.key?(:video_length)\n @video_number_of_frames = args[:video_number_of_frames] if args.key?(:video_number_of_frames)\n @video_number_of_invisible_frames = args[:video_number_of_invisible_frames] if args.key?(:video_number_of_invisible_frames)\n @video_pixel_aspect_ratio = args[:video_pixel_aspect_ratio] if args.key?(:video_pixel_aspect_ratio)\n @video_rotation = args[:video_rotation] if args.key?(:video_rotation)\n @video_start_timestamp = args[:video_start_timestamp] if args.key?(:video_start_timestamp)\n @video_stream = args[:video_stream] if args.key?(:video_stream)\n @video_stream_codec_tag = args[:video_stream_codec_tag] if args.key?(:video_stream_codec_tag)\n @video_width = args[:video_width] if args.key?(:video_width)\n @videostreaminfo_version = args[:videostreaminfo_version] if args.key?(:videostreaminfo_version)\n @y_psnr = args[:y_psnr] if args.key?(:y_psnr)\n end", "def ffmpeg_libvpx_cmd(input_path, output_path, bitrate, output_size, force=false)\n replace = force ? \"-y\" : \"\"\n return [\n \"ffmpeg -i '#{input_path}' -threads 8\",\n \"-c:v libvpx -pix_fmt yuv420p -crf 10 -b:v #{bitrate} -s #{output_size} -movflags +faststart -r 29.97 -c:a libvorbis -aq 5 #{replace} '#{output_path}'\"\n ]\nend", "def test_convert_video\n get convert_url, params: { url: Predoc::TestConfig::FIXTURE_URLS[:mp4] }\n assert_response :success\n assert_template(:error)\n end", "def video_convert_to_mp4(opts = {})\n data, _status_code, _headers = video_convert_to_mp4_with_http_info(opts)\n data\n end", "def pbResolveAudioFile(str,volume=nil,pitch=nil)\n if str.is_a?(String)\n str=pbStringToAudioFile(str)\n str.volume=100\n str.volume=volume if volume\n str.pitch=100\n str.pitch=pitch if pitch\n end\n if str.is_a?(RPG::AudioFile)\n if volume || pitch\n return RPG::AudioFile.new(str.name,\n volume||str.volume||80,\n pitch||str.pitch||100)\n else\n return str\n end\n end\n return str\nend", "def get_video_codec \n send_cmd(\"get_video_codec\")\n end", "def encode\n Rails.logger.debug \"*** Sending video to encoding.com\"\n self.encodingid = ENCQ.add_and_process(\n encoding_source_url, #source\n {\n # Task 1: Encode into a 608x size video mp4 (normal)\n # encoding_target_url => EncodingDotCom::Format.create(\n # 'output' => 'mp4',\n # 'size' => '608x0',\n # 'add_meta' => 'yes',\n # 'bitrate' => '1024k',\n # 'framerate' => '25',\n # 'video_codec' => 'libx264',\n # 'audio_bitrate' => '128k',\n # 'profile' => 'baseline',\n # 'two_pass' => 'yes'),\n # Encode into a 608x size video flv w/ vp6\n encoding_target_url('flv') => EncodingDotCom::Format.create(\n 'output' => 'flv',\n 'size' => '608x0',\n 'bitrate' => '1024k',\n 'framerate' => '25',\n 'video_codec' => 'vp6',\n 'audio_bitrate' => '128k'),\n # # Task 2: Encode into a 320x size video (preview)\n # resource.container_encoded_url('preview') => EncodingDotCom::Format.create(\n # 'output' => 'mp4',\n # 'size' => '320x0',\n # 'add_meta' => 'yes',\n # 'bitrate' => '1024k',\n # 'framerate' => '25',\n # 'video_codec' => 'libx264',\n # 'audio_bitrate' => '128k',\n # 'profile' => 'baseline',\n # 'two_pass' => 'yes'),\n \n # Task 2: Generate a thumbnail\n encoding_target_url('jpg') => EncodingDotCom::Format.create(\n 'output' => 'thumbnail', \n 'width' => '100', \n 'height' => '100',\n 'time' => 2),\n },\n #{ 'notify' => encoding_callback_url }\n { 'notify' => encoding_callback_url(:host => ENCODING_DOT_COM_POSTBACK_HOST)}\n # Alternatively you could also:\n #{ 'notify' => \"[email protected]\" }\n )\n save\n end", "def multiplex(movie, video_file, audio_file)\n codecs = ['xvid', 'mpeg2', 'mp4']\n codec = 'xvid'\n if codecs.include?(movie.format)\n codec = movie.format\n end\n \n if(codec == \"xvid\")\n multiplexer = XvidMultiplexer.new\n multiplexer.multiplex(movie, video_file, audio_file)\n elsif(codec == \"mpeg2\")\n multiplexer = Mpeg2Multiplexer.new\n multiplexer.multiplex(movie, video_file, audio_file)\n elsif(codec == \"mp4\")\n multiplexer = Mp4Multiplexer.new\n multiplexer.multiplex(movie, video_file, audio_file)\n end\n \n end", "def set_formatvideo\n @formatvideo = Formatvideo.find(params[:id])\n end", "def ffmpeg_libx264_cmd(input_path, output_path, bitrate, output_size, force=false)\n crf = case bitrate\n when \"10M\" then 20\n when \"2M\" then 20\n when \"500k\" then 21\n else 21\n end\n replace = force ? \"-y\" : \"\"\n return [\n \"ffmpeg -i '#{input_path}' -threads 8\",\n \"-c:v libx264 -profile:v main -pix_fmt yuv420p -tune film -crf #{crf} -s #{output_size} -movflags +faststart -r 29.97 -c:a libfdk_aac -b:a 48k #{replace} '#{output_path}'\"\n ]\nend", "def audio_format(infile)\n format = nil\n cmd = [\"ffprobe\", \"-hide_banner\", infile]\n \n IO.popen(cmd, \"rb\", :err=>[:child, :out]) do |io| \n io.each_line do |line|\n # Stream #0:1: Audio: aac (LC), 22050 Hz, stereo, fltp\n # Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s\n # Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p, 67 kb/s\n # Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 310 kb/s\n if line =~ /Stream.+Audio.+(aac|mp3)/\n format = $1\n break\n end\n end\n end\n\n case format\n when nil\n \"\"\n when \"aac\" \n \"m4a\"\n else\n format\n end\nend", "def convert_video_to_flv(filename, path, content, url)\n logger.debug \"Convert the video ( #{filename} ) path ( #{path}) from content type of #{content} to flv\"\n File.new(File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.flv\"), File::CREAT | File::TRUNC| File::RDWR, 0644)\n videoflv = File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.flv\")\n system(\"ffmpeg -i #{url} -r 25 -ar 44100 -vcodec flv -ab 32 -y -f flv -s 320x240 #{videoflv}\")\n return videoflv\n end", "def convert_audio(stream, index)\n args = []\n\n # If this is the first audio stream in an MP4 video file, and it contains more than two channels, a stereo AAC\n # version of the stream is needed to satisfy strict MP4 clients, like QuickTime. Then the original multi-channel\n # stream can be added, below.\n if index == 0 && stream[:channels] > 2\n args << convert_audio_to_aac(stream, index)\n index = 1\n end\n\n if stream[:channels] > 2\n # Ensure that multi-channel audio is in AC3 format.\n case stream[:codec]\n when 'ac3', 'eac3'\n args << copy_audio(stream, index)\n else\n args << convert_audio_to_ac3(stream, index)\n end\n else\n # Ensure that stereo audio is in AAC format.\n if stream[:codec] == 'aac'\n args << copy_audio(stream, index)\n else\n args << convert_audio_to_aac(stream, index)\n end\n end\n\n return (index + 1), args\nend", "def audio; end", "def create\n @video = Video.new(video_params.merge(:owner => current_user))\n @original = nil\n if (@video.errors[:video_exists])\n @original = Video.where(:external_id => @video.external_id, :type => @video.type).first\n end\n if @video.save\n render :json => @video, :include => ALL_INCLUDES\n else\n render :json => @video.errors, status: :unprocessable_entity\n end\n end", "def convert(f, opts = {})\n opts = opts.dup\n f = f.to_s.downcase\n allowed = cwv_config.allowed_formats\n raise ArgumentError, \"Format must be one of: #{allowed.join(',')}\" unless allowed.include?(f)\n self.format_override = f == 'jpeg' ? 'jpg' : f\n opts[:Q] = opts.delete(:quality) if opts.has_key?(:quality)\n write_opts.merge!(opts)\n get_image\n end", "def do_video_job(*inputs)\n puts \"Creating output movie: #{@output}\"\n do_system(\"cp\", inputs.first, @output) # FIXME\n # TODO: http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files\n # do_system\n # dir & .work -> output to: @output\n end", "def video\n \"#{self.video_file_name}\"\n end", "def media(filename, opts = {})\n n = input(filename, opts)\n @videos << n\n @audios << n\n n\n end", "def create\n @channel = params[:forminfo]\n @video = Video.new(params[:video])\n video_file = params[:video_file]\n img_file = params[:img_file]\n @video.video_type = params[:video_type]\n @video.video_id = Utils.videoid\n\n if video_file != nil\n @video.video_url = \"http://#{Constants::UPLOAD_IP}/files/videos/\"+Utils.upload(video_file, videoid)\n end\n\n if img_file != nil\n @video.video_img =\"http://#{Constants::UPLOAD_IP}/files/images/\"+Utils.upload(img_file, nil)\n end\n @video.cid = @channel\n respond_to do |format|\n if @video.save\n format.html { redirect_to channel_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def encode_movie(m)\r\n\tmovie_path = m[0..(m.length-2)].join('\\\\')\r\n\tmovie_folder = m[m.length-1]\r\n\r\n\tprint movie_folder + \", path:\" +movie_path+ \"\\n\"\r\n\r\n\tmovie_data_path = movie_path + \"\\\\\" + movie_folder + \"\\\\Pos0\\\\\"\r\n\tout_file = movie_data_path + \"..\\\\\" + movie_folder\r\n\tffmpeg_cmd = \"ffmpeg32 -framerate 30 -threads 2 -report -i \\\"#{movie_data_path}\\\\img_%09d_Default_000.tif\\\" -pix_fmt yuv420p \\\"#{out_file}.m4v\\\"\"\r\n\tprint \"#{ffmpeg_cmd}\\n=>\\n\"\r\n\t`#{ffmpeg_cmd}`\r\n\treturn [movie_path, \"#{out_file}.m4v\", movie_folder]\r\nend", "def video_params\n params.require(:video).permit(:title, :source, :board_id, :iFrame_Source, :type)\n end", "def video_params\n params.require(:video).permit(:user_id, :id_code, :provider, :title, :duration, :description, :thumbnail, :embed_url, :embed_code, :tags, :category1, :category2, :plays)\n end", "def to_mp3\n temp = Tempfile.new(File.basename(filename, '.flv') + \".mp3\")\n \n begin\n transcoder = Transcoder.new(full_filename, temp.path)\n transcoder.flashToAudio\n save_transcoder_commands(transcoder)\n rescue RVideo::TranscoderError => e\n save_transcoder_commands(transcoder)\n raise AudioConversionException.new(\"Unable to convert recording to audio: #{e.message}\")\n end\n \n temp.path\n end", "def convert_mkv_to_mp4(mkv_file)\n mp4_name = clean_mp4_name(mkv_file)\n system(\"ffmpeg -i '#{mkv_file}' -vcodec copy -acodec copy '#{mp4_name}'\")\n end", "def test_youtube_different_formats\r\n result = `ruby bin/viddl-rb http://www.youtube.com/watch?v=Zj3tYO9co44 --url-only --quality 640:360:mp4`\r\n assert_equal $?, 0\r\n can_download_test(result)\r\n assert result.include?(\"itag=18\")\r\n\r\n result2 = `ruby bin/viddl-rb http://www.youtube.com/watch?v=Zj3tYO9co44 --url-only --quality *:720:*`\r\n assert_equal $?, 0\r\n can_download_test(result2)\r\n assert result2.include?(\"itag=22\")\r\n end", "def video(*sources)\n options = sources.extract_options!.symbolize_keys\n sources = sources.shift if sources.size == 1\n\n if options[:poster]\n options[:poster] = asset_path(options[:poster])\n end\n\n if size = options.delete(:size)\n options[:width], options[:height] = size =~ /^\\d+x\\d+$/ ? size.split('x') : size\n end\n\n if sources.is_a?(Array)\n content_tag(:video, options) do\n sources.collect { |source| tag(:source, src: asset_path(source)) }.join(\"\\n\")\n end\n else\n tag(:video, options.reverse_merge(src: asset_path(sources)))\n end\n end", "def update!(**args)\n @ambisonics = args[:ambisonics] if args.key?(:ambisonics)\n @bitrate = args[:bitrate] if args.key?(:bitrate)\n @channel_position = args[:channel_position] if args.key?(:channel_position)\n @channels = args[:channels] if args.key?(:channels)\n @clock_discontinuity_us = args[:clock_discontinuity_us] if args.key?(:clock_discontinuity_us)\n @codec_fourcc = args[:codec_fourcc] if args.key?(:codec_fourcc)\n @codec_id = args[:codec_id] if args.key?(:codec_id)\n @codec_string = args[:codec_string] if args.key?(:codec_string)\n @content_type = args[:content_type] if args.key?(:content_type)\n @decode_offset = args[:decode_offset] if args.key?(:decode_offset)\n @end_timestamp = args[:end_timestamp] if args.key?(:end_timestamp)\n @frame_size = args[:frame_size] if args.key?(:frame_size)\n @language = args[:language] if args.key?(:language)\n @length = args[:length] if args.key?(:length)\n @metadata = args[:metadata] if args.key?(:metadata)\n @number_of_frames = args[:number_of_frames] if args.key?(:number_of_frames)\n @profile = args[:profile] if args.key?(:profile)\n @sample_rate = args[:sample_rate] if args.key?(:sample_rate)\n @sample_size = args[:sample_size] if args.key?(:sample_size)\n @start_timestamp = args[:start_timestamp] if args.key?(:start_timestamp)\n @stream_codec_tag = args[:stream_codec_tag] if args.key?(:stream_codec_tag)\n @stream_index = args[:stream_index] if args.key?(:stream_index)\n end", "def video_params\n params.require(:video).permit(:name, :description, :added_by, :duration, :video_file, :audio_file, :image_file)\n end", "def wp_get_video_extensions()\n # Filters the list of supported video formats.\n apply_filters('wp_video_extensions', ['mp4', 'm4v', 'webm', 'ogv', 'flv'])\n end", "def media_video_processed_url\n if self.asset_type == TYPE[:media_video] && read_attribute(:processed).present? && self.processed == true\n self.file.url(:processed,false).gsub(/\\.[0-9a-zA-Z]+$/,\".mp4\")\n end\n end", "def video_params\n params.require(:video).permit(:name_autor, :last_name_autor, :email_autor, :comment, :state, :url_converted_video)\n end", "def video?\n codec_type == 'video'\n end", "def create\n \n #@video = params\n params[:video]['price'] = '0.00';\n params[:video]['is_active'] = '1';\n #params[:video]['lesson_upload'] = 'no_image';\n #params[:video]['lesson_upload_file_name'] = 'no_image';\n #params[:video]['lesson_upload_content_type'] = 'no_image';\n #params[:video]['lesson_upload_file_size'] = '0';\n \n \n \n @video = current_user.videos.build(params[:video])\n respond_to do |format|\n if @video.save\n #@video.convert\n VideoMailer.video_confirmation(@video).deliver\n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n else\n format.html { render action: \"new\" }\n format.js\n end\n end\n end", "def process_audio\n `ffmpeg -y #{debug_settings} -i #{@filename} -c:a libfdk_aac -b:a 128k -vn #{audio_filepath}`\n `mp4fragment #{audio_filepath} #{audio_filepath_fragmented}`\n FileUtils.rm audio_filepath\n end", "def video_path(source, options = T.unsafe(nil)); end", "def deliver(iSrcFileName, iDstFileName, iFormatConf, iMetadata)\n # TODO: Implement it using an external tool, and make regression testing\n lTranslatedParams = []\n iParams.each do |iParam, iValue|\n case iParam\n when :SampleRate\n lTranslatedParams << \"Sample rate: #{iValue} Hz\"\n when :BitRate\n lTranslatedParams << \"Bit rate: #{iValue} kbps\"\n else\n log_warn \"Unknown MP3 format parameter: #{iParam} (value #{iValue.inspect}). Ignoring it.\"\n end\n end\n puts \"Convert file #{iSrcFileName} into file #{iDstFileName} in MP3 format with following parameters: #{lTranslatedParams.join(', ')}\"\n puts 'Press Enter when done.'\n $stdin.gets\n end", "def convert(src, dst, src_in_local, dst_in_local, is_url, options=nil, storage_name=nil)\r\n if src_in_local\r\n res = @storage_api.upload_file(\"/\", src)\r\n if res.uploaded.length != 1 || res.errors.length != 0\r\n fail ApiError.new('Unable to upload file')\r\n end\r\n file_in_storage = res.uploaded[0]\r\n else\r\n file_in_storage = src\r\n end\r\n\r\n out_file = File.basename(dst)\r\n out_file = dst unless dst_in_local\r\n\r\n input_format = 'html'\r\n input_format = get_input_format(src) unless is_url\r\n\r\n output_format = File.extname(dst).strip.downcase[1..-1]\r\n\r\n if output_format == 'jpg'\r\n output_format = 'jpeg'\r\n elsif output_format == 'mht'\r\n output_format = 'mhtml'\r\n elsif output_format == 'tif'\r\n output_format = 'tiff'\r\n end\r\n\r\n local_var_path = \"/html/conversion/{from}-{to}\".sub('{' + 'from' + '}', input_format.to_s).sub('{' + 'to' + '}', output_format.to_s)\r\n\r\n post_body = {}\r\n post_body[:'inputPath'] = file_in_storage.to_s\r\n post_body[:'outputFile'] = out_file.to_s\r\n post_body[:'storageName'] = storage_name.to_s\r\n\r\n unless options.nil?\r\n post_body[:'options'] = {}\r\n post_body[:'options'][:'width'] = options[:'width'] unless options[:'width'].nil?\r\n post_body[:'options'][:'height'] = options[:'height'] unless options[:'height'].nil?\r\n post_body[:'options'][:'leftMargin'] = options[:'left_margin'] unless options[:'left_margin'].nil?\r\n post_body[:'options'][:'rightMargin'] = options[:'right_margin'] unless options[:'right_margin'].nil?\r\n post_body[:'options'][:'topMargin'] = options[:'top_margin'] unless options[:'top_margin'].nil?\r\n post_body[:'options'][:'bottomMargin'] = options[:'bottom_margin'] unless options[:'bottom_margin'].nil?\r\n post_body[:'options'][:'resolution'] = options[:'resolution'] unless options[:'resolution'].nil?\r\n post_body[:'options'][:'background'] = options[:'background'] unless options[:'background'].nil?\r\n post_body[:'options'][:'jpegquality'] = options[:'jpeg_quality'] unless options[:'jpeg_quality'].nil?\r\n post_body[:'options'][:'usegit'] = options[:'use_git'] unless options[:'use_git'].nil?\r\n post_body[:'options'][:'error_threshold'] = options[:'error_threshold'] unless options[:'error_threshold'].nil?\r\n post_body[:'options'][:'max_iterations'] = options[:'max_iterations'] unless options[:'max_iterations'].nil?\r\n post_body[:'options'][:'colors_limit'] = options[:'colors_limit'] unless options[:'colors_limit'].nil?\r\n post_body[:'options'][:'line_width'] = options[:'line_width'] unless options[:'line_width'].nil?\r\n end\r\n\r\n query_params = {}\r\n\r\n # header parameters\r\n header_params = {}\r\n # HTTP header 'Accept' (if needed)\r\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\r\n # HTTP header 'Content-Type'\r\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\r\n\r\n # form parameters\r\n form_params = {}\r\n\r\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\r\n :header_params => header_params,\r\n :query_params => query_params,\r\n :form_params => form_params,\r\n :body => post_body,\r\n :return_type => 'OperationResult')\r\n if @api_client.config.debug\r\n @api_client.config.logger.debug \"API called: Create task\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\r\n end\r\n\r\n if status_code != 200\r\n fail ApiError.new('Conversion failed')\r\n end\r\n\r\n while true\r\n data, status_code, headers = get_status(data.id)\r\n fail ApiError.new('Conversion failed') if data.code != 200 or data.status == 'faulted' or data.status == 'canceled'\r\n break if data.status == 'completed'\r\n sleep 3\r\n end\r\n\r\n if dst_in_local\r\n out_folder = File.dirname(dst)\r\n d = @storage_api.download_file(data.file)\r\n out_name = out_folder + '/' + File.basename(data.file)\r\n File.rename(d, out_name)\r\n data.file = out_name\r\n end\r\n\r\n data\r\n end", "def update!(**args)\n @h264 = args[:h264] if args.key?(:h264)\n @h265 = args[:h265] if args.key?(:h265)\n @vp9 = args[:vp9] if args.key?(:vp9)\n end", "def audio(path, attr=nil)\n attr ||= {}\n attr.merge!( {width: 0, height: 0, hidden: true} )\n video(path, attr)\nend", "def convertToOGG()\n call = \"mpg321 #{File.join(RAILS_ROOT, self.filePath)} -w - | oggenc -o #{ File.join(RAILS_ROOT, @@publicDir, @@tracksDir, self.fileName)}.ogg -\"\n system(call)\n File.delete(self.filePath) if File.exist?(self.filePath)\n self.fileType = \".ogg\"\n \n #ID3 tags get lost in the conversion process - put them back into file\n begin\n musicFile = TagLib::File.new(self.filePath())\n musicFile.title = self.id3Title\n musicFile.artist = self.id3Artist\n musicFile.save()\n rescue TagLib::BadFile => exc\n logger.error(\"Failed to id track: \\n #{exc}\")\n end\n \n \n end", "def run\n outputs = nil\n \n in_tmp_dir do\n image = tmp_path 'text_to_image.jpg'\n Image::Editing::Cmd::TextToImage.new(text, image, @options).run!\n\n outputs = ImageToVideo.new(image, @output_without_extension, duration, @log_folder).run\n end\n\n outputs\n end", "def encode(file=\"output.avi\")\n puts \"encoding video #{file}\"\n MEncoder.encode do |mencoder|\n mencoder.input = \"mf://#{@frames_dir.file_list(@date, @hour, @length, @frame_type).join(',')}\"\n mencoder.mf.fps = 2\n mencoder.mf.type = \"jpg\"\n mencoder.output_video_codec = :lavc\n mencoder.lavc.vcodec = \"mpeg4\"\n mencoder.lavc.mbd = 2\n mencoder.lavc.trell = true\n mencoder.output_audio_codec = 'copy'\n mencoder.output = file\n end\n end", "def create\n @audio_encoding = AudioEncoding.find_audio_to_encode\n \n # Quit unless there's an audio encoding\n unless @audio_encoding\n respond_to { |format| format.json {render :json => ''} }\n return\n end\n \n respond_to do |format|\n if @audio_encoding.encode_mp3_and_video\n format.json { render :json => @audio_encoding, :status => :created, :location => @audio_encoding }\n else\n format.json { render :json => @audio_encoding.errors, :status => :unprocessable_entity }\n end\n end\n end", "def video_params\n params[:video]\n end", "def video_params\n params[:video]\n end", "def video_params\n params[:video]\n end", "def create\n @raw_video = RawVideo.new(params[:raw_video])\n\n respond_to do |format|\n if @raw_video.save\n format.html { redirect_to(@raw_video, :notice => 'Raw video was successfully created.') }\n format.xml { render :xml => @raw_video, :status => :created, :location => @raw_video }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @raw_video.errors, :status => :unprocessable_entity }\n end\n end\n end", "def encode(path)\n exec = \"ffmpeg\"\n input = \"-i #{@path.shellescape}\"\n vcodec = \"-vcodec mpeg4\"\n vsize = \"-s #{@data[:size] or DEFAULT[:size]}\"\n vrate = \"-r #{@metadata[:framerate] or DEFAULT[:framerate]}\"\n vbit = \"-b #{@data[:bitrate].split(' ').first or DEFAULT[:bitrate]}k\"\n acodec = \"-acodec libfaac\"\n achan = \"-ac 2\"\n arate = \"-ar #{@metadata[:audiosamplerate] or DEFAULT[:audiosamplerate]}\"\n abit = \"-ab #{@metadata[:audiodatarate] or DEFAULT[:audiodatarate]}k\"\n output = \"#{path.shellescape} 2>&1\"\n command = [exec, input,\n vcodec, vsize, vrate, vbit,\n acodec, achan, arate, abit,\n output].join(' ')\n LOGGER.info self\n LOGGER.info DEFAULT\n LOGGER.info command\n LOGGER.info `#{command}`\n end", "def codec\n \"-acodec libmp3lame -y\"\n end", "def video?\n if mime_type == 'application/mxf'\n ffprobe.codec_type.any? {|type| type == 'video'}\n else\n super\n end\n end", "def video_params\n params.require(:video).permit(:anime_id, :video_url, :frame, :release)\n end" ]
[ "0.6938868", "0.6635411", "0.6513551", "0.64837646", "0.6384144", "0.63588923", "0.6340649", "0.6329003", "0.6306368", "0.62831634", "0.6236936", "0.61529404", "0.6118663", "0.6039648", "0.6009672", "0.5977794", "0.5940882", "0.5904802", "0.5895687", "0.58783036", "0.58403414", "0.58392596", "0.58127725", "0.5794799", "0.57822144", "0.57749504", "0.5749035", "0.57418525", "0.57338434", "0.5726175", "0.57190424", "0.57184744", "0.5712364", "0.5688229", "0.5680273", "0.5654555", "0.5646959", "0.5641108", "0.5631495", "0.5609966", "0.5553415", "0.5546452", "0.55377036", "0.552314", "0.5521663", "0.55126244", "0.550469", "0.5492345", "0.54914945", "0.5479385", "0.54757804", "0.5465648", "0.546207", "0.5461564", "0.54565895", "0.5455705", "0.5437696", "0.5430974", "0.54292226", "0.541917", "0.54125434", "0.5411498", "0.5396319", "0.53916067", "0.5388846", "0.5387448", "0.5382767", "0.5371816", "0.53693247", "0.53451854", "0.53430635", "0.5336381", "0.5335348", "0.5332503", "0.5326189", "0.53210616", "0.53176624", "0.5304952", "0.52991515", "0.5298425", "0.52980864", "0.52967936", "0.5291795", "0.52898234", "0.5276902", "0.5272787", "0.5271421", "0.52649164", "0.52638686", "0.5258806", "0.5249163", "0.5241646", "0.52395594", "0.52395594", "0.52395594", "0.523888", "0.5232686", "0.5225562", "0.52243894", "0.52242446" ]
0.6819266
1
Add debug parameter to get information on transformation image
def debug @transform_tasks.push( add_transform_task('debug') ) response = UploadUtils.make_call(url, 'get') JSON.parse(response.body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_image_transformation?\n true\n end", "def get_debug_string\n s = \"3D Camera: [ #{@x.round(2)}, #{@y.round(2)}, #{@z.round(2)} ]\\n\"\n s += \" T[ #{@tx.round(2)}, #{@ty.round(2)}, #{@tz.round(2)} ]\\n\"\n s += \"Fov: #{@fov.round(2)} View: #{@near.round(2)} -> #{@far.round(2)}\\n\\t\"\n s += \"Gosu::Window FPS (#{Gosu.fps})\\n\\t\"\n s += \"Map Objects: (#{$program.active_state.map_objects.size})\"\n return s\n end", "def inspect\n img = []\n @images.each { |image| img << image.inspect }\n img = '[' + img.join(\",\\n\") + \"]\\nscene=#{@scene}\"\n end", "def output_image\n @transformed_matrix.each do |element|\n puts element.join\n end\n end", "def debug; end", "def debug; end", "def debug; end", "def debug; end", "def debug\n \"origin: #{@unit_origin} | value: #{@value} | destiny: #{@unit_destiny}\"\n end", "def get_debug_string\n string = \"Object(#{@obj_filename})\\nfaces(#{@face_count}) texture:\\n \\\"#{@texture_file}\\\"\"\n return string\n end", "def debug args, msg\n args.outputs.debug << {\n x: 10,\n y: 700,\n text: msg\n }.label\nend", "def debug?; end", "def debug?; end", "def debug_final_report\n\t\t\tsuper\n\t\t\tif @debug_level > 0\n\t puts \"Lowest OLD: \\t#{@lowest_old[0].to_a}\"\n\t puts \"Angle: \\t\\t#{@get_angle.(@current_point, @start_vector)}\"\n\t\t\tend\n\t\tend", "def transform()\n @stages.each do |stage|\n# Pry::ColorPrinter.pp stage\n @ead = stage.transform(@ead)\n#Rails.logger.debug(\"#{@ead.to_s.pretty_inspect}\")\n end\n @ead.to_s\n end", "def debug\n\t\t\texec_parsed_action('debug', [], false)\n\t\tend", "def transforms; end", "def generate_on_upload\n {\n transformation: [\n resize_base_image\n ]\n }\n end", "def debug(info)\n puts(info) if @debug\n end", "def debug\n Puppet::Util::Log.level = :debug\n end", "def inspect\n snapshot.inspect\n end", "def debug\n with_template_factory do |template_factory|\n orig_debug = Graphics.debug\n Graphics.debug = true\n render_screen(template_factory, StringIO.new)\n Graphics.debug = orig_debug\n end\n end", "def print\n Catpix::print_image self.img_url,\n :limit_x => 1.0,\n :limit_y => 0,\n :center_x => true,\n :center_y => true,\n :bg => \"white\",\n :bg_fill => true,\n :resolution => \"low\"\n end", "def inspect\n @info.inspect \n end", "def output_debug(params)\n Rails.logger.debug(\"\\n\\n\\n\\n------------------------------------------------\\n\")\n Rails.logger.debug(params.inspect)\n Rails.logger.debug(\"\\n------------------------------------------------\\n\\n\\n\\n\")\n end", "def debug=(_arg0); end", "def debug=(_arg0); end", "def inspect_details\n\t\treturn \"for %p:%#016x\" % [ self.world.class, self.world.object_id * 2 ]\n\tend", "def transformations; end", "def inspect\n @info.inspect\n end", "def inspect\n @info.inspect\n end", "def debug!\n self.severity = :DEBUG\n end", "def transformation_options\n if current_geometry\n scale, crop = current_geometry.transformation_to(target_geometry, crop?)\n trans = []\n trans << \"-resize\" << %[\"#{scale}\"] unless scale.nil? || scale.empty?\n trans << \"-crop\" << %[\"#{crop}\"] << \"+repage\" if crop\n trans.join(\" \")\n end\n end", "def transformation\n end", "def debug! \n $DEBUG = true\n end", "def to_s\r\n puts \"Pic name: #{@name}\"\r\n puts \"Image size (cols x rows): #{@image.columns} x #{@image.rows}\"\r\n end", "def show\n @samples = ImageReaderService.new(@image).analyze.generate_samples 4\n end", "def image_points\n [\n @state.ctm_transform(0, 0),\n @state.ctm_transform(0, 1),\n @state.ctm_transform(1, 0),\n @state.ctm_transform(1, 1)\n ]\n end", "def debug\n @@debug ||= false\n end", "def debug_output(x, y)\n\t\t\tputs \"left eye #{@left_eye_width}\"\n\t\t\tputs \"glabella #{@glabella_width}\"\n\t\t\tputs \"right eye #{@right_eye_width}\"\n\t\t\tputs \"mouth #{x}, #{y}\"\n\t\tend", "def debug(message)\n Hiera.debug(\"[cloudformation_backend]: #{message}\")\n end", "def transform \n \n @pixel_location = get_pixel_points \n puts \"px loc : #{@pixel_location}\"\n \n while @pixel_location.size != 0 \n transform_pixel_points(@pixel_location)\n @pixel_location.shift\n @pixel_location.shift\n end\n end", "def transform(transformation)\n end", "def debug_output=(arg); end", "def transformation_command\n scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)\n trans = []\n trans << \"-coalesce\" if animated?\n trans << \"-auto-orient\" if auto_orient\n trans << \"-resize\" << %[\"#{scale}\"] unless scale.nil? || scale.empty?\n trans << \"-crop\" << %[\"#{crop}\"] << \"+repage\" if crop\n trans << '-layers \"optimize\"' if animated?\n trans\n end", "def debug_info\n cursor_pos = @cursor.cursor_pos\n selected_piece = @board[cursor_pos]\n enemy_color = (selected_piece.color == :white) ? :black : :white\n puts \"selected piece: #{selected_piece.symbol}, position: #{cursor_pos}\"\n puts \"selected piece's available moves:\"\n puts \"#{selected_piece.valid_moves}\".colorize(:yellow)\n puts \"Enemy color in check?: #{@board.in_check?(enemy_color)}\"\n end", "def rmagik_info(file)\n puts \"- - - - - :rmagik-S\"\n puts file\n puts \">> Checking for oversized file > 430px wide\"\n img = Magick::Image::read(file).first\n puts \"Geometry: #{img.columns}x#{img.rows} - #{img.columns.class}x#{img.rows.class}\"\n\n if img.columns > 430 # resize to 430 wide\n \n scale = (430.0 / img.columns.to_f).round(6) # calculate scaling factor for image\n \n puts \"RESIZING before copying x#{scale}\"\n \n file_large = file.sub(File.extname(file), '_LRG.jpg') # copy to image_name_LRG.jpg\n FileUtils.cp( file, \"scratch/#{file_large}\")\n \n img_430 = img.scale(scale)\n \n img_430.write(file)\n \n end\n \n #img = Magick::Image::read(file).first\n #puts \" Format: #{img.format}\"\n #puts \" Geometry: #{img.columns}x#{img.rows}\"\n #puts \" Class: \" + case img.class_type\n # when Magick::DirectClass\n # \"DirectClass\"\n # when Magick::PseudoClass\n # \"PseudoClass\"\n # end\n #puts \" Depth: #{img.depth} bits-per-pixel\"\n #puts \" Colors: #{img.number_colors}\"\n #puts \" Filesize: #{img.filesize}\"\n #puts \" Resolution: #{img.x_resolution.to_i}x#{img.y_resolution.to_i} \"+\n # \"pixels/#{img.units == Magick::PixelsPerInchResolution ?\n # \"inch\" : \"centimeter\"}\"\n #if img.properties.length > 0\n # puts \" Properties:\"\n # img.properties { |name,value|\n # puts %Q| #{name} = \"#{value}\"|\n # }\n #end\n puts \"- - - - - :rmagik-E\"\nend", "def inspect\n\n \"Tetronimo: type: #{@type}, value: #{@value}, rotation: #{@rotation}, grid_row: #{@grid_row}, grid_col: #{@grid_col}\"\n\n end", "def set_debug_output(arg); end", "def debug(current_resolver_depth)\n # debug info will be returned if you call yield here, but it seems to be\n # broken in current Molinillo\n nil\n end", "def debug?; @logger.debug? end", "def imagemagick?; end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def debug?\n true\n end", "def debug?\n true\n end", "def camaleon_image_optimizer_on_active(plugin)\n end", "def inspect\n end", "def inspect\n end", "def inspect\n materialize.inspect\n end", "def debug(*info)\n puts(info) if debug_mode?\n end", "def debug_state\n super\n end", "def debug_state\n super\n end", "def transformation_command\n scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)\n trans = \"-scale \\\"#{scale}\\\"\"\n trans << \" -crop \\\"#{crop}\\\" +repage\" if crop\n trans << \" #{convert_options}\" if convert_options\n trans\n end", "def to_s\n return \"{ image_type: #{image_type},\"\\\n \" image_width: #{self[:image_width]},\"\\\n \" image_height: #{self[:image_height]},\"\\\n \" image_depth: #{self[:image_depth]},\"\\\n \" image_array_size: #{self[:image_array_size]},\"\\\n \" image_row_pitch: #{self[:image_row_pitch]},\"\\\n \" image_slice_pitch: #{self[:image_slice_pitch]},\"\\\n \" num_mip_levels: #{self[:num_mip_levels]},\"\\\n \" num_samples: #{self[:num_samples]},\"\\\n \" buffer: #{self[:buffer].to_i.to_s(16)} }\"\n end", "def embed_info(input_file, qr, label, x_coord, y_coord)\n img_template = ChunkyPNG::Image.from_file(input_file)\n img_label = ChunkyPNG::Image.from_file(label)\n img_template.compose!(qr, x_coord, y_coord)\n img_template.compose!(img_label, x_coord + 255, y_coord)\n rename_file = input_file[5..-1]\n img_template.save(\"./out-pdf\" + rename_file.gsub(\".png\", \"-e.png\"), :fast_rgba)\nend", "def png\n self.to_s\n end", "def test03()\n imageFile = $directory + \"/images/DSCN0733.JPG\"\n baseImageName = \"rotatedimage2.jpg\"\n begin\n theCommands = CommandModule::SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n importerName = SecureRandom.uuid\n createImporterCommand = CommandModule.make_createimporter(imageFile,\n name: importerName)\n imageImporterObject = SmigIDHash.make_objectid(objecttype: :imageimporter,\n objectname: importerName)\n theCommands.add_command(createImporterCommand)\n theCommands.add_tocleanupcommands_closeobject(imageImporterObject)\n imageDimensions = SpotlightCommand.get_imagedimensions(imageFile)\n bitmapContextName = SecureRandom.uuid\n createBitmapContextCommand = CommandModule.make_createbitmapcontext(\n size: imageDimensions,\n name: bitmapContextName)\n bitmapContextObject = SmigIDHash.make_objectid(objecttype: :bitmapcontext,\n objectname: bitmapContextName)\n theCommands.add_command(createBitmapContextCommand)\n theCommands.add_tocleanupcommands_closeobject(bitmapContextObject)\n\n theSize = MIShapes.make_size(imageDimensions[:width] * 0.5,\n imageDimensions[:height] * 0.5)\n theOrigin = MIShapes.make_point(imageDimensions[:width] * 0.25,\n imageDimensions[:height] * 0.25)\n sourceRect = MIShapes.make_rectangle(size: theSize, origin: theOrigin)\n destRect = sourceRect\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagefile_imagesource(source_object: imageImporterObject,\n imageindex: 0)\n drawImageElement.destinationrectangle = destRect\n affineTransform = MITransformations.make_affinetransform(\n m11: 0.707, m12: 0.707, m21: -0.707,\n m22: 0.707, tX: 373.74, tY: -221.29)\n drawImageElement.affinetransform = affineTransform\n # With the draw element put together, now create the draw element command\n drawCommand = CommandModule.make_drawelement(bitmapContextObject,\n drawinstructions: drawImageElement)\n theCommands.add_command(drawCommand)\n tempFile = File.join(Dir.tmpdir(), baseImageName)\n imageExporterName = SecureRandom.uuid\n createExporterCommand = CommandModule.make_createexporter(tempFile,\n export_type: \"public.jpeg\",\n name: imageExporterName)\n exporterObject = SmigIDHash.make_objectid(objecttype: :imageexporter,\n objectname: imageExporterName)\n theCommands.add_command(createExporterCommand)\n theCommands.add_tocleanupcommands_closeobject(exporterObject)\n addImageToExporterCommand = CommandModule.make_addimage(exporterObject, \n bitmapContextObject)\n theCommands.add_command(addImageToExporterCommand)\n exportImageToFileCommand = CommandModule.make_export(exporterObject)\n theCommands.add_command(exportImageToFileCommand)\n commandsHash = theCommands.commandshash\n $teststring = commandsHash.to_json\n theResult = Smig.perform_commands(commandsHash)\n puts \"The result is: \" + theResult unless theResult.length.zero?\n\n origFile = File.join($compareImageDir, baseImageName)\n unless AreImageFilesSame(origFile, tempFile, 0)\n raise \"Different image files: \" + origFile + \" and \" + tempFile\n end\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts $teststring + \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n# exit 240\n ensure\n # Open3.capture2(\"open\", origFile)\n # Open3.capture2(\"open\", tempFile)\n # FileUtils.rm_f(tempFile) unless tempFile.nil?\n end\nend", "def apply_custom_transformation\n end", "def to_s\n \"(#{self.real} + #{self.img}i)\"\n end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end" ]
[ "0.6138533", "0.5833899", "0.5806911", "0.5784997", "0.55208325", "0.55208325", "0.55208325", "0.55208325", "0.55108416", "0.5478344", "0.54262155", "0.5347938", "0.5347938", "0.52806526", "0.5216288", "0.5199178", "0.51805854", "0.51802915", "0.5172661", "0.51674354", "0.51421595", "0.5139148", "0.5131785", "0.51306313", "0.5130164", "0.51138693", "0.51138693", "0.5104601", "0.5103192", "0.5085151", "0.5085151", "0.5073393", "0.5066868", "0.5064189", "0.5063067", "0.5057328", "0.5051544", "0.50313056", "0.502423", "0.5016731", "0.50074434", "0.49813575", "0.49587992", "0.4957628", "0.49541968", "0.4950476", "0.49495637", "0.4935465", "0.4917713", "0.49062082", "0.4904562", "0.49035278", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.48997244", "0.4893779", "0.4893779", "0.48901236", "0.48815784", "0.48815784", "0.4874104", "0.4861824", "0.4847495", "0.4847495", "0.48447177", "0.48408043", "0.48403752", "0.48289126", "0.48264173", "0.48199773", "0.48168296", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525", "0.48133525" ]
0.6230256
0
Stores a transformation URL and returns a filelink
def store @transform_tasks.push( add_transform_task('store', {}) ) response = UploadUtils.make_call(url, 'get') response_body = JSON.parse(response.body) handle = response_body['url'].split('/').last FilestackFilelink.new(handle, apikey: @apikey, security: @security) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convertUrlToStream(url, out_stream)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrlToStream::url\", \"pdf-to-text\", \"The supported protocols are http:// and https://.\", \"convert_url_to_stream\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data, out_stream)\n end", "def convertUrlToStream(url, out_stream)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrlToStream::url\", \"pdf-to-html\", \"The supported protocols are http:// and https://.\", \"convert_url_to_stream\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data, out_stream)\n end", "def convertUrlToFile(url, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertUrlToFile::file_path\", \"pdf-to-html\", \"The string must not be empty.\", \"convert_url_to_file\"), 470);\n end\n \n if (!(isOutputTypeValid(file_path)))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertUrlToFile::file_path\", \"pdf-to-html\", \"The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.\", \"convert_url_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertUrlToStream(url, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end", "def url_for_file(filename, anchor = T.unsafe(nil)); end", "def convert_source_url_to_external_storage\n return unless converting_activated_for_current_resource?\n\n endpoint = Rails.application.credentials.dig(:minio, :endpoint)\n return if endpoint.blank?\n return if source_url.blank? || source_url.url.blank?\n return if source_url.url.start_with?(endpoint)\n\n begin\n uri = URI.open(source_url.url)\n file = File.open(uri)\n attachment.attach(io: file, filename: File.basename(file))\n rescue StandardError\n return\n end\n\n source_url.url = attachment.service_url.sub(/\\?.*/, \"\")\n source_url.save\n end", "def file_to_uri(file); end", "def file_to_uri(file); end", "def file_url\n end", "def convertUrlToStream(url, out_stream)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrlToStream::url\", \"html-to-pdf\", \"The supported protocols are http:// and https://.\", \"convert_url_to_stream\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data, out_stream)\n end", "def convertUrlToStream(url, out_stream)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrlToStream::url\", \"image-to-pdf\", \"The supported protocols are http:// and https://.\", \"convert_url_to_stream\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data, out_stream)\n end", "def convertUrlToFile(url, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertUrlToFile::file_path\", \"pdf-to-text\", \"The string must not be empty.\", \"convert_url_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertUrlToStream(url, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end", "def convertUrl(url)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrl\", \"pdf-to-text\", \"The supported protocols are http:// and https://.\", \"convert_url\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data)\n end", "def convertUrlToStream(url, out_stream)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrlToStream::url\", \"html-to-image\", \"The supported protocols are http:// and https://.\", \"convert_url_to_stream\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data, out_stream)\n end", "def to_url\n JavaFile.new(self.canonicalize.to_s).toURL().to_s\n end", "def uri_to_file(uri); end", "def uri_to_file(uri); end", "def convertUrlToFile(url, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertUrlToFile::file_path\", \"image-to-pdf\", \"The string must not be empty.\", \"convert_url_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertUrlToStream(url, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end", "def convertUrlToFile(url, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertUrlToFile::file_path\", \"html-to-pdf\", \"The string must not be empty.\", \"convert_url_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertUrlToStream(url, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end", "def convertUrlToStream(url, out_stream)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrlToStream::url\", \"image-to-image\", \"The supported protocols are http:// and https://.\", \"convert_url_to_stream\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data, out_stream)\n end", "def convertUrl(url)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrl\", \"pdf-to-html\", \"The supported protocols are http:// and https://.\", \"convert_url\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data)\n end", "def process(path, transformations, user_id)\n file = upload_file(path, (id = SecureRandom.uuid))\n file.save\n end", "def convertUrl(url)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrl\", \"image-to-pdf\", \"The supported protocols are http:// and https://.\", \"convert_url\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data)\n end", "def output_path\n File.join(Musako.destination_path, @url)\n end", "def url_content\n\t file.url\n\tend", "def convertUrlToFile(url, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertUrlToFile::file_path\", \"html-to-image\", \"The string must not be empty.\", \"convert_url_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertUrlToStream(url, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end", "def output_archive_path\n return if file.url.blank?\n\n file\n .url\n .sub(/https:\\/\\/v1\\/pageflow/, '/output.scrollytelling.com/v1/main/pageflow')\n end", "def convertUrl(url)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrl\", \"html-to-pdf\", \"The supported protocols are http:// and https://.\", \"convert_url\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data)\n end", "def link\n file = XFile.first(id: params[:id], uploaded: true)\n\n raise RequestError.new(:file_not_found, \"File not found or not public\") unless file\n raise RequestError.new(:bad_param, \"File not uploaded\") if !file.folder && !file.uploaded\n raise RequestError.new(:bad_param, \"Can not get the download link of the root folder\") if file.id == session[:user].root_folder.id\n raise RequestError.new(:bad_param, \"Can't get the link of a folder\") if file.folder\n\n file.generate_link\n @result = { link: file.link, uuid: file.uuid, success: true }\n end", "def transform_file\n @transform_file ||= File.join(staging_dir, \"doc-transform\")\n end", "def file_link\n return \"#{SITE_URL}system/ufiles/#{id}/original/#{ufile_file_name}\"\n end", "def convertUrlToFile(url, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertUrlToFile::file_path\", \"image-to-image\", \"The string must not be empty.\", \"convert_url_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertUrlToStream(url, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end", "def map_url(loc, opts={})\n self.locker.synchronize do\n loc = Sitemapper.urlfy(loc)\n lastmod, changefreq, priority = extract_options(opts)\n url = get_url(loc) || self.builder.root.add_element('url')\n (url.elements['loc'] || url.add_element('loc')).text = loc\n (url.elements['lastmod'] || url.add_element('lastmod')).text = lastmod.strftime('%Y-%m-%d') if lastmod\n (url.elements['changefreq'] || url.add_element('change_freq')).text = changefreq.to_s if changefreq\n (url.elements['priority'] || url.add_element('priority')).text = '%.2f' % priority if priority\n\n write_file\n end\n end", "def destination(dest)\n # The url needs to be unescaped in order to preserve the correct filename\n File.join(dest, CGI.unescape(full_url))\n end", "def public_url(*args)\n add_filename_to(:public_tmp_url, *args)\n end", "def get_transformed_file(category, subset, transformation, preprocess)\n format = :\"#{transformation}_#{preprocess}\"\n\n begin\n filename = @paths[:data][category][:transformed][format][subset]\n rescue => e\n @logger.warn(\"Hash path #{category}/transformed/#{format}/#{subset}\"\\\n + \" does not exist: #{e.message}\")\n end\n\n filename\n end", "def original_url; end", "def store\n result = QcloudCos.upload(path, file.to_file)\n\n if result != nil\n self.url = result\n end\n end", "def convertUrl(url)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrl\", \"html-to-image\", \"The supported protocols are http:// and https://.\", \"convert_url\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data)\n end", "def url_to_asset(source, options = T.unsafe(nil)); end", "def presigned_link_uri(object, version, file)\n url_for controller: :file,\n action: :presign,\n object: object,\n version: version,\n file: file\n end", "def url(options = {})\n file.path\n end", "def derivative_url_target\n if file_set.try(:file_set_id)\n file_set.file_set_id.to_s\n else\n file_set\n end\n end", "def url=(url)\n extension = File.extname(url)\n file = Tempfile.new([\"\", extension])\n file.binmode\n file << open(url).read\n self.assign(file)\n end", "def file_url(attachment_name, style=nil); file_path(attachment_name, style); end", "def unit_url\n is_processed ?\n FileSystem.url(unit_path) :\n orig_image_url\n end", "def create_file_from_url_through_valkyrie(env, uri, file_name, auth_header)\n import_url = URI.decode_www_form_component(uri.to_s)\n fs = Hyrax.persister.save(resource: Hyrax::FileSet.new(import_url: import_url, label: file_name))\n actor = Hyrax::Actors::FileSetActor.new(fs, env.user, use_valkyrie: true)\n actor.create_metadata(visibility: env.curation_concern.visibility)\n actor.attach_to_work(env.curation_concern)\n if uri.scheme == 'file'\n # Turn any %20 into spaces.\n file_path = CGI.unescape(uri.path)\n IngestLocalFileJob.perform_later(fs, file_path, env.user)\n else\n ImportUrlJob.perform_later(fs, operation_for(user: actor.user), auth_header)\n end\n end", "def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:)\n instrument :url, key: key do |payload|\n verified_token_with_expiration = ActiveStorage.verifier.generate(\n {\n key: key,\n content_type: content_type,\n content_length: content_length,\n checksum: checksum\n },\n { expires_in: expires_in,\n purpose: :blob_token }\n )\n\n generated_url = url_helpers.update_rails_imgur_service_url(verified_token_with_expiration, host: current_host)\n\n payload[:url] = generated_url\n generated_url\n end\n end", "def original_url\n self.source.url\n end", "def url\n Djatoka.resolver.region(filename).scale(1800).url\n end", "def url\n return @url unless @url.nil?\n @url = destination.sub(::Webby.site.output_dir, '')\n end", "def create_resultfile_link(report, job)\n \"http://s3.amazonaws.com/#{report[:bucket_name]}/resultfiles/#{job.resultfile_name}.zip\"\n end", "def construct_output_url(destination:, file_input_url:, name_modifier:, file_suffix:)\n output = destination\n\n # MediaConvert operates such that if you give a destination ending in '/',\n # it'll use the original file name as part of output url.\n if output.end_with?('/')\n # \".*\" on the end will strip extension off\n output += File.basename(file_input_url, '.*')\n end\n\n output += name_modifier if name_modifier\n\n output += \".\" + file_suffix\n\n output\n end", "def convertUrl(url)\n unless /(?i)^https?:\\/\\/.*$/.match(url)\n raise Error.new(Pdfcrowd.create_invalid_value_message(url, \"convertUrl\", \"image-to-image\", \"The supported protocols are http:// and https://.\", \"convert_url\"), 470);\n end\n \n @fields['url'] = url\n @helper.post(@fields, @files, @raw_data)\n end", "def make_tm_link( filename, line=nil )\n encoded_file_url = ''\n ('file://'+filename).each_byte do |b|\n if b.chr =~ /\\w/\n encoded_file_url << b.chr\n else\n encoded_file_url << sprintf( '%%%02x', b )\n end\n end\n \n 'txmt://open?url=' + encoded_file_url + ((line.nil?) ? '' : '&amp;line='+line.to_s)\n end", "def transform(transformation)\n end", "def file_content_return_url(url, text, content_type = nil)\n url = CGI::escape(url)\n text = CGI::escape(text)\n content_type = CGI::escape(content_type) if content_type\n\n return_url = \"#{content_return_url}?return_type=file&url=#{url}&text=#{text}\"\n return_url = \"#{return_url}&content_type=#{content_type}\" if content_type\n\n return return_url\n end", "def digested_reference\n url\n end", "def digested_reference\n url\n end", "def thumbnail_url document\n document.derivative_paths[:thumbnail].relative_path.to_s\n end", "def convert_url_to_storage(src, dst, storage, options=nil)\r\n convert(src, dst, false, false, true, options, storage)\r\n end", "def original_url\n url\n end", "def get_file(url); end", "def mkurl(oldurl, selector)\n mlog(\"checking %p ...\", oldurl)\n url = oldurl\n # yes, technically one can include a resource from FTP.\n # some people actually do that.\n # but you really shouldn't.\n if oldurl.match(/^(https?|ftp)/) or (autoscm = oldurl.match(/^\\/\\//)) then\n if autoscm then\n # in case of \"//somehost.com/...\" urls, just create an absolute url by\n # reusing the scheme from the mothership\n url = @parsed.scheme + \":\" + oldurl\n end\n else\n # macgyver the url together from the mothership scheme and host\n url = String.new\n url << @parsed.scheme << \"://\" << @parsed.host\n # if the url starts with a slash, it's an absolute path (i.e., \"/blah/something.js\")\n if oldurl.match(/^\\//) then\n url << oldurl\n else\n # otherwise, it's a relative one (i.e., \"subdir/whatever/thing.js\")\n url << File.dirname(@parsed.path)\n if ((url[-1] != \"/\") && (oldurl[0] != \"/\")) then\n url << \"/\"\n end\n url << oldurl\n end\n end\n localdest = File.join(@opts.resdir, Utils.mkname(url, selector))\n fulldest = File.join(@opts.destination, localdest)\n # coincidentally, the local url is the same as the file dest. whudathunkit\n @flog[:urls] << {url: url, local: fulldest}\n if File.file?(fulldest) then\n return localdest\n end\n response = geturl(url)\n if response then\n mlog(\"storing as %p\", fulldest)\n FileUtils.mkdir_p(File.join(@opts.destination, @opts.resdir))\n response.to_file(fulldest)\n return localdest\n end\n raise Exception, \"bad response from geturl?\"\n end", "def create_file_from_url(url, file_name)\n ::FileSet.new(import_url: url, label: file_name) do |fs|\n actor = CurationConcerns::Actors::FileSetActor.new(fs, user)\n actor.create_metadata(curation_concern, visibility_attributes)\n fs.save!\n uri = URI.parse(URI.encode(url))\n if uri.scheme == 'file'\n IngestLocalFileJob.perform_later(fs, URI.decode(uri.path), user)\n else\n ImportUrlJob.perform_later(fs, file_name, log(actor.user))\n end\n end\n end", "def direct_upload_url=(escaped_url)\n write_attribute(:direct_upload_url, (CGI.unescape(escaped_url) rescue nil))\n end", "def direct_upload_url=(escaped_url)\n write_attribute(:direct_upload_url, (CGI.unescape(escaped_url) rescue nil))\n end", "def direct_upload_url=(escaped_url)\n write_attribute(:direct_upload_url, (CGI.unescape(escaped_url) rescue nil))\n end", "def url_for(style)\n reprocess_for(style)\n file.url(style)\n end", "def compose_url(url)\n abort \"Invalid URL: #{url}\" unless validate_url(url)\n\n query = {}\n query['map'] = 'true' if options['map']\n query['api_key'] = options['key'] if options['key']\n query['compression'] = options['compress'] if options['compress']\n\n uri = URI(url)\n uri.path = '/files'\n uri.query = URI.encode_www_form(query)\n uri.to_s\n end", "def file_url\n resource.send(mount_point).url\n end", "def external_download_url\n @file.external_bytestream_uri.to_s\n end", "def make_link(old) File.link(old, path) end", "def link() url; end", "def link() url; end", "def get_url_encoded_file(file)\n begin\n file.gsub!('https','http')\n uri = URI.parse(URI.escape(URI.unescape(file)))\n return uri\n end\n end", "def to(url); end", "def url(key, expires_in:, disposition:, filename:, content_type:)\n instrument :url, key: key do |payload|\n payload[:url] = storage.temporary_url(\n key,\n 'GET',\n expires_in: expires_in,\n disposition: disposition,\n filename: filename\n )\n payload.fetch(:url)\n end\n end", "def url\n @doc.url\n end", "def raw_url(file_name)\n \"ftp://#{user}@#{host}#{folder}#{file_name}\"\n end", "def create_temp_url(file, expires = Time.now.to_i + 600, account_meta_key = @account_meta_key)\n \n # Generate tempURL\n method = 'GET'\n \n public_url = URI(file.public_url)\n base = \"#{public_url.scheme}://#{public_url.host}/\"\n path = public_url.path\n\n hmac_body = \"#{method}\\n#{expires}\\n#{path}\"\n sig = Digest::HMAC.hexdigest(hmac_body, account_meta_key, Digest::SHA1)\n\n \"#{file.public_url}?temp_url_sig=#{sig}&temp_url_expires=#{expires}\"\n end", "def get_url(filename)\n return YAML.load_file(filename)['original-url']\nend", "def filename_to_url(filename)\n # Remove the cache path\n f = strip_prefix(filename, path)\n # Remove the leading . from the base filename\n f = strip_filename_prefix(f, '.')\n # Remove the leading / from the path\n f.slice!(0) if f.start_with?('/')\n # Return the full Aspire linked data URL\n ld_api.api_url(f)\n end", "def path_to_url(path)\n URI.encode(path =~ %r{^https?://} ? path : \"http://#{aliyun_upload_host}/#{path}\")\n end", "def square_url\n is_processed ?\n FileSystem.url(square_path) : \n orig_image_url\n end", "def link(document, url)\n url = url.gsub(/[^a-zA-Z0-9\\-\\/]+/, '-').downcase\n slugs = Slug.where document_id: document.id\n if slugs.count > 0\n slug = slugs.first\n else\n slug = Slug.new\n slug.document_id = document.id\n slug.generate_id\n slug.save\n end\n \"/#{slug.id}/#{url}\"\n end", "def direct_upload_url=(escaped_url)\n write_attribute(:direct_upload_url, (CGI.unescape(escaped_url) rescue nil))\n end", "def thumbnail_value_from_document\n url = super\n return if url.blank?\n return unless url.match? URI::DEFAULT_PARSER.make_regexp # do not try to resolve invalid URLs\n\n return view_context.image_proxy_path(url: url) if url.to_s.start_with?('http://')\n\n url\n end", "def url; \"file:#{@root}\"; end", "def file_url\n file.attached? ? url_for(file) : ''\n end", "def extract_url(resource)\n rails_blob_path(resource, disposition: 'attachment', only_path: true)\n end", "def relative_url(input); end", "def file_url\n return nil if target_item.files.empty?\n target_item.files.last.uri.to_s\n end", "def get_url(file_format)\n base_url = CollectionMatrix.get_base_url\n case file_format\n when :matlab\n \"#{base_url}mat/#{group}/#{name}.mat\"\n when :rutherford_boeing\n \"#{base_url}RB/#{group}/#{name}.tar.gz\"\n when :matrix_market\n \"#{base_url}MM/#{group}/#{name}.tar.gz\"\n when :svd\n \"#{base_url}svd/#{group}/#{name}_SVD.mat\"\n else\n raise ArgumentError, 'Unknown matrix file type - only :matlab, :rutherford_boeing, and :matrix_market allowed'\n end\n end", "def file_set_url(file_set_id)\n \"https://#{ENV['SERVER_NAME']}/downloads/#{file_set_id}\"\n end", "def create_file_from_url(url, file_name)\n ::GenericFile.new(import_url: url, label: file_name).tap do |gf|\n actor = Sufia::GenericFile::Actor.new(gf, current_user)\n actor.create_metadata(params[:batch_id])\n gf.save!\n Sufia.queue.push(ImportUrlJob.new(gf.id))\n end\n end", "def url(key, expires_in:, disposition:, filename:, content_type:)\n instrument :url, key: key do |payload|\n image = image_for(key)\n\n image.link.tap do |url|\n payload[:url] = url\n end\n end\n end", "def url\n make_file_name('html', name)\n end", "def url(**options)\n file&.url(**options)\n end", "def wicked_pdf_url_base64(url); end", "def fetch_file_by_url\n if (self.url)\n self.file = self.url\n end\n end" ]
[ "0.5993629", "0.5924104", "0.5902358", "0.5900278", "0.5861543", "0.58524156", "0.58524156", "0.58390164", "0.5832023", "0.58243275", "0.58148485", "0.57751346", "0.5752952", "0.5736592", "0.57275695", "0.57275695", "0.56775725", "0.56716746", "0.564195", "0.5640427", "0.56394935", "0.5594918", "0.55949044", "0.5591314", "0.55734706", "0.5571025", "0.55655", "0.5537621", "0.5533537", "0.55254114", "0.55221325", "0.55166477", "0.5494228", "0.5476555", "0.5468427", "0.5468089", "0.5464177", "0.5460916", "0.54593724", "0.54465115", "0.54438144", "0.5425699", "0.5415961", "0.5409025", "0.5380798", "0.5378729", "0.5375152", "0.536623", "0.5365255", "0.5363533", "0.53603226", "0.53597647", "0.5348592", "0.53476954", "0.5340451", "0.53314453", "0.53034014", "0.53034014", "0.530137", "0.5298251", "0.5297128", "0.5277671", "0.52765524", "0.52753097", "0.5262801", "0.52627057", "0.52627057", "0.5254638", "0.5253274", "0.5251192", "0.5246564", "0.5239331", "0.5235878", "0.5235878", "0.5221033", "0.5216147", "0.52151537", "0.52146995", "0.5213747", "0.5211198", "0.5206653", "0.5206526", "0.5204166", "0.52031934", "0.5203045", "0.5195846", "0.519273", "0.51831967", "0.5182776", "0.51815176", "0.51659524", "0.51635385", "0.5159249", "0.5159061", "0.51509446", "0.51505953", "0.5144009", "0.5141882", "0.51364875", "0.5124697" ]
0.6447807
0
Override default method (best practice when overriding method_missing)
def respond_to_missing?(method_name, *) TransformConfig::TRANSFORMATIONS.include?(method_name.to_s || super) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing(meth, *args); end", "def method_missing(method_name, *args); end", "def method_missing(method_name, *args); end", "def method_missing(name, *args, &block); end", "def method_missing(name, *args, &block); end", "def method_missing(name, *args, &block); end", "def method_missing(name, *args, &block); end", "def method_missing(name, *args); end", "def method_missing(name, *args); end", "def method_missing(meth, *args, &block); end", "def method_missing(meth, *args, &block); end", "def method_missing(meth, *args, &block); end", "def method_missing(*args, &block); end", "def method_missing(method, *args, &block); end", "def method_missing(meth, *args, &block)\n\n end", "def method_missing(method, *args)\r\n self.class.method_missing(method, *args)\r\n end", "def method_missing(method, *args, &blk); end", "def method_missing(method_name, *args) self end", "def method_missing(method_name, *args) self end", "def method_missing(method_name, *method_args)\n get(method_name) || super.method_missing(method_name, *method_args)\n end", "def method_missing(method, *arguments, &block); end", "def method_missing(mth, *args, &block); end", "def method_missing(name, *args, &blk)\n self\n end", "def method_missing(code, *args, &blk); end", "def method_missing(code, *args, &blk); end", "def method_missing(m, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n base.respond_to?(method_name) ? base.send(method_name, *args, &block) : super\n end", "def method_missing(*args)\n default\n end", "def method_missing(id, *attr, &block); end", "def method_missing(m,*a,&block)\n if Default.respond_to?(m)\n Default.send(m,*a,&block)\n else\n super\n end\n end", "def method_missing(*rest) end", "def method_missing(:name, *args)\nend", "def method_missing(meth, *args, &block)\n Interrogate.is_interrogatory?(meth) ? Interrogate.interrogate(meth, *args, &block) : super\n end", "def method_missing(meth, options = T.unsafe(nil)); end", "def method_missing(*)\n return nil\n end", "def method_missing(method, *args) #:nodoc:\n self[method]\n end", "def method_missing(method, *args)\n send(method, *args)\n end", "def method_missing(name, *options, &block)\n self[name.to_s] or super\n end", "def method_missing meth, *args\n raise NoMethodError.new(\"undefined method `#{meth}' for \"<<\n \"\\\"#{self}\\\":#{self.class}\")\n end", "def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing\n $method_missing = [name, *args]\n (class << self; self end).add_method(nil, name) #(class << self; self end).superclass.add_method(nil, name)\n __send__(name, *args, &block)\n end", "def method_missing(method)\n\t\t self[method]\n\t\tend", "def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing\n (class << self; self end).add_method(nil, name)\n __send__(name, *args, &block)\n end", "def method_missing(name, *args, &block)\n return @info[name.to_s] if @info.key? name.to_s\n return @info[name] if @info.key? name\n super.method_missing name\n end", "def method_missing(symbol_)\n self[symbol_] || super\n end", "def method_missing(*args)\n puts \"YOU CAN'T DO THAT\"\n end", "def method_missing(m, *a, &b)\n\ta.empty? ? m : super\nend", "def method_missing(*)\n invertable nil\n end", "def method_missing(method_sym, *arguments, &block)\n if self[\"#{method_sym.to_s}\"] != nil\n self[\"#{method_sym.to_s}\"]\n else\n super\n end\n end", "def method_missing(*a)\n end", "def method_missing(selector, *args, &block); end", "def method_missing(m, *args, &block)\n # ignore\nend", "def method_missing(name, *args)\n return super unless args.empty?\n self[name]\n end", "def method_missing(method_sym, *args, &block)\n return nil\n end", "def method_missing(*args)\n\t\t\traise \"Method missing: #{args.inspect}\"\n\t\tend", "def method_missing(name, *args, &block)\n method_name = method_name_info(name)\n \n if method_name.define_for(self)\n method_name.value_for(self)\n else\n super\n end\n end", "def method_missing(m, *args, &block)\n target = self.__getobj__\n unless target.respond_to?(m)\n super(m, *args, &block)\n else\n target.__send__(m, *args, &block)\n end\n end", "def method_missing(method, *args, &block)\n # proxy to metadata\n if @metadata.has_key?(method)\n @metadata[method]\n\n else\n super(method, *args, &block)\n end\n end", "def method_missing(method, *args, &block)\n # proxy to metadata\n if @metadata.has_key?(method)\n @metadata[method]\n\n else\n super(method, *args, &block)\n end\n end", "def method_missing(method, *args)\n self[method]\n end", "def method_missing(name)\n return nil\n end", "def method_missing(meth, *args, &block)\n if respond_to?(meth)\n object.__send__(meth, *args, &block)\n else\n super\n end\n end", "def respond_to_missing?(*_args); super; end", "def method_missing(meth, *args)\n if respond_to_missing?(meth)\n person.send(meth)\n else\n super(meth, *args)\n end\n end", "def method_missing(sym, *args)\n # don't screen other things that operate via method_missing\n return super if [:to_ary, :to_json, :to_yaml, :to_xml].include? sym\n key = sym.to_s\n return self[key] if self.has_key? key\n raise NoSuchKey.new(\"#{self.class} has no key #{sym}: #{self.inspect}\")\n end", "def respond_to_missing?(name, include_priv)\n super\n end", "def method_missing(meth, *args, &block)\n if !(meth.to_s =~ /=/) and (suffixed_method = \"#{meth.to_s}__c\") and respond_to?(suffixed_method)\n send(suffixed_method)\n else\n super\n end\n end", "def method_missing(sym, *args)\n # Extend this object only when needed and immediately redefine\n # #method_missing so that the new version is used on all future calls.\n extensions.each {|e| extend(e) } if @extensions\n redefine_method_missing!\n __send__(sym, *args)\n end", "def method_missing( sym, *args, &block )\n\t\treturn self.prop[ sym.to_s ] || super\n\tend", "def method_missing(sym)\n @hash[sym] || super\n end", "def method_missing( method, *args )\n return super unless args.empty?\n _value_for_key( method )\n end", "def method_missing(*)\n nil\n end", "def method_missing(name, *args, &block)\n return super unless base.respond_to? name# and forward? name\n base.send(name, *args, &block)\n end", "def method_missing(undefined_meth_yet,*args,&block)\n \"#{self.class.to_s} doesn't know how to perform :#{undefined_meth_yet}\"\n end", "def method_missing\n\tdefine_method :a, a do |x|\n\t\tdddddddd\n\tend\n\tsuper\nend", "def method_missing(meth, *args, &block)\n @object.send(meth, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n if @object.respond_to? method_name.to_sym\n @object.__send__(method_name, *args, &block)\n else\n super\n end\n end", "def method_missing(m, *args, &block)\n if has? m.to_s\n opt(m.to_s)\n else\n super(m, *args, &block)\n end\n end", "def method_missing(*args)\n # p args\n end", "def method_missing(method, *args, &block)\n if self.respond_to? method\n self.send(method, *args, &block)\n end\n end", "def method_missing(sym, *args, &block)\n if self.internal_object.key?(sym.to_s)\n return self.internal_object[sym.to_s]\n end\n\n super\n end", "def method_missing(name, *args, &bl)\n @parent ? @parent.__send__(name, *args, &bl) : super\n rescue NoMethodError => ex\n name = ex.message[/`(.*?)'/, 1]\n ::Kernel.raise NoMethodError, \"Not found `#{name}` on #{self}\"\n end", "def method_missing(method_name, *args, &block)\n ignore_list = [:to_hash]\n return if ignore_list.include? method_name\n\n respond_to?(method_name) ? attribute(method_name.to_s.tr('_', '-')) : super\n end", "def method_missing(meth, *args) = parameters.has_key?(meth) ? parameters[meth] : meth", "def method_missing(method, *args, &block)\n name = method.to_s\n if respond_to_missing? name\n @bases[name]\n else\n super(method, *args, &block)\n end\n end", "def method_missing(method_name, *args)\n\t\tif DELEGATED_METHODS.include?(method_name)\n\t\t\[email protected](method_name, *args)\n\t\telse\n\t\t\tsuper\n\t\tend\n\tend", "def method_missing(method, params={})\n call(method, params)\n end", "def method_missing(m,*a)\n self[m]\n end", "def method_missing(method_name, *arguments)\n puts \"#{@name} tried to #{method_name}!\"\n end", "def method_missing(meth, *args, &blk)\n c.key?(meth.to_s) ? c[meth.to_s] : super\n end", "def method_missing(method, *args, &block)\n super unless original_self\n original_self.send method, *args, &block\n end", "def method_missing( attribute, *args )\n\t\treturn self.base.send( attribute, *args )\n\tend", "def method_missing(m)\n key = m.to_s\n return self[key] if self.has_key? key\n super\n end", "def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end", "def method_missing(symbol, *args)\r\n (args.empty? and labeled.has_key?(symbol)) ? labeled[symbol] : super\r\n end", "def method_missing(method_name, *args, &block)\n @data.key?(method_name.to_s) ? @data[method_name.to_s] : super\n end", "def method_missing(m, *args, &block)\n # Attempt to call a method on the object directly\n if(method_names.index(m.to_s))\n $DEBUG and puts(\"Attempting to invoke_method '#{m}'\")\n invoke_method(get_method(m.to_s), args)\n else\n super.method_missing(m, *args, &block)\n end\n end", "def method_missing(meth, *args, &blk)\n value = instance_variable_get(\"@#{meth}\")\n return value if value\n super(meth, args, blk)\n end", "def method_missing(m)\n get_options\n key = m.to_s.gsub(/\\_/, \"-\")\n @options[key].nil? ? super : @options[key]\n end", "def method_missing(*args)\n puts \"unimplemented: #{args}\"\n end", "def method_missing(*args)\n send(*args)\n end", "def method_missing(name, *args)\n\t\t\tcall(name, *args)\n\t\tend" ]
[ "0.8236227", "0.81401527", "0.81401527", "0.81321037", "0.81321037", "0.81321037", "0.81321037", "0.8125404", "0.8125404", "0.8118093", "0.8118093", "0.8118093", "0.80988085", "0.8033045", "0.8026799", "0.80178005", "0.8013305", "0.800588", "0.800588", "0.7926243", "0.79047316", "0.7809705", "0.77744526", "0.7762464", "0.7762464", "0.77559656", "0.77377117", "0.7711469", "0.7708937", "0.765939", "0.76347655", "0.76271075", "0.76000327", "0.7534414", "0.7499437", "0.7482321", "0.7465627", "0.7425764", "0.74253124", "0.7411984", "0.739059", "0.73617244", "0.7347289", "0.73341423", "0.732117", "0.73112285", "0.7298367", "0.72870415", "0.7280659", "0.72602236", "0.7255496", "0.7248318", "0.722378", "0.72095186", "0.71843964", "0.7171756", "0.716805", "0.716805", "0.7159459", "0.7159132", "0.71343124", "0.7107865", "0.7103036", "0.7080376", "0.7073288", "0.7060217", "0.7057367", "0.7040875", "0.7011829", "0.70045686", "0.69935393", "0.697519", "0.69660556", "0.69501716", "0.69448453", "0.69408584", "0.69290066", "0.6928371", "0.69218725", "0.69176847", "0.69169116", "0.69065636", "0.69065386", "0.6900291", "0.6887069", "0.6874156", "0.6863894", "0.68638355", "0.6863258", "0.6861781", "0.68600845", "0.6856763", "0.68520993", "0.68466413", "0.68384755", "0.6838445", "0.68363863", "0.6833068", "0.68293405", "0.68273294", "0.6822951" ]
0.0
-1
Creates a URL based on transformation instance state
def url base = [FilestackConfig::CDN_URL] if @transform_tasks.include? 'debug' @transform_tasks.delete('debug') base.push('debug') end base.push(@apikey) if @apikey && @external_url if @security policy = @security.policy signature = @security.signature security_string = "security=policy:#{policy},signature:#{signature}" base.push(security_string) end base += @transform_tasks base.push(@handle || @external_url) base.join('/') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_url(template); end", "def generate_url\n\t\tself.url ||= name.parameterize\n\tend", "def url_create(state_code, city_name)\n 'http://en.m.wikipedia.org/wiki/' + self.url_suffix_create(state_code, city_name)\n end", "def url\n self.compile\n url = \"#{properties[:endpoint]}/render/?width=586&height=308&#{properties_to_url}&target=\" + CGI.escape(targets.map{|i| i.compile}.compact.join(\"&target=\"))\n end", "def url_template; end", "def url_template; end", "def generated_url; end", "def to_url\n self.class.to_url\n end", "def url\n @url ||= URL.new(\n template: template,\n placeholders: url_placeholders,\n permalink: permalink\n ).to_s\n end", "def to_uri\n build_uri\n end", "def create_url\n uri = Addressable::URI.new\n uri.query_values = properties\n \"#{ BASE_URI }#{ Hubspotter.configuration.portal_id }#{ create_endpoint }#{ uri.query }\"\n end", "def create_uri\n end", "def url\n @url ||= URL.new(\n :template => template,\n :placeholders => url_placeholders,\n :permalink => permalink\n ).to_s\n end", "def instance_url\n \"#{parsed_resource_url}/#{self.id}\"\n end", "def create_url\n\t\tif self.url.blank?\n\t\t\tself.dev_stage.blank? ? dev_stage_string = \"\" : dev_stage_string = \"-\" + self.dev_stage + \"-\"\n\t\t\tcomponent_string = self.component.downcase.gsub(/[^a-zA-Z0-9]+/, \"-\").chomp(\"-\")\n\t\t\tversion_string = self.maj_version.to_s + \"-\" + self.min_version.to_s\n\t\t\tself.url = component_string + dev_stage_string + version_string\n\t\tend\n\tend", "def to_url\n\t\t\tto_uri.to_s\n\t\tend", "def url_generic\n url_constructor\n end", "def build_urlpath\n render_endpoint_request do\n erb = EndpointRequestBuilder.new(@endpoint)\n extra_params = erb.formatted_url_path(@arguments)\n render json: { success: extra_params }, status: 200\n end\n end", "def url(name, *params)\n params.map! do |param|\n if param.is_a?(Hash)\n param[:format] = param[:format].to_s if param.has_key?(:format)\n param.each { |k,v| param[k] = v.to_param if v.respond_to?(:to_param) }\n end\n end\n url = router.generator.generate(name, *params)\n uri_root != \"/\" ? uri_root + url : url\n end", "def to_url\n to_uri.to_s\n end", "def _url\n URI.join(domain, path_gen.for_uri)\n end", "def original_url; end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def to_s; @url; end", "def url\n @url ||= URL.new(\n :template => url_template,\n :placeholders => url_placeholders,\n :permalink => permalink\n ).to_s\n end", "def make_url(method, params)\n params[:key] = @key\n params[:output] = 'xml'\n\n super method, params\n end", "def make_url(params) #:nodoc:\n super params.merge(:output => \"xml\", :oe => 'utf8', :ll => @ll, :spn => @spn, :sensor => false)\n end", "def to_url\n\t\treturn self.\n\t\t\tunaccent.\n\t\t\tstrip_tags.\n\t\t\tgsub(\"&nbsp;\", \" \").\n\t\t\tgsub(\"&amp;\", \" \").\n\t\t\tdowncase.\n\t\t\tgsub(/[^a-z0-9\\.\\s,\\-_]/, \"\").\n\t\t\tgsub(/[\\.\\s,\\-_]+/, \"-\").\n\t\t\ttrim(\"-\")\n\tend", "def to_param; self.permalink end", "def build_as_url\n URI(build_as_string)\n rescue Urb::InvalidUrl => e\n URI('/')\n end", "def destination\n return if self.url.blank?\n uri = URI.parse(self.url)\n uri.fragment = self.slug\n uri.to_s\n end", "def url_was\n \"#{self.class.url}/#{slug_was}\"\n end", "def to(url); end", "def converted_url\n #Rails.application.routes.url_helpers.root_url\n \"http://localhost:3000/#{hash_code}\"\n end", "def url\n connection.build_url(url_chunk, params).to_s\n end", "def url\n @url ||= build_url\n\n if @url.is_a?(Hash)\n { only_path: true }.merge(@url)\n elsif @url.respond_to?(:call)\n @url.call\n else\n @url\n end\n end", "def snapshots_transport_destination_url=(_arg0); end", "def to_endpoint\n endpoint = @uri.path\n endpoint = '/' + endpoint unless endpoint.start_with?('/')\n Wgit::Url.new(endpoint)\n end", "def to_endpoint\n endpoint = @uri.path\n endpoint = '/' + endpoint unless endpoint.start_with?('/')\n Wgit::Url.new(endpoint)\n end", "def make_url(string)\n puts \"not implemented\"\nend", "def snapshots_transport_destination_url; end", "def create url\n function = ''\n \n post_data = {}\n post_data[:url] = url\n\n request(@resource, function, nil, 'post', post_data)\n end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def build_url(query_params: nil)\n url = [add_version(''), *@url_path].join('/')\n url = build_query_params(url, query_params) if query_params\n URI.parse(\"#{@host}#{url}\")\n end", "def _url\n return @link['href'] unless _templated?\n\n @url ||= _uri_template.expand(@uri_variables || {}).to_s\n end", "def url_str\n SiteProcessor.new(self).url_str\n end", "def functional_urls(states)\n states.map { |state| urlify(state) }\nend", "def url_template\n collection.url_template\n end", "def url_to(*args, **options)\n\t\t\t\tfirst_arg = args.first\n\t\t\t\tpath =\n\t\t\t\t\tif first_arg.is_a?(String) || first_arg.is_a?(Flame::Path)\n\t\t\t\t\t\tfind_static(first_arg).path(with_version: options[:version])\n\t\t\t\t\telse\n\t\t\t\t\t\tpath_to(*args, **options)\n\t\t\t\t\tend\n\t\t\t\tAddressable::URI.new(\n\t\t\t\t\tscheme: request.scheme, host: request.host_with_port, path: path\n\t\t\t\t).to_s\n\t\t\tend", "def url\n url = \"http://#{country_imghost}/images/P/#{asin}\"\n url << \".\" << country_imgcode << \".\"\n \n url << \"_\" << @transforms.join(\"_\") << \"_\" << \".jpg\"\n end", "def build_url(action)\n \"#{@base_url}#{action}\"\n end", "def to(object)\n return unless mapped = url_map.to(object)\n [location, mapped].join('/').squeeze('/')\n end", "def normalise\n Wgit::Url.new(@uri.normalize.to_s)\n end", "def preview_url(opts={})\n url(opts)\n end", "def url_for(url) url end", "def generated_permalink; end", "def url\n create_episode_url(@slug)\n end", "def url_preview\n parsed_url = Domainatrix.parse(self.url)\n return \"#{parsed_url.domain}.#{parsed_url.public_suffix}\"\n end", "def url\n \"#{self.public_path}/#{self.slug}\"\n end", "def new_resource_url\n send route_prefix_to_method_name(\"new_#{class_name.model_name.singular_route_key}_url\")\n end", "def to_s\n url\n end", "def create_url\n\t\tif self.url.blank?\n\t\t\tself.url = self.title.downcase.gsub(/[^a-zA-Z0-9]+/, \"-\").chomp(\"-\")\n\t\tend\t\n\tend", "def replacer\n lambda do |resource_id, _graph|\n parent_id = Hyrax.config.translate_uri_to_id.call(parent_url)\n return parent_url + resource_id.sub(parent_id, '') if resource_id.start_with?(parent_id)\n Rails.application.routes.url_helpers.solr_document_url(resource_id, host: hostname)\n end\n end", "def url\n @url ||= if single_post?\n single_post.url.gsub(/\\.html$/, \".#{@format}\")\n else\n URL.new({\n template: @config['bundle_permalink'],\n placeholders: url_placeholders,\n permalink: nil }).to_s\n end\n end", "def url_for(string); end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def url\n if derivative\n derivative_url || regular_url\n elsif version\n version_url\n else\n regular_url\n end\n end", "def to_url\n \"%s/web/api/%s/%s/authkey=%s/%s\" % [ host, target, url_options, authkey, output ]\n end", "def url_path\n self.class.url_path_class.new(self).call\n end", "def uri\n uri_for({}, nil)\n end", "def to_url\n port = @attrs[:port]\n url = \"#{@attrs[:protocol]}://#{@attrs[:host]}\"\n url << \":#{port}\" if port\n url << \"#{@attrs[:path]}?\"\n\n params_str = params.map {|name, value|\n \"#{CGI.escape(name)}=#{CGI.escape(value)}\"\n }.join('&')\n url << params_str\n end", "def create_short_url(url_params) \n url = Url.new(url_params)\n url.suffix= url.create_suffix(url_params[:longurl],0)\n while url.unique(url.suffix) == false\n url.suffix = url.create_suffix(url_params[:longurl],1)\n end\n domain = Domainatrix.parse(url_params[:longurl]).domain + '.' + Domainatrix.parse(url_params[:longurl]).public_suffix\n short_domain = ShortDomain.where(domain: domain).first[:prefix]\n url.shorturl = \"http://\" + short_domain +'/'+ url.suffix\n if url.save\n return url\n else\n return nil\n end\n end", "def convert_instance(acct, i)\n route = ApiResources::Instances.actions[:show].named_routes[:instance_href]\n i['href'] = make_href(acct, i['instance'])\n i\n end", "def to_url\n return if nil?\n\n s = downcase.tr(\"\\\"'\", \"\")\n s = s.gsub(/\\P{Word}/, \" \")\n s.strip.tr_s(\" \", \"-\").tr(\" \", \"-\").sub(/^$/, \"-\")\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def create_url\n DocumentHelper.get_create_url(document_type)\n end", "def url=(_); end", "def original_url\n self.source.url\n end", "def rest_url\n # Transifex API doc says always use a trailing slash even if the last element is a slug\n build_nodes_url.to_s + '/'\n end", "def build_url(host)\n host.protocol + host.url\n end", "def plan_url(request)\n build_url(request[:from], request[:to], request[:trip_time], request[:arrive_by], request[:options] || {})\n end", "def create_url\n #we trim away all periods and break apart the name by spaces to use to acquire the url of the poet in the Poetry Foundation website\n name_no_periods = @name.tr(\".\", \"\")\n name_no_periods = name_no_periods.split(\" \")\n\n #we use name_no_periods to generate the url for the poet (example url: \"https://www.poetryfoundation.org/poets/ben-jonson\")\n url = \"https://www.poetryfoundation.org/poets/\"\n name_no_periods.each { |part| url = \"#{url}#{part}-\"}\n\n #this leaves an extra hyphen at the end, but we can just cut that off in the return.\n url = url.chop\n end", "def url(name, params={})\n Merb::Router.generate(name, params)\n end", "def generate\n src = read_dsl\n dsl = Isstempl::Dsl.new\n dsl.instance_eval(src)\n url = apply_erb(dsl.isstempl)\n URI.escape(url)\n end", "def original_url\n url\n end", "def url_generator\n\t\t@page_name = PAGE_NAME_PART_1 + @movie_type + PAGE_NAME_PART_2 + @page_num.to_s + PAGE_NAME_PART_3\n\tend", "def make_url(params)\n escaped_params = params.sort_by { |k,v| k.to_s }.map do |k,v|\n \"#{URI.escape k.to_s}=#{URI.escape v.to_s}\"\n end\n\n url = @url.dup\n url.query = escaped_params.join '&'\n return url\n end", "def url\n \"#{Rails.configuration.baseurl}#{creator_path(self)}\"\n end", "def to_param\n url\n end", "def url\n return permalink if permalink\n\n @url ||= (ext == '.html') ? template.gsub(':name', basename) : \"/#{name}\"\n end", "def relative_url(input); end", "def p_url\n Rails.application.routes.url_helpers.rent_url(id, host: PUBLIC_URL)\n end" ]
[ "0.6690815", "0.6297288", "0.61537284", "0.61522096", "0.61232096", "0.61232096", "0.6055554", "0.6047978", "0.60457575", "0.6018218", "0.5964717", "0.59356177", "0.5923602", "0.5918802", "0.59133685", "0.5903214", "0.5898177", "0.58971846", "0.58752286", "0.58705646", "0.587026", "0.5854188", "0.58083147", "0.57994425", "0.57967895", "0.57870305", "0.57463366", "0.5720627", "0.5716184", "0.5715088", "0.5703385", "0.5692067", "0.56826913", "0.56586325", "0.5627255", "0.56234276", "0.5620883", "0.5620588", "0.5620588", "0.56150156", "0.5603839", "0.55715054", "0.5565382", "0.5565382", "0.5565382", "0.5565382", "0.5565382", "0.5565382", "0.5565382", "0.5550781", "0.5546968", "0.5543768", "0.5541109", "0.55218184", "0.55183613", "0.5517462", "0.5516343", "0.55158114", "0.5509962", "0.54991263", "0.54960495", "0.54942185", "0.5492424", "0.5490046", "0.5483346", "0.5471681", "0.54648966", "0.54636896", "0.54636604", "0.5460872", "0.54575074", "0.5448404", "0.5448404", "0.5448404", "0.5446753", "0.544411", "0.54398316", "0.5435437", "0.54329234", "0.5418887", "0.5413591", "0.54119337", "0.5403807", "0.5403807", "0.5402201", "0.54013944", "0.53876764", "0.53871554", "0.5381554", "0.53812397", "0.53796506", "0.53788644", "0.53773767", "0.5371422", "0.53666717", "0.5363914", "0.5363283", "0.535924", "0.53552157", "0.5354334", "0.5350127" ]
0.0
-1
Gets hit by the SendGrid API
def create @correspondence = Correspondence.new_from_sendgrid(params) @correspondence.save render :text => "Saved", :status => 200 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mail(email)\n \n client = SendGrid::Client.new do |c|\n c.api_key = ENV['SENDGRID_API_KEY']\n end\n\n mail = SendGrid::Mail.new do |m|\n # Specify to whom you are sending with the Email object\n m.to = '[email protected]'\n m.from = email.c_email \n m.subject = 'Guest Comments' \n #passing the 'first name' into the body of email\n m.text = email.c_comments \n end\n \n res = client.send(mail) \n puts res.code\n puts res.body \n \nend", "def spendgrid\n begin\n response_body = JSON.parse(\n Net::HTTP.post(\n URI('https://bw-interviews.herokuapp.com/spendgrid/send_email'),\n {\n \"sender\": \"#{from_name} <#{from}>\",\n \"recipient\": \"#{to_name} <#{to}>\",\n \"subject\": subject,\n \"body\": body\n }.to_json,\n {\n \"Content-Type\" => \"application/json\",\n \"x-api-key\" => \"api_key_GeQoxAP64rGyXFyRjmD96D0g\"\n }\n ).body\n )\n\n record_success(response_body['id'])\n sent!\n rescue => e\n record_exception(e)\n end\n end", "def sendgrid(lead)\n data = JSON.parse(\"{\n \\\"personalizations\\\": [\n {\n \\\"to\\\": [\n {\n \\\"email\\\": \\\"#{lead.email}\\\"\n }\n ],\n \\\"dynamic_template_data\\\": {\n \\\"subject\\\": \\\"Sending with SendGrid is Fun\\\",\n \\\"name\\\": \\\"#{lead.full_name}\\\",\n \\\"project_name\\\": \\\"#{lead.project_name}\\\"\n }\n }\n ],\n \\\"from\\\": {\n \\\"email\\\": \\\"[email protected]\\\"\n },\n \\\"template_id\\\": \\\"d-4b8f080e0e4441efade8a13ecff3ddcd\\\"\n }\")\n \n sg = SendGrid::API.new(api_key: ENV['sendgrid_api_key'])\n response = sg.client.mail._('send').post(request_body: data)\n end", "def index\n @send_grid_emails = SendGridEmail.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @send_grid_emails }\n end\n end", "def show\n @send_grid_email = SendGridEmail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @send_grid_email }\n end\n end", "def post_email(sg_mail)\n sg = SendGrid::API.new(api_key: Rails.application.secrets.email_key, host: 'https://api.sendgrid.com')\n begin\n response = sg.client.mail._('send').post(request_body: sg_mail.to_json)\n rescue SocketError\n if Rails.env.test?\n # not connected to the internet - so just allow it to continue.\n return Response.new(OfflineResponse.new)\n end\n end\n response\n end", "def send_request\n message_request = mail_params\n puts \"#############################################\"\n p message_request[:messages].values\n sender = message_request[:sender]\n messages = message_request[:messages]\n messages = messages.to_hash.map { |m| m[1] }\n\n mailing_service = GoogleApiServices::MailingService.new(google_auth_client)\n mailing_service.send(sender: sender, messages: messages)\n end", "def api_get\n handler.get({email: email}, path)\n end", "def send_notification\n @emails = EmployeeEmail.all\n if @emails == []\n return\n else\n #rather unwise to have my api key just sitting here in the code, need to check if a new api-key can be generated\n RestClient.post \"https://api:key-5f4ada711a8a86a1292bcfe23aa9d0aa\"\\\n \"@api.mailgun.net/v2/sandbox3fcc0ad1e9ee457da78753f228405f7e.mailgun.org/messages\",\n :from => \"Excited User <[email protected]>\",\n :to => send_who_us,\n :subject => \"Ovuline Notification Test\",\n #ack! I need to find a way to get @company info into this next line\n :text => \"This is the Ovuline Notification System test message! A company (need to make this more specific) has submitted information to the Quotes Table! Is that former sentence incomplete or otherwise incorrect? Oh no! A bug!\"\n end\n end", "def new\n @send_grid_email = SendGridEmail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @send_grid_email }\n end\n end", "def initialize(api_key)\n @sg = SendGrid::API.new(api_key: api_key)\n end", "def call_request\n client = Client.last\n ClientMailer.call_request(client)\n end", "def get_email_notification\n service_response = ClientManagement::GetEmailNotificationSetting.new(params).perform\n render_api_response(service_response)\n end", "def show\n render_meta ::Admin::Sendgrid::Metrics.cached_call\n end", "def send_email( params, silent = false )\n mail = Mail.new\n mail.from = Email.new(email: params[:from])\n mail.subject = params[:subject][0...78] if params[:subject] # SendGrid limits subject to 78 characters\n personalization = Personalization.new\n params[:to].each do |address|\n personalization.to = Email.new(:email => address)\n end\n mail.personalizations = personalization\n mail.contents = Content.new(type: 'text/plain', value: params[:body])\n if @sandbox\n mail_settings = MailSettings.new\n mail_settings.sandbox_mode = SandBoxMode.new(enable: true)\n mail.mail_settings = mail_settings\n end\n sg = SendGrid::API.new(api_key: @apikey, host: 'https://api.sendgrid.com')\n response = sg.client.mail._('send').post(request_body: mail.to_json)\n status = response.status_code.to_i\n if ( !status || status > 299 )\n if !silent \n puts \"email via SendGrid failed with status code #{status}\"\n puts \"for status code descriptions see https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html\\n\"\n puts response.body\n end\n return false\n else\n return true\n end\n end", "def exp_msg\n { :'message' => SendgridClient.exp_msg }.to_json\n end", "def endpoint\n @endpoint ||= 'https://api.emailcampaigns.net/2/REST/'\n end", "def get_emails_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EmailsApi#get_emails ...\"\n end\n \n # resource path\n local_var_path = \"/Emails\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'brief'] = opts[:'brief'] if opts[:'brief']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<InlineResponse2009>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EmailsApi#get_emails\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def sendWithStatus (parameters = {})\r\n\treturn $server.call(\"APIEmailService.sendEmailWithStatus\", $api_key, parameters[:from], parameters[:to], parameters[:cc]||=\"\", parameters[:bcc]||=\"\",parameters[:subject], parameters[:text], parameters[:html])\r\nend", "def bad_req_code\n SendgridClient.bad_req_code\n end", "def test_sg_client_request_returns_bad_request\n RestClient.stubs(:post).returns(fail_msg)\n ENV.stubs(:[]).returns('AN ENV VAR')\n valid_addr = EmailAddress.new ''\n\n email_obj = EmailObject.new\n email_obj.from = valid_addr\n email_obj.to = [valid_addr]\n email_obj.cc = [valid_addr]\n email_obj.bcc = [valid_addr]\n email_obj.subject = valid_addr\n email_obj.content = valid_addr\n assert_equal internal_err_code, SendgridClient.send_email(email_obj)\n end", "def get_emails_by_search_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EmailsApi#get_emails_by_search ...\"\n end\n \n # resource path\n local_var_path = \"/Emails/Search\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'email_from'] = opts[:'email_from'] if opts[:'email_from']\n query_params[:'email_to'] = opts[:'email_to'] if opts[:'email_to']\n query_params[:'tag'] = opts[:'tag'] if opts[:'tag']\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'brief'] = opts[:'brief'] if opts[:'brief']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<InlineResponse2009>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EmailsApi#get_emails_by_search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n # TODO pull out api key before pushing to github & pull out binding prys\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n subId = message[:data][0][:id]\n else\n # Port is open in our router\n params = { url: SUBSCRIPTION_URL, events: ['invitee.created', 'invitee.canceled'] }\n newRes = HTTParty.post URL, body: params, headers: HEADERS\n message = JSON.parse newRes.body, symbolize_names: true\n # TODO need error handling\n subId = message[:id]\n end\n end\n end", "def ok_code\n SendgridClient.ok_code\n end", "def get_mail\n \n end", "def test_sg_client_input_has_optional_variables\n RestClient.stubs(:post).returns(exp_msg)\n ENV.stubs(:[]).returns('AN ENV VAR')\n valid_addr = EmailAddress.new ''\n\n email_obj = EmailObject.new\n email_obj.from = valid_addr\n email_obj.to = [valid_addr]\n email_obj.cc = [valid_addr]\n email_obj.bcc = [valid_addr]\n email_obj.subject = valid_addr\n email_obj.content = valid_addr\n assert_equal ok_code, SendgridClient.send_email(email_obj)\n end", "def send_message(message)\n message = JSON.parse(message)\n params = {email:message[\"email\"],project:message[\"project\"],event:message[\"event\"],count:message[\"count\"]}\n @connection.get '/activities', params\n end", "def send_request; end", "def run_schedule_works\n # TODO list\n puts \"send email\"\n user_list = User.includes(:goods_stores).where('goods_stores.goods_expire_date < ?', Time.now.strftime(\"%Y-%m-%d\")).references(:goods_stores)\n\n\n user_list.each{|user|\n if user.goods_stores.length == 0\n next\n end\n\n email_content = \"\"\n email_content += \"<h1>Alert! Some Item in Your Fridge were expired</h1>\"\n email_content += \"<p>Hello #{user.username}</p>\"\n email_content += \"<p>The following item in your fridge is expired</p>\"\n email_content += \"<ul>\"\n\n user.goods_stores.each{|goods|\n email_content += \"<li>food name: #{goods.goods_info.goods_name} food expire date: #{goods.goods_expire_date} fridge: #{goods.fridge.fridge_name}</li>\"\n }\n\n email_content += \"</ul>\"\n puts email_content\n\n from = Email.new(email: '[email protected]')\n to = Email.new(email: user.email)\n subject = \"Alert! Some Item in Your Fridge were expired\"\n content = Content.new(type: 'text/html', value: email_content)\n mail = Mail.new(from, subject, to, content)\n\n sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])\n response = sg.client.mail._('send').post(request_body: mail.to_json)\n puts response.status_code\n puts response.body\n puts response.headers\n }\n\n end", "def update_verificado\n respond_to do |format|\n activo = params[:farmacium][:activo]\n id = params[:id]\n Farmacium.where(id:id).update_all(verificado: activo )\n @farmacium = Farmacium.find(params[:id])\n # Envio de correo electronico de confirmacion de verificacion farmacia\n from = Email.new(email: '[email protected]')\n to = Email.new(email: \"#{@farmacium.correo}\")\n subject = 'Bienvenida a la aplicación App Medicamentos'\n content = Content.new(type: 'text/plain', value: \"Bienvenida Farmacia: #{@farmacium.nombre}. Pronto le notificaremos al correo #{@farmacium.correo},\n que el registro de su farmacia fue verificada exitosamente .\")\n mail = Mail.new(from, subject, to, content)\n\n sg = SendGrid::API.new(api_key: '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')\n response = sg.client.mail._('send').post(request_body: mail.to_json)\n puts response.status_code\n puts response.body\n puts response.headers\n\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def send\n begin\n response = RestClient.post \"https://api:#{ENV['MG_API_KEY']}\"\\\n \"@api.mailgun.net/v3/#{ENV['MG_DOMAIN']}/messages\",\n from: \"#{@params['from_name']} <#{@params['from']}>\",\n to: \"#{@params['to_name']}, #{@params['to']}\",\n subject: \"#{@params['subject']}\",\n html: \"#{ActionController::Base.helpers.sanitize(@params[\"body\"])}\"\n rescue RestClient::ExceptionWithResponse => e\n @errors = e.response\n end\n end", "def by_mail_tracker\n end", "def list\n perform_request(Entities::MarketingEmail, 'newsletter/list.json')\n end", "def request_options\n {\n headers: {\n 'Content-Type': 'application/json',\n authorization: \"Bearer #{ENV.fetch('SENDGRID_API_KEY')}\"\n }\n }\n end", "def test_sg_client_input_has_mandatory_variables\n RestClient.stubs(:post).returns(exp_msg)\n ENV.stubs(:[]).returns('AN ENV VAR')\n valid_addr = EmailAddress.new ''\n\n email_obj = EmailObject.new\n email_obj.from = valid_addr\n email_obj.to = [valid_addr]\n email_obj.subject = valid_addr\n email_obj.content = valid_addr\n assert_equal ok_code, SendgridClient.send_email(email_obj)\n end", "def mock_sendgrid_client_for(user)\n mock_response = mock\n mock_response.expects(:status_code).returns('201').at_least_once\n mock_response.stubs(:body).returns('{ \"error_count\": 0, \"persisted_recipients\": [ \"1234\" ] }')\n\n mock_recipients = mock\n mock_recipients.expects(:post).with(request_body: ['first_name' => user.first_name, 'last_name' => user.last_name, 'email' => user.email]).returns(mock_response)\n\n mock_list_response = mock\n mock_list_response.stubs(:status_code).returns('201')\n mock_list_response.stubs(:body).returns(nil)\n\n mock_list_post = mock\n mock_list_post.stubs(:post).returns(mock_list_response)\n\n mock_recipient_id = mock\n mock_recipient_id.stubs(:_).with(['1234']).returns(mock_list_post)\n\n mock_list_id = mock\n mock_list_id.stubs(:recipients).returns(mock_recipient_id)\n\n mock_lists = mock\n mock_lists.stubs(:_).with(SendGridClient::LIST_ID).returns(mock_list_id)\n\n mock_contactdb = mock\n mock_contactdb.stubs(:recipients).returns(mock_recipients)\n mock_contactdb.stubs(:lists).returns(mock_lists)\n\n mock_client = mock\n mock_client.stubs(:contactdb).returns(mock_contactdb)\n\n SendGrid::API.any_instance.stubs(:client).returns(mock_client)\n end", "def get_email_tasks_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EmailtasksApi.get_email_tasks ...\"\n end\n # resource path\n local_var_path = \"/public-api/email-tasks\"\n\n # query parameters\n query_params = {}\n query_params[:'listId'] = opts[:'list_id'] if !opts[:'list_id'].nil?\n query_params[:'assignee'] = opts[:'assignee'] if !opts[:'assignee'].nil?\n query_params[:'statusId'] = opts[:'status_id'] if !opts[:'status_id'].nil?\n query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['X-API-Key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<EmailTask>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EmailtasksApi#get_email_tasks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def sub_request\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end", "def gricer_request\n @gricer_request\n end", "def update\n respond_to do |format|\n idfarmacia = params[:idfarmacia]\n id = params[:id]\n \n Pago.where(id: id).update_all(verificado: true )\n farmacia = Farmacium.find_by_sql(\"select nombre, correo, cant_lab from farmacia where id = #{idfarmacia} \").first\n \n cant = farmacia.cant_lab + 1 \n Farmacium.where(id:idfarmacia).update_all(cant_lab: cant )\n # notificar a la farmacia por correo\n from = Email.new(email: '[email protected]')\n to = Email.new(email: \"#{farmacia.correo}\")\n subject = 'Verificación de pago laboratorios'\n content = Content.new(type: 'text/plain', value: \"Estimada Farmacia: #{farmacia.nombre}, su compobante número #{id}, sea verificado con éxito.\")\n mail = Mail.new(from, subject, to, content)\n\n sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])\n response = sg.client.mail._('send').post(request_body: mail.to_json)\n puts response.status_code\n puts response.body\n puts response.headers\n\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def send_bulk_email(message, subject = 'Notification')\n client = IronWorkerNG::Client.new\n payload = {}\n payload['message'] = message\n payload['Subject'] = subject\nend", "def create\n\nMail.defaults do\n delivery_method :smtp, { :address => \"smtp.sendgrid.net\",\n :port => 587,\n :domain => \"heroku.com\",\n :user_name => \"selvakumarvr\",\n :password => \"vr14021980\",\n :authentication => 'plain',\n :enable_starttls_auto => true }\nend\n\n contact1 = Contact.new(contact_params)\n @contact = Contact.new\n\n\nMail.deliver do\n to '[email protected]'\n from contact1.email\n subject ' Project request from '+ contact1.email\n body contact1.message\nend\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to root_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_bounce\n begin\n RestClient.post $cnf['mailgun']['apikey'] + $cnf['mailgun']['bounnces'],\n :address => '[email protected]'\n rescue Exception => e\n puts \"Exception raised add_bounce:\" + e.class.to_s\n puts e.message\n end\n end", "def invitation(users)\n # making sure we only send in bulks of 1000 emails by the Sendgrid Api limits\n users = users[0..998]\n sendgrid_recipients users.collect {|user| user.email}\n sendgrid_substitute \"|name|\", users.collect {|user| user.name}\n mail :to => \"[email protected]\", :subject => \"Invitation to a demo app\"\n end", "def invite_detail\n service_response = AdminManagement::AdminUser::GetInviteDetail.new(params).perform\n render_api_response(service_response)\n end", "def test_sg_client_request_raises_exception\n RestClient.stubs(:post).raises(StandardError)\n ENV.stubs(:[]).returns('AN ENV VAR')\n valid_addr = EmailAddress.new ''\n\n email_obj = EmailObject.new\n email_obj.from = valid_addr\n email_obj.to = [valid_addr]\n email_obj.cc = [valid_addr]\n email_obj.bcc = [valid_addr]\n email_obj.subject = valid_addr\n email_obj.content = valid_addr\n assert_equal bad_req_code, SendgridClient.send_email(email_obj)\n end", "def test_test_get_recipients()\r\n # Parameters for the API call\r\n page = nil\r\n size = nil\r\n\r\n # Perform the API call through the SDK function\r\n result = self.class.controller.get_recipients(page, size)\r\n\r\n # Test response code\r\n assert_equal(@response_catcher.response.status_code, 200)\r\n\r\n # Test headers\r\n expected_headers = {}\r\n expected_headers['content-type'] = 'application/json'\r\n\r\n assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))\r\n end", "def index\n # @interface_senders = InterfaceSender.where(\"class_name is not null\")\n @interface_senders_grid = initialize_grid(@interface_senders,\n :order => 'interface_senders.id',\n :order_direction => 'desc')\n end", "def test_sg_client_empty_input\n RestClient.stubs(:post).returns(exp_msg)\n ENV.stubs(:[]).returns('AN ENV VAR')\n\n assert_equal bad_req_code, SendgridClient.send_email(EmailObject.new)\n end", "def internal_err_code\n SendgridClient.internal_err_code\n end", "def get_send_quota\n request({\n 'Action' => 'GetSendQuota',\n :parser => Fog::Parsers::AWS::SES::GetSendQuota.new\n })\n end", "def invite\n service_response = AdminManagement::AdminUser::Invite::Send.new(params).perform\n render_api_response(service_response)\n end", "def request_email ucr\n extract_variables ucr\n @url = accept_change_request_url(ucr.token)\n\n mail to: @user.email\n end", "def send_to_hubspot\n if self.customer.present? #&& self.user.blank? #if customer is not a user then use the default ID to create order \n #find the Hubspot user id (called vid)\n hubspot_customer_response = Hubspot::Contact.find_by_email(self.customer.email)\n hubspot_id = hubspot_customer_response.vid if hubspot_customer_response.present?\n\n #if not present then create new hubspot id and assigned the new id to hubspot_id\n if hubspot_id.blank?\n hubspot_id = HubspotService::Send.user_to_hubspot_and_retrieve_hubspot_id(self.customer)\n end\n\n #check if payment is received? \n if self.authorized == true \n dealstage = ENV['HUBSPOT_STAGE_ID_ORDER_RECEIVED']\n else\n dealstage = ENV['HUBSPOT_STAGE_ID_ABANDONED_CART']\n end\n\n if @hubspot_deal_id.present? == true\n #update \n HubspotService::Send.order_to_hubspot(self, hubspot_id, dealstage, @hubspot_deal_id)\n else\n #create hubspot deals\n HubspotService::Send.order_to_hubspot(self, hubspot_id, dealstage, \"\")\n end\n else\n return \"ERROR CREATING HUBSPOT DEAL\"\n end\n end", "def admin_request # :prefetch: :norobots:\n sender = @user\n pass_query_params\n if @project = find_or_goto_index(Project, params[:id].to_s)\n if request.method == :post\n subject = params[:email][:subject]\n content = params[:email][:content]\n for receiver in @project.admin_group.users\n AccountMailer.deliver_admin_request(sender, receiver, @project,\n subject, content)\n end\n flash_notice(:admin_request_success.t(:title => @project.title))\n redirect_to(:action => 'show_project', :id => @project.id,\n :params => query_params)\n end\n end\n end", "def after_create_sendgrid_event(event_data)\n end", "def index\n @emails = JSON[access_token.get(\"/api/v1/emails\").body]\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @emails }\n end\n end", "def welcome_email(user)\n\t\t@user = user\n\t\t@url = 'http://example.com/login'\n\t\tmail(to: @user.email, subject: 'Welcome to My Awesome Site')\n\n\t\t# from = Email.new(email: '[email protected]')\n\t\t# subject = 'Hello World from the SendGrid Ruby Library!'\n\t\t# to = Email.new(email: '[email protected]')\n\t\t# content = Content.new(type: 'text/plain', value: 'Hello, Email!')\n\t\t# mail = Mail.new(from, subject, to, content)\n\n\t\t# sg = SendGrid::API.new(api_key: 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)\n\t\t# response = sg.client.mail._('send').post(request_body: mail.to_json)\n\t\t# puts response.status_code\n\t\t# puts response.body\n\t\t# puts response.headers\n\tend", "def send_raw_email_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MessagingApi.send_raw_email ...\"\n end\n # resource path\n local_var_path = \"/messaging/raw-email\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'raw_email_resource'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MessagingApi#send_raw_email\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def execute\n uri = URI.parse(\"https://analyticsreporting.googleapis.com/v4/reports:batchGet\")\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = true\n # https.set_debug_output($stdout)\n request = Net::HTTP::Post.new(uri.request_uri,\n \"Content-Type\" => \"application/json\",\n \"Authorization\" => \"Bearer #{access_token}\")\n request.body = query.to_json\n Response.new(https.request(request))\n end", "def call(_obj, args, ctx)\n\t\tif ctx[:current_user].blank?\n raise GraphQL::ExecutionError.new(\"Authentication required.\")\n else\n user = User.find_by(id: ctx[:current_user][:id])\n end\n\n\t\tif args[:name].blank?\n error = GraphQL::ExecutionError.new(\"This field is required.\", options: { field: \"name_field\" } )\n ctx.add_error(error)\n end\n\n\t\tif args[:email].blank?\n error = GraphQL::ExecutionError.new(\"This field is required.\", options: { field: \"email_field\" } )\n ctx.add_error(error)\n end\n\n\t\tif args[:message].blank?\n error = GraphQL::ExecutionError.new(\"This field is required.\", options: { field: \"message_field\" } )\n ctx.add_error(error)\n end\n\n\t\tif args[:category].blank?\n error = GraphQL::ExecutionError.new(\"This field is required.\", options: { field: \"category_field\" } )\n ctx.add_error(error)\n end\n\n\t\taccepted_categories = ['Employment Opportunities', 'General Questions', 'Suggestion', 'Something Else']\n\n if error.present?\n raise GraphQL::ExecutionError.new(ctx.errors)\n end\n\n\t mail = Mail.new\n\t mail.from = Email.new(email: '[email protected]')\n\t mail.subject = 'Inquiry - James Gallagher'\n\t personalization = Personalization.new\n\t personalization.add_to(Email.new(email: args[:email]))\n\t personalization.add_substitution(Substitution.new(key: '-name-', value: args[:name]))\n\t mail.add_personalization(personalization)\n\t mail.template_id = '13b8f94f-bcae-4ec6-b752-70d6cb59f932'\n\n\t sg = SendGrid::API.new(api_key: \"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\")\n\t begin\n\t response = sg.client.mail._(\"send\").post(request_body: mail.to_json)\n\t rescue Exception => e\n\t puts e.message\n\t end\n\n\t\tInquiry.create!(\n\t name: args[:name],\n\t email: args[:email],\n\t message: args[:message],\n\t category: args[:category]\n\t )\n end", "def send(options) \n @client.get_request('/cm/list.send', options)\n end", "def send\n generate_url\n end", "def send\n generate_url\n end", "def index\n options = params.dup\n email = options.delete(:email)\n if ContactsMailer.receive(email, options)\n render :nothing => true, :status => :created\n else\n render :nothing => true, :status => :unprocessable_entity\n end\n end", "def get_emails_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProjectsApi#get_emails ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_emails\" if id.nil?\n \n # resource path\n path = \"/Projects/{id}/Emails\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'brief'] = opts[:'brief'] if opts[:'brief']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<APIEmail>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#get_emails\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def email\n @email ||= Email::Gateway.new(client)\n end", "def send_grid_mail_bounces\n #get the parsed_response from sendgrid and store in all_bounces variable\n all_bounces = BOUNCES.retrieve.parsed_response\n all_bounces.each { |bounce|\n #for each bounce which gives the email id which was bounced, find it from User table and make :is_bounced column true\n email = bounce.values_at(\"email\")[0]\n user = User.find_by_email(email)\n unless user.nil? then\n if user.crypted_password.nil? then\n user.update_attribute(:is_bounced, true)\n BOUNCES.delete :email => email\n end\n end\n }\n end", "def postEntitySend_email( entity_id, gen_id, from_email, subject, content)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n params['from_email'] = from_email\n params['subject'] = subject\n params['content'] = content\n return doCurl(\"post\",\"/entity/send_email\",params)\n end", "def to_get_request\n 'get_%ss' % api_name\n end", "def get_send(send_id)\n self.api_get(:send, {:send_id => send_id.to_s})\n end", "def add_batch_recipients(number_of_recipients=10)\n #dummy_email_addresses = [\"[email protected]\",\"[email protected]\",\"[email protected]\"]\n dummy_email_addresses = generate_random_email_addresses(number_of_recipients)\n email_array_batch_input = create_email_list_for_batch_recipient_add(dummy_email_addresses)\n payload = email_array_batch_input.to_json\n puts \"adding recipients to db from #{payload}\"\n url = \"#{@goseg_base_url}/recipients_batch\"\n res = RestClient.post(url,payload){|response, request, result| response }\n return res\n end", "def find(email)\n Mailgun.submit :get, complaint_url(email)\n end", "def get_subscriber_by_email_address_with_http_info(format, apikey, mailing_list_id, email, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SubscribersApi.get_subscriber_by_email_address ...\"\n end\n # verify the required parameter 'format' is set\n if @api_client.config.client_side_validation && format.nil?\n fail ArgumentError, \"Missing the required parameter 'format' when calling SubscribersApi.get_subscriber_by_email_address\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['json', 'xml'].include?(format)\n fail ArgumentError, \"invalid value for 'format', must be one of json, xml\"\n end\n # verify the required parameter 'apikey' is set\n if @api_client.config.client_side_validation && apikey.nil?\n fail ArgumentError, \"Missing the required parameter 'apikey' when calling SubscribersApi.get_subscriber_by_email_address\"\n end\n # verify the required parameter 'mailing_list_id' is set\n if @api_client.config.client_side_validation && mailing_list_id.nil?\n fail ArgumentError, \"Missing the required parameter 'mailing_list_id' when calling SubscribersApi.get_subscriber_by_email_address\"\n end\n # verify the required parameter 'email' is set\n if @api_client.config.client_side_validation && email.nil?\n fail ArgumentError, \"Missing the required parameter 'email' when calling SubscribersApi.get_subscriber_by_email_address\"\n end\n # resource path\n local_var_path = \"/subscribers/{MailingListID}/view.{Format}\".sub('{' + 'Format' + '}', format.to_s).sub('{' + 'MailingListID' + '}', mailing_list_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'apikey'] = apikey\n query_params[:'Email'] = email\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'GetSubscriberByEmailAddressResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SubscribersApi#get_subscriber_by_email_address\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_endpoint()\n end", "def get_raw_email(raw_id)\n params = {'key' => @api_key}\n RestClient.get(\"#{@base_uri}/raw/#{raw_id}\", {:params => params}).body\n end", "def send\n post_params = {}\n self.parameters.each { |key, value|\n if value.is_a? Array\n i = 0\n value.each { |value_value|\n post_params[key.to_s + '[' + i.to_s + ']'] = value_value.to_s\n i += 1\n }\n elsif value.is_a? Hash\n value.each { |value_key, value_value|\n post_params[key.to_s + '[' + value_key.to_s + ']'] = value_value.to_s\n }\n else\n post_params[key.to_s] = value.to_s\n end\n }\n\n url = URI.parse(@@API_URL)\n http_request = Net::HTTP::Post.new(url.path)\n http_request.form_data = post_params\n http_request.basic_auth url.user, url.password if url.user\n\n response = Spree::PAYONE::Proxy::Response.new\n connection = Net::HTTP.new(url.host, url.port)\n load_ca_file connection\n connection.use_ssl = true\n connection.start { |http|\n http_response = http.request(http_request)\n response.response_body= http_response.body\n }\n\n response\n end", "def call_api\n @client.build_url\n @client.get\n assign_data\n end", "def deliver!(mail)\n parameters = settings.dup\n parameters.delete(:return_response)\n message = MultiMail::Message::SendGrid.new(mail).to_sendgrid_hash.merge(parameters)\n\n connection = Faraday.new do |conn|\n conn.request :multipart\n conn.request :url_encoded\n conn.adapter Faraday.default_adapter\n end\n\n response = connection.post('https://sendgrid.com/api/mail.send.json', message)\n\n body = JSON.load(response.body)\n\n unless response.status == 200\n if body['message'] == 'error'\n case body['errors']\n when ['Bad username / password']\n raise InvalidAPIKey, body['errors'].first\n when ['Empty from email address (required)']\n raise MissingSender, body['errors'].first\n when ['Missing destination email']\n raise MissingRecipients, body['errors'].first\n when ['Missing subject']\n raise MissingSubject, body['errors'].first\n when ['Missing email body']\n raise MissingBody, body['errors'].first\n else\n raise body['errors'].join\n end\n else\n raise body['errors'].join\n end\n end\n\n if settings[:return_response]\n body\n else\n self\n end\n end", "def update params\n post \"https://api.sendgrid.com/apiv2/customer.profile.json\", params.merge(task: 'set')\n end", "def send_an_email\r\n SendEmails.new(1)\r\n end", "def send(key)\n HTTParty.post(@add_url, {\n :headers => {\n \"Content-Type\" => \"application/json; charset=UTF8\",\n \"X-Accept\" => \"application/json\"\n },\n :body => {\n #:url => formatted[:url],\n :url => \"https://www.engadget.com/2016/10/09/more-galaxy-note-7-replacement-fires/\",\n #:tags => formatted[:tags],\n :consumer_key => ENV['POCKET_CONSUMER_KEY'],\n :access_token => key\n }.to_json\n })\n end", "def contact_request\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end", "def add_recipient_request(data)\n @sendgrid.client.contactdb.recipients.post(request_body: [data])\n end", "def additional_grid_rest_parameters\n GridRest.additional_parameters\n end", "def send_bulk_sms(message)\n client = IronWorkerNG::Client.new\n client.tasks.create('master_email', payload)\n payload = {}\n payload['message'] = message\n client.tasks.create('master_sms', payload)\nend", "def send_invite\n\n Email::HookCreator::SendTransactionalMail.new(\n client_id: Client::OST_KYC_CLIENT_IDENTIFIER,\n email: @invite_admin_obj.email,\n template_name: GlobalConstant::PepoCampaigns.admin_invite_template,\n template_vars: {\n inviter_name: @admin.name,\n invitee_name: @invite_admin_obj.name,\n company_name: @client.name,\n invite_token: @invite_token\n\n }\n ).perform\n\n end", "def get_tokens_page_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PublicSmtpTokensApi.get_tokens_page ...'\n end\n # resource path\n local_var_path = '/marketing/v3/transactional/smtp-tokens'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'campaignName'] = opts[:'campaign_name'] if !opts[:'campaign_name'].nil?\n query_params[:'emailCampaignId'] = opts[:'email_campaign_id'] if !opts[:'email_campaign_id'].nil?\n query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].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\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'CollectionResponseSmtpApiTokenViewForwardPaging'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oauth2']\n\n new_options = opts.merge(\n :operation => :\"PublicSmtpTokensApi.get_tokens_page\",\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: PublicSmtpTokensApi#get_tokens_page\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end", "def send_with_schedule_with_http_info(inbox_id, send_email_options, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InboxControllerApi.send_with_schedule ...'\n end\n # verify the required parameter 'inbox_id' is set\n if @api_client.config.client_side_validation && inbox_id.nil?\n fail ArgumentError, \"Missing the required parameter 'inbox_id' when calling InboxControllerApi.send_with_schedule\"\n end\n # verify the required parameter 'send_email_options' is set\n if @api_client.config.client_side_validation && send_email_options.nil?\n fail ArgumentError, \"Missing the required parameter 'send_email_options' when calling InboxControllerApi.send_with_schedule\"\n end\n # resource path\n local_var_path = '/inboxes/{inboxId}/with-schedule'.sub('{' + 'inboxId' + '}', CGI.escape(inbox_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'sendAtTimestamp'] = opts[:'send_at_timestamp'] if !opts[:'send_at_timestamp'].nil?\n query_params[:'sendAtNowPlusSeconds'] = opts[:'send_at_now_plus_seconds'] if !opts[:'send_at_now_plus_seconds'].nil?\n query_params[:'validateBeforeEnqueue'] = opts[:'validate_before_enqueue'] if !opts[:'validate_before_enqueue'].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(['*/*'])\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(send_email_options) \n\n # return_type\n return_type = opts[:return_type] || 'ScheduledJobDto' \n\n # auth_names\n auth_names = opts[:auth_names] || ['API_KEY']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: InboxControllerApi#send_with_schedule\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def selenium_grid_hub\n ENV['GRID_HUB']\n end", "def send_test\n @bulletin = @project.bulletins.find(params[:id]) \n \n if request.post?\n addr = params[:recipient][:email]\n recip = @project.recipients.find_by_email(addr)\n if ! recip\n recip = Recipient.new(:email => addr, :firstname => 'Sample', :surname => 'User')\n subscription = Subscription.new( :project => @project, :recipient => recip )\n else\n subscription = @project.subscriptions.find_by_recipient_id( recip.id )\n end\n \n #begin \n BulkMailer::deliver_bulletin(@bulletin, subscription)\n flash[:notice] = _(\"Test e-mail sent successfully!\")\n redirect_to :action => 'index'\n #rescue\n # flash[:error] = \"Unable to send the test email! \" + $!\n #end\n end\n end", "def show\n json_response(@email)\n end", "def index\n @accounts = current_user.person.gmail_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def send_gcm_message(title, body, reg_tokens)\n # Construct JSON payload\n post_args = {\n # :to field can also be used if there is only 1 reg token to send\n :registration_ids => reg_tokens,\n :notification => {\n :title => \"You look has been voted on\",\n :body => \"Check out the results!\"\n }\n }\n \n print post_args \n\n # Send the request with JSON args and headers\n RestClient.post 'https://gcm-http.googleapis.com/gcm/send', post_args.to_json,\n :Authorization => 'key=AIzaSyC0EVhbTNqgr69Pr8pWEdPDe5SSSIWhaU0', :content_type => :json, :accept => :json\nend", "def mailman\n a = RestClient.post \"https://api:03ee8a853e31d8648cf06b82f7c30dcb-3d0809fb-3486193e\" \\\n\t \"@api.mailgun.net/v3/sandbox023900a156f3425e819b872335392423.mailgun.org/messages\",\n :from => \"MPPP MAILER BOT <[email protected]>\",\n :to => \"[email protected]\",\n :subject => \"Hello\",\n :text => params[:lorem]\n\n if a.code == 200\n redirect_to dashboard_path, notice: \"Mail sended\"\n else\n redirect_to dashboard_path, notice: \"Impossible to send mail\"\n end\n end", "def index\n @emails = EventEmail.scoped\n\n if params.keys.include? \"company_id\"\n @emails = @emails.where(:company_id => params[:company_id])\n end\n\n if params.keys.include? \"limit\"\n @emails = @emails.limit(params[:limit])\n end\n\n respond_with @emails\n end", "def send_data\n request = Collector::Request.\n new(self.api_location,\n :user => config[:htpasswd_user],\n :pass => config[:htpasswd_pass])\n\n # convert the array of object to a hash\n server = {\n websites: @websites.map{ |w| w.to_hash(@version).merge({server: config[:client_name].underscore }) }.map{ |w| w[:website] },\n name: config[:client_name].underscore\n }\n\n request.send(server)\n\n end", "def create\n logger.info '!!!params.to_yaml: ' + params.to_yaml\n @send_grid_email = SendGridEmail.new(params)\n\n respond_to do |format|\n if @send_grid_email.save\n format.html { redirect_to(@send_grid_email, :notice => 'Send grid email was successfully created.') }\n format.all do\n render :text => 'OK', :status => :ok \n end\n else\n format.html { render :action => \"new\" }\n format.all do\n render :text => 'Internal Server Error', :status => :internal_server_error \n end\n end\n end\n end", "def waitlist(attendance_id)\n sendgrid_category 'Waitlist Enrolment'\n\n @attendance = Attendance.find(attendance_id)\n @tea_time = @attendance.tea_time\n @user = @attendance.user\n\n mail(to: @attendance.user.email,\n from: @tea_time.host.friendly_email(at_tws: true),\n subject: \"You're on the wait list for tea time on #{@tea_time.start_time.strftime('%B %-e')}!\") do |format|\n format.text\n format.html\n end\n end" ]
[ "0.6953341", "0.6729336", "0.6402483", "0.61519945", "0.5960618", "0.58754337", "0.584071", "0.5828535", "0.5703552", "0.5695776", "0.56949216", "0.5654781", "0.5639799", "0.56355953", "0.56291264", "0.557974", "0.5551625", "0.5528122", "0.54911584", "0.54709023", "0.54628736", "0.54552066", "0.54527026", "0.54379", "0.5414896", "0.5409862", "0.5406878", "0.5392041", "0.53807664", "0.5376041", "0.53733885", "0.53411967", "0.5331617", "0.52907616", "0.52865124", "0.525051", "0.52097166", "0.5202088", "0.519972", "0.518735", "0.5175835", "0.5173886", "0.5173115", "0.517227", "0.5155128", "0.51207715", "0.51187396", "0.51177037", "0.5116855", "0.51148677", "0.51083094", "0.5107719", "0.5105748", "0.5086739", "0.50854844", "0.508121", "0.5076511", "0.5071148", "0.50651884", "0.5063796", "0.5062217", "0.50584173", "0.5053903", "0.5053903", "0.5051032", "0.50483114", "0.5048121", "0.5045165", "0.5044427", "0.50439286", "0.50400424", "0.502669", "0.50195", "0.50189924", "0.5008494", "0.50050426", "0.50026083", "0.50002325", "0.4990703", "0.4990292", "0.4989449", "0.49824262", "0.49743652", "0.4971152", "0.4967211", "0.49638236", "0.496087", "0.495924", "0.49583557", "0.4953855", "0.49465454", "0.49447075", "0.49413615", "0.49369156", "0.49330148", "0.49321967", "0.4931435", "0.49287403", "0.49203384", "0.49139196" ]
0.5182727
40
Do generic database stuff
def doDB begin # Query the inventory inv = InventoryService.getInv(@@config) yield(inv) rescue Exception => ex error = "Inventory - Error connecting to the Inventory Database - '#{ex}''" raise HTTPStatus::InternalServerError, error end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orm; end", "def select(db); end", "def select(db); end", "def db; end", "def db; end", "def single_object_db; end", "def db(*args); data(1, args); end", "def db(*args)\n adapter = repository(:default).adapter\n args.first =~ /^select /i ? adapter.select(*args) : adapter.execute(*args)\n end", "def execute sql\n db[sql]\n end", "def retrieve_database_meta(modelname, adapter,driver,host,username,password,database,urltemplate)\n \n urltemplate.gsub!(\"{host}\",host)\n urltemplate.gsub!(\"{password}\",password)\n urltemplate.gsub!(\"{username}\",username)\n urltemplate.gsub!(\"{database}\",database)\n mdmtype=MdmDataType.first\n \n curr_connect = ActiveRecord::Base.connection\n if adapter==\"mysql\"\n arconfig = {\n :adapter => adapter,\n :host => host,\n :username => username,\n :password => password,\n :database => database }\n \n config = ActiveRecord::ConnectionAdapters::ConnectionSpecification.new( {\n :adapter => adapter,\n :driver => driver,\n :username => username,\n :password => password,\n :host => host,\n :url => urltemplate,\n :pool => 2\n }, 'mysql_connection')\n \n connection = ActiveRecord::ConnectionAdapters::ConnectionPool.new(config)\n \n else\n # jdbc = JDBCAR.new\n # connection = jdbc.connect(driver,username,password,urltemplate)\n arconfig = {:adapter => 'jdbc',\n :driver => driver,\n :username => username,\n :password => password,\n :url => urltemplate,\n :pool => 2}\n config = ActiveRecord::ConnectionAdapters::ConnectionSpecification.new( {\n :adapter => 'jdbc',\n :driver => driver,\n :username => username,\n :password => password,\n \n :url => urltemplate,\n :pool => 2\n }, 'jdbc_connection')\n \n connection = ActiveRecord::ConnectionAdapters::ConnectionPool.new(config)\n end\n \n primary_k = {}\n newtables={}\n metaconnect = connection.checkout\n metaconnect.tables.each do |table|\n newtables[table] = [] \n primary_k[table] = metaconnect.primary_key(table)\n metaconnect.columns(table.to_s).each do |col|\n newtables[table] << col.name\n print col.name + \", \"\n end\n end\n \n connection.checkin metaconnect\n \n \n mdm_model = MdmModel.find_by_name(modelname) \n mdm_model = MdmModel.new if mdm_model.nil? \n mdm_model.connect_src = serialize_config(adapter,driver,host,username,password,database,urltemplate)\n mdm_model.name = modelname\n newtables.keys.each do |table|\n mdmexist = MdmObject.find_by_name(table)\n mdmexist.destroy if mdmexist\n mdmobject = MdmObject.new\n mdmobject.name=table\n newtables[table].each do |col|\n mdmcolumn = MdmColumn.new\n mdmcolumn.name = col\n mdmcolumn.mdm_data_type = mdmtype\n mdmcolumn.is_primary_key=true if !primary_k[table].nil? && primary_k[table].include?(mdmcolumn.name)\n mdmcolumn.save\n if mdmcolumn.is_primary_key\n pk = MdmPrimaryKey.new\n pk.mdm_column = mdmcolumn\n mdmobject.mdm_primary_keys << pk\n end\n mdmobject.mdm_columns << mdmcolumn\n end\n mdm_model.mdm_objects << mdmobject\n \n end\n \n mdm_model.save\n generate_active_record(mdm_model,arconfig)\n end", "def prepare_sql; raise \"Define #prepare_sql in your subclass\"; end", "def subscribe_sql_active_record; end", "def alchemy\r\n end", "def flushdb; end", "def determine_database\n self.class.database \n end", "def sql_modes; end", "def handle_database_creation\n database = Sequel.sqlite('./actions_db.db') # memory database, requires sqlite3\n database.create_table? :\"#{@username}_follows\" do\n primary_key :id\n String :user_id\n String :username\n Time :follow_time\n end\n database.create_table? :\"#{@username}_likes\" do\n primary_key :id\n String :media_id\n String :user_id\n String :shortcode\n Time :like_time\n end\n @table_follows = database[:\"#{@username}_follows\"]\n @table_likes = database[:\"#{@username}_likes\"]\n end", "def query; end", "def method_missing(method, *args)\n return @@db.send(method, *args) if @@db.respond_to?(method)\n super\n end", "def db=(_arg0); end", "def db=(_arg0); end", "def log_options( generic )\n if Maadi::Generic::Generic::is_generic?( generic )\n options = generic.options\n if options.length > 0\n if @db != nil\n options.each do |option|\n begin\n # CREATE TABLE IF NOT EXISTS tblOptions ( oID integer primary key, oType varchar(255), oInstance varchar(255), oOption varchar(255), oValue TEXT)\n stm = @db.prepare( 'INSERT INTO tblOptions (oType, oInstance, oOption, oValue) VALUES (?, ?, ?, ?)' )\n stm.bind_params(generic.type, generic.instance_name, option, generic.get_option(option))\n rs = stm.execute\n oId = @db.last_insert_row_id.to_s\n stm.close\n rescue ::SQLite3::Exception => e\n Maadi::post_message(:Warn, \"Repository (#{@type}:#{@instance_name}) encountered an error (#{e.message}).\")\n end\n end\n end\n end\n end\n end", "def collect_db(db_type, host, user, password)\n case db_type\n when 'mysql'\n collect_mysql(host, user, password)\n when 'postgres'\n collect_postgres(host, user, password)\n else\n MyLog.log.error StandardError.new(\n \"db_type `#{db_type}` is neither `mysql` nor `postgres`.\"\n )\n end\n end", "def execute(*args)\n @db.execute(*args)\n end", "def prepare\n super\n\n # open the database.\n if File.exist?(@options['DATABASE'])\n @db = ::SQLite3::Database.open(@options['DATABASE'])\n else\n @db = ::SQLite3::Database.new(@options['DATABASE'])\n end\n @db.results_as_hash = true\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"table\" AND name=\"tblMessages\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblMessages (\n mID integer primary key,\n mStatus char(5),\n mTime datetime,\n mText varchar(255))\n )\n\n @db.execute( tbl_def )\n end\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"table\" AND name=\"tblOptions\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblOptions (\n oID integer primary key,\n oType varchar(255),\n oInstance varchar(255),\n oOption varchar(255),\n oValue TEXT)\n )\n\n @db.execute( tbl_def )\n end\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"table\" AND name=\"tblProcedures\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblProcedures (\n pID integer primary key,\n pTime datetime,\n pProc varchar(255))\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblSteps (\n sID integer primary key,\n pID integer,\n sLabel varchar(255),\n sCommand TEXT,\n sFinal TEXT)\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblParameters (\n pID integer primary key,\n sID integer,\n pLabel varchar(255),\n pValue varchar(255),\n pConstraint varchar(255))\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblComparisons (\n cID integer primary key,\n pID integer,\n sID1 integer,\n sID2 integer,\n cRelationship varchar(255))\n )\n\n @db.execute( tbl_def )\n end\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"table\" AND name=\"tblResults\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblResults (\n rID integer primary key,\n rTime datetime,\n rTestId integer,\n rProc varchar(255),\n rProcId integer,\n rApp varchar(255))\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblResultData (\n dID integer primary key,\n rID integer,\n dStep varchar(255),\n dStepId integer,\n dStatus varchar(255),\n dType varchar(255),\n dData TEXT)\n )\n\n @db.execute( tbl_def )\n end\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"view\" AND name=\"qryResults\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE VIEW IF NOT EXISTS qryResults AS\n SELECT R.rTestId As qTestId, R.rProc As qProc, R.rProcId As qProcId, R.rApp As qApp,\n D.dStep As qStep, D.dStepId As qStepId, D.dStatus As qStatus, D.dType As qType, D.dData As qData\n FROM tblResults As R, tblResultData As D\n WHERE D.rID = R.rID\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE VIEW IF NOT EXISTS qryComparisons AS\n SELECT R.rTestId As qTestId, R.rProc As qProc, R.rProcId As qProcId, C.cRelationship As qRelationship,\n D1.dStep As qStep1, D1.dStepId As qStepId1, D1.dStatus As qStatus1, D1.dType As qType1, D1.dData As qData1,\n D2.dStep As qStep2, D2.dStepId As qStepId2, D2.dStatus As qStatus2, D2.dType As qType2, D2.dData As qData2\n FROM tblComparisons As C, tblResults As R, tblResultData As D1, tblResultData As D2\n WHERE C.pID = R.rProcID AND C.sID1 = D1.dStepId AND C.sID2 = D2.dStepId\n )\n\n @db.execute( tbl_def )\n end\n end", "def test_database_name\n @db.execute('create table foo(text BLOB)')\n @db.execute('insert into foo(text) values (?)',SQLite3::Blob.new('hello'))\n stmt = @db.prepare('select text from foo')\n if stmt.respond_to?(:database_name)\n assert_equal 'main', stmt.database_name(0)\n end\n end", "def type_to_sql(*args); connection.type_to_sql(*args); end", "def select_db(name)\n #This is a stub, used for indexing\n end", "def data_complextest(db); end", "def begin_db_transaction() end", "def begin_db_transaction() end", "def each_model(options = {}, &block)\n WingedCouch::Model.subclasses.each do |klass|\n if options[:raise_exceptions] and not klass.database.exist?\n raise %Q{Database for model #{klass.name} doesn't exist, run rake winged_couch:db:create}\n end\n block.call(klass)\n end\n end", "def method_missing(meth, *args, &block)\n read_only = (meth == :[])\n\n @db.transaction(read_only) do\n @db.send(meth, *args, &block)\n end\n end", "def create_kitten(db, name, age)\r\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\r\nend", "def db\n @db == true ? TABLE : @db.try(:parameterize, separator: \"_\")\n end", "def subscribe_sql_active_record=(_arg0); end", "def test_manipulate_databases\n number=1000\n relation_name = \"Dog\"\n relation_schema = {\"name\" => \"string\", \"race\" => \"string\", \"age\" => \"integer\"}\n values = {\"name\" => \"Bobby\", \"age\" => 2, \"race\"=> \"labrador\"}\n @dbids.each do |id|\n database(id).create_relation(relation_name,relation_schema)\n assert_equal(\"Dog\",database(id).relation_classes[\"Dog\"].table_name)\n end\n \n @dbids.each do |id|\n puts \"insert into db : #{id}\"\n\n (0..number).each do |i|\n count_values = {\"name\" => \"Bobby#{i}\", \"age\" => i, \"race\"=> \"labrador\"}\n database(id).relation_classes[\"Dog\"].insert(count_values)\n end\n assert_equal(number+1,database(id).relation_classes[\"Dog\"].all.size)\n\n end\n \n @dbids.each do |id|\n number_of_tuples_to_delete = rand(number)\n (1..number_of_tuples_to_delete).each do |i|\n database(id).relation_classes[\"Dog\"].delete(i)\n end\n assert_equal(number+1-number_of_tuples_to_delete,database(id).relation_classes[\"Dog\"].all.size)\n end\n \n end", "def create_table\n puts \"Creating people table\"\n $db.execute %q{\n CREATE TABLE people(\n id integer primary key,\n name varchar(50),\n job varchar(50),\n gender varchar(6),\n age integer\n )\n }\nend", "def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end", "def database; datastore['DATABASE']; end", "def database\n @database ||= determine_database\n end", "def save_post(params)\n sql= 'INSERT INTO posts (title, description, url, created_at)\n VALUES($1,$2,$3,NOW())'\n db_connection do |conn|\n conn.exec_params(sql,[params[:title],params[:description],params[:url]])\n end\nend", "def prepare( str )\n @db.prepare( str )\n end", "def commit_db_transaction() end", "def commit_db_transaction() end", "def database(dbname=nil, &block)\n dbname ||= database_name\n if dbname then\n repository dbname, &block\n else\n yield\n end\n end", "def database_configuration; end", "def database_configuration; end", "def engine\n @dbi.engine\n end", "def engine\n @dbi.engine\n end", "def fetch_and_import!(opts={})\n eve_table = opts[:eve_table]\n dest_table = opts[:dest_table]\n mapping = opts[:mapping]\n dbh = opts[:conn] || @dbh\n comment_label = opts[:label]\n \n # Fetch Data from crpActivities Table\n results = dbh.query(\"SELECT * FROM \"+eve_table)\n # Clear Destination Table to eliminate Redundancy\n dest_table.camelize.constantize.delete_all\n # Do some Meta programming FU magic\n results.each do |row|\n insert_map = {}\n mapping.each do |key,value|\n insert_map[key.to_sym] = row[value]\n end \n dest_table.camelize.constantize.create!(insert_map)\n # Just so you see something when running this script..\n p \"Creating Record for #{dest_table} : \" + row[comment_label].to_s\n end\nend", "def prepare; end", "def prepare; end", "def prepare; end", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def create_kitten(db, name, age)\n db.execute(\"INSERT INTO kittens (name, age) VALUES (?, ?)\", [name, age])\nend", "def db_write! args\n #TODO put this in rescue blocks so that if something chokes, we don't completely die, and put in a new table (or maybe a column for logging errors?)\n args.collect! do |o|\n o.is_a?(String) ? SQLite3::Database.quote(o) : o\n end\n \n sql = %{\n INSERT INTO %s\n (article_name, desc, revision_id, old_id, user, byte_diff, ts, description)\n VALUES ('%s', '%s', '%d', %d, '%s', %d, %d, '%s')\n } % ([@table_name] + args)#article_name, desc, rev_id, old_id, user, byte_diff, ts, description\n \n #deal with multiple threads writing to db\n key = Digest::MD5.hexdigest(Time.now.to_i.to_s + sql)\n @db_queue << [sql, key]\n key\n #return the primary id of the row that was created:\n #@db.get_first_value(\"SELECT last_insert_rowid()\")\n end", "def run(&block)\n case prepared_type\n when :select, :all\n # Most common scenario, so listed first\n all(&block)\n when :each\n each(&block)\n when :insert_select\n with_sql(prepared_sql).first\n when :first\n first\n when :insert, :update, :delete\n if opts[:returning] && supports_returning?(prepared_type)\n returning_fetch_rows(prepared_sql)\n elsif prepared_type == :delete\n delete\n else\n send(prepared_type, *prepared_modify_values)\n end\n when :insert_pk\n fetch_rows(prepared_sql){|r| return r.values.first}\n when Array\n case prepared_type[0]\n when :map, :as_hash, :to_hash, :to_hash_groups\n send(*prepared_type, &block) \n end\n else\n Sequel::Deprecation.deprecate(\"Using an unsupported prepared statement type (#{prepared_type.inspect})\", 'Switch to using :select as the prepared statement type')\n all(&block)\n end\n end", "def setup_database\n Hanami::Model.load!\n end", "def db_adder(database, year, variety, region, notes)\n database.execute(\"INSERT INTO wine_cellar (year,variety,region,notes) VALUES (?,?,?,?)\", [year,variety,region,notes])\nend", "def hijack_db\n ActiveRecord::Base.establish_connection(\n :adapter => ENV['YAPTESTFE_DBTYPE'],\n :host => ENV['YAPTESTFE_DBIP'],\n :port => ENV['YAPTESTFE_DBPORT'].to_i,\n :username => ENV['YAPTESTFE_DBUSER'],\n :password => ENV['YAPTESTFE_DBPASS'],\n :database => ENV['YAPTESTFE_DBNAME']\n ) \n begin # catch db connection errors\n if not ActiveRecord::Base.connection.active?\n render :template => 'help/dberror', :layout => false\n end\n rescue PGError => msg\n logger.info \"DBERROR: #{msg}\"\n render :template => 'help/dberror', :layout => false\n end\n end", "def db_action action, *args\n if [:migrate, :migrate_to].include? action\n KitDBSupport.send action, path, *args\n else\n if config[:db][:adapter] == 'sqlite3'\n db_path = config[:db][:database]\n config[:db][:database] = \"#{path}/#{db_path}\" unless db_path =~ /^(\\/|~)/\n end\n KitDBSupport.send action, config[:db], *args\n end\n end", "def db_record\n db or MyBiaDJ::Table(:files)[:path => relative_path, :name => name.to_s]\n end", "def transactions_to_db\n\n end", "def get_budgets(db)\r\n budgets = db.execute(\"SELECT * FROM budgets\")\r\nend", "def create_from_database(id)\n rec = CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{id};\").first\n if rec.nil?\n self.new()\n else\n self.new(rec)\n end\n end", "def run\n if @prepared_type == :insert\n fetch_rows(prepared_sql){|r| return r.values.first}\n else\n super\n end\n end", "def db\n self.class.db\n end", "def prepare\n # Only do this once\n return if $has_prepared\n\n prepared_statements = {\n temperature_readings: :insert_temp,\n moisture_readings: :insert_moisture,\n light_readings: :insert_light,\n }\n\n prepared_statements.each do |table, name|\n DB[table].prepare(:insert, name, plant_id: :$plant_id, value: :$value)\n end\n\n $has_prepared = true\nend", "def add_media(db, mediatype, title, rentLease, mediaconsumed)\r\n\tdb.execute('INSERT INTO media (mediatype, title, rentLease, mediaconsumed) VALUES (?, ?, ?, ?)', [mediatype, title, rentLease, mediaconsumed])\r\nend", "def initialize(database)\r\n @database = database\r\n end", "def database\n @database\n end", "def database\n @database\n end", "def query\n end", "def db_info\n @conn.query({url_path: \"#{database}\", method: :get})\n end", "def main\n create_table\n set_timestamp_to_now\n json = fetch_data.to_json\n store json\nend", "def insert(sql, name = nil, pk = nil, id_value = nil) end", "def use_database(db)\n self.database = db\n end", "def target_sql_mode=(_arg0); end", "def create_table\n puts \"Creating table >> PEOPLE\"\n $db.execute %q{\n CREATE TABLE people(\n id integer primary key,\n name varchar(50),\n job varchar(50),\n gender varchar(6),\n age integer\n )\n }\nend", "def query_db(sql)\n #specifies the path of our database file\n db = SQLite3::Database.open('movies.db')\n\n #forces results returned to be hash format\n db.results_as_hash = true\n\n #puts a message showing the SQL statement to be executed\n puts \"----------------------------------------------------------------\"\n puts \"Executing SQL: #{ sql }\"\n puts \"----------------------------------------------------------------\"\n\n #execute the query and return the result\n db.execute(sql)\nend", "def find\n self.db.query(\"\n select * \n from dogs\n \")\n end", "def transaction; end", "def transaction; end", "def transaction; end", "def get_database_object\n\t\t\t\t\t$TRACE.debug 5, \"getting database object #{self.database_object} for object #{self.class}:#{self.id}, called by #{caller[0]}\"\n\t\t\t\t\tself.database_object\n\t\t\t\tend", "def setup_database!\n mapper = Praxis::Application.instance.plugins[:praxis_mapper]\n Sequel.connect(mapper.config.repositories[\"default\"]['connection_settings'].dump) do |db|\n db.create_table! :people do\n primary_key :id\n string :name\n end\n end\nend", "def getDB\n @db\n end", "def initialize( db )\n @db = db\n end", "def initialize(options)\n super\n\n # The default Ruby <-> SQL type mappings, should be valid\n # for most RDBM systems.\n @typemap = {\n Integer => \"integer\",\n Fixnum => \"integer\",\n Float => \"float\",\n String => \"text\",\n Time => \"timestamp\",\n Date => \"date\",\n TrueClass => \"boolean\",\n Object => \"text\",\n Array => \"text\",\n Hash => \"text\"\n }\n end", "def flushdb(options = T.unsafe(nil)); end", "def get_db(**db_conn_info)\n Sequel.mysql2(db_conn_info)\nend", "def initDb\n @db.create_table! :tasks do\n primary_key :id\n Integer :created\n Integer :changed\n Integer :wake\n Integer :completed\n Integer :status\n String :title\n String :path\n String :data, :text=>TRUE\n end\n\n @db.create_table! :locks do\n Integer :id, :primary_key=>TRUE\n Integer :locked\n end\n end" ]
[ "0.70075333", "0.69723696", "0.69723696", "0.69383854", "0.69383854", "0.6653664", "0.6445549", "0.6409405", "0.6234449", "0.6224832", "0.60799253", "0.60697293", "0.60623735", "0.6059936", "0.6025676", "0.59740025", "0.5966069", "0.5921116", "0.5902026", "0.589543", "0.589543", "0.5864005", "0.5861493", "0.58330864", "0.5825399", "0.5815303", "0.5806283", "0.5789595", "0.5776123", "0.5764707", "0.5764707", "0.57586837", "0.57456106", "0.57019985", "0.56742555", "0.5662647", "0.5653811", "0.5646495", "0.56326795", "0.56321424", "0.5616046", "0.56148666", "0.5607735", "0.5597509", "0.5597509", "0.55962384", "0.55956", "0.55956", "0.5595302", "0.5595302", "0.5591385", "0.558736", "0.558736", "0.558736", "0.5578769", "0.5578769", "0.5578769", "0.5578769", "0.5578769", "0.5578769", "0.5578769", "0.5578769", "0.5578769", "0.55715257", "0.5567302", "0.55592525", "0.55475074", "0.5545135", "0.55434597", "0.553694", "0.55346525", "0.5525051", "0.55226266", "0.55169606", "0.5515643", "0.5513978", "0.5512033", "0.5509217", "0.55087006", "0.55087006", "0.5502815", "0.5496213", "0.5493332", "0.5493159", "0.5484026", "0.5483499", "0.5483452", "0.5480004", "0.54782736", "0.54727685", "0.54727685", "0.54727685", "0.5471937", "0.54700756", "0.546759", "0.5464781", "0.54631126", "0.5462507", "0.546223", "0.54606766" ]
0.5498449
81
Returns the id of the particular testbed in the OMF inventory.
def getInvTestbedId(testbedName) result = Hash.new doDB { |inv| result = inv.getTestbedId(testbedName) } result['id'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def automation_id\n @attributes[:automation_id]\n end", "def getInvLocationId(name, x, y, z, testbedId)\n\t\t\tresult = Hash.new\n\t\t\t# Fill in the db id of the location of this node added in the db\n doDB { |inv|\n result = inv.getLocationId(name, x, y, z, testbedId)\n }\n\t\t\tresult['id']\n\t\tend", "def test_can_return_id_of_item\n assert_equal 263515158, item.id\n end", "def automation_id\n return @automation_id\n end", "def item_id(input_name:, op:)\n fv = op.input(input_name)\n fv.part.try(:id) || fv.item.id\n end", "def id\n unitid.to_i\n end", "def fetch_id\n return unless @name\n\n begin\n response = Inventory.request[\"assets/#{@name}\"].get :content_type => :json, :accept => :json \n asset = JSON.parse(response)\n asset['id']\n rescue RestClient::ResourceNotFound\n nil\n rescue => exception\n puts exception.message\n puts exception.response\n exit 1\n end\n end", "def id\n raise \"Item.id not set\" unless @id\n $stderr.puts \"Item.id >#{@id}<\"\n @id\n end", "def testcase_id_from_beaker_script(beaker_file)\n # Find first matching line\n match = File.readlines(beaker_file).map { |line| line.match(TESTCASE_ID_REGEX) }.compact.first\n\n raise MissingTestRailId, 'Testcase ID could not be found in file' if match.nil?\n\n match[:testrun_id]\n end", "def item_id\n id\n end", "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def get_id \n part_number = PartNumber.get_part_number(self)\n part_number.id if part_number\n end", "def item_id\n params['VendorTxCode']\n end", "def pull_id(id)\n return Dish(@catchpoint.get(\"tests/#{id}\"))\n end", "def getTestId\n @test_id\n end", "def item_id\n item_hash.deep_find(:item_id)\n end", "def id\n ChefPlatformSpec.id_from(chef_server, name)\n end", "def test_id(test_key)\n request = ServiceHelper.new base_url: @jira_url, path: \"rest/api/3/issue\"\n request.auth 'basic', @jira_user, @jira_token\n request.headers.add 'Accept', 'application/json'\n request.append_to_route test_key\n response = request.get\n raise Exception, response.body unless response.ok?\n\n response.parsed_body['id']\n end", "def GetItemID(arg0)\r\n ret = _invoke(1610743825, [arg0], [VT_BSTR])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end", "def agent_id\n self.dig_for_string(\"agentSummary\", \"id\")\n end", "def find(item_name)\n @inventory.find(item_name)\n end", "def get_id_value(artifact)\n return get_value(artifact,'id')\n end", "def actual_id\n args = params[:id].split('-')\n args[0]\n end", "def id()\n #This is a stub, used for indexing\n end", "def scribd_id\n @attributes[:id]\n end", "def get_id(ind)\n\t\treturn @tile_Array[ind].return_id\n\tend", "def record_id\n attributes['item_id']\n end", "def get_id(test_case)\n # ap test_case.methods - Object.methods\n tagged_id = test_case.tags.detect{|tag| tag.name =~/testcase/}\n if tagged_id\n result = /testcase_(\\d+)/.match(tagged_id.name)[1]\n else\n tags = test_case.tags\n project_id = /\\d+/.match(tags.select{|tag| tag.name =~/project/}.last.name)[0] \n suite_id = /\\d+/.match(tags.select{|tag| tag.name =~/suite/}.last.name)[0] \n section_id = /\\d+/.match(tags.select{|tag| tag.name =~/sub_section/}.last.name)[0]\n title = extract_title(test_case)\n found_case = testrail_api_client.send_get(\"get_cases/#{project_id}&suite_id=#{suite_id}&section_id=#{section_id}\").select{|c| c['title'] == title}.first\n if found_case\n result= found_case['id']\n else\n result = create_new_case(project_id,suite_id,section_id,test_case)['id']\n end\n end\n return result\n end", "def id\n vm_info['VM']['ID'].to_i\n end", "def click_key_offer_part\n id\n end", "def id\n @json['uuid']\n end", "def get_summoner_id(str, region=nil)\n Summoner.find_by_name(str, region)[\"id\"]\n end", "def id\n @pe_id\n end", "def get_id()\n return @id\n end", "def id\n @power_up.id\n end", "def get_ef_id(ef)\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n id = ef.split(\"ef_id=\")\n\t\tef_id = id[1].split(\":\")\n\t\t$tracer.report(\"EF ID from URL: #{ef_id[0]}\")\n\t\treturn ef_id[0]\n end", "def id\n self.event['id'].to_i\n end", "def id\n object.evss_id\n end", "def id\n get_screen_config['id']\n end", "def id\n object[\"id\"]\n end", "def item_id\n params['item_number'] || params['custom']\n end", "def item_id\n params['item_number'] || params['custom']\n end", "def id\n hid\n end", "def id\n code\n end", "def current_test_app_uuid\n if defined?(@gear)\n @gear.uuid\n elsif defined?(@app) && @app.respond_to?(:uid)\n @app.uid\n else\n raise \"Neither @app nor @gear is defined\"\n end\nend", "def item_entry_id\n return @item_entry_id\n end", "def item_entry_id\n return @item_entry_id\n end", "def item_from_uuid(id)\n @items.find { |i| i[:id].to_s == id } || raise(\"Unable to resolve item for uuid '#{id}'\")\n end", "def id\n return @args[:id]\n end", "def id\n @attributes['id']\n end", "def unit_id\n\t\t@csv[1]\n\tend", "def id\n @obj['id']\n end", "def unit_of_work_id\n context[:unit_of_work_id]\n end", "def line_item_id\n @row[\"売上詳細ID\"].to_s\n end", "def entity(index)\n i = get_field_index_by_external_id(index,@fields[:entity])\n fields(index, i)['item_id'].to_i unless i.nil?\n end", "def find_by_id(item)\n @driver.find_element(:id, item)\n end", "def id(id)\n #::Hero.find_by_id(id)\n ::Item.where(id: id)\n end", "def inventoryParts(part_id)\n Parts.find(:all,:conditions => {:Parts_Id => part_id})\n end", "def id\n self[:identifier]\n end", "def id\r\n @ole.txn_id\r\n end", "def id\n id = \"#{self.lane}\"\n id += \"_#{illumina_barcode}\" unless illumina_barcode.empty?\n id\n end", "def job_spec_id\n self.job_spec.id\n end", "def oid\n id(get_oid())\n end", "def digitool_id\n return nil if @mods.nil?\n return @mods.digitool_ids.first\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def automation_id=(value)\n @automation_id = value\n end", "def power_up_id\n @power_up\n end", "def id\n @attributes[:_id]\n end", "def get_id\n return @m_id\n end", "def get_id\n return @m_id\n end", "def get_id\n return @m_id\n end", "def get_id\n return @m_id\n end", "def get_id\n return @m_id\n end", "def GetUnitId(unit)\n cmd = Builtins.sformat(\"%1 --no-pager -p Id show %2\", @invoker, unit)\n ret = Convert.convert(\n SCR.Execute(path(\".target.bash_output\"), cmd, { \"TERM\" => \"raw\" }),\n :from => \"any\",\n :to => \"map <string, any>\"\n )\n if Ops.get_integer(ret, \"exit\", -1) != 0\n Builtins.y2error(\n _(\"Unable to query '%1' unit Id\\nCommand returned: %2\\n\"),\n unit,\n ret\n )\n return nil\n end\n\n # extract first line\n _end = Builtins.findfirstof(Ops.get_string(ret, \"stdout\", \"\"), \" \\n\")\n out = Builtins.substring(\n Ops.get_string(ret, \"stdout\", \"\"),\n 0,\n _end != nil ? _end : 0\n )\n\n # extract key anv value\n tmp = Builtins.splitstring(out, \"=\")\n if Builtins.size(tmp) != 2 || Ops.get_string(tmp, 0, \"\") != \"Id\" ||\n Ops.get_string(tmp, 1, \"\") == \"\"\n Builtins.y2error(\n _(\"Unable to parse '%1' unit Id query output: '%2'\\n\"),\n unit,\n out\n )\n return nil\n end\n\n Ops.get_string(tmp, 1, \"\")\n end", "def get_item_id(index)\n return nil if index.blank?\n raise \"您填写的内容不像是个数字啊(#{index})!\" unless only_num?(index)\n index = index.to_i - 1\n raise \"您确定有这个选项吗(#{index})?\" unless (0..(self.issue[\"items\"].count)).include? index\n self.issue[\"items\"][index][\"id\"]\n end", "def get_id()\n return @id\n end", "def item_id\n\tparams['item_number'] || params['custom']\n end", "def record_id\n block.id\n end", "def id\n self.struct.send(:table)[:id]\n end", "def test_staging_hid_to_id\n assert_equal(1234, Vault::App.hid_to_id('[email protected]'))\n end", "def ostack_get_instance_id ()\n # The instance id is kept in @passthrough[:instance] or\n # can be obtained from @instance_data which has all instance\n # details.\n if ! @instance_data.nil? and ! @instance_data.id.nil?\n return @instance_data.id # we already know the id\n elsif @passthrough.has_key?(:instance)\n return @passthrough[:instance] # we know the id we want\n else\n @logger.debug(sprintf('unable to determine id from instance_data[%s] or passthrough specification[%s]', @instance_data, @passthrough))\n return nil # we don't have an id yet, likely a up() call\n end\n end", "def get_id()\n @id\n end", "def get_id()\n @id\n end", "def id\n object.id.to_i\n end", "def event_chest_id\n event_name.match(Chest_Service::CHEST_REGX)[1]\n end", "def id\n hid\n end", "def id\n hid\n end", "def getId()\n\t\t\treturn @_id\n\t\tend", "def test_find_id_by_serial_num\n d = Dog.new({\"name\"=>\"Phoebe\", \"breed\"=>\"Heeler x\", \"age\"=>3, \"serial_num\"=>3, \n \"colour\"=>\"Black tri\", \"description\"=>\"Fearful of people.\", \"temperament_id\"=>13, \"owner_id\"=>1})\n x = Dog.find_id_by_serial_num({\"serial_num\"=>3})\n assert_kind_of(Integer, x)\n end" ]
[ "0.61996126", "0.5984846", "0.5939659", "0.58910453", "0.58338696", "0.582442", "0.5739547", "0.566752", "0.56154394", "0.56071454", "0.5592836", "0.5592836", "0.5592836", "0.5585922", "0.5540718", "0.5528908", "0.55243576", "0.5474642", "0.542393", "0.53706956", "0.5362792", "0.536183", "0.53282833", "0.5306177", "0.5305737", "0.5301771", "0.5297798", "0.5285842", "0.52717817", "0.52711594", "0.5266892", "0.5263802", "0.52458066", "0.5221726", "0.52118546", "0.52100635", "0.520738", "0.5203251", "0.5193814", "0.51927257", "0.5179011", "0.51698476", "0.51684177", "0.51684177", "0.5167533", "0.5165521", "0.5164668", "0.5159849", "0.5159849", "0.51562274", "0.5153612", "0.5148606", "0.5147593", "0.5147166", "0.51434207", "0.5141193", "0.5119716", "0.51180786", "0.5106095", "0.51060104", "0.5097256", "0.50918955", "0.5091627", "0.5074823", "0.50728005", "0.50707847", "0.5048237", "0.5048237", "0.5048237", "0.5048237", "0.5048237", "0.5048237", "0.5048237", "0.5048237", "0.5048237", "0.5048237", "0.50472367", "0.50441027", "0.50428843", "0.50380147", "0.50380147", "0.50380147", "0.50380147", "0.50380147", "0.50344366", "0.5031073", "0.5028632", "0.502522", "0.50243735", "0.50238836", "0.50190866", "0.50182253", "0.500551", "0.500551", "0.50028694", "0.49964952", "0.49946558", "0.49946558", "0.4990269", "0.49803466" ]
0.74814546
0
Returns the id of the particular location in the OMF inventory.
def getInvLocationId(name, x, y, z, testbedId) result = Hash.new # Fill in the db id of the location of this node added in the db doDB { |inv| result = inv.getLocationId(name, x, y, z, testbedId) } result['id'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_id\n @location.id if @location.present?\n end", "def location\n ln = location_name\n return nil if ln == \"\" || ln == nil\n @engine.item_by_name(location_name)\n end", "def locationId\n if locationMode == Yext::Api::Enumerations::AddRequestLocationMode::NEW\n newLocationId\n else\n existingLocationId\n end\n end", "def location_id\n\t\t\tLocation.count + 1\n\t\tend", "def storage_location_id\n value = field_value('storage_location_id', find_by: :code)\n if value.nil?\n return self.storage_location_id = self.generate_uuid # make sure persistent_id is set & use that\n else\n return value\n end\n end", "def locate_id\n @config[:locate_id]\n end", "def location_type_id\n f1_type = F1::AddressType.where(id: self.address_type_id).take\n return if f1_type.nil?\n\n location_type = CIVICRM::LocationType.where(name: f1_type.name).take\n return if location_type.nil?\n\n location_type.id\n end", "def location\n\t\tUnitLocation.new(@db, @id)\n\tend", "def get_location_sys_id(location)\n query_data = URI::encode(location)\n url = \"#{@service_now_url}/table/cmn_location?sysparm_query=city%3D#{query_data}\"\n sys_id = get_record_sys_id(url)\n sys_id\n end", "def location_type_id\n addr_type = ALF::AddressType.where('address_type_id', self.address_type).first\n return if addr_type.nil?\n\n location_type = CIVICRM::LocationType.where(name: addr_type.name).take\n return if location_type.nil?\n\n location_type.id\n end", "def get_instagram_location_id(building)\n return_hash = HTTParty.get(\"https://api.instagram.com/v1/locations/search?lat=#{building.latitude}&lng=#{building.longitude}&distance=25&client_id=#{INSTAGRAM_CLIENT_ID}\")\n data = return_hash[\"data\"]\n location_hash = data.detect { |item| item[\"name\"].include?(@building.name) }\n unless location_hash == nil\n location = location_hash[\"id\"]\n end\n end", "def set_item_location\n @item_location = ItemLocation.find(params[:id])\n end", "def location\n Location.get(@entity['location_id'], client: @client)\n end", "def set_item_location\n @item_location = ItemLocation.find(params[:id])\n end", "def item_id\n item_hash.deep_find(:item_id)\n end", "def item_id(input_name:, op:)\n fv = op.input(input_name)\n fv.part.try(:id) || fv.item.id\n end", "def location\n @location ||= locations.hq.first\n end", "def location\n self.location_id > 0 ? Location.find(self.location_id).name : NOT_SET \n end", "def get_summoner_id(str, region=nil)\n Summoner.find_by_name(str, region)[\"id\"]\n end", "def location\n fetch('games.super_mario.locations')\n end", "def location\n fetch('hey_arnold.locations')\n end", "def live_lookup_item_id\n id || folio_item&.id || barcode\n end", "def parent_location\n return \"\" if self.location_id.nil? || self.location_id.blank?\n self.location.name\n end", "def location_name\n LOCATIONS[location.to_s]\n end", "def location_name\n LOCATIONS[location.to_s]\n end", "def location_name\n LOCATIONS[location.to_s]\n end", "def location_name\n LOCATIONS[location.to_s]\n end", "def item_id\n id\n end", "def show_store_inventory_item(locations,products,itemid)\n #Loop through Stores Location Id List\n puts \"====== STORE INVENTORY CHECK ===Id: #{itemid}=====\"\n ind = 0\n for locid in @location_list\n prod_list = locations[ind][1].product_list\n prod_list.each do | product_id, quantity |\n pquery = Utils::product_name_query(product_id,products)\n pname = pquery[0]\n price = pquery[1]\n if (itemid == product_id)\n puts \"Location: #{locid}, Product Id: #{product_id}, Product Name: #{pname}, Price: $#{price}, Quantity: #{quantity}\"\n end\n end\n ind += 1 #update index\n end #for\n end", "def id\n @position\n end", "def location\n return @location\n end", "def id\n raw_data[:HotelID].to_i\n end", "def id\n raw_data[:HotelID].to_i\n end", "def region_id(x, y)\n $game_map.region_id(x, y)\n end", "def find_region_id(description)\n find(:first, :conditions => {_(:desc) => description}).id\n end", "def location\n ans = location_answers.first\n ans ? ans.location : nil\n end", "def version_location_to_integer(location = nil)\n version_location_values = {\n :r => 2,\n :a => 1\n }\n\n version_location_values[location.to_s.to_sym] || location.to_i\n end", "def set_location\n @location = Spree::Location.find(params[:id])\n end", "def set_location\n @location = Location.friendly.find(params[:id])\n end", "def oid\n id(get_oid())\n end", "def set_location\n @location = Location.friendly.find(params[:id])\n end", "def location\n @location\n end", "def location\n @location\n end", "def location\n @ole.Location\n end", "def location\n @location ||= Station.get(@attrs['LocationCode'])\n end", "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def location_of(item)\r\n return @pack if @pack.has?(item)\r\n @rooms.each { |id, r|\r\n return r if r.has?(item)\r\n }\r\n return nil\r\n end", "def locate(id)\n return self if are_you(id)\n\n # Try Inventory\n i = @inv.fetch(id)\n return i if !i.nil?\n\n return nil\n end", "def location\n\t\tStructureLocation.new(@db, @id)\n\tend", "def location\n fetch('rick_and_morty.locations')\n end", "def location\n\t\t@location\n\tend", "def location\n @location\n end", "def location_fingerprint\n location_fingerprints.first\n end", "def id\n unitid.to_i\n end", "def location\n return Location.find_by_LOCATION_PROFILE_ID(self.LOCATION_PROFILE_ID)\n end", "def getLocation\r\n\t\t\t\t\treturn @location\r\n\t\t\t\tend", "def edit\n @location = Location.find(params[:id])\n end", "def find_location(location_name)\n Location.find_by name: location_name\n end", "def location_code\n text(data.at_xpath(\"#{data_root}/did/physloc\"))\n end", "def location\n fetch('harry_potter.locations')\n end", "def id\n raise \"Item.id not set\" unless @id\n $stderr.puts \"Item.id >#{@id}<\"\n @id\n end", "def edit \n @location = Location.find(params[:id])\n end", "def location_name\n pos = @state[\"position\"]\n pos ? pos.split(\"#\",2)[0] : nil\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def room(location = nil)\n return @@current_room if location.nil?\n Item.allRooms.each do |r|\n return r if r.item_id == location\n end\n# @room[@room_id]\n end", "def id\n self[:identifier]\n end", "def city_id\n\t\tobject.id\n\tend", "def id_from_response(response)\n response['Location'][/\\/([^\\/]*?)(\\.\\w+)?$/, 1]\n end", "def location\n fetch('sword_art_online.location')\n end", "def local_id; end", "def locate(location)\n get :q => location.is_a?(String) ? location : location_from_params(location).to_s, :output => 'locations'\n end", "def location_info(location = locations.first)\n if location\n location.full_location\n else\n []\n end\n end", "def location\n @location\n end", "def id\n @nodes_xml['geo_id']\n end", "def get_id\n @single_city_data[\"id\"]\n end", "def location_from_session\n self.current_location = Core::Location.find_by_location_id(session[:location_id]) if session[:location_id]\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def generate_location\n if id.blank?\n raise Occi::Core::Errors::MandatoryArgumentError,\n 'Cannot generate default location without an `id`'\n end\n URI.parse \"#{kind.location}#{id}\"\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def makeInventoryLocation(name, x, y, z, testbedId)\n location = Hash.new\n\n # Fill in that received from CONFINE Portal\n location['name'] = name\n location['x'] = x\n location['y'] = y\n location['z'] = z\n location['testbed_id'] = testbedId\n\t\t\t\n\t\t\t# DUMMY\n\t\t\tlocation['switch_ip'] = '10.0.0.201'\n\t\t\tlocation['switch_port'] = '1'\n\n # return\n location\n end", "def name\n @location.name\n end", "def fetch_id\n return unless @name\n\n begin\n response = Inventory.request[\"assets/#{@name}\"].get :content_type => :json, :accept => :json \n asset = JSON.parse(response)\n asset['id']\n rescue RestClient::ResourceNotFound\n nil\n rescue => exception\n puts exception.message\n puts exception.response\n exit 1\n end\n end", "def set_location\n\t\t@location = Location.find(params[:id])\n\tend", "def id\n object[\"id\"]\n end", "def getLocationId\n return @driver.find_element(:xpath, \"//div[@id='subject-info-window']/ul/li[3]/span[2]\").text\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end", "def set_location\n @location = Location.find(params[:id])\n end" ]
[ "0.7403202", "0.7144191", "0.6892235", "0.65431225", "0.65259737", "0.64972156", "0.630877", "0.6279246", "0.6273052", "0.6268334", "0.6234642", "0.61621934", "0.61224884", "0.61220646", "0.6047226", "0.604611", "0.6029856", "0.598028", "0.5972476", "0.5957294", "0.59280485", "0.5895596", "0.58782685", "0.5875739", "0.5875739", "0.5875739", "0.5875739", "0.5837629", "0.58370584", "0.5816892", "0.57911474", "0.5790293", "0.5790293", "0.57834595", "0.5774356", "0.5767648", "0.57561916", "0.5746419", "0.57331616", "0.5731132", "0.5720439", "0.5719055", "0.5719055", "0.56993586", "0.5690254", "0.56875634", "0.56875634", "0.56875634", "0.56836146", "0.5670209", "0.5666844", "0.56646544", "0.5663057", "0.5662067", "0.56596184", "0.5658652", "0.5656038", "0.56518245", "0.56333214", "0.56204593", "0.5618032", "0.5596468", "0.55912316", "0.55902636", "0.5589726", "0.5582013", "0.5582013", "0.55816007", "0.55803025", "0.557808", "0.5570335", "0.5565406", "0.5562289", "0.55608666", "0.55605", "0.5555015", "0.5549467", "0.55475616", "0.55447483", "0.55306923", "0.5524272", "0.5523968", "0.55036", "0.55036", "0.55036", "0.55036", "0.54941136", "0.54912263", "0.5487476", "0.5485257", "0.5483294", "0.5479132", "0.5478123", "0.5478123", "0.5478123", "0.5478123", "0.5478123", "0.5478123", "0.5478123", "0.5478123" ]
0.6812678
3
Add a OMF testbed to the OMF inventory.
def addInvTestbed(testbedName) doDB { |inv| resultTestbed = inv.addTestbed(testbedName) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addItemToVest _obj, _args\n \"_obj addItemToVest _args;\" \n end", "def add_to_inventory(item)\n @inventory.push(item)\n update\n end", "def add_to_inventory(item)\n @items << item\n equip(item)\n items_weight\n end", "def add_ab_test(ab_test, opts = {})\n @transporter.write(:POST, '/2/abtests', ab_test, opts)\n end", "def add_to_inventory(price, description)\n\t\tself.items << Item.new(price, description)\n\tend", "def run(test)\r\n @tests << test\r\n end", "def test_simpleArmor\n w = Window_EquipDetails.new(0,192,640,96,$data_armors[1])\n @windows.push(w)\n return true\n end", "def add_item(item)\n @inventory.push(item)\n if item.include? \"weapon\"\n @weapon = item\n end\n end", "def add(object)\n @inventory << object\n\n object.container = @game_object_id\n\n if object.is_a? Player or object.is_a? Mobile\n object.update_display\n end\n end", "def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend", "def run(test)\n @tests << test\n end", "def addInvLocation(name, x, y, z, testbedId)\n\t\t\tlocation = makeInventoryLocation(name, x, y, z, testbedId)\n\t\t\tdoDB do |inv|\n \tresultLocation = inv.addLocation(location)\n\t\t\tend\n\t\tend", "def add_item(item)\n item = Item.find item unless item.is_a? Item\n $logger.debug{\"#{self} add #{item}\"}\n items << item\n inventory << item.id\n item\n end", "def test_add_to_bag\r\n \t@test_prospector.current_gold = 2\r\n \t@test_prospector.current_silver = 3\r\n \t@test_prospector.add_to_bag\r\n \tassert_equal 3, @test_prospector.total_silver\r\n \tassert_equal 2, @test_prospector.total_gold\r\n end", "def test_for_add_guest\n assert_equal(0,@venue.guests.length)#assert 0 guests\n @venue.add_guest(@gina)#push /shovel guest\n assert_equal(1,@venue.guests.length)#check guest list increased\n end", "def add_item(item)\n if @item\n log(\"Item is already equipped in EquipSlot.\")\n return\n end\n @item = item\n return\n end", "def test_simpleDamageItem\n w = Window_ItemDetails.new(0,192,640,96,$data_items[16])\n @windows.push(w)\n return true\n end", "def test_create_order\n setup_new_order()\n @o.order_line_items << OrderLineItem.for_product(items(:small_stuff))\n assert @o.save\n end", "def analytics_add_item(order_id, product_id, product_name, product_variation, unit_price, quantity)\n analytics_render_event(GA::Events::Ecommerce::AddItem.new(order_id, product_id, product_name, product_variation, unit_price, quantity))\n end", "def add_inventory(product_name, quantity)\n @products.each do |product|\n if product.name == product_name.upcase\n product.quantity += quantity\n end\n end\n end", "def test_add_product\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 1)\n a_cart.add_product(items(:red_lightsaber), 3)\n assert_equal 1, a_cart.items.length, \"Cart added multiple order line items for the same product. #{a_cart.items.inspect}\"\n assert a_cart.save\n a_cart.reload()\n assert_equal 1, a_cart.items.length\n assert_equal 4, a_cart.items[0].quantity\n end", "def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end", "def add_test_target(test_target)\n testable = TestAction::TestableReference.new(test_target)\n test_action.add_testable(testable)\n end", "def add_test_record(tester: V1_TESTER, sell_time: Time.now)\n self.send(tester.to_sym).add(sell_time.to_i)\n truncate_test_record(tester: tester, sell_time: sell_time)\n end", "def test_fullArmor\n w = Window_EquipDetails.new(0,384,640,96,$data_armors[31])\n @windows.push(w)\n return true\n end", "def test_add_guest_to_room\n @room.add_guest_to_room(@guest1)\n assert_equal(1, @room.number_of_guests())\n end", "def add_item_verify\n\t\twait_for_animate\n\t\tvalue1= query(\"* marked:'quantityText'\", :text)[0]\n\t\tguide_price1 = query(\"* marked:'basket_action_bar_up'\", :text)[0]\n\t\tputs \"Quantity Before Add Item : : #{value1}\"\n\t\ttouch(\"* id:'add_btn'\")\n\t\twait_for_animate\n\t\tsleep 4\n\t\t#wait_for_elements_exist( [\"button marked:'Open basket'\"], :timeout => 40)\n\t\tvalue2 = query(\"* marked:'quantityText'\", :text)[0]\n\t\tif (value2 == \"0\")\n\t\t\tvalue2 = query(\"* marked:'quantityText'\", :text)[3]\n\t\tend\n\t\tguide_price2 = query(\"* marked:'basket_action_bar_up'\", :text)[0]\n\t\tputs \"Quantity After Add Item: : #{value2}\"\n\t\t#campare_values(value1,value2)\n\t\t#campare_values(guide_price1,guide_price2)\n\t\t#puts \"Item added successfully\"\n\n\tend", "def test_adding_equipment_adds_to_weight\n assert_equal(6.1, @character.encumbrance)\n end", "def add_item(item, quant=0)\n\t$grocery_list.store(item, quant)\n\tp \"You added #{item} to your list.\"\nend", "def test_adds_up_in_quanttity\n\t\tcart = Cart.new\n\t\t3.times { cart.add_item 1 }\n\n\t\tassert_equal cart.items.length, 1 #solo un item\n\t\tassert_equal cart.items.first.quantity, 3 #varias unidades del mismo item\n\tend", "def add_to_inventory(object, silent=false)\n # tests to see if the item will fit\n if @inventory.length < @inventory_size\n\n # if the object fits, add it to the player's inventory and return true\n @inventory += [object]\n\n if silent == false\n @gc.d_print(\"You toss \" + object.get_name + \" into your bag.\")\n end\n\n return true\n\n else\n\n # if the object does not fit, do not add it to the inventory and return false\n if silent == false\n @gc.d_print(\"You already have \"+String(@inventory_size)+\" objects in your inventory.\")\n end\n\n return false\n\n end\n\n end", "def test_fullDamageItem\n w = Window_ItemDetails.new(0,384,640,96,$data_items[24])\n @windows.push(w)\n return true\n end", "def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end", "def test_simpleWeapon\n w = Window_EquipDetails.new(0,96,640,96,$data_weapons[1])\n @windows.push(w)\n return true\n end", "def test_simpleRecoveryItem\n w = Window_ItemDetails.new(0,96,640,96,$data_items[1])\n @windows.push(w)\n return true\n end", "def add(args)\n return @client.api_helper.add(args, \"item_add\")\n end", "def test_try_add_guest_to_room\n @room1.add_guest_to_room(@guest1)\n assert_equal(1,@room1.guest_count)\n end", "def attach_item(item)\r\n equal_item = self.check_for_equal_item(item.name,item.price,item.description)\r\n if equal_item == nil\r\n self.items << item\r\n item.owner = self\r\n item.deactivate\r\n else\r\n equal_item.quantity += item.quantity\r\n equal_item.deactivate\r\n item.delete\r\n end\r\n end", "def addItemToBackpack _obj, _args\n \"_obj addItemToBackpack _args;\" \n end", "def add_item(order_id, item_sku, price, quantity, name = nil, category = nil, utmhid = random_id)\n check_account_params\n hey(item_params(order_id, item_sku, name, category, price, quantity, utmhid))\n end", "def add_test_step(step_result)\n current_executable.steps.push(step_result)\n @step_context.push(step_result)\n step_result\n end", "def add_item(new_item)\n item = Item.new(new_item)\n @items.push(item)\n end", "def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end", "def AddItem(arg0, arg1)\r\n ret = _invoke(1610743819, [arg0, arg1], [VT_BSTR, VT_I4])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end", "def test_add_recipe\n @fdb = setup\n assert(@fdb.recipes.length >= 2, \"at least 2 recipes were originally added from the file\")\n end", "def add_item(electives, item)\n puts electives.push(\"debate club\")\nend", "def add_item(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def test_recipe_within_recipe\n @fdb = setup\n idk = Recipe.new(\"Double PB&J\", [@fdb.get_recipe(\"PB&J Sandwich\"), @fdb.get_recipe(\"PB&J Sandwich\")])\n \n bool = @fdb.add_recipe(\"Double PB&J\", [\"PB&J Sandwich\", \"PB&J Sandwich\"])\n assert(bool == true, \"whoops fuck you\")\n end", "def test_enter_the_room\n enter_the_room(\"test_name\")\n end", "def add_test\n unless @cart.test_ids.include?(params[:id].to_i)\n @test = Test.find(params[:id])\n @cart.add_test(@test)\n else\n @test = []\n end\n respond_to do |format|\n format.js\n end\n end", "def test_adding_an_otu_plus_adds_to_matrix\n setup2\n assert_equal 0, @mx.otus_plus.count \n o = Otu.create!(:name => 'foo')\n @mx.otus_plus << o\n @mx.reload\n\n # adds to the + list?\n assert_equal 1, @mx.otus_plus.count\n assert_equal o, @mx.otus_plus[0]\n\n # adds to the master list?\n assert_equal 1, @mx.otus.count\n assert_equal o, @mx.otus[0]\n end", "def addItem _obj, _args\n \"_obj addItem _args;\" \n end", "def test_add_song_to_room\n assert_equal([@song1], @room1.add_song_to_room(@song1))\n assert_equal(1, [@song_menu].length())\n end", "def _stack_add_item(pokemon: nil, item_id: 0, bag: nil)\n item_id = GameData::Item[item_id].id\n extend_data = ::PFM::ItemDescriptor.actions(item_id)\n if extend_data and extend_data[:action_to_push]\n @results << [1, [item_id, extend_data, pokemon.position]]\n bag.drop_item(item_id, 1)\n return true\n else\n return false\n end\n end", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(item)\n @chores << item\n end", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def addHandgunItem _obj, _args\n \"_obj addHandgunItem _args;\" \n end", "def add(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(itemToAdd)\r\n itemToAdd.set_owner(self)\r\n itemToAdd.deactivate\r\n self.items.push(itemToAdd)\r\n end", "def add\n\t\tputs \"\\nEnter the name of the item you would like to add:\"\n\t\tnew_item = gets.chomp\n\t\tputs \"\\nHow many #{new_item} would you like?\"\n\t\tnew_qty = gets.chomp\n\t\t@grocery_list.add(new_item, new_qty)\n\t\tputs \"\\nAdding #{new_item} to list...\"\n\t\tputs \"#{new_qty} #{new_item} were added to your Grocery List!\"\n\tend", "def test_check_inventory\n # Create a cart and add some products.\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 2)\n a_cart.add_product(items(:blue_lightsaber), 4)\n assert_equal a_cart.items.length, 2\n \n an_out_of_stock_product = items(:red_lightsaber)\n assert an_out_of_stock_product.update_attributes(:quantity => 1)\n \n # Assert that the product that was out of stock was removed.\n removed_products = a_cart.check_inventory\n assert_equal removed_products, [an_out_of_stock_product.name]\n\n # Should last the right quantity of the rest.\n assert_equal a_cart.items.length, 1\n end", "def build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend", "def add_item(barcode, name, price)\n @barcodes << barcode\n @names << name\n @prices << price\n end", "def add_item(list, item, quantity = 1)\r\n# input: list, item name, and optional quantity\r\n# steps: \r\n # check for optional quantity. if not present, set to default (1)\r\n list[item] = quantity\r\n # update list with input\r\n puts \"#{item.upcase} has been added to your grocery list!\"\r\n p list\r\n# output: complete list, updated\r\nend", "def ui_add(component)\n add component\n end", "def add_expectation(&term)\n expectations.add(&term)\n end", "def add_expectation(&term)\n expectations.add(&term)\n end", "def add_new(type, new_item)\n #Add exercise to exercise_list\n if type == \"exercise\"\n @exercise_list.push(new_item)\n return 0\n #Add a workout to workout_routines\n elsif type == \"workout\"\n @workout_routines.push(new_item)\n return 0\n #Error handling\n else\n return -1\n end\n\n end", "def add_new_item(new_item)\n @items.push(new_item)\n end", "def add_item\n\t puts \"What is the name of the item you'd like to add?\"\n\t\t@item_name = gets.chomp\n\t\tputs \"And how many?\"\n\t\t@quantity = gets.chomp.to_i\n\t\tif @quantity <= 0\n\t\t puts \"Please enter a number higher than 0.\"\n\t\t puts \"(Also, must be '1' not 'one'.)\"\n\t\telse\n\t\t @grocery_list[@item_name] = @quantity\n\t\tend\n\t\tget_item\n\tend", "def test_add_guest()\n @room1.add_guest(@guest3)\n assert_equal(3, @room1.guests.length())\n end", "def add_item (grocery, item_name, quantity)\n grocery[item_name] = quantity\n display_list(grocery)\n end", "def test_fullRecoveryItem\n w = Window_ItemDetails.new(0,288,640,96,$data_items[23])\n @windows.push(w)\n return true\n end", "def add_boating_test(test_name, status, instructor)\n BoatingTest.new(self, test_name, status, instructor)\n end", "def add_boating_test(test_name, status, instructor)\n BoatingTest.new(self, test_name, status, instructor)\n end", "def test_should_create_order_line_item\n a_towel = items(:towel)\n an_order_line_item = OrderLineItem.for_product(a_towel)\n \n assert_equal an_order_line_item.item, a_towel\n assert_equal an_order_line_item.name, a_towel.name\n assert_equal an_order_line_item.unit_price, a_towel.price\n # When created the quantity should be 1.\n assert_equal an_order_line_item.quantity, 1\n \n assert_equal an_order_line_item.total, a_towel.price * 1\n assert_equal an_order_line_item.product_id, a_towel.id\n assert_equal an_order_line_item.product, a_towel\n assert_equal an_order_line_item.code, a_towel.code\n assert_equal an_order_line_item.code, a_towel.code\n assert_equal an_order_line_item.name, a_towel.name\n \n assert an_order_line_item.save\n end", "def add_boating_test(instructor, test_name, test_status)\n BoatingTest.new(self, instructor, test_name, test_status)\n end", "def test_add_dir()\n dirpath = \"#{ENV['TCGA_CLINICAL_TEST_DATA']}/Biotab/\"\n rs = ClinicalTCGA::RetrieveSamples.new([\"TCGA-A6-2671\"], [\"death_days_to\"], false)\n rs.add_all_sources(dirpath, false) # suppress progress bar for unit test\n\n assert_equal(rs.h.keys.size, 18)\n assert(rs.h.has_key?(\"biospecimen_sample\"))\n end", "def add_item(d_item, name=nil)\n item = d_item.item\n if !name then name = item.name end\n #if we already have an item in this box\n if @d_item\n #if same item or\n if (item.id == @d_item.item.id) && (item.quality == @d_item.item.quality)\n max = @d_item.max?\n total = @d_item.item.quantity+item.quantity\n if total > max\n @d_item.item.quantity = max\n item.quantity = (total - max)\n @d_item.refresh\n return 2\n else\n @d_item.item.quantity += item.quantity\n @d_item.refresh\n return 1\n end\n end\n #if different item or quality, cannot merge\n return 2\n end\n #if empty, add the item\n @d_item, @last_item = d_item, item.clone\n @d_item.refresh\n return 3\n end", "def test_add_1food\n\t\tputs \"TEST 2\"\n\t\tassert( @db.empty?, \"DB should be empty\" )\n\t\[email protected](\"Potato\", \"123\")\n\t\tassert( @db.size == 1, \"Size of DB != 1\")\n\t\tassert( [email protected]?, \"DB should not be empty\")\n\tend", "def test_room_can_add_drinks_to_stock\n @room1.add_drinks_to_stock(@vodka)\n @room1.add_drinks_to_stock(@vodka)\n @room1.add_drinks_to_stock(@water)\n @room1.add_drinks_to_stock(@cola)\n assert_equal(5, @room1.show_drinks_count())\n end", "def test_add_song_to_room\n @room.add_song(@song4)\n assert_equal(4, @tracklist.length())\n end", "def brief_vendor_add_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n brief_vendor.items << Item.new{|r| r.parent_id = params[:item_id]}\n\n redirect_to(cheil_brief_vendor_items_path(params[:brief_id],params[:vendor_id])) \n end", "def test_add_playlist_to_rooms_karaoke_machine\n @room.add_playlist(@playlist)\n assert_equal(1, @room.room_playlist())\n end", "def test_add_alias\n new_todo = Todo.new('new todo')\n @list.add(new_todo)\n @todos << new_todo\n\n assert_equal(@todos, @list.to_a)\n end", "def test_update_raw_material_qty\n assert_equal(15, @bakery.update_raw_material_qty(5,\"flour\"))\n end", "def add_item(list,item_name, qty)\n list[item_name] = qty\nend", "def add_boating_test(name, status, instructor)\n BoatingTest.new(self, name, status, instructor)\n end", "def add\n\t\t# se o usuário não entiver infectado e já existir o inventário salvo, insere a qauantidade no inventário\n\t\tunless User.healthy? inventory_params[:user_id]\n \t \trender json: { error: \"Denied access. User is contaminated!\" }, status: 403 and return\n\t\tend\n\n\t\tif @inventory.add(inventory_params[:amount].to_i)\n\t\t\trender json: @inventory, status: 200\n\t\telse\n\t\t\trender json: @inventory.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def save_to_inventory\n @user = User.find(params[:id])\n @item = Item.find(1)\n @user.items.push(@item)\n end", "def add_item(hash,item)\n hash[:inventory].push(item)\nend", "def run_test(test_name, osm_path, epw_path, blinds_expected)\n\n assert(File.exist?(osm_path))\n assert(File.exist?(epw_path))\n\n # create run directory if it does not exist\n if !File.exist?(run_dir(test_name))\n FileUtils.mkdir_p(run_dir(test_name))\n end\n assert(File.exist?(run_dir(test_name)))\n\n # change into run directory for tests\n Dir.chdir run_dir(test_name)\n\n # copy weather file and osm to test directory\n new_osm_path = \"#{run_dir(test_name)}/#{File.basename(osm_path)}\"\n FileUtils.cp(osm_path, new_osm_path)\n osm_path = new_osm_path\n new_epw_path = \"#{run_dir(test_name)}/#{File.basename(epw_path)}\"\n FileUtils.cp(epw_path, new_epw_path)\n epw_path = new_epw_path\n\n # remove prior runs if they exist\n if File.exist?(model_output_path(test_name))\n FileUtils.rm(model_output_path(test_name))\n end\n if File.exist?(report_path(test_name))\n FileUtils.rm(report_path(test_name))\n end\n # create an instance of the measure\n measure = AddBlindsToSelectedWindows.new\n\n # create an instance of a runner\n runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)\n\n # load the test model\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(OpenStudio::Path.new(osm_path))\n assert((not model.empty?))\n model = model.get\n\n # set model weather file\n epw_file = OpenStudio::EpwFile.new(OpenStudio::Path.new(epw_path))\n OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file)\n assert(model.weatherFile.is_initialized)\n\n # set arguments to good values\n arguments = measure.arguments(model)\n argument_map = OpenStudio::Measure::OSArgumentMap.new\n\n puts 'ARGUMENTS HERE'\n puts arguments\n\n add_blinds = arguments[0].clone\n assert(add_blinds.setValue(true))\n argument_map['add_blinds'] = add_blinds\n\n # run the measure\n puts \"\\nAPPLYING MEASURE...\"\n measure.run(model, runner, argument_map)\n result = runner.result\n\n # show the output\n show_output(result)\n\n # assert that it ran correctly\n assert(result.value.valueName == \"Success\")\n assert(result.warnings.size == 0)\n\n # check that blinds were added to the model\n blinds_area = 0\n model.getSubSurfaces.sort.each do |sub_surface|\n next unless sub_surface.subSurfaceType == 'FixedWindow' || sub_surface.subSurfaceType == 'OperableWindow'\n next unless sub_surface.outsideBoundaryCondition == 'Outdoors' && sub_surface.surface.get.surfaceType == 'Wall'\n blinds_area += sub_surface.grossArea unless sub_surface.shadingControl.empty?\n end\n if blinds_expected\n assert(blinds_area > 0)\n else\n assert(blinds_area.zero?)\n end\n\n # save model\n model.save(model_output_path(test_name), true)\n\n # run the model\n puts \"\\nRUNNING MODEL...\"\n\n # method for running the test simulation using OpenStudio 2.x API\n osw_path = File.join(run_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_output_path(test_name)))\n workflow.setWeatherFile(File.absolute_path(epw_path))\n workflow.saveAs(osw_path)\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n\n # check that the model ran successfully\n assert(File.exist?(model_output_path(test_name)))\n assert(File.exist?(sql_path(test_name)))\n end", "def addSetupBlock( &block ); self.class.addSetupBlock( &block ); end", "def add_boating_test(test_name, test_status, instructor)\n BoatingTest.new(self, test_name, test_status, instructor)\n end", "def test_add_invoice\n kwhite17 = members(:kwhite17)\n tank = members(:tank)\n invoices_expected = Array.new\n \n invoice1 = invoices(:one)\n group_purchase1 = group_purchases(:one)\n invoice1.group_purchase = group_purchase1\n invoice1.debtor = kwhite17\n invoice1.save\n\n invoices_expected.push(invoice1)\n\n assert_equal group_purchase1.invoices, invoices_expected, \"Test adding invoice\"\n \n end", "def add(gemspec)\n @specs << gemspec\n end", "def test_add\n \tassert_equal(UI.parseCommand('add', AddCmd1*\" \"),UI.main(AddCmd1))\n \tassert_equal(UI.parseCommand('add', AddCmd2*\" \"),UI.main(AddCmd2))\n \tassert_equal(UI.parseCommand('add', AddCmd3*\" \"),UI.main(AddCmd3))\n \tassert_equal(UI.parseCommand('add', AddCmdInv*\" \"),UI.main(AddCmdInv))\n end" ]
[ "0.60642403", "0.6011623", "0.5907385", "0.58929735", "0.5730414", "0.5684033", "0.56762743", "0.56364465", "0.5620108", "0.5607303", "0.5595575", "0.55943716", "0.5570289", "0.555624", "0.5454128", "0.54482514", "0.5406886", "0.5404394", "0.54013205", "0.5373504", "0.5365399", "0.53606325", "0.5344551", "0.5331082", "0.5325811", "0.5311022", "0.52956975", "0.5282795", "0.52798027", "0.5276501", "0.523318", "0.52311003", "0.5225727", "0.5223947", "0.52187765", "0.51959276", "0.5194303", "0.51811635", "0.517859", "0.5166229", "0.51657075", "0.5165102", "0.51442367", "0.5129739", "0.512847", "0.5125196", "0.51181465", "0.51181465", "0.5106897", "0.5105528", "0.50828445", "0.50727457", "0.5066965", "0.5061863", "0.50597596", "0.5058851", "0.5058851", "0.50578237", "0.50573003", "0.5055207", "0.5054615", "0.505136", "0.5050578", "0.5046256", "0.50451285", "0.5036534", "0.50291646", "0.5018448", "0.5017037", "0.5017037", "0.5016376", "0.50152516", "0.50118095", "0.5011649", "0.5004952", "0.5003928", "0.4995663", "0.4995663", "0.4994356", "0.49794397", "0.4978545", "0.49744666", "0.49716175", "0.49627307", "0.49595615", "0.4949768", "0.49395207", "0.49384165", "0.49330387", "0.49289054", "0.49245733", "0.4921909", "0.4921427", "0.49213952", "0.49192867", "0.49183", "0.49168414", "0.4914967", "0.49130958", "0.4912424" ]
0.68506134
0
Add a OMF location, based on the CONFINE location, to the OMF inventory.
def addInvLocation(name, x, y, z, testbedId) location = makeInventoryLocation(name, x, y, z, testbedId) doDB do |inv| resultLocation = inv.addLocation(location) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(location)\n $LEDGER.add(location)\n end", "def add_location(path, line); end", "def location(value)\n @ole.Location = value\n nil\n end", "def add_location(name, location_type, parent_name=nil, default_item_type_name=nil)\n\t\t\tloc = Location.new\n\t\t\tloc.name = name\n\t\t\tloc.location_type = location_type\n\t\t\t\n\t\t\tif parent_name.present?\n\t\t\t\tloc.parent_id = find_location_id(parent_name)\n\t\t\tend\n\t\t\t\n\t\t\tif \tdefault_item_type_name.present?\n\t\t\t\tloc.default_item_type_id = find_item_type_id(default_item_type_name)\n\t\t\tend\n\n\t\t\tloc.save\n\t\tend", "def add_location(f)\n return 0 if !f.location? || Location.exists?(fragment: f)\n Location.create! fragment_id: f.id, content: f.orig_text\n 1\n end", "def add_to_location # :norobots:\n if location = find_or_goto_index(Location, params[:location])\n where = params[:where].strip_squeeze rescue ''\n if not where.blank? and\n update_observations_by_where(location, where)\n flash_notice(:runtime_location_merge_success.t(:this => where,\n :that => location.display_name))\n end\n redirect_to(:action => 'list_locations')\n end\n end", "def add(location)\n $LOAD_MANAGER.add(location)\n end", "def location\n ln = location_name\n return nil if ln == \"\" || ln == nil\n @engine.item_by_name(location_name)\n end", "def add=(location)\n @destinations << location\n end", "def create_item_with_location\n inventory_item = FactoryBot.create :inventory_item\n warehouse_location = FactoryBot.create :warehouse_location\n ItemLocation.create(inventory_item_id: inventory_item.id, warehouse_location_id: warehouse_location.id, quantity: inventory_item.quantity)\n\n inventory_item\n end", "def add_to_my_location\n\t\tadd_to_my_location = Location.find(params[:id])\n\n\t\t# Validation prevents a user from adding a duplicate of the same location.\n\t\tif current_user.locations.include?(add_to_my_location) == false\n\t\t\tcurrent_user.locations << add_to_my_location\n\t\tend\n\n\t\tredirect_to locations_path\n\tend", "def location=(loc)\n @location.contents.delete self if @location\n @location = loc\n @location.contents << self if @location\n end", "def set_item_location\n @item_location = ItemLocation.find(params[:id])\n end", "def set_item_location\n @item_location = ItemLocation.find(params[:id])\n end", "def <<(new_path)\n @locations.unshift(new_path)\n end", "def location=(value)\n @location = value\n end", "def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end", "def add_location(loc)\n # KeeperLocation.find(:all, :conditions => [\"keeper_id = ?\", self.id]).each { |kl|\n # kl.destroy\n # }\n kl = KeeperLocation.create(:keeper_id => self.id, :location_id => loc.id)\n end", "def location=(new_location)\n @location = new_location\n end", "def office_location=(value)\n @office_location = value\n end", "def add_location(task)\n loc = find_location\n task.locations << loc if loc\n task\n end", "def set_Location(value)\n set_input(\"Location\", value)\n end", "def perform\n add_location\n save\n end", "def add(location)\n body = {\n :location => {:lat => location.coordinates.first.to_f, :lng => location.coordinates.last.to_f},\n :accuracy => 50, #meters,\n :name => location.name,\n :types => [location.types],\n :language => 'en-US'\n }.to_json\n response = RestClient.post ADD_PLACE_URL, body, :content_type => :json, :accept => :json\n result = ActiveSupport::JSON.decode response\n if result['status'] == 'OK'\n location.reference = result['reference']\n true\n else\n Rails.logger.error \"Unable to add Place for location #{location.name}: #{result}\"\n false\n end\n end", "def location=(container)\n @location.remove(self) if @location\n @location = container\n @location.add(self)\n end", "def create\n @location = Location.new(params[:location])\n \n @location.location = current_location\n @location.location_type = \"shelf\"\n \n respond_to do |format|\n if @location.save\n format.html { redirect_to current_location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_location(location={})\n\t\tclient.update(location)\n\tend", "def set_location\n @location = \"Minneapolis, MN\"\n end", "def add_location(source, target, weight)\n connect_graph(source, target, weight) #directional graph\n connect_graph(target, source, weight) #non directed graph (inserts the other locations too)\n end", "def add_file( location, permission = 660 )\n\n files_nodes = @sopm.xpath('/otrs_package/Filelist/File')\n\n update = true\n files_nodes.each { |files_node|\n\n next if files_node['Location'] != location\n next if files_node['Permission'] != permission\n\n update = false\n\n break\n }\n\n return if !update\n\n # append Filelist/File\n new_file_entry = Nokogiri::XML::Node.new 'File', sopm\n new_file_entry['Permission'] = permission\n new_file_entry['Location'] = location\n\n files_nodes.last.next = \"\\n \" + new_file_entry.to_xml\n\n store\n end", "def add_to_inventory(item)\n @inventory.push(item)\n update\n end", "def relocate(inventory_item, quantity, new_location)\n current_item_location = ItemLocation.find_by(\n inventory_item_id: inventory_item.id,\n warehouse_location_id: id\n )\n raise SilExceptions::ItemNotInLocation if current_item_location.nil?\n raise SilExceptions::InvalidQuantityToRelocate if current_item_location.quantity < quantity\n\n new_location.locate(inventory_item, quantity)\n\n if current_item_location.quantity == quantity\n remove_item(inventory_item.id) \n update_status\n return\n end\n \n remove_quantity(inventory_item.id, quantity, WarehouseTransaction::RELOCATION)\n end", "def add_to_sequence(sequence, locations, location)\n unless sequence.include? location\n dependency = location.closer_location\n add_to_sequence(sequence, locations, dependency) if !dependency.nil? && locations.include?(dependency)\n sequence << location\n end\nend", "def update_main_location\n update_attribute( :main_location, self.main_locations.try( :first ))\n end", "def save_inventory_adjustment_vend(response, quantity)\n location_id = response['inventory_level']['location_id']\n shopify_inventory = retail_shopify.shopify_inventories.find_by(location: location_id)\n new_inventory = response['inventory_level']['available']\n\n InventoryUpdate.create(\n vend_qty: vend_datum.sf_inventory,\n prior_qty: shopify_inventory.inventory,\n adjustment: quantity,\n product_id: id,\n new_qty: new_inventory\n )\n\n shopify_inventory.update_attribute(:inventory, new_inventory)\n end", "def location (location)\n self.class.new(@path += \"location=#{location}&\")\n end", "def location\n fetch('hey_arnold.locations')\n end", "def location=(location)\n @attributes[\"location\"] = location\n end", "def store_location expected_location, variable_name\r\n command 'storeLocation', expected_location, variable_name\r\n end", "def location\n fetch('games.super_mario.locations')\n end", "def add_azr_location(opts = {})\n data, _status_code, _headers = add_azr_location_with_http_info(opts)\n data\n end", "def set_catalog_location\n @catalog_location = Catalog::Location.find(params[:id])\n end", "def location=(location)\n @location_set = true\n @attributes[:location] = location\n end", "def location_address\n begin\n \"#{cart.line_items.first.menu_section_item.menu_section.menu.location.\n address}, #{cart.line_items.first.menu_section_item.menu_section.menu.\n location.city}, #{cart.line_items.first.menu_section_item.menu_section.\n menu.location.region}\"\n rescue\n \"No current address on record.\"\n end\n end", "def add_to_inventory(price, description)\n\t\tself.items << Item.new(price, description)\n\tend", "def create\n @item_location = ItemLocation.new(item_location_params)\n\n respond_to do |format|\n if @item_location.save\n format.html do\n redirect_to api_v1_item_location_url(@item_location),\n notice: 'Item location was successfully created.'\n end\n format.json { render :show, status: :created, location: @item_location }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def makeInventoryLocation(name, x, y, z, testbedId)\n location = Hash.new\n\n # Fill in that received from CONFINE Portal\n location['name'] = name\n location['x'] = x\n location['y'] = y\n location['z'] = z\n location['testbed_id'] = testbedId\n\t\t\t\n\t\t\t# DUMMY\n\t\t\tlocation['switch_ip'] = '10.0.0.201'\n\t\t\tlocation['switch_port'] = '1'\n\n # return\n location\n end", "def add_favorite_location\n\n if get_uniq_locations.empty?\n puts \"You don't have any locations yet! Start a new ride to add a location.\"\n puts \"\\n\"\n location_menu\n else\n #add a location to favorites\n puts \"Here are all of your locations:\"\n get_uniq_locations.each_with_index { |location, i| puts \"#{i+1}: #{location}\" }\n puts \"\\nPlease enter the location number you want to add to favorites:\"\n #get favorite location name\n favorite_location_number = get_user_input.to_i\n #title page------\n title\n #end title page----\n\n if favorite_location_number == 0 || favorite_location_number > get_uniq_locations.length\n puts \"\\nPlease enter a number between 1 and #{get_uniq_locations.length}\"\n add_favorite_location\n else\n location_name = get_uniq_locations[favorite_location_number-1]\n #update start and end location in database with favorite\n StartLocation.where(name: location_name).update(favorite: true)\n EndLocation.where(name: location_name).update(favorite: true)\n end\n puts \"\\n\"\n view_favorite_locations\n end\n end", "def delivery_location=(value)\n @delivery_location = value\n end", "def add_location_to_context(iLocation)\n # * *iLocation* (_String_): Directory\n $LOAD_PATH << iLocation\n end", "def add_location\n #To make sure that location is within 3.5 kilometers radius from door2door location\n body_params = JSON.parse(params.keys[0])\n if(body_params[\"lat\"]<(D2DLOCATION[:lat] + RADIUS) && body_params[\"lat\"]>(D2DLOCATION[:lat] - RADIUS) && body_params[\"lng\"]>(D2DLOCATION[:lng] - RADIUS/Math.cos(body_params[\"lat\"]).abs) && body_params[\"lng\"]<(D2DLOCATION[:lng] + RADIUS/Math.cos(body_params[\"lat\"]).abs) )\n vehicle=Vehicle.where(uid: params[:id]).first\n location = Location.new\n location.lat = body_params[\"lat\"]\n location.lng = body_params[\"lng\"]\n location.location_timestamp = DateTime.parse(body_params[\"at\"])\n location.vehicle_id=vehicle.id\n location.title = params[:id]\n prev_locations = PrevHash.instance\n if(prev_locations.value(params[:id])!=[])\n prev_lat = prev_locations.value(params[:id]).split(\",\")[0].to_f\n prev_lng = prev_locations.value(params[:id]).split(\",\")[1].to_f\n# => Check location relative to the previous location indicating direction\n if(location.lng-prev_lng<0)\n location.picture=DIRECTION[:left]\n elsif(location.lng-prev_lng>0)\n location.picture=DIRECTION[:right]\n elsif(location.lat-prev_lat<0)\n location.picture=DIRECTION[:down]\n elsif(location.lat-prev_lat>0)\n location.picture=DIRECTION[:up]\n end\n end\n prev_locations.add(params[:id],location.lat.to_s+\",\"+location.lng.to_s)\n location.save\n end\n render nothing: true, :status =>204\n end", "def set_location\n @location = Spree::Location.find(params[:id])\n end", "def add_connection(location)\n raise 'Error: input arguement to method add_connection' unless location.is_a? Location\n @neighbors << location\n end", "def update\n respond_to do |format|\n if @item_location.update(item_location_params)\n format.html do\n redirect_to api_v1_item_location_url(@item_location),\n notice: 'Item location was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @item_location }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_locations(items, location)\n items.each do |item|\n item.move_to(location)\n item.save\n end\n end", "def add_location(did, address1, address2, city, state, zip, plus_four, caller_name)\n raise ArgumentError unless did.is_a?(String)\n raise ArgumentError unless address1.is_a?(String)\n raise ArgumentError unless address2.is_a?(String)\n raise ArgumentError unless city.is_a?(String)\n raise ArgumentError unless state.is_a?(String)\n raise ArgumentError unless zip.is_a?(String)\n raise ArgumentError unless plus_four.is_a?(String)\n raise ArgumentError unless caller_name.is_a?(String)\n self.arguments = {\n did: did,\n address1: address1, \n address2: address2, \n city: city,\n state: state,\n zip: zip,\n plus_four: plus_four,\n caller_name: caller_name,\n }\n self.action = :add_location\n self.response = VoipApi.account.request(self.action, self.klass, self.arguments)\n self\n end", "def location\n\t\tUnitLocation.new(@db, @id)\n\tend", "def location\n fetch('sword_art_online.location')\n end", "def setLocation(location)\r\n\t\t\t\t\t@location = location\r\n\t\t\t\tend", "def location=(loc)\n unless loc.is_a?(EEML::Location)\n raise TypeError.new('loc must be an EEML::Location') \n end\n @location = loc\n end", "def set_location\n LocationHelper.browse_location(params['select_location'], current_user)\n end", "def set_office_location\n @office_location = @company.office_locations.find(params[:id])\n end", "def location\n @location ||= TermuxRubyApi::SubSystems::Location.new(self)\n end", "def create\n @location = Spree::Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def locationId\n if locationMode == Yext::Api::Enumerations::AddRequestLocationMode::NEW\n newLocationId\n else\n existingLocationId\n end\n end", "def location\n [equipment_rack.room.building.name, equipment_rack.room.name, equipment_rack.name, \"Unit #{rack_elevation}\"].join(', ') unless equipment_rack.nil?\n end", "def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend", "def location\n\t\t@location\n\tend", "def update!(**args)\n @custom_location = args[:custom_location] if args.key?(:custom_location)\n @home_location = args[:home_location] if args.key?(:home_location)\n @office_location = args[:office_location] if args.key?(:office_location)\n end", "def with_location(loc)\n delta = loc.minus(@location)\n @location = loc\n #when the body location is updated, all of the fixtures must also move\n @fixtures.each { |fixture|\n new_x = fixture.center.x + delta.x\n new_y = fixture.center.y + delta.y\n fixture.with_center(Point.new(new_x, new_y))\n }\n end", "def store_location!; end", "def location\n @ole.Location\n end", "def at(location)\n @location = location\n self\n end", "def insert(name, location, *args)\n if(block = @register[name])\n location.instance_exec(*args, &block)\n else\n raise KeyError.new(\"Requested item not found in registry (#{name})\")\n end\n end", "def add_location_to_hardware(hardware_id, latitude, longitude)\n unless hardware_id.nil? and latitude.nil? and longitude.nil?\n tag = Tag.joins(:hardwares).find_by('hardwares.identifier' => hardware_id)\n\n location = HardwareLocation.create(latitude: latitude, longitude: longitude)\n\n tag.hardwares.each do |item|\n if item.identifier == hardware_id\n item.hardware_locations << location\n end\n end\n end\n end", "def location\n @location ||= Station.get(@attrs['LocationCode'])\n end", "def add_location_and_clone_list(current_user, location = nil, name = nil)\n if current_user.friends.present? && current_user.friends.map(&:friend_id).include?(self.user_id)\n new_list = clone_list(current_user, name)\n new_list.add_location(self, location, current_user)\n new_list.name = name unless name.nil?\n new_list.original_share_id = self.shares.first.id if self.shares.present?\n new_list\n else\n begin\n self.locations << location if location.present?\n self.name = name unless name.nil?\n self\n rescue\n self\n end\n end\n end", "def folio_location_code\n @folio_location_code ||= FolioLocationMap.folio_code_for(library_code: library, home_location: location)\n rescue FolioLocationMap::NotFound\n Honeybadger.notify('Location code not found', context: { library:, location: })\n nil\n end", "def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end", "def item_location_params\n params.require(:item_location).permit(:grocery_item_id, :store, :section)\n end", "def add_two_locations(organization)\n\t\t\t2.times do \n\t\t\t\tp \"Adding 1 location for organization #{organization.id}\"\n\t\t\t\torganization.locations.create(name: \"Location #{location_id}\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taddress: \"Location Addr #{location_id}\")\n\t\t\tend\n\t\tend", "def set_catalogs_location\n @catalogs_location = Catalogs::Location.find(params[:id])\n end", "def location\n\t\tif @location\n\t\t\t@location\n\t\telsif File.exists?(default_location)\n\t\t\tdefault_location\n\t\telsif File.exists?(appstore_location)\n\t\t\tappstore_location\n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def load_locations\n add_location('Bangalore', 'Belgaum', 24)\n add_location('Bangalore', 'Mysore', 71)\n add_location('Belgam', 'Tumkur', 59)\n add_location('Mandya', 'Mangalore', 141)\n add_location('Tumkur', 'Mandya', 65.5)\n add_location('Mandya', 'Mysore', 101)\n add_location('Belgaum', 'Chickmangalur', 103)\n add_location('Mandya', 'Tumkur', 65)\n add_location('Mangalore', 'Mysore', 169)\n add_location('Mysore', 'Tumkur', 134)\n end", "def add_quantity(quantity, variant, sub_location, row_hash)\n # if only one sub location listed\n if sub_location.split(\",\").length > 1\n @errors << { :part_number => row_hash[:name], :condition => row_hash[:condition], :message => \"Cannot add initial quantity for part with multiple sub locations (#{sub_location})\" }\n # otherwise if there is a sub_location stock item\n elsif stock_item = variant.sub_location(sub_location)\n #if !(stock_item = @new_product_condition.where(\"sub_location=?\", sub_location)).empty\n stock_item.adjust_count_on_hand(quantity)\n else\n @errors << { :part_number => row_hash[:name], :condition => row_hash[:condition], :message => \"Cannot find stock item for \" + sub_location }\n end\n\n end", "def record_location_change\n if (self.actual_storage_location != self.item.storage_location)\n \t self.update_attribute(:location_overridden, true)\n \t end\n end", "def create_stock_item\n\n added_new_stock_item = false\n # Get stock location for appropriate location\n @product_row[:location].split(',').each do |sub_location|\n sub_location.chomp!\n stock_location = case sub_location.to_s.downcase\n when /george/\n @@loc_attic\n # NFS no matter what - JC10 OR buffalo display case OR back shop\n when /jc\\d{1,2}|buffalo|back\\sshop|attic/\n @@loc_home_nfs\n # NFS if listed as not for sale (don't count in quantity)\n when /w\\d{1,2}/\n (@product_row[:available] && @product_row[:available].downcase == \"n\") ? @@loc_home_nfs : @@loc_home\n when /[[:alpha:]]\\d{2,3}|D\\d{3}\\.\\d|h\\d|file\\scabinet|suite\\s2/\n (@product_row[:available] && @product_row[:available].downcase == \"n\") ? @@loc_suite2_nfs : @@loc_suite2\n # NWC08\n when /nw[[:alpha:]]\\d{1,2}|ste3/\n @@loc_suite3\n # Warehouse\n when /warehouse/\n @@loc_warehouse\n # West trailer OR east racks\n when /east\\sracks|west\\strailer/\n @@loc_east_racks\n else # if unidentifiable location\n @errors << { :part_number => @product_row[:name], :condition => @product_row[:condition], :message => \"Cannot identify location \" + sub_location }\n next # skip to next location\n end\n\n # if no exisiting sub location, add one\n if(@new_product_condition.add_sub_location(sub_location, stock_location))\n added_new_stock_item = true\n end\n\n end # end location loop\n\n added_new_stock_item # return true if at least one new stock item added\n\n end", "def other_loc(location)\n\t\t# uses location class equals method (TODO)\n\t\tif location == loc1\n\t\t\tloc2\n\t\telse\n\t\t\tloc1\n\t\tend\n\tend", "def location=(v)\n raise \"Improper format\" if v && v.to_s !~ /[a-z]{2}/\n @location = v\n end", "def to_wear_location\n self\n end", "def final_location\n\t\[email protected]\n\tend", "def location=(loc)\r\n @options[:location] = loc\r\n @perimeter = get_perimeter()\r\n end", "def set_location\n @location = Location.find(params[:id])\n add_location_breadcrumb @location\n end", "def update!(**args)\n @location = args[:location] if args.key?(:location)\n end", "def update!(**args)\n @location = args[:location] if args.key?(:location)\n end", "def update!(**args)\n @location = args[:location] if args.key?(:location)\n end", "def location\n # TODO Check this\n # return poi.location unless poi.nil?\n # return place.location unless place.nil?\n return get_location\n end", "def location(value)\n self.send('in', value)\n end", "def set_location_key(key)\n CookbookSource.add_location_key(key, self)\n @location_key = key\n end", "def add_to_inventory(item)\n @items << item\n equip(item)\n items_weight\n end" ]
[ "0.58918136", "0.5636241", "0.5633311", "0.5592083", "0.5559592", "0.552741", "0.55261445", "0.54571044", "0.54205734", "0.5417633", "0.5405386", "0.533996", "0.5336202", "0.5333745", "0.5321343", "0.52979887", "0.529477", "0.52861065", "0.52859235", "0.5215518", "0.52145964", "0.5212095", "0.5205618", "0.51932114", "0.5191604", "0.519106", "0.51877624", "0.5146194", "0.51385194", "0.5133481", "0.5120936", "0.5104573", "0.5103258", "0.50997245", "0.5088689", "0.5079992", "0.5074887", "0.5056813", "0.50490505", "0.50434524", "0.5042023", "0.50298136", "0.5029343", "0.502841", "0.50198686", "0.501851", "0.4996468", "0.49956685", "0.49955595", "0.49954057", "0.4989218", "0.4987039", "0.4968943", "0.4960214", "0.49576545", "0.4957241", "0.4948096", "0.4944219", "0.49429306", "0.49397752", "0.49332565", "0.4920754", "0.49163494", "0.49158087", "0.4914453", "0.4913103", "0.48973313", "0.4895146", "0.48910165", "0.48908997", "0.48880708", "0.48848417", "0.48795462", "0.4875488", "0.48729947", "0.48533365", "0.48517215", "0.4850028", "0.48391137", "0.48264444", "0.4825892", "0.48247007", "0.48229644", "0.481671", "0.4815112", "0.47993", "0.4795528", "0.47950274", "0.47891876", "0.47843558", "0.47813427", "0.47803798", "0.4769991", "0.47684404", "0.47684404", "0.47684404", "0.47672233", "0.47587866", "0.47555992", "0.4754537" ]
0.62831306
0
Add a OMF node, based on the CONFINE sliver, to the OMF inventory.
def addInvNode(control_ip, control_mac, hostname, hrn, locationId) node = makeInventoryNode(control_ip, control_mac, hostname, hrn, locationId) doDB do |inv| resultNode = inv.addNode(node) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_node(node)\n #$DEBUG.puts \"Registering #{SNMPPass.num2oid(node.oid)} with #{node}\"\n @fields[node.oid]=node\n end", "def add_item(item, amount)\n # Check if the Entity already has that item\n # in the inventory. If so, just increase\n # the amount.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end", "def add_node(node = {})\n @nodes.push Bark::Client.new node\n end", "def addNode(node, toListView:listView)\n @expandableRowToNodeMap[node.id] = node if node.expandable?\n listView.addNode(node)\n end", "def add_to_inventory(item)\n @inventory.push(item)\n update\n end", "def add_node( node )\n super( node )\n __add_node__( node )\n end", "def add_to_inventory(item)\n @items << item\n equip(item)\n items_weight\n end", "def add_node(node)\n @nodes.add node\n end", "def add_node(node); end", "def add_to_inventory(price, description)\n\t\tself.items << Item.new(price, description)\n\tend", "def add_item(item, amount = 1)\n\n # Increase the amount if the item already exists in the inventory.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end", "def add_node(n1)\n raise ArgumentError, \"Duplicate node name #{n1.name}\" if @nodes.find_index(n1)\n @nodes << n1\n @incident_map[n1] = []\n end", "def add(node)\r\n @nodes << node\r\n end", "def add_item(item, amount = 1)\n\n # Increase the amount if the item already exists in the inventory.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n\n # If not already in the inventory, push a couple.\n @inventory.push(C[item, amount])\n end", "def add_node(node)\n\t\t\tunless has_node?(node)\n\t\t\t\t@nodes[node] = new_node(node)\n\t\t\t\t@order += 1\n\t\t\tend\n\t\t\tself\n\t\tend", "def add_node(graph, document)\n unless graph.node(document.key)\n node = graph.add(Refinery::Node.new(document.key, model: document))\n establish_slots(node, document)\n end\n end", "def add_node(node)\n @nodes[node.uri] ||= node\n end", "def add_edge(node)\n @adj_nodes.push(node.position)\n end", "def add_node(node)\n if node.respond_to?(:to_sym)\n node = Woodhouse::Layout::Node.new(node.to_sym) \n end\n expect_arg :node, Woodhouse::Layout::Node, node\n @nodes << node\n node\n end", "def add_node\n return if @node_name == nil\n unless node_exist? \n tool_hash = Hash[*@tool_properties.zip(@tool_values).flatten]\n new_node = {\n \"node_name\" => @node_name,\n \"tools\" => [\n tool_hash\n ]\n }\n @site_data[\"site\"][\"node\"] << new_node\n end\n end", "def add_item(item)\n item = Item.find item unless item.is_a? Item\n $logger.debug{\"#{self} add #{item}\"}\n items << item\n inventory << item.id\n item\n end", "def add_item(item)\n @inventory.push(item)\n if item.include? \"weapon\"\n @weapon = item\n end\n end", "def makeInventoryNode(control_ip, control_mac, hostname, hrn, locationId)\n\t\t node = Hash.new\n\n \t\t# Fill in that received from CONFINE Portal\n \t\tnode['control_ip'] = control_ip\n \t\tnode['control_mac'] = control_mac\n \t\t\tnode['hostname'] = hostname\n\t\t node['hrn'] = hrn\n\t\t\tnode['location_id'] = locationId\n\n\t\t\t# DUMMY values.\n \t\tnode['inventory_id'] = 1 \n\t\t\tnode['chassis_sn'] = 'BOGUS SN 123'\n\t\t\tnode['motherboard_id'] = 1\n\t\t\tnode['pxeimage_id'] = 1\n\t\t\tnode['disk'] = '/dev/sda'\n\t\t\t# return\n\t\t\tnode\n\t\tend", "def add_node(node)\n nodes[node.value] = node\n end", "def add_node(node)\n @nodes[node.id.to_i] = node\n node.db = self\n end", "def add(item)\n @clxn[key_for(item)] = item\n end", "def add_chocolate_bar(chocolate_bar)\ncurrent_item = line_items.find_by(chocolate_bar_id: chocolate_bar.id)\nif current_item\ncurrent_item.quantity += 1\nelse\ncurrent_item = line_items.build(chocolate_bar_id: chocolate_bar.id)\nend\ncurrent_item\nend", "def add_node node\n nodes << node\n node.scene = self\n end", "def add(item)\n self.items.push(item)\n if self.min_price > item.price.to_i\n self.min_price = item.price.to_i\n end\n self.owners.push(item.owner)\n self.owners = self.owners.uniq\n self.quantity += item.quantity\n self\n end", "def add_node(node)\r\n raise \"you can only add node #{node.name} to a Proposed Deployment\" unless snapshot.proposed?\r\n NodeRole.create :node_id=>node.id, :snapshot_id=>snapshot_id, :role_id=>role_id\r\n end", "def add(item)\n\t\t\t@hash[item] = Node.new\n\t\tend", "def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend", "def add_edge(from, to, cost)\n @edges << Edge.new(from, to, cost)\n end", "def add_inv inv_file\n self.inventory_database = JSON.parse File.read(inv_file)\n end", "def add_taxon(taxon_node)\n taxons << taxon_node\n end", "def AddNode(type, xpos, ypos, numRadios = 0)\n\tname = NodeName(xpos, ypos)\n\tnode = Orbit::Topology::Node.new(@lastId, name, type)\n\tnode.SetPos(xpos,ypos)\n\t@lastId=@lastId+1\n\t#let OMF know we have created this node\n\tDefineGroup(node)\n\t@nodes_by_name[name]=node\n\treturn node\n end", "def add_edge(source, target = nil, label = nil)\n @reversal = nil\n if target\n edge = Puppet::Relationship.new(source, target, label)\n else\n edge = source\n end\n [edge.source, edge.target].each { |vertex| setup_vertex(vertex) unless vertex?(vertex) }\n @vertices[edge.source].add_edge :out, edge\n @vertices[edge.target].add_edge :in, edge\n @edges << edge\n true\n end", "def node=(node)\n items_node[:node] = node\n end", "def add_node(new_node)\n @nodes[new_node] ||= Array.new #only adds if not in graph\n @node_dir_ancestors[new_node] ||= Array.new\n end", "def addItemToVest _obj, _args\n \"_obj addItemToVest _args;\" \n end", "def add_shelf\n\t\[email protected](Shelf.new)\n\tend", "def add_edge(e)\n @edges[e.from] << e\n end", "def add_item(item)\n if @item\n log(\"Item is already equipped in EquipSlot.\")\n return\n end\n @item = item\n return\n end", "def addNode(node)\r\n\t\tif @nodes.nil?\r\n\t\t\t@nodes = [node]\r\n\t\telse\r\n\t\t\t@nodes << node\r\n\t\tend\r\n\tend", "def add_oai_item_id\n\t\t#literal specifies that it should be in the form of...<oai:itemID>...</oai:itemID>\n \t\tself.add_relationship :oai_item_id, \"oai:gcu.ac.uk:\" + self.pid, :literal => true\n\tend", "def node_add(node)\n raise Deployment::InvalidArgument.new self, 'Cluster can add only nodes!', node unless node.is_a? Deployment::Node\n return node_get node if node_present? node\n unless node.cluster == self\n node.cluster.node_remove node if node.cluster\n end\n nodes.store prepare_key(node), node\n node.cluster = self\n node\n end", "def put(item)\n @inv.push(item)\n end", "def update_node(field_name, value)\n case field_name\n when 'offer_accepted'\n self.offer_accepted = value\n when 'referal_bonus'\n self.referal_bonus += value\n else\n return \"No operation needed.\"\n end\n self\n end", "def add_edge(target_node,value)\n edges[target_node] = Edge.new(target_node,value)\n end", "def <<(node)\n node.dispatcher = @dispatcher\n @nodes << node\n end", "def add\n ensure_client\n required_attributes = %w[deviceVolumeName isShareable storageSystemUri]\n required_attributes.each { |k| raise IncompleteResource, \"Missing required attribute: '#{k}'\" unless @data.key?(k) || @data.key?(k.to_sym) }\n @data['name'] ||= @data['deviceVolumeName']\n response = @client.rest_post(\"#{BASE_URI}/from-existing\", { 'body' => @data }, @api_version)\n set_all(client.response_handler(response))\n self\n end", "def add_oai_item_id\n\t\t#literal specifies that it should be in the form of...<oai:itemID>...</oai:itemID>\n \t\tself.add_relationship :oai_item_id, \"oai:hull.ac.uk:\" + self.pid, :literal => true\n\tend", "def add_to_tree(item, node)\n return rebalance(super(item, node))\n end", "def add_to_neighbors(node)\n @neighbors << node\n end", "def addOtherEdge (node, dist)\n\t\[email protected]([node, dist])\n\tend", "def add_item(item_id)\n line_item = self.line_items.find_by(item_id: item_id)\n if line_item\n line_item.quantity += 1\n else\n line_item=self.line_items.build(item_id: item_id)\n end\n line_item\n end", "def add_new_item(name, price)\r\n item = Trading::Item.named(name, price, self)\r\n list_of_items.push(item)\r\n end", "def add(new_line_items)\n new_line_items = Array.wrap(new_line_items).reject{ |li| li.product.supplier_id.nil? || li.product.supplier_id != self.supplier_id }\n new_line_items.each do |new_line_item|\n if line_item = self.drop_ship_line_items.find_by_line_item_id(new_line_item.id)\n else\n self.drop_ship_line_items.create({line_item_id: new_line_item.id}, without_protection: true)\n end\n end\n # TODO: remove any old line items?\n self.save ? self : nil\n end", "def add(node, value)\n tree_navigator.descendents(node).each do |descendent|\n values[descendent] += value\n end\n end", "def add_fish (fish)\n @fish_population << fish\n\n end", "def add_to_rioter(rioter)\n\n\t\t\t\t# pre-setup - combine blocks added\n\t\t\t\trioter.setup_node = lambda {|node,defaults|\n\t\t\t\t\tnode_setup_blocks.each {|blk| blk[node,defaults]}\n\t\t\t\t}\n\n\t\t\t\t# in-setup - combine blocks added\n\t\t\t\trioter.node_defaults = lambda {|node,defaults|\n\t\t\t\t\tnode_default_blocks.each {|blk| blk[node,defaults]}\n\t\t\t\t}\n\n\t\t\t\t# post-setup\n\t\t\t\trioter.consolidate_node = @node_consolidation_block\n\n\t\t\t\t# create and bind acts\n\t\t\t\tacts.each do |act|\n\t\t\t\t\tact.extend helper_mod \n\t\t\t\t\tact.bind_rioter(rioter)\n\t\t\t\tend\n\n\t\t\t\t# bind event processors\n\t\t\t\tevent_processors.each do |ev_proc|\n\t\t\t\t\tev_proc.bind(rioter)\n\t\t\t\tend\n\n\t\t\t\trioter = Rioter.new\n\t\t\t\trioter\n\t\t\tend", "def item_add item\n\t\tret = super\n\t\titem.known! if (ret)\n\t\treturn ret\n\tend", "def add_item(item)\n @chores << item\n end", "def add_ingredient_to_recipe quantity, measure, food_item_name, recipe \n food_item = FoodItem.new(:name => food_item_name, :price => nil)\n ingredient = Ingredient.new(:food_item => food_item, :quantity => quantity, :measure => measure, :recipe_id => recipe.id)\n recipe.ingredients << ingredient\n end", "def add_node(name, node)\n language.nodes[name] = node if name\n node\n end", "def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end", "def add(object)\n @inventory << object\n\n object.container = @game_object_id\n\n if object.is_a? Player or object.is_a? Mobile\n object.update_display\n end\n end", "def add_item(itemN)\n @items.push(ItemShop.new(itemN))\n end", "def add(beer)\n \t$catalogue << beer\n end", "def add_item(item)\r\n items.push(item)\r\n item.owner = self\r\n end", "def addItemCargo _obj, _args\n \"_obj addItemCargo _args;\" \n end", "def add_edge(element1, element2)\n index1 = self.dict[element1]\n index2 = self.dict[element2]\n raise Exception.new(\"Nodes not exist!\") unless index1 && index2\n\n head_node2 = self.adj_list_array[index2].head_node\n new_node1 = Node.new(element1, head_node2.next_node)\n head_node2.next_node = new_node1\n\n\n head_node1 = self.adj_list_array[index1].head_node\n new_node2 = Node.new(element2, head_node1.next_node)\n head_node1.next_node = new_node2\n\n self\n end", "def add_node(n)\n @nodes.push n unless @nodes.include? n\n end", "def add_food\n srand\n self << FishFood.new(Position.new([randomFloatSigned*2,1,randomFloatSigned]))\n end", "def brief_vendor_add_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n brief_vendor.items << Item.new{|r| r.parent_id = params[:item_id]}\n\n redirect_to(cheil_brief_vendor_items_path(params[:brief_id],params[:vendor_id])) \n end", "def add_shelf(shelf_name)\n self.shelves.create(name: shelf_name)\n end", "def add_item(item_id)\n if line_item = line_items.find_by(item_id: item_id)\n line_item.quantity += 1\n else\n line_item = line_items.build(item_id: item_id)\n end\n line_item\n end", "def add_item(olist, item, quant=1)\n new_list = {item => quant}\n olist.merge(new_list)\nend", "def add_one_to_one_provenance(from_item:, to_item:,\n additional_relation_data: nil)\n from_map = AssociationMap.new(from_item)\n to_map = AssociationMap.new(to_item)\n\n add_provenance(\n from: from_item, from_map: from_map,\n to: to_item, to_map: to_map,\n additional_relation_data: additional_relation_data\n )\n from_map.save\n to_map.save\n end", "def add_ship_to(opts = {})\n shipment_root << OrganisationBuilder.new('ShipTo', opts).to_xml\n end", "def add(item)\r\n fail \"missing item\" if item.nil?\r\n fail \"item is not active, it cannot be put in your wish list\" unless item.is_active?\r\n\r\n self.items << item\r\n item.add_observer(self)\r\n end", "def add_edge(nodeA, nodeB)\n nodeA.adjacents << nodeB\n nodeB.adjacents << nodeA\n\n @nodes << nodeA\n @nodes << nodeB\n end", "def add_inventory(product_name, quantity)\n @products.each do |product|\n if product.name == product_name.upcase\n product.quantity += quantity\n end\n end\n end", "def add_item\n\t\tset_sale\n\t\tpopulate_products\n\n\t\tline_item = Item.where(sale_id: params[:sale_id], product_id: params[:product_id]).first\n\t\tline_item.quantity += 1\n\t\tline_item.save\n\n\t\t# Llama método que reduce cantidad de stock\n\t\tremove_item_from_stock(params[:product_id])\n\t\tupdate_line_item_totals(line_item)\n\n\t\tupdate_totals\n\n\t\trespond_to do |format|\n\t\t\tformat.js { ajax_refresh }\n\t\tend\n\tend", "def add_to_line_item(line_item, variant, quantity, currency=nil, shipment=nil, price=nil)\n if line_item\n line_item.target_shipment = shipment\n line_item.quantity += quantity.to_i\n line_item.currency = currency unless currency.nil?\n line_item.save\n else\n line_item = order.line_items.new(quantity: quantity, variant: variant)\n # line_item = Spree::LineItem.new(quantity: quantity)\n line_item.target_shipment = shipment\n line_item.variant = variant\n if currency\n line_item.currency = currency unless currency.nil?\n line_item.price = price || variant.price_in(currency).amount\n else\n line_item.price = price || variant.price\n end\n # order.line_items << line_item\n # line_item\n end\n \n line_item.save\n order.reload\n line_item\n end", "def catch_fish\n inventory[:fish] += @skills[:fish]\n end", "def add_edge(from_node, to_node)\n add_node(from_node)\n add_node(to_node)\n @nodes[from_node] << to_node\n @node_dir_ancestors[to_node] << from_node\n\n if self.has_cycle\n puts \"No longer DAG\"\n end\n end", "def add_item\n item = params[:item]\n image = Image.find(item[:image_id])\n\n order = current_user.init_cart.order\n line_item = order.line_items.where(\n image_id: image.id,\n product_id: item[:product_id],\n product_option_id: item[:product_option_id]\n ).first\n\n if line_item.present?\n line_item.quantity += item[:quantity].to_i\n else\n line_item = order.line_items.build(item)\n end\n\n line_item.price = Product.find(line_item.product_id).price_for_tier(image.tier_id, image.owner?(current_user))\n line_item.tax = line_item.price * PER_TAX\n\n if line_item.save\n render json: line_item, status: :created\n else\n render json: { msg: line_item.errors.full_messages.to_sentence }, status: :bad_request\n end\n end", "def reshelf(product, quantity)\n # NOT DEFINED IN EXAMPLES\n @inventory[product][\"quantity\"] += quantity\nend", "def add_node(taxonomy_node, node, options = {})\n tax_node = options[:skip_add].present? ? node : add_taxonomy_node(taxonomy_node, node)\n return unless taxonomy_node.children.any?\n taxonomy_node.xpath('./node').each do |child_node|\n add_node(child_node, tax_node) if tax_node.present?\n end\n end", "def add_item(line_item_from_cart)\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n\n if current_item\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n else\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n end\n\n current_item\n end", "def append_node\r\n # Load parent package.\r\n parent_package = ProductPackage.find params[:id], :include => \"product_package_nodes\"\r\n # position = parent_package.product_package_nodes.collect{|node| node.position}.sort.last.nexts\r\n \r\n # Build a child node.\r\n case params[:node_type]\r\n when \"package\"\r\n parent_package.product_package_nodes << ProductPackage.new(:name => params[:new_package_name])\r\n when \"product\"\r\n parent_package.product_package_nodes << ProductPackageProduct.new(:product_id => params[:product_id], :display_style => \"checkbox\")\r\n end\r\n \r\n # Save node and redirect back.\r\n redirect_to :back\r\n end", "def add_entity\n e = NSEntityDescription.new\n yield e\n register_entity(e)\n end", "def add_node(graph, document)\n unless graph.node(document.key)\n graph.add(Turbine::Node.new(document.key, model: document))\n end\n end", "def add_repository!\n apt_repository 'partner' do\n uri 'http://archive.canonical.com'\n components %w(partner)\n distribution node['lsb']['codename']\n action :add\n end\n end", "def add_ship_from(opts = {})\n shipment_root << OrganisationBuilder.new('ShipFrom', opts).to_xml\n end", "def add_item(itemToAdd)\r\n itemToAdd.set_owner(self)\r\n itemToAdd.deactivate\r\n self.items.push(itemToAdd)\r\n end", "def add_item amount, tax, name, discount=0, full_amount=0\n begin\n case TaxGuess.guess(amount, tax)\n when :tax0\n @total_0 += amount.round(2)\n when :tax7\n if discount != 0\n @total_7 += full_amount.round(2)\n @discount_7 += discount\n else\n @total_7 += amount.round(2)\n end\n @tax_7 += tax\n when :tax19\n if discount != 0\n @total_19 += full_amount.round(2)\n @discount_19 += discount\n else\n @total_19 += amount.round(2)\n end\n if swiss?\n Magelex::logger.info(\"19% Tax Item in swiss order: #{@order_nr}: #{name}\")\n end\n @tax_19 += tax\n when :empty_item\n Magelex::logger.debug(\"Empty item: '#{name}' #{amount}, tax: #{tax}\")\n end\n rescue RuntimeError\n Magelex::logger.warn(\"Unguessable tax (#{@order_nr}: #{name} #{amount}/#{tax})\")\n @has_problems = true\n end\n end", "def assign_inventory_item\n self.inventory_item ||= inventory.item_by_product_and_code(product, lot_code)\n self\n end", "def add_to_receipt(item)\n balance = item.is_a?(Array) ? item[2] ? item[2].to_i <=> 0 : 0 : 0\n if @marw_queue.empty? || @marw_queue.all? { |receipt| \n receipt.closed || balance != receipt.balance }\n label = (balance == 0 ? marw_label_default : (balance > 0 ? \n MARW_CONFIGURATION[:vocab_gain_label] : MARW_CONFIGURATION[:vocab_lose_label]))\n show_receipt_window(label, [], balance)\n end\n @marw_queue.reverse.each { |receipt| \n if !receipt.closed && receipt.balance == balance\n receipt.item_array.push(item) \n break\n end\n }\n end" ]
[ "0.56742984", "0.5497115", "0.54929703", "0.5437522", "0.540488", "0.5373448", "0.53644323", "0.5340188", "0.52910554", "0.5290144", "0.526472", "0.51921314", "0.5173282", "0.5172374", "0.5161553", "0.5144879", "0.5093017", "0.5087404", "0.50822896", "0.50523186", "0.50340927", "0.5019507", "0.49940586", "0.49688268", "0.49678367", "0.4953971", "0.49156514", "0.49121386", "0.48950222", "0.48943055", "0.48904464", "0.48591885", "0.48577377", "0.48441985", "0.48426056", "0.48363367", "0.4830038", "0.4826716", "0.4823213", "0.48215106", "0.4821302", "0.48212814", "0.4814101", "0.480658", "0.47938013", "0.47816357", "0.4776564", "0.4757684", "0.47453782", "0.47361758", "0.4722171", "0.47065955", "0.47025287", "0.4685858", "0.4684334", "0.46843085", "0.46820933", "0.46806967", "0.46780556", "0.46766382", "0.4670793", "0.46637103", "0.46579808", "0.46547002", "0.46529517", "0.46407026", "0.4640395", "0.46325207", "0.46293283", "0.46231532", "0.4617338", "0.46134686", "0.46063662", "0.4604109", "0.4603752", "0.45907378", "0.45903885", "0.4589531", "0.45803028", "0.45802778", "0.45701677", "0.45679837", "0.45645082", "0.45641053", "0.455706", "0.4556917", "0.45549437", "0.45531902", "0.45507157", "0.4549892", "0.4548208", "0.45435143", "0.4539704", "0.45395815", "0.45389584", "0.45355156", "0.45236614", "0.4523609", "0.45160124", "0.45122313" ]
0.6209716
0
Make up the location based on the CONFINE location of the sliver, for the OMF inventory.
def makeInventoryLocation(name, x, y, z, testbedId) location = Hash.new # Fill in that received from CONFINE Portal location['name'] = name location['x'] = x location['y'] = y location['z'] = z location['testbed_id'] = testbedId # DUMMY location['switch_ip'] = '10.0.0.201' location['switch_port'] = '1' # return location end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_address\n begin\n \"#{cart.line_items.first.menu_section_item.menu_section.menu.location.\n address}, #{cart.line_items.first.menu_section_item.menu_section.menu.\n location.city}, #{cart.line_items.first.menu_section_item.menu_section.\n menu.location.region}\"\n rescue\n \"No current address on record.\"\n end\n end", "def location\n fetch('sword_art_online.location')\n end", "def location\n [equipment_rack.room.building.name, equipment_rack.room.name, equipment_rack.name, \"Unit #{rack_elevation}\"].join(', ') unless equipment_rack.nil?\n end", "def final_location\n\t\[email protected]\n\tend", "def location\n # TODO Check this\n # return poi.location unless poi.nil?\n # return place.location unless place.nil?\n return get_location\n end", "def symphony_pickup_location_code\n case service_point_code\n when 'ARS'\n 'ARS-LOAN'\n when 'RUMSEY-MAP'\n 'RUM-LOAN'\n when 'SPEC'\n 'SPE-LOAN'\n else\n 'GRE-LOAN'\n end\n end", "def location\n fetch('games.super_mario.locations')\n end", "def location\n ln = location_name\n return nil if ln == \"\" || ln == nil\n @engine.item_by_name(location_name)\n end", "def generate_location\n raise \"Cannot generate default location for #{self.class}, I don't know how\"\n end", "def to_wear_location\n self\n end", "def location\n fetch('hey_arnold.locations')\n end", "def venue_location\n major_geo = self.state || self.country\n [self.city, major_geo].compact.join(\", \")\n end", "def location_description\n LOCATION_DESCRIPTION\n end", "def addInvLocation(name, x, y, z, testbedId)\n\t\t\tlocation = makeInventoryLocation(name, x, y, z, testbedId)\n\t\t\tdoDB do |inv|\n \tresultLocation = inv.addLocation(location)\n\t\t\tend\n\t\tend", "def delivery_location\n return @delivery_location\n end", "def full_location; end", "def location\n\t\tUnitLocation.new(@db, @id)\n\tend", "def location\n @location ||= Station.get(@attrs['LocationCode'])\n end", "def location\n \"#{@position} #{DIRECTIONS[@orientation]}\"\n end", "def build_location(building)\n #stom spiral algoritme ofzo\n center = player.command_centers.first\n #spiral_location(building, {:x => center.tile_position_x,\n # :y => center.tile_position_y})\n {:x => center.x.in_build_tiles, :y => center.y.in_build_tiles - 3}\n end", "def location\n self.well_info.location\n end", "def location_hsh\n {\n \"Clancy Cullen [Offsite]\" => \"DM\",\n \"20 Cooper Square [Offsite Prep]\" => \"OK\",\n \"Bobst [Offsite Prep]\" => \"ON\"\n }\n end", "def office_location\n return @office_location\n end", "def location\n fetch('harry_potter.locations')\n end", "def location\n\t\tif @location\n\t\t\t@location\n\t\telsif File.exists?(default_location)\n\t\t\tdefault_location\n\t\telsif File.exists?(appstore_location)\n\t\t\tappstore_location\n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def fix_location\n self.location = self.location.map(&:to_f)\n end", "def create_item_with_location\n inventory_item = FactoryBot.create :inventory_item\n warehouse_location = FactoryBot.create :warehouse_location\n ItemLocation.create(inventory_item_id: inventory_item.id, warehouse_location_id: warehouse_location.id, quantity: inventory_item.quantity)\n\n inventory_item\n end", "def delivery_location=(value)\n @delivery_location = value\n end", "def location\n @ole.Location\n end", "def location\n fetch('simpsons.locations')\n end", "def inventory_path\n if config.inventory_path\n config.inventory_path\n else\n @inventory_path ||= generate_inventory\n end\n end", "def get_location\n\n end", "def initialize(name, size, price)\n\n @name = name\n @size = size\n @price = price\n @location = \"Panago Broadway\" #every single pizza will have this location\n\n end", "def location\n\t\t@location\n\tend", "def hash_for_location(offense); end", "def initialize\n # create and locate the shovel\n shovel.location = start_room\n end", "def set_item_location\n @item_location = ItemLocation.find(params[:id])\n end", "def location\n @location ||= locations.hq.first\n end", "def set_item_location\n @item_location = ItemLocation.find(params[:id])\n end", "def my_location\n\t\t\"#{address}, #{city}, GA\"\n\tend", "def from_museum\n\t\tif @random_number == 1\n\t\t\t@street_used = \"Fifth Ave.\"\n\t\t\t@location = \"Hillman\"\n\t\telse\n\t\t\t@street_used = \"Bar St.\"\n\t\t\t@location = \"Cathedral\"\n\t\tend\n\tend", "def location\n attributes.fetch(:location)\n end", "def update_main_location\n update_attribute( :main_location, self.main_locations.try( :first ))\n end", "def location\n fetch('how_to_train_your_dragon.locations')\n end", "def setup\n @l1 = Location.first\n end", "def set_catalog_location\n @catalog_location = Catalog::Location.find(params[:id])\n end", "def antipodal\n Location.new(:longitude => 180 - (longitude.abs),\n :latitude => -latitude )\n end", "def location_of_bay(bay)\n location = WAREHOUSE.select{ |item| item[:product_name] == bay }\n return location[0][:rack_bay_position]\nend", "def default_location\n @default_location ||= Spree::StockLocation.find_by_name('default')\n end", "def location_s\n self.location.to_s\n end", "def location\n @fog_wrapper.location\n end", "def office_location=(value)\n @office_location = value\n end", "def set_office_location\n @office_location = @company.office_locations.find(params[:id])\n end", "def pickup_location_name(code)\n if Settings.ils.client == 'FolioClient'\n Folio::ServicePoint.name_by_code(code) || code\n else\n Mylibrary::Application.config.library_map[code] || code\n end\n end", "def location\n @location\n end", "def other_loc(location)\n\t\t# uses location class equals method (TODO)\n\t\tif location == loc1\n\t\t\tloc2\n\t\telse\n\t\t\tloc1\n\t\tend\n\tend", "def location(value)\n @ole.Location = value\n nil\n end", "def location\n fetch('books.the_kingkiller_chronicle.locations')\n end", "def define_location\n config\n mtime = File.mtime(@msrun.rawfile)\n arr = [@msrun.group, @msrun.user, \"#{mtime.year}#{\"%02d\" % mtime.mon}#{\"%02d\" % mtime.day}\", @msrun.rawid]\n t = Time.now\n @location = File.join(arr.zip( [\"Unknown\", \"unknown\", \"#{t.year}#{\"%02d\" % t.mon}#{\"%02d\" % t.day}\", \"Never see this\"] ).map {|a| a.first.nil? ? a.last : a.first } )\n @msrun.archive_location = @location\n end", "def set_default_item_location\n \tself.actual_storage_location = self.item.storage_location\n end", "def i18n_location_title_key\n holding = current_request.holdings.first\n if holding\n if holding.checked_out?\n 'CHECKEDOUT'\n elsif holding.on_order?\n 'ON-ORDER'\n elsif holding.missing?\n 'MISSING'\n elsif holding.processing?\n 'INPROCESS'\n else\n current_request.origin_location.presence\n end\n elsif (origin_location = current_request.origin_location).present?\n origin_location\n end\n end", "def set_catalogs_location\n @catalogs_location = Catalogs::Location.find(params[:id])\n end", "def location\n @location ||= TermuxRubyApi::SubSystems::Location.new(self)\n end", "def location\n @location\n end", "def location\n @location\n end", "def store_location!; end", "def location\n \"#{((street_id.nil? or street.nil?) ? I18n.t('noname') : (street.isempty? ? I18n.t('no-street') : street.name.to_s) + ', ' + (street.city_id.nil? ? I18n.t('no-city') : (street.city_isempty ? I18n.t('no-city') : street.city_name.to_s) + ', ' + ((street.state_id.nil? or street.state_name.empty?) ? I18n.t('no-state') : street.state_name.to_s)))}\"\n end", "def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end", "def to_loc\n Location.new(id,\n @name,\n country,\n generic_name: core_name,\n valid_creatures: @creatures,\n valid_plants: @plants,\n fitness: fitness,\n structure_key: core_node || id)\n end", "def folio_location_code\n @folio_location_code ||= FolioLocationMap.folio_code_for(library_code: library, home_location: location)\n rescue FolioLocationMap::NotFound\n Honeybadger.notify('Location code not found', context: { library:, location: })\n nil\n end", "def location\n fetch('rick_and_morty.locations')\n end", "def location\n return [city, state, zip_code].join(\" \")\n end", "def generate_location\n if id.blank?\n raise Occi::Core::Errors::MandatoryArgumentError,\n 'Cannot generate default location without an `id`'\n end\n URI.parse \"#{kind.location}#{id}\"\n end", "def locations; end", "def to_s\n location\n end", "def location\n @location\n end", "def location\n country = Carmen::Country.coded(self.country)\n if country.present? && self.state.present?\n location = country.subregions? ? country.subregions.coded(self.state).name : self.state\n location += \", \"\n else\n location = ''\n end\n country.present? ? location + country.name : nil\n end", "def location\n [city, state, zip_code].join(\" \")\n end", "def location\n [city, state, zip_code].join(\" \")\n end", "def location\n [city, state, zip_code].join(\" \")\n end", "def set_location\n @location = \"Minneapolis, MN\"\n end", "def set_catalogs_location\n @resource = Catalogs::Location.find(params[:id])\n end", "def electronic_holding_location\n @electronic_holding_location ||= holdings&.find { |h| (h.dig('holdingsType', 'name') || h.dig('location', 'effectiveLocation', 'details', 'holdingsTypeName')) == 'Electronic' }\n end", "def location\n return @location\n end", "def from_cathy\n\t\tif @random_number == 1\n\t\t\t@street_used = \"Fourth Ave.\"\n\t\t\t@location = \"Monroeville\"\n\t\telse \n\t\t\t@street_used = \"Bar St.\"\n\t\t\t@location = \"Museum\"\n\t\tend\n\tend", "def location=(_arg0); end", "def locationPosition _args\n \"locationPosition _args;\" \n end", "def set_location\n location = flickr.places.findByLatLon(lat: lat, lon: lon)\n location.size >= 1 ? @location = location.first['name'] : @location = \"Unidentifiable location\"\n end", "def location\n Location.get(@entity['location_id'], client: @client)\n end", "def location_name\n LOCATIONS[location.to_s]\n end", "def location_name\n LOCATIONS[location.to_s]\n end", "def location_name\n LOCATIONS[location.to_s]\n end", "def location_name\n LOCATIONS[location.to_s]\n end", "def location\n @client.get(\"#{path}/location\")\n end", "def location\n fetch('games.league_of_legends.location')\n end", "def location\n fetch('doraemon.locations')\n end", "def set_location\n @location = Spree::Location.find(params[:id])\n end", "def locate!\n if foursquare_venue_id\n locate_via_foursquare!\n else\n locate_via_coords!\n end\n end", "def relocate(inventory_item, quantity, new_location)\n current_item_location = ItemLocation.find_by(\n inventory_item_id: inventory_item.id,\n warehouse_location_id: id\n )\n raise SilExceptions::ItemNotInLocation if current_item_location.nil?\n raise SilExceptions::InvalidQuantityToRelocate if current_item_location.quantity < quantity\n\n new_location.locate(inventory_item, quantity)\n\n if current_item_location.quantity == quantity\n remove_item(inventory_item.id) \n update_status\n return\n end\n \n remove_quantity(inventory_item.id, quantity, WarehouseTransaction::RELOCATION)\n end", "def get_location(io, context)\n generate_location(io, context)\n end" ]
[ "0.58103305", "0.5683924", "0.56237704", "0.5618594", "0.5605452", "0.5591263", "0.5569881", "0.55562127", "0.55368865", "0.5530229", "0.5505586", "0.54201597", "0.53998035", "0.53924996", "0.5384654", "0.53754014", "0.5371212", "0.5369955", "0.53646576", "0.5359624", "0.53388464", "0.532892", "0.5322907", "0.5282776", "0.52786064", "0.52690816", "0.52539796", "0.52201605", "0.52121115", "0.52020556", "0.5198576", "0.51977193", "0.5193799", "0.51932555", "0.51904166", "0.5168838", "0.51620334", "0.5156013", "0.51398385", "0.5125156", "0.51235807", "0.51225656", "0.5117524", "0.5115711", "0.51133215", "0.5112", "0.5103228", "0.51024944", "0.50929743", "0.50902694", "0.5089372", "0.50866014", "0.5080955", "0.50757897", "0.5064689", "0.5064223", "0.50605804", "0.5056746", "0.5055224", "0.50446445", "0.5037314", "0.50368965", "0.50334305", "0.50299203", "0.50299203", "0.5025009", "0.502167", "0.5021212", "0.50188404", "0.5018718", "0.50117624", "0.50016063", "0.4994133", "0.498639", "0.49856952", "0.4979632", "0.49586982", "0.4957081", "0.4957081", "0.4957081", "0.49503693", "0.49412346", "0.49409178", "0.49303764", "0.4925101", "0.4914619", "0.49076858", "0.49053004", "0.49033374", "0.48978233", "0.48978233", "0.48978233", "0.48978233", "0.48977882", "0.48958012", "0.4889179", "0.48867387", "0.48845732", "0.48756033", "0.48715425" ]
0.6131656
0
Make up the node based on the CONFINE sliver, for the OMF inventory.
def makeInventoryNode(control_ip, control_mac, hostname, hrn, locationId) node = Hash.new # Fill in that received from CONFINE Portal node['control_ip'] = control_ip node['control_mac'] = control_mac node['hostname'] = hostname node['hrn'] = hrn node['location_id'] = locationId # DUMMY values. node['inventory_id'] = 1 node['chassis_sn'] = 'BOGUS SN 123' node['motherboard_id'] = 1 node['pxeimage_id'] = 1 node['disk'] = '/dev/sda' # return node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addInvNode(control_ip, control_mac, hostname, hrn, locationId)\n\t\t\tnode = makeInventoryNode(control_ip, control_mac, hostname, hrn, locationId)\n\t\t\tdoDB do |inv|\n\t\t\t\tresultNode = inv.addNode(node)\n\t\t\tend\n\t\tend", "def build_node\n Chef::Log.trace(\"Building node object for #{@node_name}\")\n @node = Chef::Node.find_or_create(node_name)\n ohai_data = @ohai.data.merge(@node.automatic_attrs)\n @node.consume_external_attrs(ohai_data, nil)\n @run_list_expansion = @node.expand!(\"server\")\n @expanded_run_list_with_versions = @run_list_expansion.recipes.with_version_constraints_strings\n Chef::Log.info(\"Run List is [#{@node.run_list}]\")\n Chef::Log.info(\"Run List expands to [#{@expanded_run_list_with_versions.join(\", \")}]\")\n @node\n end", "def create_cfg_info(node_ips, o, masters)\n node_os = ENV['CONTIV_NODE_OS'] || CENTOS\n conn = {}\n node_ips.each_with_index do |node_ip, n|\n node = if n < masters\n { 'role' => 'master' }\n else\n {}\n end\n def_ctrl_if = node_os == UBUNTU ? 'enp0s8' : 'eth1'\n def_data_if = node_os == UBUNTU ? 'enp0s9' : 'eth2'\n node['control'] = ENV['CONTIV_CONTROL_IF'] || def_ctrl_if\n node['data'] = ENV['CONTIV_DATA_IF'] || def_data_if\n conn[node_ip] = node\n end\n cfg_data = { 'CONNECTION_INFO' => conn }\n cfg_file = (ENV['VAGRANT_CWD'] || '.') + '/.cfg_' + o + '.yaml'\n File.write(cfg_file, cfg_data.to_yaml)\nend", "def _create_chef_node(&block)\n step(\" creating chef node\", :green)\n @chef_node = Chef::Node.new\n @chef_node.name(fullname)\n set_chef_node_attributes\n set_chef_node_environment\n sync_ipconfig_attribute\n sync_volume_attributes\n chef_api_server_as_client.post_rest('nodes', @chef_node)\n end", "def match_node_to_res(node, i)\n n = Marshal.load(Marshal.dump(@base_node))\n puts \"new node: '#{n.inspect}'\"\n n[:name] = node['hostname']\n n[:hostname] = node['hostname']\n n[:urn] = \"#{BASE_URN}#{node['hostname']}\"\n n[:interfaces_attributes].each do |interface|\n if interface[:role] == \"control\"\n interface[:name] = node['hostname'] + \":if0\"\n interface[:ips_attributes].first[:address] = node['control_ip']\n interface[:mac] = node['control_mac']\n elsif interface[:role] == \"experimental\"\n interface[:name] = node['hostname'] + \":if1\"\n interface[:mac] = calc_mac(node['control_mac'])\n end\n end\n n[:cmc_attributes][:name] = node['hostname'] + \":cm\"\n n[:cmc_attributes][:mac] = calc_cmc_mac(n[:cmc_attributes][:mac], i)\n n[:cmc_attributes][:ip_attributes][:address] = calc_cmc_ip(node['control_ip'])\n\n if i >= 2 && i <= 9\n domain = OUTDOOR_DOMAIN\n additional_info = Marshal.load(Marshal.dump(@orbit_info))\n elsif i == 1 || i == 10 || (i >= 14 && i <= 35)\n domain = OUTDOOR_DOMAIN\n additional_info = Marshal.load(Marshal.dump(@grid_info))\n elsif i >= 36 && i <= 40\n domain = OFFICE_DOMAIN\n additional_info = Marshal.load(Marshal.dump(@diskless_info))\n elsif i >= 41 && i <= 49\n domain = OFFICE_DOMAIN\n additional_info = Marshal.load(Marshal.dump(@icarus_info))\n elsif i >= 50 && i <= 85\n domain = INDOOR_DOMAIN\n additional_info = Marshal.load(Marshal.dump(@icarus_info)) \n else\n return n\n end\n n[:domain] = domain\n n[:urn] = n[:urn].sub('omf:nitos', domain)\n n.merge!(additional_info)\n n\nend", "def initialize(source_instance,transition) \n @number=0 \n @nodecost=0\n @passby=false\n @instance=source_instance\n @transition=transition\n @neighbours=[]\n \n @name = \"NODE \" +source_instance + \" - \" + transition.to_s \n \n end", "def node(data)\n if (data['provisioning'])\n if(data['provisioning']['node_group'] && data['provisioning']['node_group']['size'])\n Topo::Provision::NodeGroupGenerator.new(data)\n else \n Topo::Provision::MachineGenerator.new(data)\n end\n else\n Topo::Provision::ChefNodeGenerator.new(data)\n end \n end", "def create_item\n @item = Fox_Item.new(self, @content.join(\"\\t\"), @icon, @icon)\n end", "def build_shipper_or_recipient_node(name, location)\n node = XmlNode.new(name) do |xml_node|\n xml_node << XmlNode.new('Contact') do |contact_node|\n contact_node << XmlNode.new('PersonName', location.name)\n contact_node << XmlNode.new('CompanyName', location.company_name) if location.company_name.present?\n contact_node << XmlNode.new('PhoneNumber', location.phone)\n end\n xml_node << XmlNode.new('Address') do |address_node|\n address_node << XmlNode.new('StreetLines', location.address1)\n if location.address2\n address_node << XmlNode.new('StreetLines', location.address2)\n end\n address_node << XmlNode.new('City', location.city)\n address_node << XmlNode.new('StateOrProvinceCode', location.state)\n address_node << XmlNode.new('PostalCode', location.postal_code)\n address_node << XmlNode.new(\"CountryCode\", location.country_code(:alpha2))\n address_node << XmlNode.new(\"Residential\", true) unless location.commercial?\n \n end\n end\n end", "def create_taxonomy_node\n Taxonomite::Species.new(name: self.name)\n end", "def create_line_item_from_inventory_item inventory_item, qty, payable_party, billable_party, include_price_in_expense, include_price_in_revenue, notes\n # Vendor\n l1 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_vendor, :quantity => qty,\n :unit_price_expense => inventory_item.cogs,\n :tax_rate_expense => 0,\n :payable_party => payable_party,\n :include_price_in_expense => include_price_in_expense,\n :inventory_item => inventory_item, :notes => notes, :event => self)\n\n # Account\n l2 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_public, :quantity => qty,\n :unit_price_revenue => calculate_sell_price_from_inventory_item(inventory_item),\n :billable_party => billable_party,\n :include_price_in_revenue => include_price_in_revenue,\n :inventory_item => inventory_item, :notes => notes, :event => self)\n\n l1.opposing_line_item = l2\n l2.opposing_line_item = l1\n l1.save\n l2.save\n\n [l1, l2]\n end", "def init\n create_file options[:inventory_config] do\n<<-YML\n# sources:\n# - \"https://supermarket.getchef.com\"\n# cookbooks:\n# cookbook-name:\n# versions:\n# - \"~> 4.0.2\"\n# - \"> 5.0.0\"\n# git:\n# location: url | path\n# branches:\n# - a_branch_name\n# refs:\n# - SHA\n\nYML\n end\n end", "def node\n @node ||=\n begin\n node = Chef::Node.new(chef_server_rest: client_rest)\n node.name(node_name)\n node.run_list(normalized_run_list)\n node.normal_attrs = first_boot_attributes if first_boot_attributes\n node.environment(environment) if environment\n node.policy_name = policy_name if policy_name\n node.policy_group = policy_group if policy_group\n (config[:tags] || []).each do |tag|\n node.tags << tag\n end\n node\n end\n end", "def create_desc_item(node_name, id_suffix)\n \n #puts \"node_name = #{node_name}\"\n #puts \"id_suffix = #{id_suffix}\"\n \n node = @xml.at('/ead/archdesc/' + node_name)\n return unless node\n if head = node.at('head')\n label = head.text.empty? ? id_suffix : head.text.capitalize\n else\n label = id_suffix\n end\n \n doc = self.base_doc.merge({\n :xml_display => node.to_xml,\n :id => generate_id(id_suffix),\n :title_t => label,\n :hierarchy => [self.title, label]\n })\n doc\n end", "def create_nsxt\n #-----------------------------------------------------------------------\n # Get NSX parameters needed to create the network\n #-----------------------------------------------------------------------\n ls_name = self['NAME']\n ls_description = self['TEMPLATE/DESCRIPTION']\n tz_id = self['TEMPLATE/NSX_TZ_ID']\n rep_mode = self['TEMPLATE/NSX_REP_MODE']\n admin_status = self['TEMPLATE/NSX_ADMIN_STATUS']\n\n #-----------------------------------------------------------------------\n # Use first cluster/dc to create the virtual wire\n #-----------------------------------------------------------------------\n host_id = @cluster[0][:hid]\n uuid = @cluster[0][:uuid]\n dc = @cluster[0][:dc]\n\n nsx_client = NSXDriver::NSXClient.new_from_id(host_id)\n\n opaque_spec = %(\n {\n \"transport_zone_id\": \"#{tz_id}\",\n \"replication_mode\": \"#{rep_mode}\",\n \"admin_state\": \"#{admin_status}\",\n \"display_name\": \"#{ls_name}\",\n \"description\": \"#{ls_description}\"\n }\n )\n\n lsw = NSXDriver::OpaqueNetwork.new(nsx_client, nil, tz_id, opaque_spec)\n\n vnet_ref = dc.nsx_network(lsw.ls_id,\n VCenterDriver::Network::NETWORK_TYPE_NSXT)\n\n \"VCENTER_NET_REF = '#{vnet_ref}'\\n\"\\\n \"VCENTER_INSTANCE_ID = '#{uuid}'\\n\"\\\n \"NSX_ID = '#{lsw.ls_id}'\\n\"\\\n \"NSX_VNI = '#{lsw.ls_vni}'\\n\"\\\n \"BRIDGE = '#{lsw.ls_name}'\\n\"\n end", "def create_disc(node)\n disc = @factory.new_disc\n disc.id = node.attributes['id']\n disc.sectors = node.attributes['sectors'].to_i\n return disc\n end", "def create_line_item_from_inventory_item inventory_item, qty, payable_party, billable_party, include_price_in_expense, include_price_in_revenue, notes\n\n [\n # Vendor\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_vendor, :quantity => qty,\n :unit_price_expense => inventory_item.cogs,\n :tax_rate_expense => 0,\n :payable_party => payable_party,\n :include_price_in_expense => include_price_in_expense,\n :inventory_item => inventory_item, :notes => notes),\n\n # Account\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_public, :quantity => qty,\n :unit_price_revenue => calculate_sell_price_from_inventory_item(inventory_item),\n :billable_party => billable_party,\n :include_price_in_revenue => include_price_in_revenue,\n :inventory_item => inventory_item, :notes => notes)\n ]\n end", "def load_node\n events.node_load_start(node_name, config)\n Chef::Log.trace(\"Building node object for #{node_name}\")\n\n @node =\n if Chef::Config[:solo_legacy_mode]\n Chef::Node.build(node_name)\n else\n Chef::Node.find_or_create(node_name)\n end\n select_implementation(node)\n implementation.finish_load_node(node)\n node\n events.node_load_success(node)\n rescue Exception => e\n events.node_load_failed(node_name, e, config)\n raise\n end", "def generate_initial_node\n\t\tnode_text = \".,\" + self.name\n\t\t\n\t\tinitial_node = Node.new()\n\t\t#this line will also build the \"\" category, since it is the first instance of it\n\t\tinitial_node = build_node(initial_node, node_text)\n\t\tinitial_node.save\n\n\t\t#update the ordering\n\t\tordering = []\n\t\tordering.insert(0, ObjectPlace.new(\"Node\", initial_node.id))\n\t\tset_order(ordering)\n\t\t#insert_element(0, node_text)\n\tend", "def initialize\n #each item has name and inventory number\n @inventory_list = {strawberry: 6, raspberry: 4, blueberry: 8}\n end", "def assign_inventory_item\n self.inventory_item ||= inventory.item_by_product_and_code(product, lot_code)\n self\n end", "def inventory_unit1\n Spree::InventoryUnit.new(variant: variant1)\n end", "def initialize(node, client)\n @xml = node\n @client = client\n @hash = nil\n \n if self['ID']\n @pe_id = self['ID'].to_i\n else\n @pe_id = nil\n end\n @name = self['NAME'] if self['NAME']\n end", "def node\n items_node[:node]\n end", "def initialize(name, location, capacity, cuisine, chef_name)\n @name = name\n @location = location\n @capacity = capacity\n @cuisine = cuisine\n # @open = true\n @clients = []\n # self represents the restaurant instance being initialized\n @chef = Chef.new(chef_name, self)\n end", "def node_create(node, node_class=Deployment::Node)\n if node_present? node\n node = node_get node\n elsif node.is_a? Deployment::Node\n node = node_add node\n else\n node = node_class.new node, self\n node = node_add node unless node_present? node\n end\n node\n end", "def create_item(index)\n item = @data[index]\n rect = item_rect(index, true)\n \n shopItem = UCShopItem.new(self, item, rect,\n SHOP_CONFIG::ITEM_NUMBER_PATTERN)\n \n shopItem.cItemPrice.align = 2\n shopItem.cItemPossess.align = 2 \n shopItem.cItemPossess.font = Font.shop_possess_font\n shopItem.ucItemNumber.cLabelNumber.align = 2\n shopItem.ucItemNumber.min = 0\n shopItem.ucItemNumber.max = shopItem.inventory_quantity\n return shopItem\n end", "def create_nsxv\n #-----------------------------------------------------------------------\n # Get NSX parameters needed to create the network\n #-----------------------------------------------------------------------\n ls_name = self['NAME']\n ls_description = self['TEMPLATE/DESCRIPTION']\n tz_id = self['TEMPLATE/NSX_TZ_ID']\n rep_mode = self['TEMPLATE/NSX_REP_MODE']\n\n #-----------------------------------------------------------------------\n # Use first cluster/dc to create the virtual wire\n #-----------------------------------------------------------------------\n host_id = @cluster[0][:hid]\n uuid = @cluster[0][:uuid]\n\n nsx_client = NSXDriver::NSXClient.new_from_id(host_id)\n\n vwire_spec =\n \"<virtualWireCreateSpec>\\\n <name>#{ls_name}</name>\\\n <description>#{ls_description}</description>\\\n <tenantId>virtual wire tenant</tenantId>\\\n <controlPlaneMode>#{rep_mode}</controlPlaneMode>\\\n <guestVlanAllowed>false</guestVlanAllowed>\\\n </virtualWireCreateSpec>\"\n\n lsw = NSXDriver::VirtualWire.new(nsx_client, nil, tz_id, vwire_spec)\n\n \"VCENTER_NET_REF = '#{lsw.ls_vcenter_ref}'\\n\"\\\n \"VCENTER_INSTANCE_ID = '#{uuid}'\\n\"\\\n \"NSX_ID = '#{lsw.ls_id}'\\n\"\\\n \"NSX_VNI = '#{lsw.ls_vni}'\\n\"\\\n \"BRIDGE = '#{lsw.ls_name}'\\n\"\n end", "def create_product_icon\n @product_icon = Sprite.new\n @product_icon.x = cent_x\n @product_icon.y = cent_y\n end", "def create\n params[:deployment_id] = Deployment.find_key(params[:deployment]).id if params.has_key? :deployment\n params[:deployment_id] ||= Deployment.system\n params.require(:name)\n params.require(:deployment_id)\n default_net = nil\n Node.transaction do\n @node = Node.create!(params.permit(:name,\n :description,\n :admin,\n :deployment_id,\n :allocated,\n :alive,\n :system,\n :available,\n :bootenv))\n # Keep suport for mac and ip hints in short form around for legacy Sledgehammer purposes\n if params[:ip]\n default_net = Network.lookup_network(params[:ip]) ||\n Network.find_by_name(\"unmanaged\")\n Attrib.set(\"hint-#{default_net.name}-v4addr\",@node,params[:ip]) if default_net\n Attrib.set(\"hint-admin-macs\", @node, [params[:mac]]) if params[:mac]\n end\n end\n default_net.make_node_role(@node) if default_net\n render api_show @node\n end", "def create\n Souffle::Log.info \"#{@node.log_prefix} Creating a new node...\"\n provider.create_node(@node)\n end", "def node_config(node)\n node.public_send(carrier)\n end", "def new\n puts \"xxxxxxx NodesC a:new xxxxxxx\"\n # @node = Node.new # orig \n \n @node = Node.new\n #@node.build ==> this does not work as there is m\n #@node.node_attrbs.build\n #byebug\n end", "def make_node(type, *args)\n elem = type.new self, *args\n @nodes << elem\n self.core_node ||= elem.id\n elem.expand\n elem\n end", "def from_node(node); end", "def initialize(parent, node, cost)\n @parent = parent\n @node = node\n @cost = cost\n end", "def initialize(head = nil, move = nil)\n self.move = move\n self.head = head\n self.tails = Set.new\n self.node = Opener::Node.instance(self.to_epd)\n end", "def content\n return <<-EOF\ndefault lucie\n\nlabel lucie\nkernel #{ INSTALLER_KERNEL }\nappend initrd=#{ initrd } ip=dhcp devfs=nomount root=/dev/nfs nfsroot=#{ @nfsroot } boot=live hostname=#{ @node.name } #{ $KERNEL_OPTIONS }\nEOF\n end", "def initialize(inventory, item_data)\n @defindex = item_data[:defindex]\n @backpack_position = item_data[:inventory] & 0xffff\n @class = inventory.item_schema[@defindex][:item_class]\n @count = item_data[:quantity]\n @id = item_data[:id]\n @level = item_data[:level]\n @name = inventory.item_schema[@defindex][:item_name]\n @quality = inventory.qualities[item_data[:quality]]\n @slot = inventory.item_schema[@defindex][:item_slot]\n @tradeable = !(item_data[:flag_cannot_trade] == true)\n @type = inventory.item_schema[@defindex][:item_type_name]\n\n unless inventory.item_schema[@defindex][:attributes].nil?\n @attributes = inventory.item_schema[@defindex][:attributes]\n end\n end", "def new_invoice_item(invoice, i)\n invoice_item = SupplierInvoiceItem.new\n if i.class.name == 'ReceiptNoteItem'\n invoice_item.receipt_note_id = i.receipt_note_id\n invoice_item.receipt_note_item_id = i.id\n else\n invoice_item.purchase_order_id = i.purchase_order_id\n invoice_item.purchase_order_item_id = i.id\n end\n invoice_item.supplier_invoice_id = invoice.id\n invoice_item.product_id = i.product_id\n invoice_item.code = i.code\n invoice_item.description = i.description\n invoice_item.quantity = i.balance\n invoice_item.price = i.price\n invoice_item.discount_pct = i.discount_pct\n invoice_item.discount = i.discount\n invoice_item.tax_type_id = i.tax_type_id\n invoice_item.work_order_id = i.work_order_id\n invoice_item.project_id = i.project_id\n if !i.charge_account_id.blank?\n invoice_item.charge_account_id = i.charge_account_id\n else\n invoice_item.charge_account_id = ChargeAccount.expenditures(i.project_id).first.id\n end\n invoice_item.created_by = current_user.id if !current_user.nil?\n return invoice_item\n end", "def create_line_item_for_per_person_charge_2 qty, event_vendor, include_price_in_expense, include_price_in_revenue, notes\n\n [\n # Vendor\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Fee\",\n :sku => \"MT-\" + event_vendor.menu_template_id.to_s.rjust(7, '0'), :name => \"* Per Person Charge (\" + event_vendor.vendor.name + \")\", :quantity => qty,\n :unit_price_expense => event_vendor.calculate_menu_level_cogs,\n :tax_rate_expense => 0,\n :payable_party => event_vendor.vendor,\n :include_price_in_expense => include_price_in_expense,\n :menu_template => event_vendor.menu_template),\n\n # Account\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Fee\",\n :sku => \"MT-\" + event_vendor.menu_template_id.to_s.rjust(7, '0'), :name => \"* Per Person Charge (\" + event_vendor.vendor.name + \")\", :quantity => qty,\n :unit_price_revenue => event_vendor.calculate_menu_level_sell_price,\n :billable_party => account,\n :include_price_in_revenue => include_price_in_revenue,\n :menu_template => event_vendor.menu_template)\n ]\n end", "def inventory()\n\t\tInventory.new(@db, 'sgt-structure:' + @id + ':inv')\n\tend", "def new_node\n\t\t\traise NotImplementedError.new('#new_node must be implemented')\n\t\tend", "def wsman_initialize client, epr_or_uri, node\n# STDERR.puts \"Wbem::WsmanInstance.new epr_or_uri #{epr_or_uri}\"\n @node = node.body.child rescue node\n# STDERR.puts \"Wsman::Instance.new @node #{@node.class}\"\n @epr = (epr_or_uri.is_a? Openwsman::EndPointReference) ? epr_or_uri : Openwsman::EndPointReference.new(epr_or_uri) if epr_or_uri\n @client = client\n end", "def get_or_create_node(conn, uri)\n # PARSE URI\n _, namespace, name = uri.split(/^(.*[\\/|#])([^\\/|#]+)$/)\n # LOOK FOR THIS NODE IN THE INDEX\n r = conn.get(\"/db/data/index/node/#{CGI.escape(namespace)}/name/#{CGI.escape(name)}\")\n node = (JSON.parse(r.body).first || {})['self'] if r.status == 200\n #puts r.status, node\n unless node\n # THIS NODE IS NOT FOUND IN THE INDEX, SO CREATE IT\n r = conn.post(\"/db/data/node\", JSON.unparse({\"name\" => name, \"uri\" => uri}), HEADER)\n node = (JSON.parse(r.body) || {})['self'] if [200, 201].include? r.status\n # ADD THE NAME OF THE NEW NODE TO THE INDEX\n node_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"name\\\", \\\"value\\\" : \\\"#{CGI.escape(name)}\\\"}\"\n conn.post(\"/db/data/index/node/#{CGI.escape(namespace)}\", node_data, HEADER)\n # GET OR CREATE NAMESPACE NODE, AND CREATE RELATIONSHIP\n #namespace_node = get_or_create_namespace_node(conn, namespace)\n #get_or_create_relationship(conn, namespace_node, node, 'namespace_of')\n $load_n += 1\n else\n $skip_n += 1\n end\n # RETURN NEO4J'S NODE OBJECT\n node\nend", "def from_node(original_node); end", "def shopify_object\n Nokogiri::XML::Builder.new{ |xml|\n xml.items {\n ShopifyAPI::Product.all.each do |product|\n variant_root = product.variants.first\n xml.item {\n xml.sku variant_root.sku\n # == Google based Parameters ==\n # xml.parent_sku\n # xml.multipack_amount\n # xml.is_bundle\n # == Collections related Parameters ==\n set_product_collections(xml, product)\n # == Variants related Parameters ==\n set_product_variants(xml, product)\n # == Other Parameters ==\n xml.product product.title\n xml.description product.body_html if product.body_html.present?\n xml.brand product.vendor if product.vendor.present?\n xml.gtin variant_root.barcode if variant_root.barcode.present?\n xml.image_url product.image.src if product.image.present?\n xml.price variant_root.price if variant_root.price.present?\n xml.stock_amount variant_root.inventory_quantity if variant_root.inventory_quantity.present?\n xml.stock_available (variant_root.inventory_quantity != 0 ) if variant_root.inventory_quantity.present?\n }\n end\n }\n }.to_xml\n end", "def create_new_customer \n ForestOperations.link_parent_child_nodes_return_parent(\n ForestOperations.create_node(\n line_content[:sent_or_accepted_by],\n :accepted),\n ForestOperations.create_node(\n line_content[:recived_by]\n ) \n )\n end", "def create_invoice_packages\n \n Caboose.log(\"Creating invoice packages...\")\n \n store_config = self.site.store_config \n if !store_config.auto_calculate_packages \n InvoicePackage.custom_invoice_packages(store_config, self)\n return\n end\n \n # Make sure all the line items in the invoice have a quantity of 1\n extra_line_items = []\n self.line_items.each do |li| \n if li.quantity > 1 \n (1..li.quantity).each{ |i| \n extra_line_items << li.copy \n }\n li.quantity = 1\n li.save\n end \n end\n extra_line_items.each do |li| \n li.quantity = 1 \n li.save \n end \n \n # Make sure all the items in the invoice have attributes set\n self.line_items.each do |li| \n v = li.variant\n next if v.downloadable\n Caboose.log(\"Error: variant #{v.id} has a zero weight\") and return false if v.weight.nil? || v.weight == 0\n next if v.volume && v.volume > 0\n Caboose.log(\"Error: variant #{v.id} has a zero length\") and return false if v.length.nil? || v.length == 0\n Caboose.log(\"Error: variant #{v.id} has a zero width\" ) and return false if v.width.nil? || v.width == 0\n Caboose.log(\"Error: variant #{v.id} has a zero height\") and return false if v.height.nil? || v.height == 0 \n v.volume = v.length * v.width * v.height\n v.save\n end\n \n # Reorder the items in the invoice by volume\n line_items = self.line_items.sort_by{ |li| li.quantity * (li.variant.volume ? li.variant.volume : 0.00) * -1 }\n \n # Get all the packages we're going to use \n all_packages = ShippingPackage.where(:site_id => self.site_id).reorder(:flat_rate_price).all \n \n # Now go through each variant and fit it in a new or existing package \n line_items.each do |li| \n next if li.variant.downloadable\n \n # See if the item will fit in any of the existing packages\n it_fits = false\n self.invoice_packages.all.each do |op|\n it_fits = op.fits(li)\n if it_fits \n li.invoice_package_id = op.id\n li.save \n break\n end\n end \n next if it_fits\n \n # Otherwise find the cheapest package the item will fit into\n it_fits = false\n all_packages.each do |sp|\n it_fits = sp.fits(li.variant) \n if it_fits \n op = InvoicePackage.create(:invoice_id => self.id, :shipping_package_id => sp.id)\n li.invoice_package_id = op.id\n li.save \n break\n end\n end\n next if it_fits\n \n Caboose.log(\"Error: line item #{li.id} (#{li.variant.product.title}) does not fit into any package.\") \n end \n end", "def new\n @chef = Chef.new\n end", "def makeInventoryLocation(name, x, y, z, testbedId)\n location = Hash.new\n\n # Fill in that received from CONFINE Portal\n location['name'] = name\n location['x'] = x\n location['y'] = y\n location['z'] = z\n location['testbed_id'] = testbedId\n\t\t\t\n\t\t\t# DUMMY\n\t\t\tlocation['switch_ip'] = '10.0.0.201'\n\t\t\tlocation['switch_port'] = '1'\n\n # return\n location\n end", "def set_creator_node(fnode)\n @node.set_creator_node(fnode)\n end", "def new\n\t\t@user = User.find_by(id: params[:owner])\n\t\t@order = Order.new\n\t\[email protected] = @user.cuisine\n\t\t@cuisine_inventory = get_inventory(@user.cuisine)\n\t\tif @cuisine_inventory.nil?\n\t\t\tflash[:danger] = \"Order failed. Cuisine template unavailable. Contact City Produce.\"\n\t\t\tredirect_to contact_path and return # was render 'new'\t\t\n\t\tend\n#\t\tdebugger\n\t\tif !@cuisine_inventory.lineitems.empty?\n\t\t\t@cuisine_inventory.lineitems.sort.each do |l|\n\t\t\t\[email protected](product_id: l.product_id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tquantity: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tselum: l.selum)\n\t\t\tend\n\t\tend\n#\t\t@full_inventory = get_inventory(\"Inventory\")\n#\t\tdebugger\n\tend", "def create_network_equipment(network_uid, network, refapi_path, site_uid = nil)\n network[\"type\"] = \"network_equipment\"\n network[\"uid\"] = network_uid\n\n network_path = ''\n if site_uid\n network_path = Pathname.new(refapi_path).join(\"sites\", site_uid, \"network_equipments\")\n else\n network_path = Pathname.new(refapi_path).join(\"network_equipments\")\n end\n network_path.mkpath()\n\n # Change the format of linecard from Hash to Array\n linecards_tmp = Marshal.load(Marshal.dump(network[\"linecards\"])) # bkp (deep_copy)\n\n linecards_array = []\n network[\"linecards\"].each do |linecard_index, linecard|\n ports = []\n linecard.delete(\"ports\").each do |port_index, port|\n port = { \"uid\"=> port } if port.is_a? String\n if port.is_a? Hash\n # complete entries (see bug 8587)\n if port['port'].nil? and linecard['port']\n port['port'] = linecard['port']\n end\n if port['kind'].nil? and linecard['kind']\n port['kind'] = linecard['kind']\n end\n if port['snmp_pattern'].nil? and linecard['snmp_pattern']\n port['snmp_pattern'] = linecard['snmp_pattern']\n end\n if port['snmp_pattern']\n port['snmp_name'] = port['snmp_pattern']\n .sub('%LINECARD%',linecard_index.to_s).sub('%PORT%',port_index.to_s)\n port.delete('snmp_pattern')\n end\n if ((!linecard['kind'].nil? &&\n port['kind'].nil? &&\n linecard['kind'] == 'node') ||\n port['kind'] == 'node') &&\n port['port'].nil?\n p = port['uid'].match(/([a-z]*-[0-9]*)-?(.*)/).captures[1]\n port['port'] = p != '' ? p : 'eth0'\n port['uid'] = port['uid'].gsub(/-#{p}$/, '')\n end\n end\n ports[port_index] = port\n end\n linecard[\"ports\"] = ports.map { |p| p || {} }\n linecards_array[linecard_index] = linecard\n end\n network[\"linecards\"] = linecards_array.map{|l| l || {}}\n\n network.delete_if {|k, v| k == \"network_adapters\"} # TO DELETE\n\n write_json(network_path.join(\"#{network_uid}.json\"), network)\n\n network[\"linecards\"] = linecards_tmp # restore\nend", "def config_lv_define_box2(vm, conf)\n vm.define conf['hostname_box2'] do |box2|\n box2.vm.hostname = conf['hostname_box2']\n box2.vm.box = conf['imagename_box2']\n box2.vm.network :private_network,\n :libvirt__network_name => \"mgmt\",\n :mac => conf['libvirt_mgmt_mac_box2'],\n :ip => conf['libvirt_mgmt_ip_box2'],\n :libvirt__netmask => conf['libvirt_mgmt_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.network :public_network,\n :network_name => \"ext\",\n :ip => conf['libvirt_ext_ip_box2'],\n :netmask => conf['libvirt_ext_netmask_box2'],\n :gateway => conf['libvirt_ext_gateway_box2'],\n :mac => conf['libvirt_ext_mac_box2'],\n :dev => conf['libvirt_dev'],\n :type => conf['libvirt_type'],\n :mode => conf['libvirt_mode']\n box2.vm.network :private_network,\n :libvirt__network_name => \"ceph\",\n :mac => conf['libvirt_ceph_mac_box2'],\n :ip => conf['libvirt_ceph_ip_box2'],\n :libvirt__netmask => conf['libvirt_ceph_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.network :private_network,\n :libvirt__network_name => \"vm_tunnel\",\n :mac => conf['libvirt_tunnel_mac_box2'],\n :ip => conf['libvirt_tunnel_ip_box2'],\n :libvirt__netmask => conf['libvirt_tunnel_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.provider :libvirt do |domain|\n domain.memory = conf['memory_box2']\n domain.cpus = conf['cpus_box2']\n domain.management_network_name = 'vagrantmgmt'\n domain.management_network_address = conf['libvirt_vagrantmgmt_ip_box2']\n domain.management_network_mode = conf['libvirt_mgmt_mode']\n end\n config_provision(box2.vm, conf)\n end\nend", "def create!\n Subnet.reserve(@subnet)\n super\n Address.mkdir(@id)\n PoolNode.mkdir(@id)\n create_address(gateway)\n end", "def edit(entry)\n return \"Node hostname cannot be empty!\" if entry['hostname'].empty?\n load\n doc = REXML::Element.new(\"NODE\")\n doc.add_attributes(entry)\n if entry['oldname'].empty?\n # adding a new node\n @@nds.each{|n|\n return \"'#{n['hostname']}' already exists!\" if n['hostname'] == entry['hostname'] && n['testbed'] == entry['testbed']\n }\n result = OMF::Services.inventory.addNode(doc.to_s)\n return AM_ERROR if !XPath.match(result, \"ADD_NODE/OK\" )\n else\n # update an existing entry\n @@nds.collect! {|n|\n if n['hostname'] == entry['oldname']\n n = entry\n n.delete('oldname')\n end\n n\n }\n end\n saveDnsmasqConfig\n return \"OK\"\n end", "def master_node\n {:nodename => @master_nodename}\n end", "def new\n prepare_options\n @inventory_shelf_barcode = InventoryShelfBarcode.new(inventory_manage_id: @inventory_manage.id)\n puts @inventory_shelf_barcode.inventory_manage.id\n end", "def create_res_edge(from, to, res_capacity)\n edge = Edge.new(from, to)\n class << edge; class_eval \"attr_accessor :res_capacity\"; end\n edge.res_capacity = res_capacity\n @edges[from] ||= []\n @edges[from] << edge\n end", "def init_node\n end", "def init_node\n end", "def initialize(node)\n @items = [node]\n end", "def establish_slots(node, document)\n (document.out_slots + document.in_slots).each do |slot|\n next if slot.carrier == :coupling_carrier\n\n collection = node.slots.public_send(slot.direction)\n\n ref_slot =\n if collection.include?(slot.carrier)\n collection.get(slot.carrier)\n else\n collection.add(slot.carrier)\n end\n\n ref_slot.set(:model, slot)\n ref_slot.set(:type, :elastic) if slot.is_a?(Slot::Elastic)\n end\n end", "def defNodeHostname(jobid, nodeList)\n hosts = %x(uniq /var/lib/oar/#{jobid} && echo $?)\n hostList = hosts.split(\"\\n\") \n if(hostList.delete_at(hostList.size-1).to_i != 0)\n STDERR.puts hosts\n exit 1\n end\n if hostList.size < nodeList.size\n STDERR.puts \"Not enough nodes in the reservation\"\n STDERR.puts \"You must have #{nodeList.size} nodes\"\n exit 1\n end\n i=0\n nodeList.each do |v|\n v.setNodeRealName(hostList[i])\n i+=1 \n end\n end", "def initialize(new_part, parent = nil, network: :testnet)\n @type = TYPE\n @network = network\n\n @newPart = new_part\n @parent = parent\n @rentalFee = rental[:fee]\n @rentalFeeSink = rental[:sink]\n\n @fee = Nis::Fee::ProvisionNamespace.new(self)\n end", "def new\n @pack = @reservation.pack\n end", "def create_vm(config, node_name)\n config.vm.define node_name do |vm|\n vm.vm.host_name = node_name\n vm.vm.network \"private_network\", type: \"dhcp\"\n vm.vm.box = \"ubuntu/xenial64\"\n end\nend", "def provision(node)\n node_inventory = node.inventory\n node_ipaddress_fact = @config.settings[\"target\"][\"ipaddress_fact\"] || \"ipaddress\"\n master_ipaddress_fact = @config.settings[\"master\"][\"ipaddress_fact\"] || \"ipaddress\"\n\n raise \"Could not determine node ip address from fact #{node_ipaddress_fact}\" unless node_inventory[:facts].include?(node_ipaddress_fact)\n\n steps = @config.settings[\"steps\"].keys.select{|s| @config.settings[\"steps\"][s] }\n MCProvision.info(\"Provisioning #{node.hostname} / #{node_inventory[:facts][node_ipaddress_fact]} with steps #{steps.join ' '}\")\n\n\n chosen_master, master_inventory = pick_master_from(@config.settings[\"master\"][\"criteria\"], node_inventory[:facts])\n\n raise \"Could not determine master ip address from fact #{master_ipaddress_fact}\" unless master_inventory[:facts].include?(master_ipaddress_fact)\n master_ip = master_inventory[:facts][master_ipaddress_fact]\n\n MCProvision.info(\"Provisioning node against #{chosen_master.hostname} / #{master_ip}\")\n\n node.lock if @config.settings[\"steps\"][\"lock\"]\n\n node.set_puppet_host(master_ip) if @config.settings[\"steps\"][\"set_puppet_hostname\"]\n\n # Only do certificate management if the node is clean and doesnt already have a cert\n unless node.has_cert?\n @master.clean_cert(node.hostname.downcase) if @config.settings[\"steps\"][\"clean_node_certname\"]\n\n node.send_csr if @config.settings[\"steps\"][\"send_node_csr\"]\n\n @master.sign(node.hostname.downcase) if @config.settings[\"steps\"][\"sign_node_csr\"]\n else\n MCProvision.info(\"Skipping SSL certificate management for node - already has a cert\")\n end\n\n node.bootstrap if @config.settings[\"steps\"][\"puppet_bootstrap_stage\"]\n node.run_puppet if @config.settings[\"steps\"][\"puppet_final_run\"]\n node.unlock if @config.settings[\"steps\"][\"unlock\"]\n node.flag if @config.settings[\"steps\"][\"flag\"]\n @notifier.notify(\"Provisioned #{node.hostname} against #{chosen_master.hostname}\", \"New Node\") if @config.settings[\"steps\"][\"notify\"]\n end", "def node=(node)\n items_node[:node] = node\n end", "def delivery_chef_server(node)\n server_details = {}\n ::Chef_Delivery::ClientHelper.enter_client_mode_as_delivery\n server_details[:chef_server_url] = Chef::Config[:chef_server_url]\n server_details[:options] = {\n client_name: ::Chef::Config[:node_name],\n signing_key_filename: ::Chef::Config[:client_key]\n }\n ::Chef_Delivery::ClientHelper.leave_client_mode_as_delivery\n server_details\n end", "def create_node(node, host, &block)\n pubsub.create_with_configuration(node, PUBSUB_CONFIGURE, host, &callback_logging(__method__, node, &block))\n end", "def generate_new_item_object\n @new_item = Flight.new\n insert_required_params_into_new_item_object\n insert_default_params_into_new_item_object\n insert_optional_params_into_new_item_object(self)\n return @new_item\n end", "def create_item()\n\n request_body = {\n 'name' => 'Milkshake',\n 'variations' => [\n {\n 'name' => 'Small',\n 'pricing_type' => 'FIXED_PRICING',\n 'price_money' => {\n 'currency_code' => 'USD',\n 'amount' => 400\n }\n }\n ]\n }\n\n response = Unirest.post CONNECT_HOST + '/v1/' + LOCATION_ID + '/items',\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully created item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item creation failed'\n puts response.body\n return nil\n end\nend", "def create_line_item_for_per_person_charge_2 qty, event_vendor, include_price_in_expense, include_price_in_revenue, notes\n # Vendor\n l1 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Fee\",\n :sku => \"MT-\" + event_vendor.menu_template_id.to_s.rjust(7, '0'), :name => \"* Per Person Charge (\" + event_vendor.vendor.name + \")\", :quantity => qty,\n :unit_price_expense => event_vendor.calculate_menu_level_cogs,\n :tax_rate_expense => 0,\n :payable_party => event_vendor.vendor,\n :include_price_in_expense => include_price_in_expense,\n :menu_template => event_vendor.menu_template, :event => self)\n\n # Account\n l2 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Fee\",\n :sku => \"MT-\" + event_vendor.menu_template_id.to_s.rjust(7, '0'), :name => \"* Per Person Charge (\" + event_vendor.vendor.name + \")\", :quantity => qty,\n :unit_price_revenue => event_vendor.calculate_menu_level_sell_price,\n :billable_party => account,\n :include_price_in_revenue => include_price_in_revenue,\n :menu_template => event_vendor.menu_template, :event => self)\n\n l1.opposing_line_item = l2\n l2.opposing_line_item = l1\n l1.save\n l2.save\n \n [l1, l2]\n end", "def construct(x, y, item_type)\n item = Item.new(item_type)\n\n raise Errors::SpaceUnavailbleError.new unless can_build?(x,y)\n raise Errors::NotEnoughMoneyError.new unless can_afford?(item)\n\n # currently all items are 1x1\n grid.grid[x][y] = item\n\n # This has to be marked as self.money not money and i'm not sure why\n self.money -= item.cost\n end", "def inflate_node(node_data)\n node_data['chef_environment'] ||= @chef_environment if @chef_environment\n node_data['attributes'] = inflate_attrs(node_data)\n if @tags\n node_data['tags'] ||= []\n node_data['tags'] |= @tags\n end\n node_data\n end", "def new_node(addrinfo)\n ip = extract_ip addrinfo\n\n found = search_node ip\n\n if found\n raise Errors::NodeAlreadyKnownError, \"Node #{found} already known\"\n end\n\n node = Node.new(ip)\n @known_nodes << node\n end", "def build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend", "def create\n chef_server_rest.post(\"nodes\", data_for_save)\n self\n rescue Net::HTTPClientException => e\n # Chef Server before 12.3 rejects node JSON with 'policy_name' or\n # 'policy_group' keys, but 'policy_name' will be detected first.\n # Backcompat can be removed in 13.0\n if e.response.code == \"400\" && e.response.body.include?(\"Invalid key policy_name\")\n chef_server_rest.post(\"nodes\", data_for_save_without_policyfile_attrs)\n else\n raise\n end\n end", "def nodesCreate\n nodes=Array.new\n @parser.getAllNodes.each do |node|\n nodes.push(Node.new(@parser.getNodeName(node), @parser.getOS(node)))\n nodes.last.interfaces=interfacesCreate(node)\n nodes.last.toInstall=listToInstall(node)\n end\n return nodes\n end", "def inventory_discovery (fileVInventory, fileAInventory, ipMap, groups)\n\n # set proxy if defined in ENV\n proxy = \"\"\n if (ENV.has_key?('HTTP_PROXY'))\n proxy = ENV['HTTP_PROXY']\n end\n if (ENV.has_key?('http_proxy'))\n proxy = ENV['http_proxy']\n end\n\n # Initialize variable to keep track of group name\n groupName = \"\"\n nodeCount = 0\n\n # Read Vagrant inventory file\n File.open(fileVInventory, \"r\") do |f|\n\n # For each line in the inventory file\n f.each_line do |line|\n\n # Remove comments\n line = line.gsub(/#.*/, '')\n\n # If the line has a group name\n if (line =~ /\\[(.*)\\]/)\n\n # Remember the group name\n\tgroupName = $1\n\tnodeCount = 1 \n\n\t# If this group name is not in the hash, then set it up and use defaults\n\tif (!groups.has_key?(groupName))\n\t groups[groupName] = {}\n groups[\"default\"].each do |parameterName, parameter|\n\t groups[groupName][parameterName] = parameter\n end\n if (!(groups[groupName][\":kubernetes_stem\"] == \"true\") && (proxy != \"\"))\n groups[groupName][\":proxy\"] = proxy\n end\n end\n\n # If the line contains an IP address\n elsif (line =~ /:ip\\s+([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)/)\n\n ipaddrs = line.split(\" \")\n\n\t# Initialize IP address list if needed\n\tif (!groups[groupName].has_key?(\":ip\"))\n\t groups[groupName][\":ip\"] = []\n\tend\n\n # Generate node name\n nodeName = groupName + groups[groupName][\":format\"] % nodeCount\n nodeCount = nodeCount + 1\n\n\t# Record critical information for IP address\n groups[groupName][\":ip\"] << $1\n\tif (!ipMap.has_key?($1))\n\t ipMap[$1] = {}\n if (ipaddrs.length == 3)\n ipMap[$1][\":extip\"] = ipaddrs[2]\n end\n ipMap[$1][\":hostname\"] = nodeName\n\t ipMap[$1][\":box\"] = groups[groupName][\":box\"]\n\t ipMap[$1][\":memory\"] = 0.0\n\t ipMap[$1][\":cores\"] = 0.0\n\t if (!(groups[groupName][\":kubernetes_stem\"] == \"true\"))\n\t if (groups[groupName].has_key?(\":proxy\"))\n\t ipMap[$1][\":proxy\"] = groups[groupName][\":proxy\"]\n\t end\n else\n ipMap[$1][\":kubernetes_stem\"] = groups[groupName][\":kubernetes_stem\"]\n end\n end\n ipMap[$1][\":memory\"] += groups[groupName][\":memory\"].to_f\n ipMap[$1][\":cores\"] += groups[groupName][\":cores\"].to_f\n\n # Generic group information\n elsif (line =~ /(:\\S+)\\s+(\\S+)/)\n\n groups[groupName][$1] = $2\n\n\n end\n\n end\n\n end\n\n # Write Ansible inventory file\n File.open(fileAInventory, \"w\") do |f|\n\n # Find current Vagrant home directory\n vagrantHome = File.dirname(__FILE__)\n\n # Set up the group vars for kubernetes. You must use kubernetes and not \n # mesos_proxy since this will break the proxy env that vagrant\n # sets up.\n top_level_group = 'kubernetes'\n f.puts \"[\" + top_level_group + \":children]\"\n\n flannel_var = '' \n if (groups['default'].has_key?(':flannel_interface'))\n flannel_var = ' flannel_interface=' + groups['default'][':flannel_interface']\n end\n provider = 'virtualbox'\n if (groups['default'].has_key?(':provider'))\n provider = groups['default'][':provider']\n end\n puts \"provider \" + provider\n\n groups.each do |groupName, group|\n if groupName == 'default'\n next\n end\n f.puts groupName\n end\n\n # For each group...\n groups.each do |groupName, group|\n\n # Print out group name\n if (groupName != \"default\")\n f.puts \"[\" + groupName + \"]\"\n end\n\n if (group.has_key?(\":ip\"))\n\n # For each ip address in the group...\n group[\":ip\"].each do |ip|\n\n\t multiple_registry_hosts = \"\"\n if (group.has_key?(\":multiple_registry_hosts\"))\n multiple_registry_hosts = \" multiple_registry_hosts=\" + group[\":multiple_registry_hosts\"]\n end\n\n use_vault_opt = \"\"\n\t if (group.has_key?(\":use_vault\"))\n use_vault_opt = \" use_vault=\" + group[\":use_vault\"]\n end\n\n\t # Generate the inventory entry\n # you need ansible_ssh_user for < 2.0 ansible, which most setups in picasso group\n # is using currently\n line = ipMap[ip][\":hostname\"] + \" ansible_ssh_host=\" + ip +\n\t \" ansible_ssh_user=vagrant ansible_user=vagrant ansible_ssh_private_key_file=\" +\n vagrantHome + \"/.vagrant/machines/\" + ipMap[ip][\":hostname\"] + \"/\" + provider + \"/private_key\" +\n multiple_registry_hosts + flannel_var + use_vault_opt\n\n f.puts line\n\n end\n\n end\n\n f.puts \"\"\n\n end\n\n end\n\nend", "def createH2KSysType2( elements, sysType2Name )\n\n locationText = \"HouseFile/House/HeatingCooling/Type2\"\n elements[locationText].add_element(sysType2Name)\n elements[locationText].attributes[\"shadingInF280Cooling\"] = \"AccountedFor\"\n\n if ( sysType2Name == \"AirHeatPump\" )\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump\"\n elements[locationText].add_element(\"EquipmentInformation\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/EquipmentInformation\"\n elements[locationText].attributes[\"energystar\"] = \"false\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump\"\n elements[locationText].add_element(\"Equipment\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Equipment\"\n elements[locationText].attributes[\"crankcaseHeater\"] = \"60\"\n elements[locationText].add_element(\"Type\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Equipment/Type\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Equipment\"\n elements[locationText].add_element(\"Function\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Equipment/Function\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump\"\n elements[locationText].add_element(\"Specifications\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Specifications\"\n elements[locationText].add_element(\"OutputCapacity\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\"\n # I think these can be commented out if we default to 'calculated'\n #elements[locationText].attributes[\"value\"] = \"\"\n #elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Specifications\"\n elements[locationText].add_element(\"HeatingEfficiency\")\n elements[locationText].add_element(\"CoolingEfficiency\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Specifications/HeatingEfficiency\"\n elements[locationText].attributes[\"isCop\"] = \"true\"\n elements[locationText].attributes[\"value\"] = \"2\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Specifications/CoolingEfficiency\"\n elements[locationText].attributes[\"isCop\"] = \"true\"\n elements[locationText].attributes[\"value\"] = \"2\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump\"\n elements[locationText].add_element(\"Temperature\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Temperature\"\n elements[locationText].add_element(\"CutoffType\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Temperature/CutoffType\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].attributes[\"value\"] = \"0\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Temperature\"\n elements[locationText].add_element(\"RatingType\")\n\n # CHECK this - should be 8.3 ?\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/Temperature/RatingType\"\n elements[locationText].attributes[\"code\"] = \"3\"\n elements[locationText].attributes[\"value\"] = \"-5.0\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump\"\n elements[locationText].add_element(\"CoolingParameters\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/CoolingParameters\"\n elements[locationText].attributes[\"sensibleHeatRatio\"] = \"0.76\"\n elements[locationText].attributes[\"openableWindowArea\"] = \"20\"\n\n elements[locationText].add_element(\"FansAndPump\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/CoolingParameters/FansAndPump\"\n # Do we need to set this? what should we set it to?\n elements[locationText].attributes[\"flowRate\"] = \"700\"\n\n elements[locationText].add_element(\"Mode\")\n elements[locationText].add_element(\"Power\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/CoolingParameters/FansAndPump/Mode\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirHeatPump/CoolingParameters/FansAndPump/Power\"\n elements[locationText].attributes[\"isCalculated\"] = \"true\"\n\n elsif ( sysType2Name == \"WaterHeatPump\" )\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/EquipmentInformation\"\n elements[locationText].attributes[\"canCsaC448\"] = \"false\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Equipment\"\n elements[locationText].attributes[\"crankcaseHeater\"] = \"0\"\n elements[locationText].add_element(\"Function\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Equipment/Function\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Specifications\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].attributes[\"value\"] = \"21.5\"\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Specifications\"\n elements[locationText].add_element(\"HeatingEfficiency\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Specifications/HeatingEfficiency\"\n elements[locationText].attributes[\"isCop\"] = \"true\"\n elements[locationText].attributes[\"value\"] = \"3\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump\"\n elements[locationText].add_element(\"Temperature\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Temperature\"\n elements[locationText].add_element(\"CutOffType\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Temperature/CutOffType\"\n elements[locationText].attributes[\"code\"] = \"3\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Temperature\"\n elements[locationText].add_element(\"RatingType\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/Temperature/RatingType\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].attributes[\"value\"] = \"8.3\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump\"\n elements[locationText].add_element(\"SourceTemperature\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/SourceTemperature\"\n elements[locationText].attributes[\"depth\"] = \"1.5\"\n elements[locationText].add_element(\"Use\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/WaterHeatPump/SourceTemperature/Use\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n elsif ( sysType2Name == \"GroundHeatPump\" )\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/EquipmentInformation\"\n elements[locationText].attributes[\"canCsaC448\"] = \"false\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Equipment\"\n elements[locationText].attributes[\"crankcaseHeater\"] = \"0\"\n elements[locationText].add_element(\"Function\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Equipment/Function\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Specifications\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].attributes[\"value\"] = \"21.5\"\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Specifications\"\n elements[locationText].add_element(\"HeatingEfficiency\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Specifications/HeatingEfficiency\"\n elements[locationText].attributes[\"isCop\"] = \"true\"\n elements[locationText].attributes[\"value\"] = \"3\"\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Specifications\"\n elements[locationText].add_element(\"CoolingEfficiency\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Specifications/CoolingEfficiency\"\n elements[locationText].attributes[\"isCop\"] = \"true\"\n elements[locationText].attributes[\"value\"] = \"3\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump\"\n elements[locationText].add_element(\"Temperature\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Temperature\"\n elements[locationText].add_element(\"CutoffType\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Temperature/CutoffType\"\n elements[locationText].attributes[\"code\"] = \"3\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Temperature\"\n elements[locationText].add_element(\"RatingType\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/Temperature/RatingType\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].attributes[\"value\"] = \"8.3\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump\"\n elements[locationText].add_element(\"SourceTemperature\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/SourceTemperature\"\n elements[locationText].attributes[\"depth\"] = \"1.5\"\n elements[locationText].add_element(\"Use\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/SourceTemperature/Use\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump\"\n elements[locationText].add_element(\"CoolingParameters\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/CoolingParameters\"\n elements[locationText].attributes[\"sensibleHeatRatio\"] = \"0.76\"\n elements[locationText].attributes[\"openableWindowArea\"] = \"20\"\n\n elements[locationText].add_element(\"FansAndPump\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/CoolingParameters/FansAndPump\"\n # Do we need to set this? what should we set it to?\n elements[locationText].attributes[\"flowRate\"] = \"360\"\n\n elements[locationText].add_element(\"Mode\")\n elements[locationText].add_element(\"Power\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/CoolingParameters/FansAndPump/Mode\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/GroundHeatPump/CoolingParameters/FansAndPump/Power\"\n elements[locationText].attributes[\"isCalculated\"] = \"true\"\n\n elsif ( sysType2Name == \"AirConditioning\" )\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/EquipmentInformation\"\n elements[locationText].attributes[\"energystar\"] = \"false\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/Equipment\"\n elements[locationText].attributes[\"crankcaseHeater\"] = \"60\"\n elements[locationText].add_element(\"CentralType\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/Equipment/CentralType\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1\"\n elements[locationText].add_element(\"RatedCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/Specifications/RatedCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].attributes[\"value\"] = \"0\"\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/Specifications\"\n elements[locationText].add_element(\"Efficiency\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/Specifications/Efficiency\"\n elements[locationText].attributes[\"isCop\"] = \"true\"\n elements[locationText].attributes[\"value\"] = \"3\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning\"\n elements[locationText].add_element(\"CoolingParameters\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/CoolingParameters\"\n elements[locationText].attributes[\"sensibleHeatRatio\"] = \"0.76\"\n elements[locationText].attributes[\"openableWindowArea\"] = \"20\"\n elements[locationText].add_element(\"FansAndPump\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/CoolingParameters/FansAndPump\"\n elements[locationText].attributes[\"flowRate\"] = \"0\"\n elements[locationText].add_element(\"Mode\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/CoolingParameters/FansAndPump/Mode\"\n elements[locationText].attributes[\"code\"] = \"1\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/CoolingParameters/FansAndPump\"\n elements[locationText].add_element(\"Power\")\n locationText = \"HouseFile/House/HeatingCooling/Type2/AirConditioning/CoolingParameters/FansAndPump/Power\"\n elements[locationText].attributes[\"isCalculated\"] = \"true\"\n end\nend", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end" ]
[ "0.5573708", "0.5483965", "0.5400582", "0.53877926", "0.5267932", "0.5244332", "0.5167308", "0.5121926", "0.5055073", "0.5019252", "0.50184184", "0.50074005", "0.49931866", "0.49676597", "0.49610743", "0.49585003", "0.49441966", "0.494206", "0.4935568", "0.49232703", "0.49203753", "0.49117982", "0.49090827", "0.49021536", "0.4899856", "0.48998323", "0.48894313", "0.48863435", "0.48630857", "0.4862444", "0.48605785", "0.48600933", "0.4847836", "0.4840533", "0.48363528", "0.48206946", "0.48062536", "0.4798159", "0.47939438", "0.47916856", "0.47907436", "0.47896868", "0.47754738", "0.47744757", "0.47644356", "0.4763964", "0.47572798", "0.47473097", "0.47395608", "0.47385824", "0.47367898", "0.47295433", "0.470866", "0.47013578", "0.47005817", "0.46999943", "0.46975172", "0.46942776", "0.46912417", "0.4689908", "0.46887416", "0.46887416", "0.46881816", "0.46870562", "0.4686059", "0.468396", "0.4675022", "0.46698776", "0.46657476", "0.4660225", "0.4653907", "0.46516362", "0.46494478", "0.46469492", "0.46447918", "0.4637414", "0.46354046", "0.46346182", "0.4632951", "0.46204305", "0.4620068", "0.46122608", "0.46105635", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108", "0.46090108" ]
0.68695194
0
asserts that no N+1s were detected during the block's execution
def assert_optimized_queries assert_nothing_raised { Prosopite.scan { yield } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_block_count_correct_false\n assert_equal(false, @bv.block_count_correct?(1, [1,2,3,4]))\n end", "def test_check_block_num_unequal\r\n assert_nil nil, @g.check_block_num(1, 0)\r\n end", "def test_block_count_correct_true\n assert @bv.block_count_correct?(1, [1,2,3,4,5])\n end", "def exactly(n, &block)\n (1..n).all? { try(&block) }\n end", "def test_check_block_num_equal\r\n assert_equal true, @g.check_block_num(1, 1)\r\n end", "def test_blocks_not_consecutive\n block_num_checker = BlockNumChecker::new\n arr = [0,1,2,8,4,5,6]\n assert_equal 1, block_num_checker.check_block(arr)\n end", "def test_block_number_correct_false\n assert_equal(false, @bv.block_number_correct?(0, 1))\n end", "def assert_no_error_reported(&block)\n reports = ErrorCollector.record do\n _assert_nothing_raised_or_warn(\"assert_no_error_reported\", &block)\n end\n assert_predicate(reports, :empty?)\n end", "def test_block_number_correct_true\n assert @bv.block_number_correct?(1, 1)\n end", "def check_for_implication_loops\n # actually this is tricky\n end", "def test_check_good_block\n line = ['0', '0', 'SYSTEM>569274(100)', '1553184699.650330000', '288d']\n line_num = 1\n assert_output(nil) { @verify.check_block(line, line_num) }\n end", "def test(m,n,&block)\n\tif (m > 20000)\n\t\treturn\n\tend\n\n\tyield(m,n)\n\ttest(2*m - n, m, &block)\n\ttest(2*m + n, m, &block)\n\t#if (n != 1)\n\t#test(m + 2*n, n, &block)\n\t#end\nend", "def verify\n insns[0...-1].each { |insn| raise unless insn.branch_targets.empty? }\n end", "def pending(&block)\n begin\n @__assert_pending__ += 1\n instance_eval(&block)\n ensure\n @__assert_pending__ -= 1\n end\n end", "def step\n any_independent = false\n net.edges.each do |e|\n a, b = e.source, e.target\n intersect = (@net.adjacent_either(a, b) & @net.verts_on_paths(a, b)).extend(PowerSet)\n \n # Is |Aab ^ Uab| > n? \n if intersect.length <= n\n next\n else\n # Are a and b independent conditioned on any subsets of Aab ^ Uab of cardinality n+1?\n valid_intersects = intersect.power_set.select {|s| s.length == n+1}.reject { |subset| subset.include?(a) || subset.include?(b) }\n if valid_intersects.any? { |subset|\n print \"Testing independence between #{a.name} and #{b.name}, conditioning on #{(subset.any? ? subset.map(&:name).join(', ') : 'nothing') + '...'}\"\n print (coindependent?(p_value, a, b, *subset) ? \"[+]\\n\" : \"[-]\\n\")\n coindependent?(p_value, a, b, *subset)\n }\n @net = remove_edge(net, e)\n net.edges.each do |e|\n puts \"#{e.source.name} => #{e.target.name}\"\n end\n any_independent = true\n end\n end\n end\n @n += 1\n any_independent\n end", "def skip_or_pending_inside_block?(param0 = T.unsafe(nil)); end", "def missing_one_at_either_end\n [2,3].each { |i|\n return true if @counts[i]>0 && @counts[i+1]>0 && @counts[i+2]>0\n }\n return false\n end", "def check_block_num(curr_block)\n # make sure number of blocks is in order starting at 0\n return unless curr_block.block_number.to_i != @curr_count\n\n @block_num_error = true\n puts \"Line #{curr_count}: Invalid block number #{curr_block.block_number}, should be #{curr_count} \"\n puts 'BLOCKCHAIN INVALID'\n exit 1\n end", "def test_valid_block_number\n assert check_block_number('0', 0)\n end", "def test_does_not_have_zero\n skip\n numbers = [3, 1, 3, 2, 4, 9, 8]\n has_zero = false\n # write code here\n refute has_zero\n end", "def verify_block_num\r\n unless @block_number == @@total_block_number\r\n raise \"Line #{@@total_block_number}: invalid block number #{@block_number}, should be #{@@total_block_number}\"\r\n\r\n end\r\n\r\n true\r\n end", "def test_block_zero_valid\n text = []\n File.open(\"sample.txt\", \"r\") do |f|\n f.each_line do |line|\n text << line\n end\n end\n assert_equal true , @ver.incrementCorrectly(text)\n\n end", "def test_that_full_tile_rack_doesnt_need_any_tiles\n 7.times{|num| @newTileRack.append(:A)}\n assert_equal(0,@newTileRack.number_of_tiles_needed)\n end", "def test_no_task()\n [0, 10].each() do |concurrent_duties|\n [true, false].each() do |persistent_workers|\n [true, false].each() do |perform_now|\n assert_nothing_thrown() do\n s = generate_spawner(concurrent_duties, persistent_workers, 0,\n @jobs_log_file, @spawner_log_file)\n generate_tasks_addition(s, 0, perform_now, 2) {}\n end\n\n assert_equal(0, File.stat(@jobs_log_file).size(), \"The jobs log is not empty, while it should\")\n end\n end\n end\n end", "def warn_no_continuations; end", "def test_num_transactions_correct_not_0_true\n assert @bv.num_transactions_correct?(1, [0,2,3])\n end", "def assert\n# puts \"Processing...\"\n raise \"Assertion failed!\" unless yield \n puts \"True!\"\nend", "def exactly?(arr, n, &blck)\n # n == arr.count { |el| blck.call(el) }\n counter = 0\n arr.each do |el|\n counter += 1 if blck.call(el)\n end\n return counter == n\nend", "def assert(num)\n raise \"Assertion test number #{num} failed\" unless yield\n puts \"Assertion test #{num} passed\"\nend", "def test_check_bad_block\n assert_raises SystemExit do\n assert_output \"Line 1: Invalid block, missing or extra element(s)\\nBLOCKCHAIN INVALID\" do\n line = ['0', '0', 'SYSTEM>569274(100)', '1553184699.650330000', '288d', '']\n line_num = 1\n @verify.check_block(line, line_num)\n end\n end\n end", "def assert_no_enqueued_emails(&block)\n assert_enqueued_emails 0, &block\n end", "def test_check_num\n assert_raises SystemExit do\n assert_output 'Line 2: Invalid block number 1, should be 2\\nBLOCKCHAIN INVALID' do\n block_no = '1'\n line_no = '2'\n @verify.check_num(block_no, line_no)\n end\n end\n end", "def assert\n\traise \"Mr. Fibonacci is not working\" unless yield\nend", "def check_for_infinite_loop(processed_source, offenses_by_iteration); end", "def test_exercise_1127\n @rec_calls = 0\n binomial(10, 4, 0.25)\n predicate = Proc.new { |actual|\n Math.log10(actual).truncate == Math.log10(@rec_calls).truncate\n }\n\n params = [10, 4]\n verify_method :exercise_1127,\n :with => [{params: params, predicate: predicate}]\n end", "def test_empty_tasks()\n [3, 10].each() do |concurrent_duties|\n [true, false].each() do |persistent_workers|\n [true, false].each() do |perform_now|\n assert_nothing_thrown() do\n s = generate_spawner(concurrent_duties, persistent_workers, 0,\n @jobs_log_file, @spawner_log_file)\n generate_tasks_addition(s, 10, perform_now, 3) {}\n end\n\n assert_equal(0, File.stat(@jobs_log_file).size(), \"The jobs log is not empty, while it should\")\n end\n end\n end\n end", "def test_multiple_validity\n @eval.load_stacks([5, 6, 7])\n assert_equal nil, @eval.check_final_validity\n end", "def assert\n puts \"Processing...\"\n raise \"Assertion failed!\" unless yield \n puts \"True!\"\nend", "def assert_consistent test\n test.flunk unless state == A or state == Enter\n end", "def assert_no_emails(&block)\n assert_emails 0, &block\n end", "def test_check_first_bad_address_non_num\n assert_raises SystemExit do\n assert_output 'Line 1: Invalid address 1ab4c67\\nBLOCKCHAIN INVALID' do\n add = %w[1ab4c67 123456]\n line_num = 1\n @verify.check_addresses(add, line_num)\n end\n end\n end", "def test_suicide_duty()\n [1, 2].each() do |concurrent_duties|\n [true, false].each() do |persistent_workers|\n assert_nothing_thrown() do\n s = generate_spawner(concurrent_duties, persistent_workers, 0,\n @jobs_log_file, @spawner_log_file)\n\n generate_tasks_addition(s, 2, true, 2) {exit 42}\n end\n end\n end\n end", "def assert_1\n raise \"Invalid argument\" unless yield\nend", "def test_exercise_1128\n verify_method :exercise_1128,\n :with => [{param: [0, 0, 1, 2, 3, 3], expect: [0, 1, 2, 3]},\n {param: [0, 1, 2, 3], expect: [0, 1, 2, 3]},\n {param: [0, 0], expect: [0]},\n {param: [0], expect: [0]}]\n end", "def warn_no_continuations\n end", "def check_unconsumed\n return if chunks.empty?\n $stderr.puts \"WARNING: line not consumed: #{@chunks}; (line: '#{@line}')\"\n end", "def assert\n\t# if yield\n\t# \tputs \"true\"\n\traise \"Assertion failed\" unless yield \n# end \nend", "def many(&block)\n return false unless try(&block)\n while try(&block); end\n true\n end", "def test_verify_n_clues\n p = puzzle.clone\n p.instance_variable_set :@n_clues, p.clues.length - 2\n assert_raise(RuntimeError) { p.verify }\n end", "def assert_no_difference(expression, &block)\n assert_difference expression, 0, &block\n end", "def never\n times 0\n end", "def around(n)\n if n.zero?\n signal :done\n else\n @node.async.around n - 1\n end\n end", "def check_consistency count\n raise \"Not implemented\"\n end", "def assert\n\tputs \"Assertion Failed!\" unless yield\nend", "def test_num_transactions_correct_0_true\n assert_equal(false, @bv.num_transactions_correct?(0, [0,1]))\n end", "def test_exercise_1119\n expected_result = nil\n time_span = time_block { expected_result = calc_all_fibonacci 20 }\n verify_method :exercise_1119,\n :with => {param: 20, expect: expected_result}\n\n actual_time_span = time_block { @target.exercise_1119 20 }\n\n assert_true actual_time_span < time_span / 5\n end", "def executeAssertionBlock(block)\n !!block.call(object)\n end", "def test_next_no_neighbors\r\n\t\tassert_nil @t.next\r\n\tend", "def at_least?(arr, n, &blck)\n count = 0\n arr.each do |el|\n count += 1 if blck.call(el)\n end\n count >= n\nend", "def test_num_transactions_correct_0_true\n assert @bv.num_transactions_correct(0, [0])\n end", "def test_one_validity\n @eval.load_stacks([5])\n assert_equal 'valid', @eval.check_final_validity\n end", "def assert\n raise \"Assertion failed!\" unless yield #unless yield, is saying unless true\nend", "def one_rv\n count = 0\n for x in [email protected]\n if @elements[x].remaining_vals.length == 1\n count+=1\n end\n end\n count\n end", "def my_none?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == false\n end\n return true if counter == size\n\n false\n end", "def test_deck_draw_emptyDeck\n deck = Deck.new\n assert_nothing_raised {81.times {deck.draw}}\n end", "def check_block_number(index_num, block)\n if index_num != block.block_number\n puts \"Line #{index_num}: Invalid block number #{block.block_number}, should be #{index_num}\"\n return false\n end\n true\n end", "def expected_count?\n return !!expected_count\n end", "def exactly?(arr, n , &prc)\n count = 0\n arr.each do |ele|\n count += 1 if prc.call(ele)\n end\n return true if n == count\n false\nend", "def test_check_first_bad_address\n assert_raises SystemExit do\n assert_output 'Line 1: Invalid address 1234567\\nBLOCKCHAIN INVALID' do\n add = %w[1234567 123456]\n line_num = 1\n @verify.check_addresses(add, line_num)\n end\n end\n end", "def test_has_zeros\n skip\n numbers = [3, 1, 0, 7, 9, 0]\n has_zero = false\n numbers.each do |number|\n # write code here\n end\n assert has_zero\n end", "def handleNoninSequence(n,seq)\n @mon.synchronize do\n @alarms = seq[:alarms]\n @spO2 = seq[:SpO2]\n @heartRate = seq[:heartRate]\n @greenp = seq.include?(:greenp) ? seq[:greenp].size : 0\n @redp = seq.include?(:redp) ? seq[:redp].size : 0\n @cond.broadcast\n lightYellowLED(@greenp > 0)\n end\n end", "def test_multiples_of_three_are_not_prime\n mults_of_three = (6..100).step(3).to_a\n\n mults_of_three.each do |x|\n assert_equal(false, @primes_container.is_prime?(x), \"#{x} caused failure\")\n end \n end", "def test_num_transactions_correct_false_not_0_false\n assert_equal(false, @bv.num_transactions_correct?(0, []))\n end", "def test_exceptions\n pool = ThreadPool.new(10)\n\n deep_exception_block = lambda do |count|\n next raise Exception.new if ( count < 1 )\n pool.future(count-1, &deep_exception_block).value\n end\n\n assert_raises(Exception) do\n pool.future(2, &deep_exception_block).value\n end\n\n end", "def test_consistency_ruby_test\r\n rubyArr = [1,1]\r\n seed = 10\r\n r = Random.new(seed)\r\n firstIteration = mine(rubyArr, r)\r\n secondIteration = mine(rubyArr, r)\r\n if firstIteration = secondIteration\r\n assert true\r\n end\r\n end", "def test_missing_numbers_some_missing\n result = @sudoku_1.missing_numbers(@sudoku_1.squares[3])\n assert_equal([1, 3, 5, 6], result)\n end", "def test_block_num_invalid\r\n hash_calc = Minitest::Mock.new('test_hash_calculator')\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n def block_checker.check_block_num(line, num); false; end\r\n output = \"Line 0: Invalid block number 1, should be 0\"\r\n assert_equal output, @g.block_num( '1', hash_calc, block_checker, 0)\r\n end", "def test_remove_duplicate_lines\n\n verify_method :remove_duplicate_lines,\n with: [\n {\n param: %w(a a),\n expect: %w(a)\n },\n {\n param: %w(aa aa),\n expect: %w(aa)\n },\n {\n param: %w(ab ab),\n expect: %w(ab)\n },\n {\n param: %w(a aa),\n expect: %w(a aa)\n },\n {\n param: %w(a b),\n expect: %w(a b)\n },\n {\n param: %w(a b b),\n expect: %w(a b)\n },\n {\n param: %w(a aa aaa aaaa aa aab aaa aabcc aabc),\n expect: %w(a aa aaa aaaa aab aabcc aabc)\n },\n ]\n\n random_lines = generate_random_lines(1000)\n naive_time = time_block { naive_remove_duplicate_lines(random_lines) }\n actual_time = time_block { @target.remove_duplicate_lines(random_lines) }\n\n if naive_time < actual_time * 2\n puts \"naive time: #{naive_time}\"\n puts \"actual time: #{actual_time}\"\n end\n\n assert_operator(actual_time, :<, naive_time)\n end", "def verify_transactions\r\n raise \"Line #{total_block_number}: transaction resulted in a negative\" if Transaction.negatives?\r\n\r\n true\r\n end", "def test_transactions_no_transactions\r\n account_tracker = Minitest::Mock.new('test_account_tracker')\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n def block_checker.parse(string, char); []; end\r\n output = \"Line 0: Cannot have 0 or less transactions \\'\\'\"\r\n assert_equal output, @g.transactions( '', account_tracker, block_checker, 0)\r\n end", "def assert\n\traise \"Assertion failed\" unless yield\nend", "def assert\n\traise \"Assertion failed\" unless yield\nend", "def my_count n = nil\n if block_given?\n truths = 0\n self.my_each {|o| truths += 1 if yield(o)}\n truths\n elsif n.nil?\n self.length\n else\n my_count {|x| x==n}\n end\n end", "def done?\n\t\treturn @num_valid == @max_block\n\tend", "def assert\n\traise \"Assertion Failed\" unless yield\nend", "def test_assert_block_works\n assert_block do\n true\n end\n end", "def assert\n\traise \"Uh oh.\" unless yield\nend", "def assert\n\traise \"Assertion Failed!\" unless yield\nend", "def assert\n\traise \"Assertion Failed!\" unless yield\nend", "def test_leaving_first_3_true\n p = Prospector.new(0,0,0)\n\tp.gold_found = 0\n\tp.silver_found = 0\n\tp.num_loc_visited = 3\n\tassert p.leaving?\n end", "def assert\n raise \"ERROR!\" unless yield \nend", "def assert \n\traise \"Assertion failed\" unless yield\nend", "def verify!(block)\n self.instance_eval(&block)\n expected = Set.new(expected_entries)\n provided = Set.new(provided_entries)\n missing_entries = expected - provided\n extra_entries = provided - expected\n missing_entries_found(missing_entries) if missing_entries.any?\n extra_entries_found(extra_entries) if extra_entries.any?\n end", "def test_full_stack_ignore\n puts \"test_full_stack_ignore\"\n expects = []\n 100.times do\n expects << random_string\n pr = push(expects[-1])\n assert_equal(0, pr, \"expected 0, got #{pr}\")\n end\n\n (rand(5) + 2).times do\n r = push(\"too full\", :timeout => 3)\n assert_equal(nil, r, \"expected nil, got #{r}\")\n end\n\n 100.times do |i|\n r = pop\n s = expects.pop\n assert_equal(s, r, \"expected #{s}, got #{r}\")\n end\n end", "def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end", "def assert\n\traise \"Assertion failed!\" unless yield\nend", "def assert\n\traise \"Assertion failed!\" unless yield\nend", "def assert\n\traise \"Assertion failed!\" unless yield\nend", "def assert\n\traise \"Assertion failed!\" unless yield\nend", "def assert\n\traise \"Assertion failed!\" unless yield\nend" ]
[ "0.6883966", "0.6857126", "0.67657816", "0.66795194", "0.623971", "0.61897767", "0.5944627", "0.5937596", "0.59225094", "0.5910601", "0.5860796", "0.5823285", "0.5821592", "0.5774631", "0.5769083", "0.5759987", "0.57579535", "0.57574755", "0.5719553", "0.5703769", "0.5698037", "0.5672826", "0.5661435", "0.5659424", "0.56314653", "0.56288624", "0.55747664", "0.55743647", "0.5561399", "0.55526555", "0.554955", "0.55415845", "0.55314386", "0.5510785", "0.55025333", "0.54923385", "0.5478059", "0.54610336", "0.544668", "0.5446372", "0.54391295", "0.54282266", "0.5425979", "0.5411473", "0.5400586", "0.54003537", "0.5392753", "0.53907406", "0.5390347", "0.53895634", "0.53819364", "0.53762585", "0.53754723", "0.5374658", "0.5363822", "0.5362038", "0.5359107", "0.5351758", "0.53515524", "0.5337904", "0.5336176", "0.5329061", "0.5319547", "0.53131235", "0.5312429", "0.5301312", "0.53", "0.5297794", "0.526766", "0.5266851", "0.52649677", "0.52596134", "0.5258553", "0.52501", "0.52479506", "0.52411556", "0.5232637", "0.522307", "0.52175665", "0.52139616", "0.52118707", "0.52118707", "0.5207453", "0.52057093", "0.520245", "0.5199329", "0.51920605", "0.51918864", "0.51918864", "0.5190818", "0.5190456", "0.51880383", "0.5186145", "0.5185723", "0.5185325", "0.51835567", "0.5183226", "0.5183226", "0.5183226", "0.5183226" ]
0.53826725
50
makes asserting earning simple! just format them like so: REGULAR_HOURS,20.0 DOUBLE_TIME,1.0 MEAL_ALLOWANCE,1.0 OVERTIME,2.0
def assert_earnings(expected, timesheet) actual = timesheet.earnings.group_by(&:code).map do |code, earning| [code, earning.sum(&:units)].join(",") end.join("\n") assert_equal expected, actual end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task_earnings\n earnings.format(:no_cents_if_whole => true, :symbol => \"$\") if earnings?\n end", "def unit_formats(type)\n #find statements\n #if sales[0]< 1000 and tot assets[0] < 1000\n #$xxx,xxx.x\n #else\n #$xxx,xxx\n #end\n end", "def describe_price\r\n\t\ta = []\r\n\t\ta << sprintf('$%.2f per item', per_item) unless per_item.zero?\r\n\t\ta << sprintf('$%.2f per kg', per_kg) unless per_kg.zero?\r\n\t\ta << sprintf('$%.2f', flat_rate) unless flat_rate.zero?\r\n\t\tif formula and !formula.empty?\r\n\t\t\tif formula_description and !formula_description.empty?\r\n\t\t\t\ta << formula_description\r\n\t\t\telse\r\n\t\t\t\ta << formula.gsub('I', \"'number of items'\").gsub('W', \"'total weight'\").gsub('V', \"'total value'\")\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\ta.empty? ? ((name == '[ to be advised ]') ? nil : 'no charge') : a.join(' + ')\r\n\tend", "def work_needed(project_minutes, freelances)\n freelance_hours = 0\n freelance_minutes = 0\n my_hours = 0\n my_minutes = 0\n\n freelances.each do |f|\n freelance_hours += f[0]\n freelance_minutes += f[1]\n end\n\n freelance_total = (freelance_hours * 60) + freelance_minutes\n remaining = project_minutes - freelance_total\n\n p freelance_total\n p remaining\n\n if remaining >= 60\n my_hours = remaining / 60\n my_minutes = remaining - (my_hours * 60)\n else\n my_minutes = remaining\n end\n\n if remaining < 1\n return \"Easy Money!\"\n else\n return \"I need to work #{my_hours} hour(s) and #{my_minutes} minute(s)\"\n end\n\nend", "def sale_message\n if \"#{price}\".to_i <= 1000\n then \"Last minute price\"\n else \"Member price\"\n end\n end", "def profit_statement(drink, profit)\r\n # Only thing of interest here is using the %.2f % profit method (is this a method? A reassignment?) to force two decimal places as this is a returning\r\n # a dollar currency value, the default return would only contain one floating point otherwise\r\n return \"Your profits from #{drink} for your current order queue is $%.2f\" % profit\r\n end", "def to_s\n \"Tax authority: #{@authority}\\n\" +\n \"-Sales Taxes: #{@sales_tax.to_i}% rate on all goods except #{exempt_basic}.\\n\" + \n \"-Import Duty: #{@import_duty.to_i}% rate on all imported goods.\"\n end", "def line(party, votes, pct, seats)\n\tparty = Repls[party] if Repls[party]\n\tpct = pct ? ('%.1f' % pct) : '' \n\tFormat % [party, thousands(votes), pct, seats]\nend", "def to_s\r\n \"Project #{@name} has $#{'%.2f' % @fund} towards a goal of $#{'%.2f' % @target_fund}.\"\r\nend", "def report\n puts \"Hello! My name is #{@name}, I've delivered #{@experience} papers\n today and I've earned $#{@earnings} so far!\"\n end", "def eats_at\n if meal_time <= 11\n \"#{meal_time + 1}AM\"\n elsif meal_time > 12\n \"#{meal_time - 11}PM\"\n else\n \"Please put a number \"\n end\n end", "def test_hr_min_rus\n time_string = '22:30 - 1:00'\n sumtime = SumTime.new(time_string)\n sumtime.output_format = :hr_min_rus\n assert_equal('02 ч. 30 мин.', sumtime.calculate_time)\n end", "def offer_display( hotel_name, offer_available , normal_rate, normal_tax )\n o_from, o_to, o_rate = offer_available.start, offer_available.end , offer_available.rate.to_i \n visit_time_period = ( @to - @from ).to_i + 1\n puts \"\\n\\n****Amazing choice, you are walking in during a special season**** \n '#{offer_available.name.upcase}' from #{o_from.strftime(\"%m/%d/%Y\")} till #{o_to.strftime(\"%m/%d/%Y\")} at #{hotel_name}\"\n bill = calculate_bill( hotel_name, visit_time_period, o_to, o_from, o_rate, normal_rate, normal_tax )\n puts \"\\nStay at #{hotel_name} \\n From : #{from.strftime(\"%m/%d/%Y\")} \\t\\t\\t To : #{to.strftime(\"%m/%d/%Y\")} (including offer)\\n TOTAL : #{bill.to_i}\"\n end", "def add_h_s(hrs)\n \n calc_to_hr = @income \n case hrs\n when 0..8\n @pay = calc_to_hr * hrs * 2\n puts \"0..8_#{pay}\"\n when 8.5..10\n @pay = (calc_to_hr * 8 * 2 + (calc_to_hr * (hrs-8) * 2.34)).to_i\n puts \"8.5..10_#{pay}\"\n else\n @pay = (calc_to_hr * 8 * 2 + (calc_to_hr * (2) * 2.34) + calc_to_hr * (hrs-10) * 2.67).to_i\n puts \"10up_#{pay}\"\n end \n end", "def to_s\n\t\t\t# Really need a money formatter */Sad Panda/*\n\t\t\t\"id: #{@id}, checking: #{@checking}, saving: #{@saving}, total: #{combined_capital}, interest_rate: #{@interest_rate}\"\n\t\tend", "def format_hours\n\n self.breakHours = self.breakHours[1,self.breakHours.length] if !self.breakHours.blank? && self.breakHours =~ /0[0-9]:/\n\t\tself.hours = self.hours[1,hours.length] if !self.hours.blank? && self.hours =~ /0[0-9]:/\n \n\tend", "def every(t = false)\r\n return [] if read_attribute(:every).nil? || read_attribute(:every) == 0\r\n return read_attribute(:every) if read_attribute(:every).is_a?(Array)\r\n read_attribute(:every).split(',').map{|i| _(EVERIES[i.to_i - 1].to_s) }\r\nend", "def proc_monster ofp, flg, lst\n ofp << \" {\"\n if lst[0] =~ /[[:digit:]]/\n ofp << \"#{lst.shift},#{lst.shift},\"\n else\n name = lst.shift\n ofp << \"Exp_#{name},Score_#{name},\"\n end\n ofp << %(mtype_#{lst.shift},\"#{lst.shift}\")\n ofp << \", #{flg}\" unless flg.empty?\n ofp << \"},\\n\"\nend", "def ok_values\n %i(decimal upperRoman lowerRoman upperLetter lowerLetter ordinal\n cardinalText ordinalText hex chicago ideographDigital japaneseCounting\n aiueo iroha decimalFullWidth decimalHalfWidth japaneseLegal\n japaneseDigitalTenThousand decimalEnclosedCircle decimalFullWidth2\n aiueoFullWidth irohaFullWidth decimalZero bullet ganada chosung\n decimalEnclosedFullstop\n decimalEnclosedParen\n decimalEnclosedCircleChinese\n ideographEnclosedCircle\n ideographTraditional\n ideographZodiac\n ideographZodiacTraditional\n taiwaneseCounting\n ideographLegalTraditional\n taiwaneseCountingThousand\n taiwaneseDigital\n chineseCounting\n chineseLegalSimplified\n chineseCountingThousand\n koreanDigital\n koreanCounting\n koreanLegal\n koreanDigital2\n vietnameseCounting\n russianLower russianUpper\n none numberInDash\n hebrew1 hebrew2\n arabicAlpha arabicAbjad\n hindiVowels hindiConsonants hindiNumbers hindiCounting\n thaiLetters thaiNumbers thaiCounting\n bahtText\n dollarText custom)\n end", "def price_format(whose)\n #Helper method\n def cent_string(cents)\n cents = cents.to_i\n if cents == 0\n return \"Free\"\n elsif cents == -1\n return \"Sold Out\"\n end\n output = (cents % 100).to_s\n if output.length != 2\n output += '0'\n end\n output = \"$\" + (cents / 100).floor.to_s + \".\" + output\n return output\n end\n\n if whose == 'full'\n low = cent_string(full_price_range_low)\n high = cent_string(full_price_range_high)\n else\n low = cent_string(our_price_range_low)\n high = cent_string(our_price_range_high)\n end\n output = low\n if high != low\n output = \"#{output} - #{high}\"\n end\n return output\n end", "def test_convert_cash_g_s\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n gold = 2\n silver = 2\n actual = pros.convert_metals_to_cash gold, silver\n expected = 43.96\n assert_equal expected, actual\n end", "def test_rec_number_positive\n @numbers.each do |value, expected|\n assert_equal expected, @TS_Rec.format(value)\n end\n end", "def format(string=\"[%{full_years} years >][%{months_after_years} months >][%{days_after_months} days >][%{hours_after_days}h>]%{minutes_after_hours}m>]%{seconds_after_minutes}s\")\n\t\t\t\n\t\tend", "def test_rec_number_negative\n @numbers.each do |value, expected|\n # add auto negative values\n value = value.is_a?(String) ? '-' + value : value * -1\n expected = expected == '0' ? expected : '-' + expected\n\n assert_equal expected, @TS_Rec.format(value)\n end\n end", "def statement\n if @amount.positive?\n \"#{@amount.round(2).to_f}\\t\\t\\t\\t\\t\\tCredited in Bank \"\n else\n \"\\t\\t\\t#{[email protected](2).to_f}\\t\\t\\tDebited From Bank\"\n end\n end", "def price_string\n\n money = self.price || 0\n copper = money % 100\n amount = (money - copper) / 100\n silver = amount % 100\n gold = (amount - silver) / 100\n\n parts = []\n parts << \"#{number_with_delimiter(gold.to_i)}g\" if gold > 0\n parts << \"#{silver.to_i}s\" if silver > 0\n parts << \"#{copper.to_i}c\" if copper > 0\n\n parts.join(' ')\n \n end", "def to_s\n \"Arete : Sommet1 = #{@sommet1}, Sommet2 = #{@sommet2}, estDouble? = #{@estDouble}\\n\"\n end", "def test_convert_cash_g\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n\n gold = 2\n silver = 0\n actual = pros.convert_metals_to_cash gold, silver\n expected = 41.34\n assert_equal expected, actual\n end", "def print_pay_stub\n print_name\n pay_for_period = @hourly_wage * @hours_per_week * 2\n formatted_pay = format(\"%.2f\", pay_for_period)\n puts \"Pay for this period: $#{formatted_pay}\"\n end", "def total_exp\n base_exp + time_bonus_exp + extra_bonus_exp\n end", "def format_row(row)\n \" #{row[:guess].join(' | ')} || #{row[:accuracy].join(' | ')} \"\n end", "def test_basic_conversions\n assert_equal 1.292, 1.euro\n assert_equal 0.019, 1.rupee\n assert_equal 0.013, 1.yen\n assert_equal 1, 1.dollar\n end", "def to_s\n s = \"Period:\"\n s += \"\\n\\tend: \" + end_time.to_s\n s += \"\\n\\tstart: \" + start_time.to_s\n s += \"\\n\\ttotal_audience: \" + total_audience.to_s if total_audience!=nil\n s += \"\\n\\ttotal_mentions: \" + total_mentions.to_s if total_mentions!=nil\n s += \"\\n\\ttotal_users: \" + total_users.to_s if total_users!=nil\n s += \"\\n\\tusers_with_subcribers: \" + users_with_subscribers.to_s if users_with_subscribers!=nil\n s\n end", "def imc_tabla\n\t\tx = self.indice_masa_corporal\n\n\n\t\tif x < 18.5\n\t\t\treturn \"#{x} < 18.5 -- Bajo peso -- Delgado\"\n\t\telsif x >= 18.5 && x <= 24.9\n\t\t\treturn \"18.5 < #{x} < 24.9 -- Adecuado -- Aceptable\"\n\t\telsif x > 24.9 && x <= 29.9\n\t\t\treturn \"25.0 < #{x} < 29.9 -- Sobrepeso -- Sobrepeso\"\n\t\telsif x > 29.9 && x <= 39.9\n\t\t\treturn \"30.0 < #{x} < 39.9 -- Obesidad grado 1 -- Obesidad\"\n\t\telsif x > 39.9\n\t\t\treturn \" #{x} > 40 -- Obesidad grado 2 -- Obesidad\"\n\t\tend\n\n\tend", "def test_multi_densa_dispersa\n\t\tassert_equal(@h13.m, @h9*@h10, \"Resultado Incorrecto\" )\n\tend", "def bonus_time(salary, bonus)\n salary = (salary*10).to_i if bonus == true\n \"$#{salary}\"\nend", "def dollar amt\n #TOOD: need commas in the right places\n sprintf \"$%0.02f\", amt\nend", "def add_period(str)\nend", "def report(driver_sum, money_result, rate_result)\n puts \"\\nPerformance Report: \\n\\n\"\n\n driver_sum.each do |item|\n puts \"Driver ##{item[:id]}: #{item[:ride_num]} rides, made $#{item[:total_money]}, averate rate #{item[:aver_rate]}\"\n end\n\n puts \"\\nDriver(s) made the most money $#{money_result[0]}: #{money_result[1]}\"\n puts \"Driver(s) got the highese average rating #{rate_result[0]}: #{rate_result[1]}\\n\\n\"\nend", "def print_pay_stub\n print_name\n pay_for_period = hourly_wage * hours_per_week * 2\n formatted_pay = format(\"$%.2f\", pay_for_period)\n puts \"Pay This Period: #{formatted_pay}\"\n end", "def eats_at\n if @meal_time < 12\n return \"#{@meal_time} AM\"\n elsif @meal_time > 12\n return \"#{@meal_time -12} PM\"\n elsif @meal_time==0\n return \"Midnight\"\n else\n return \"Current meal time is invalid.\"\n end\nend", "def beautifyHighScores(data)\n\n\ttimesString = ''\n\tdata.each do |score| \n\t\ttimesString += \"#{score} Seconds <br>\"\n \tend\n\n \treturn timesString\n\nend", "def money_checker( tline)\r\n tline = tline.split(\" \")\r\n tline.each_with_index do |word, i|\r\n if word.include?(\"$\") && tline[i+1] != \"million\" && word.include?(\"million\") == false\r\n money = word.split('-')[0].gsub(/[^0-9.]/, \"\").to_f\r\n money *= 1000 if word.include?(\"k\")\r\n tline[i] = \"hour_tag\" if money < 100 && money != 0\r\n tline[i] = \"sal_tag\" if money > 20000\r\n end\r\n end\r\n return tline.join(\" \")\r\nend", "def hours_until_next_allowed_str\n number_hours = hours_until_next_allowed\n \"#{number_hours} #{'hour'.pluralize(number_hours)}\"\n end", "def hours_until_next_allowed_str\n number_hours = hours_until_next_allowed\n \"#{number_hours} #{'hour'.pluralize(number_hours)}\"\n end", "def test_print_heading_float\n assert_output(\"Heading from 1.1 to 1.2\\n\"){@p.print_heading(1.1, 1.2)}\n end", "def get_saturadas\n @_100=((@saturadas*100)/@peso)\n @ir_100=(@_100/20)*100\n @porcion=((@saturadas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/20)*100\n\t\t#p \"| #{@saturadas} | #{@_100} | #{@ir_100.round(1)}% | #{@porcion} | #{@ir_porcion.round(1)}% |\"\n [ @saturadas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def to_s\n \"#{name} (#{serial}): Worth #{value}, recorded on #{createdAt}\"\n end", "def bonus_time(salary, bonus)\n bonus ? \"$#{(salary*10).to_s}\" : \"$#{salary.to_s}\"\nend", "def assigned_statistics_to_group_insert_query_format(group_expected_readrates,assigned_statistics)\n statistics = []\n statnames = []\n statistics = assigned_statistics.split(',')\n for i in 0..statistics.size - 1\n statnames[i] = statistics[i].split(':').last\n exp_rr_val = group_expected_readrates[statnames[i]]\n statistics[i] = statistics[i].to_s.gsub(':', '\\' : {\\'').insert(0, '\\'').insert(-1, '\\' : ').insert(-1, exp_rr_val).insert(-1, ' }')\n end\n assigned_statistics = statistics.join(\", \")\nend", "def formato\n \"\n Queso Cada 100g o 100ml IR\n \n Valor energético #{nrg_kj} kj #{nrg_kj_ir}%\n (kj/kcal) #{nrg_cal} kcal\n \n Grasas de las #{@grasa} g #{grasa_ir}%\n cuales:\n Saturadas #{@saturada} g #{saturada_ir}%\n Monoinsaturadas #{@monoinsat} g -\n Poliinsaturadas #{@poliinsat} g -\n \n Hidratos de #{@hidrato} g #{hidrato_ir}% \n carbono de los\n cuales:\n Azucares #{@azucar} g #{azucar_ir}%\n Polialcoholes #{@polialco} g -\n Almidones #{@almidon} g -\n \n Fibra alimentaria #{@fibra} g -\n \n Proteinas #{@proteina} g #{proteina_ir}%\n \n Sal #{@sal} g #{sal_ir}%\"\n end", "def eats_at\n \"#{@meal_time} pm\" \n end", "def fuel_per_hour\n 10\n end", "def calc_carbon_savings_from_chp_elec(val1= chp_salable_elec, val2= 2.7, val3= 0.643)\n\t\t(val1 * val2 * val3).round 2\n\tend", "def print_products_report(toy_name,full_price,product_purchase_cnt,sales_sum,avg_price,avg_discount)\n $report_file.puts toy_name\n $report_file.puts \"*********************************\"\n $report_file.puts \"Retail price : #{full_price}\"\n $report_file.puts \"Product purchases: #{product_purchase_cnt}\"\n $report_file.puts \"Product Sales : #{sales_sum}\"\n $report_file.puts \"Average price : #{avg_price.round(2)}\"\n $report_file.puts \"Average Discount : $#{avg_discount.round(2)} \\n\\n\" \nend", "def in_words(t)\n # to get the number of minutes subtract out days\n # Then calculate hours and subtract those out to get minutes.\n s = []\n days = t.round(4).to_i\n s << \"#{ days } day(s)\" unless days == 0\n \n remainder = t - days\n minutes = remainder * 1440.0 # number of minutes in a day\n hours = (minutes / 60.0).round.to_i\n s << \"#{ hours } hours\" unless hours == 0\n \n # round to 2 decimal places and call it\n minutes = (minutes - hours * 60).round\n s << \"#{ minutes } minutes\" unless minutes == 0\n \n if s.empty?\n s << \"now\"\n else\n s << \"ago\"\n end\n \n s.join(\" \")\n end", "def profit_cal(items)\r\n profit = 0\r\n items.item.each do |h|\r\n profit += h[:num]*(h[:price] - h[:cost])\r\n end\r\n #profit = '%.2f' % profit\r\n puts \"The total profit is $#{'%.2f' % profit}\"\r\n return nil\r\nend", "def time_in_words(time)\n\t\tdays = (time / 86_400).to_i\n\t\ttime -= days * 86_400\n\t\thours = (time / 3600).to_i\n\t\ttime -= hours * 3600\n\t\tminutes = (time / 60).to_i\n\t\tstring = \"#{days} day#{'s' unless days == 1},\"\n\t\tstring << \" #{hours} hour#{'s' unless hours == 1},\"\n\t\tstring << \" #{minutes} minute#{'s' unless minutes == 1}\"\n\tend", "def total_tuition_cost\n tuition_cost = courses.inject(0) {|sum, c| sum + c.cost}\n tuition_cost = sprintf( \"%0.02f\", tuition_cost).to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n puts \"\\nTotal tuition paid: $#{tuition_cost}\n \\n\"\n\n # puts tp self.courses,:subject,:cost\n tp self.courses,:subject, {\"Course Coste\" => {:display_method => lambda{|x| \"$\" + \"#{sprintf( \"%0.02f\", x.cost).to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse}\"}}}\n\n end", "def to_s()\n \"#{get_grasas()}\\n#{get_saturadas()}\\n#{get_monoin()}\\n#{get_poli()}\\n#{get_hidratos()}\\n#{get_azucares()}\\n#{get_alco()}\\n#{get_almidon()}\\n#{get_fibra()}\\n#{get_proteinas()}\\n#{get_sal()}\"\n end", "def suitable_quaters\n required_amount * 2\n end", "def time_management\n @personal_best = current_user.reports.map(&:time_management).max.round(2) rescue 0\n @personal_best = \"#{@personal_best}% Questions Attended\"\n learning_curve 'time_management'\n data_presenter 'time_management'\n end", "def time_in_words(time)\n days = (time / 86_400).to_i\n time -= days * 86_400\n hours = (time / 3600).to_i\n time -= hours * 3600\n minutes = (time / 60).to_i\n string = \"#{days} day#{'s' unless days == 1},\"\n string << \" #{hours} hour#{'s' unless hours == 1},\"\n string << \" #{minutes} minute#{'s' unless minutes == 1}\"\n end", "def balance_inquiry\n \"$#{'%.2f' % @balance}\"\n end", "def assess_situation(danger_level, save_the_day, bad_excuse)\n if danger_level >= 50\n p bad_excuse\n elsif danger_level <= 10\n p \"Meh, Hard pass.\"\n else\n p save_the_day\n end\nend", "def humanized_hour(hours)\n if hours == 1\n t('plugin_spent_time_in_issue.datetime.hours.one')\n elsif hours > 1\n t('plugin_spent_time_in_issue.datetime.hours.other', hours: hours)\n else\n ''\n end\n end", "def calc_alarme(cote,values)\n return [false,false] unless values[\"last\"]\n value=values[\"last\"].to_f\n p1=cote[:param1]\n p2=cote[:param2]\n c1=(value < p1) ? \"#FF4050\" : (value > p2) ? \"#7F7\" : $BGNOALARME\n c2=(value < p1*0.99) ? \"#FF4050\" : (value > p2*1.01) ? \"#7F7\" : $BGNOALARME\n [c1,c2]\nend", "def print_pay_stub\n print_name\n pay_for_period = (@salary / 365.0) * 14\n formatted_pay = format(\"%.2f\", pay_for_period)\n puts \"Pay for this period: $#{formatted_pay}\"\n end", "def report_total_hours(all_entries)\n printf \"TOTAL %.2f\\n\", total(all_entries.flatten)\nend", "def wrt_brand_tot_sales(brand_tot_sales, format = 6)\n $report_file.puts(\"Total Sales:\" + \"%#{format}s\" % \"$\" + brand_tot_sales.to_s)\nend", "def eats_at\n if @meal_time >= 13\n return \"#{@meal_time - 12}pm\"\n elsif @meal_time <= 11\n return \"#{@meal_time}am\"\n else\n return \"#{@meal_time}pm\"\n end\n end", "def test_annuity_credit_results\n @annuity_credit_Value.each { |key, value| assert_in_delta @calc_annuity[@row_number][key], value, 0.03 }\n check_count @calc_annuity\n end", "def reporthelp_decorated_hours( actual, potential )\n class_name = actual < 0 ? 'overrun' : 'no_overrun'\n output = \"<strong><span class=\\\"#{ class_name }\\\">#{ apphelp_terse_hours( actual ) }</span> / \"\n class_name = potential < 0 ? 'overrun' : 'no_overrun'\n output << \"<span class=\\\"#{ class_name }\\\">#{ apphelp_terse_hours( potential ) }</span></strong>\"\n\n return output.html_safe()\n end", "def print_scores(payout, payin, debug)\n debug = debug.sort.to_h\n payback_percent = payout * 100 / payin\n puts \"\\nPayed out: #{payout}\"\n puts \"Payed in: #{payin}\"\n puts \"\\nPayback % = #{format('%.6f', payback_percent)} % \\n\"\n puts \"Occurance payloads: #{debug}\"\n payback_percent\nend", "def description\n return @description if @description\n \n parts = []\n \n tp = trial_period(false)\n parts << \"#{tp}-day trial\" if tp && tp > 0\n \n sa = setup_amount(false)\n parts << \"#{number_to_currency(sa)} setup fee\" if sa && sa > 0\n \n am = amount(false)\n parts << \"#{number_to_currency(am)}/mo\"\n \n if prepaid_message_count >= UNLIMITED\n texts = \"unlimited\"\n else\n texts = \"#{prepaid_message_count}/mo prepaid\"\n end\n \n @description = parts.join(', ') + \" and #{texts} texts after that.\"\n\n return @description\n end", "def exp_rate; CPanel::EXPRATE; end", "def pt_et_convert(hour=0,minutes=0)\n\t\tpt = Time.parse(\"#{hour}:#{minutes}\")\n\t\tet = Time.parse(\"#{hour + 3}:#{minutes}\")\n\t\treturn \"#{et.strftime(\"%I%p\").gsub(/^0/, '').downcase} ET (#{pt.strftime(\"%I%p\").gsub(/^0/, '').downcase} PT)\"\t \n\tend", "def test_lend_money_transfers_money\n #Setup\n lender_before =\n lender_after =\n lendee_before =\n lendee_after =\n loan =\n #act\n #assert\n assert_equal(loan, lender_before - lender_after)\n assert_equal(loan, lendee_after- lendee_before)\nend", "def report_employee(employee)\n name, entries = *employee\n printf \"%s %.2f hours\\n\", name, total(entries)\nend", "def ticket_estimate(ticket, *args)\n\n options = args.extract_options!\n options[:format] ||= :long\n\n if ticket.estimated_minutes.blank?\n content_tag(:span, 'None', class: 'muted')\n else\n\n hours = ticket.estimated_minutes.to_i / 60\n minutes = ticket.estimated_minutes.to_i % 60\n\n if options[:format] == :long\n\n output = []\n output << pluralize(hours, 'hour') if hours > 0\n output << pluralize(minutes, 'minute') if minutes > 0\n output.to_sentence\n\n else\n\n output = ''\n output << \"#{hours}h \" if hours > 0\n output << \"#{minutes}m\" if minutes > 0\n output.strip\n\n end\n\n end\n\n end", "def round_row\n [\n \"($#{home_squad_odds}) #{home_squad_name} \",\n status == 'scheduled' ? '' : \"#{home_score} - #{away_score}\",\n \"#{away_squad_name} ($#{away_squad_odds})\",\n venue_name,\n date.strftime('%d/%m/%Y %I:%M%p')\n ]\n end", "def to_s\n puts \"Name 1: #{@name1}\"\n puts \"Name 2: #{@name2}\"\n puts \"Health 1: #{@health_points}\"\n puts \"Health 2: #{@health_points2}\"\n puts \"Recovery 1: #{@recovery_rate1}\"\n puts \"Recovery 2: #{@recovery_rate2}\"\n end", "def print_ticket(price, time, mph, adjusted_price)\n\tif mph > 60\n\t\tprint \"Your trip will take #{time.to_s.round(2)} hours and cost $ #{adjusted_price.to_s.round(2)} dollars. \\n\"\n\telse\n\t\tprint \"Your trip will take #{time.to_s.round(2)} hours and cost $ #{price.to_s.round(2)} dollars. \\n\"\n\tend \nend", "def kase_type_time_and_offer_in_words(kase)\n result = []\n result << kase_type_and_time_in_words(kase)\n if kase.offers_reward?\n result << \"&nbsp;\"\n result << \"&nbsp;\"\n result << kase_price(kase)\n result << (kase.expires_at > Time.now.utc ? \"offer expires in %{time}\".t : \"offer expired %{time} ago\".t) % {\n :time => distance_of_time_in_words(Time.now.utc, kase.expires_at)\n }\n end\n table_cells_tag(*result)\n end", "def format_time\n hours = format_hour @hour\n minutes = format_minute @minutes\n ampm = @hour < 12 ? @@ampm_hash['a'] : @@ampm_hash['p']\n time = ''\n time += hours[0] + minutes[0] + ' ' + ampm[0] + \"\\n\"\n time += hours[1] + minutes[1] + ' ' + ampm[1] + \"\\n\"\n time += hours[2] + minutes[2] + ' ' + ampm[2] + \"\\n\"\n time\n end", "def to_s\n \"#{@name} at #{MONEY_FORMAT % @price}\" \n end", "def test_standard_credit_results\n @standard_credit_Value.each { |key, value| assert_in_delta @calc_standard[@row_number][key], value, 0.03 }\n check_count @calc_standard\n end", "def test_69_cents #tests the coins that should be returned to total 69 cents\n \t\n\tassert_equal(2, $quarters)\n\tassert_equal(1, $dimes)\n\tassert_equal(1, $nickels)\n\tassert_equal(4, $pennies)\nend", "def to_s\n str = \"#{@name} sells #{@tea} for $#{@price}\\n\"\n str << \"This place has made $#{profit}\"\n str\n end", "def kase_offer_and_expiry_time_in_words(kase)\n result = []\n if kase.offers_reward?\n result << kase_price(kase)\n result << (kase.expires_at > Time.now.utc ? \"offer expires in %{time}\".t : \"offer expired %{time} ago\".t) % {\n :time => distance_of_time_in_words(Time.now.utc, kase.expires_at)\n }\n end\n table_cells_tag(*result)\n end", "def add_all_values\n ValuesLib.remove_currency_format(text_value_one) + ValuesLib.remove_currency_format(text_value_two_element)\n + ValuesLib.remove_currency_format(text_value_three) + ValuesLib.remove_currency_format(text_value_four)\n + ValuesLib.remove_currency_format(text_value_five)\n end", "def assess_situation(danger_level, save_the_day, bad_excuse)\n # danger_level = 75\n # save_the_day = \"All in a day's work.\"\n # bad_excuse = \"This isn't good!\"\n\n if danger_level > 50\n p bad_excuse\n elsif danger_level < 50 && danger_level > 10\n p save_the_day\n else\n p \"Meh. Hard pass.\"\n end\nend", "def display_avg_times(avg_times)\n puts(\"Tempo Médio De Voltas:\")\n puts(\"---------------\")\n avg_times.each do |array|\n puts \"#{array[0]} - Tempo Médio: #{array[1].round(2)} minutos\"\n end\n puts(\"---------------\")\n end", "def set_gojek_cost(line_items)\n\t\tline_items.any? ? 'Rp 15,000' : 'Rp 0'\n\tend", "def assess_situation(danger_level, save_the_day, bad_excuse)\n if danger_level > 50\n p \"#{bad_excuse}\"\n elsif danger_level < 50 && danger_level < 10\n p \"#{save_the_day}\"\n elsif danger_level < 10\n p \"Meh. Hard Pass.\"\n end\nend", "def display_in_time_periods(num,options={})\n format = options[:format] || '%.1f'\n precision = options[:precision]\n raise \"precision must be an integer\" if precision && precision.to_i != precision\n\n period = options[:period]\n case period\n when :seconds,:minutes,:hours,:days,:weeks,:months,:years \n t_unit = period.to_s.chomp('s')\n format_period(format % (num / TIME_IN_SECONDS[t_unit.to_sym] ), t_unit,options[:short])\n else\n text = []\n accounted = 0\n first = nil\n # makes the math eaiser ....\n precision -= 1 if precision\n [:year,:month,:week,:day,:hour,:minute,:second].each_with_index { |unit,i| \n p = TIME_IN_SECONDS[unit]\n n = (num - accounted)/ p \n if n > 1\n accounted += (n.floor)*p\n if precision\n first ||= i\n if i - first < precision\n n = n.floor.to_s\n elsif i - first == precision\n n = format % n\n else\n break\n end\n else\n n = n.floor\n end\n text << format_period(n, unit,options[:short])\n end\n }\n text*' '\n end \n end", "def test_Currency_003_Format_From_Amount\n\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Currency_003_Format_From_Amount\")\n puts2(\"#######################\")\n\n begin # convert_StringFromCurrency\n\n\n ############################\n sThisTaskName = \"$1,000 to 1000\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"$1,000\".format_from_currency(\"$\", \",\", true)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \"$1,000,000.00 to 1000000.00\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"$1,000,000.00\".format_from_currency(\"$\", \",\", false)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \"�1.000.50 to 1000\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"�1.000.50\".format_from_currency(\"�\", \".\", true)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \"$1.000.5 to 1000.50\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"$1.000.5\".format_from_currency(\"$\", \",\", false)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \"$1,000,000.50 to $1000000\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"$1,000,000.50\".format_from_currency( \"\", \",\",true)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \"�1,000,000.5 to 1000000.50\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"�1,000,000.5\".format_from_currency(\"�\", \",\", false)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \"0.5 to 0.50\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"0.5\".format_from_currency(\"\", \",\", false)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \".5 to 0.50\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \".5\".format_from_currency(\"\", \",\", false)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \"$1. to 1.00\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"$1.\".format_from_currency(\"$\", \",\", false)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n sThisTaskName = \"$. to 0.00\"\n puts2(\"\")\n puts2(\" # BEGIN: \" + sThisTaskName + \" #\")\n\n sConvertedValue = \"$.\".format_from_currency(\"$\", \",\", false)\n\n puts2(\"Formatted value = #{sConvertedValue.to_s}\")\n ############################\n\n\n rescue => e\n\n puts2(\"Error and Backtrace: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\"),\"error\")\n\n # Raise the error\n raise(\"*** TESTCASE - test_Currency_003_Format_From_Amount\")\n\n ensure\n\n end # convert_StringFromCurrency\n\n end", "def print_choices\n puts \"(L)atte $4.00\"\n puts \"(S)cone $5.00\"\n puts \"(T)ea $3.00\"\n puts \"(D)one\"\n puts\n end", "def show_values\n puts \"Name: \" + @heating_name\n puts \" Area: \" + @heating_area.to_s\n puts \" Temperature: \" + @heating_temperature.to_s\n puts \"Radiator: \" + @num_radiator.to_s\n puts \" Ground: \" + @num_ground.to_s\n puts \" Num: \" + @num.to_s\n end", "def wrt_brand_avg_prc(brand_avg_prc, format = 6)\n $report_file.puts(\"Average Product Price:\" + \"%#{format}s\" % \"$\" + brand_avg_prc.to_s)\nend" ]
[ "0.6361034", "0.575668", "0.55459774", "0.5471489", "0.54420567", "0.54201895", "0.5391023", "0.53608847", "0.5344633", "0.5340655", "0.53374463", "0.53180474", "0.52955866", "0.52786577", "0.52186686", "0.52177477", "0.52098286", "0.52029014", "0.51876193", "0.5186689", "0.51681906", "0.5163594", "0.51350135", "0.5132713", "0.51304805", "0.5127679", "0.51207507", "0.51127017", "0.5095166", "0.50940585", "0.50866276", "0.50850374", "0.50811046", "0.5073807", "0.50664705", "0.50641066", "0.50618285", "0.5050031", "0.5046843", "0.50456125", "0.5045544", "0.50428903", "0.50374484", "0.5021216", "0.5021216", "0.502043", "0.5012508", "0.50113416", "0.500882", "0.50076735", "0.50076485", "0.5005461", "0.50053775", "0.50042933", "0.50016004", "0.50004", "0.49909022", "0.49906793", "0.49840224", "0.49791807", "0.49785832", "0.49771038", "0.4976132", "0.49752304", "0.49669892", "0.49645883", "0.49641398", "0.49639493", "0.4961175", "0.4959761", "0.49585092", "0.49582866", "0.49496064", "0.4949529", "0.4940429", "0.49393854", "0.49393663", "0.49391246", "0.493759", "0.4935051", "0.49316657", "0.4928077", "0.49244463", "0.49235985", "0.49229467", "0.49228436", "0.49213767", "0.49196893", "0.4915909", "0.49132857", "0.49131778", "0.49124277", "0.49109817", "0.49000326", "0.48990828", "0.4893543", "0.48930055", "0.48899624", "0.48892507", "0.48860213" ]
0.6092925
1
allows safely calling `claimant_who_is_not_the_veteran["participantId|payeeCode"]` is not a way to test whether or not the veteran is the claimant. use `veteran_is_not_the_claimant?` for that
def claimant_who_is_not_the_veteran attributes["claimant"] || {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def participant_id\n case claimant_class_name\n when VeteranClaimant.name\n veteran.participant_id\n when OtherClaimant.name\n \"\"\n when HealthcareProviderClaimant.name\n \"\"\n else\n request_params[:claimant]\n end\n end", "def appellant_is_veteran\n !veteran_is_not_claimant\n end", "def handle_claimant_fields(options:, params:, target_veteran:)\n claimant_ssn = params[:data][:attributes][:claimantSsn]\n if claimant_ssn.present?\n claimant_ssn = claimant_ssn.delete('^0-9')\n validate_ssn(claimant_ssn)\n end\n options[:claimant_ssn] = claimant_ssn if claimant_ssn\n\n # if claimant_ssn field was not provided, then default to sending 'participant_claimant_id'\n options[:participant_claimant_id] = target_veteran.participant_id if options[:claimant_ssn].blank?\n\n options\n end", "def validate_claimant_type\n return unless claimant_type == 'veteran' && signing_appellant.claimant?\n\n source = '/data/attributes/claimantType'\n\n errors.add source, I18n.t('appeals_api.errors.sc_incorrect_claimant_type')\n end", "def claimant\n params['claimant']\n end", "def unclaimed?\n claimant.nil?\n end", "def verify_get_code_by_action_bonus_data(params)\n params[:game].is_a?(Game) &&\n (params[:bonus].is_a?(TeamBonus) || params[:bonus_id].is_a?(String)) &&\n (params[:code].is_a?(Code) || params[:code_id].is_a?(String)) &&\n params[:user].is_a?(User)\n end", "def neg_role(n)\n ret_val = \"z\"\n ret_val = \"b\" if n.buyer_id == self.id\n ret_val = \"s\" if n.seller_id == self.id\n end", "def admission_no_employee_no(t_obj, value)\n receiver = if t_obj.receiver_type == \"Student\"\n @students.detect{|s| s.admission_no == value}\n elsif t_obj.receiver_type == \"Employee\"\n @employees.detect{|e| e.employee_number == value}\n end\n t_obj.receiver_id = receiver.try(:id)\n end", "def participant?\n !participant.nil?\n end", "def get_competitor_value\n if params[:non_competitor].nil?\n true\n else\n ! (params[:non_competitor] == \"true\")\n end\n end", "def handle_claimant_fields(options:, form_attributes:, target_veteran:)\n claimant_ssn = form_attributes['claimant_ssn']\n participant_claimant_id = form_attributes['participant_claimant_id']\n\n options[:claimant_ssn] = claimant_ssn if claimant_ssn\n options[:participant_claimant_id] = participant_claimant_id if participant_claimant_id\n\n # if neither field was provided, then default to sending 'participant_claimant_id'\n if options[:claimant_ssn].blank? && options[:participant_claimant_id].blank?\n options[:participant_claimant_id] = target_veteran.participant_id\n end\n\n options\n end", "def accompaniment?\n self.participant_role == 'accompanist'\n end", "def can_conciliate_or_null?\n !(nuller_id.present? || approver_id.present?)\n end", "def can_conciliate_or_null?\n !(nuller_id.present? || approver_id.present?)\n end", "def claimable?\n # can this invite be confirmed!\n ( pending? or declined? ) and !roster.full?\n end", "def optionals\r\n %w[\r\n participant\r\n token\r\n ]\r\n end", "def ignore_pacticipant?(pacticipant)\n resolved_ignore_selectors.any? do | s |\n s.pacticipant_id == pacticipant.id && s.only_pacticipant_name_specified?\n end\n end", "def non_quest_attribute\n !!(controller == \"inspirations\" || controller == \"family_members\" || controller == \"subscriptions\" || controller == \"disciplines\" || controller == \"priority_items\")\n end", "def senior_member?\n\t\tsenior != true\n\tend", "def participants\n people.select{|person| !person.guide }\n end", "def gift_aid?\n params['GiftAid'] == '1'\n end", "def virginia_borrower?\n # @profile !~ /^[a-z]{2,3}([0-9][a-z]{1,2})?$/i\n profile.match?(/Virginia Borrower|Other VA Faculty|Alum/i) ||\n profile.blank?\n end", "def using_voter_id?\n self.voter_id.present?\n end", "def rehabilitation_ali?\n team_ali_code.rehabilitation_code?\n end", "def is_owner?(person)\n return person !=nil && person.team_id == self.id && person.role == \"captain\"\n end", "def acceptable_by?(acceptor)\n self.can_accept? &&\n !!acceptor && !!self.person && !!self.kase.person && acceptor == self.kase.person &&\n (self.kase.offers_reward? ? acceptor != self.kase.person : true)\n end", "def attendTest_no_show_imaging(patient)\n yield [] if @state[IAPPOINTMENTREQUESTED].any? {|terms| terms.size == 2 and terms[0] == patient and state(PATIENT, patient) and state(RADIOLOGIST, terms[1]) and not state(IAPPOINTMENTKEPT, patient, terms[1])}\nend", "def can_flag?(person)\n person != self.reviewer && person != self.reviewee\n end", "def has_supplemental_claim_with_vbms_claim_id(veteran)\n claim_id = \"600118926\"\n sc = SupplementalClaim.find_or_create_by!(\n veteran_file_number: veteran.file_number\n )\n EndProductEstablishment.find_or_create_by!(\n reference_id: claim_id,\n veteran_file_number: veteran.file_number,\n source: sc,\n payee_code: EndProduct::DEFAULT_PAYEE_CODE\n )\n Generators::EndProduct.build(\n veteran_file_number: veteran.file_number,\n bgs_attrs: { benefit_claim_id: claim_id }\n )\n sc\n end", "def secret?\r\n own? or invited? or admin?\r\n end", "def claimed?\n !claimant.nil?\n end", "def can_this_person_vote?(person)\n # check if their age is >= 18\n age = person[\"age\"]\n if age >= 18\n return \"yes\"\n else\n return \"no\"\n end\nend", "def hide_caregiver?( index = 1)\n if (1..3).include?( index)\n _caregiver = self.send(\"caregiver#{index}\")\n # * check subscriber status first\n # * no_caregiver_1 will be forced by this anyways\n # * then check the boolean on form\n ( (index == 1) && caregiving_subscriber? ) || (self.send(\"no_caregiver_#{index}\") == true) || _caregiver.nothing_assigned?\n else\n false # force to show. this is incorrect call anyways\n end\n end", "def athlete_result?\n !team_result?\n end", "def person_type\n offering_interviewer.nil? ? 'applicant' : 'interviewer'\n end", "def correct_meeting_only\n redirect_to current_user if current_user.service_user?\n if current_user.volunteer?\n current_user.initiatives.each do |init|\n return if init.meetings.include?(Meeting.find(params[:id]))\n end\n flash[:danger] = 'You are not allowed to access that page.'\n redirect_to current_user\n end\n end", "def additional_identity?\n secondary_identity? && participant_profiles.blank?\n end", "def mentor?\n !admin?\n end", "def is_participant?\n level <= USER_LEVELS[\"participant\"]\n end", "def check_if_user_is_team_leader?\n render json: [\"Only the Team Lead can edit this team\"], status: 422 unless current_user.id == this_team.user_id;\n end", "def vote_user_is_participant\n @user = current_user\n @owner = User.friendly.find(1)\n @game = Game.friendly.find(params[:game_id])\n @playlist = Playlist.friendly.find(params[:playlist_id])\n @league = League.friendly.find(params[:league_id])\n @week = Week.friendly.find(params[:week_id])\n @match = Match.friendly.find(params[:match_id])\n @participant_one = Participant.find(@match.match_relationships.first.participant_id)\n @participant_two = Participant.find(@match.match_relationships.last.participant_id)\n\n unless (@user.id == @participant_one.user_id) || (@user.id == @participant_two.user_id) || (@user == @owner)\n redirect_to root_url\n flash[:alert] = \"You are not the correct user.\"\n end\n end", "def compare_contractor_data(contractor)\n message_good = \"Each attribute value is equal to the corresponding attributes of a freelancer #{contractor[:name]} on a profile page:\\n#{contractor}\"\n message_bad = \"Freelancer attribute values ​​not equal to the corresponding attributes in the shared page. Expected:\\n#{contractor}\\nGot:\\n#{@hash_contractor}\"\n #hash_contractor = @hash_contractor\n (contractor == @hash_contractor) ? (puts message_good) : (puts message_bad)\n end", "def possessive(user)\n return 'your' if (user == current_user)\n return 'their' unless user.contact_information && user.contact_information.gender\n user.contact_information.gender == 'male' ? 'his' : 'her'\n end", "def team_result?\n registration_id.nil?\n end", "def not_approved?\n status_map = employee_vacation_responses.map(&:status).uniq\n status_map.size == 1 && status_map.include?(\"not_approved\")\n end", "def check_own_participant_and_redirect?\n unless @project.participants.ids.include? params[:participant_id].to_i\n flash[:danger] = 'Access denied. Participant does not belong to that project.'\n redirect_to display_project_participants_path(@project.id)\n end\n end", "def verify?(idno, vcode)\n if idno==''|| vcode==''\n flash[:error]=\"Fields can not be blank\"\n return false\n end\n\n #check if student exists\n student = Profile.find(idno)\n if student.id==3 #premade Profile for nonexistent students (check web service)\n flash[:error]=\"Student not found\"\n return false\n end\n\n #need hash formula for vcode verification here!\n if vcode != hash(idno)[4..9]\n flash[:error]=\"Invalid Verification Code #{hash(idno)[4..9]}\"\n return false\n end\n\n\n return true\n end", "def transferred_identity?\n secondary_identity? && participant_profiles.any?\n end", "def mandate_given_to?(advocate)\n return false if advocate.blank?\n !self.given_mandates.find(:first, :conditions => [\"mandates.advocate_id = ?\", advocate.id]).blank?\n end", "def msg_not_boolean(parent, key, value); end", "def can_use_ill?\n !virginia_borrower?\n end", "def pregnancy_to_confirm\n # TODO: add (Just to confirm) . . . if participant known to be pregnant\n \"A\"\n end", "def current_participant?(participant)\n\t participant == current_participant\n\tend", "def fellow_cult_members\n # we want a list of followers, so SELECT is a good tool\n # .any? will return true or false if ANY elements return true for the block\n # .include? will see if an array includes a given element\n Follower.all.select do |follower|\n follower != self && follower.cults.any? do |cult|\n self.cults.include?(cult)\n end\n end\n end", "def adoptant?\n role.name == \"Adoptante\" rescue \"N/A\"\n end", "def where_no_developers\n [[:educator_id, '!=', 12],\n [:educator_id, '!=', 509]]\n end", "def mandate_received_from?(advocate)\n return false if advocate.blank?\n !self.received_mandates.find(:first, :conditions => [\"mandates.advocate_id = ?\", advocate.id]).blank?\n end", "def is_participant?(participant)\n return false if participant.nil?\n return self.receipts_for(participant).count != 0\n end", "def foreign_visitor?\n not user\n end", "def maintenance_request_stakeholders(maintenance_request_id)\n # mr = MaintenanceRequest.find_by(id:maintenance_request_id)\n # mr_tenants = mr.tenants\n # #mr_agent = mr.agent.user.id if mr.agent != nil\n # mr_agency_admin = mr.agency_admin.user.id if mr.agency_admin != nil\n # mr_landlord = mr.property.landlord.user.id if mr.property.landlord_id != nil \n # mr_trady = mr.trady.user.id if mr.trady !=nil\n \n # mr_user_affiliates_array = []\n \n # if mr_agent != nil\n # mr_user_affiliates_array.push(mr_agent)\n # end \n\n # if mr_agency_admin != nil\n # mr_user_affiliates_array.push(mr_agency_admin)\n # end\n\n # if mr_landlord !=nil \n # mr_user_affiliates_array.push(mr_landlord)\n # end\n\n # if mr_trady !=nil \n # mr_user_affiliates_array.push(mr_trady)\n # end \n\n\n \n # mr_tenants.each do |tenant|\n # mr_user_affiliates_array.push(tenant.user.id)\n # end \n\n\n \n \n \n # if mr_user_affiliates_array.include?(current_user.id)\n # #do nothing\n \n # else\n # flash[:danger] = \"Sorry you are not allowed to see that!!!\"\n # redirect_to root_path\n # end\n end", "def who_can_drink_legally(instructors)\n instructors.select do |instructor|\n instructor[:age] >= 21\n end\nend", "def is_critical?(bet_arr)\n return false if bet_arr[0].nil?\n team = bet_arr[0].bet_on\n return false if team.nil? # Not everyone has bet on this game.\n bet_arr.each {\n | bet |\n return false if bet.nil?\n if (bet.bet_on != team)\n return false\n end\n }\n return true\nend", "def cannot_edit(_t)\n !session[:is_administrator] && !_t.approver_id.blank?\n end", "def person?\n !!self.person\n end", "def person?\n !!self.person\n end", "def invited_or_captain\n self.captain || invited?\n end", "def is_a_patient?\n ((!self.role.blank?) && (self.role == self.class::PATIENT))\n end", "def sms_eligibility_check\n redirect_to(root_url) && return unless current_user.can_edit_patient?\n\n phone_number = params.require(:phone_number)\n blocked = BlockedNumber.exists?(phone_number: phone_number)\n render json: { sms_eligible: !blocked }\n end", "def unverify_agent_from_a_property ### Invited by the vendor\n if user_valid_for_viewing?(['Vendor'], params[:udprn].to_i)\n udprn = params[:udprn].to_i\n agent_id = params[:agent_id].to_i\n vendor_id = @current_user.id\n \n #### Transfer the enquiries\n Event.where(agent_id: agent_id, udprn: udprn).update_all(agent_id: nil)\n update_hash = { agent_id: nil, claimed_at: nil, claimed_by: nil, vendor_id: nil, beds: nil, baths: nil, receptions: nil, property_type: nil, property_status_type: nil }\n\n #### Destroy the f&f lead\n Agents::Branches::AssignedAgents::Lead.where(property_id: params[:udprn].to_i, agent_id: agent_id, owned_property: true).last.destroy\n PropertyService.new(udprn).update_details(update_hash)\n\n render json: { message: \"The property has been removed from agents and vendors properties\" }, status: 200\n else\n render json: { message: 'Authorization failed' }, status: 401\n end\n end", "def vip_member\n is_admin != true\n end", "def mandatory_case_details?\n claim.court && claim.case_number && claim.external_user\n end", "def patient_implicit?\n @authorized_user.patients.size == 1 \n end", "def solo?\n self.participant_role == 'soloist'\n end", "def grants_gov_pi\n self.find_all { |user| !user[1][:primary_department_code].nil? &&\n !user[1][:phones].find{|phone| phone[:type]=='Work'}.nil? &&\n !user[1][:emails].find{|email| email[:type]=='Work'}.nil? &&\n !user[1][:era_commons_user_name].nil?\n }.shuffle[0][0]\n end", "def verified?\n (verified rescue false) == true\n end", "def is_fir?\n self.fir_role != nil\n end", "def patient_visit_list\n yes_concept = ConceptName.find_by_name('YES').concept_id\n hiv_reception_breakdown = {}\n\n (patient_visits || []).each do |v|\n # visit_date = v['obs_datetime'].to_date\n visit_type = v['name']\n ans_given = v['value_coded'].to_i == yes_concept\n patient_id = v['patient_id'].to_i\n patient_present = (visit_type.match(/patient/i) && ans_given ? true : false)\n guardian_present = (visit_type.match(/person/i) && ans_given ? true : false)\n\n if hiv_reception_breakdown[patient_id].blank?\n demographics = client_data(patient_id)\n hiv_reception_breakdown[patient_id] = {\n patient_present: false, guardian_present: false,\n given_name: demographics['given_name'],\n family_name: demographics['family_name'],\n gender: demographics['gender'],\n birthdate: demographics['birthdate'],\n arv_number: demographics['arv_number']\n }\n end\n\n hiv_reception_breakdown[patient_id][:patient_present] = patient_present if visit_type.match(/patient/i)\n hiv_reception_breakdown[patient_id][:guardian_present] = guardian_present if visit_type.match(/person/i)\n end\n\n hiv_reception_breakdown\n end", "def is_participant?(participant)\n return false unless participant\n receipts_for(participant).any?\n end", "def exclude_sender_in_team_from_recognition_recipients\n sender_recipients = recognition_recipients.select {|rr| rr.user_id == sender&.id }\n if sender_recipients.any?{|rr| rr.team_id.present? } && sender_recipients.none?{|rr| rr.team_id.nil? }\n self.recognition_recipients = self.recognition_recipients.reject{|rr| rr.team_id.present? && rr.user_id == sender.id}\n end\n end", "def vamp_test(prof)\n\tresults = \"Results inconclusive.\"\n\tif $vamp_names.include?(prof[:name])\n\t\tresults = \"Definitely a vampire.\"\n\telsif prof[:is_age] == false && prof[:likes_garlic] ==\"n\" && prof[:wants_insurance] == \"n\"\n\t\tresults = \"Almost certainly a vampire.\"\n\telsif prof[:allergies].include?(\"sunshine\") || (prof[:is_age] == false && (prof[:likes_garlic] == \"n\" || prof[:wants_insurance] == \"n\"))\n\t\tresults = \"Probably a vampire.\"\t\n\telsif prof[:is_age] != false && (prof[:likes_garlic] == \"y\" || prof[:wants_insurance] == \"y\")\n\t\tresults = \"Probably not a vampire.\"\n\telse\n\t\tresults\n\tend\nend", "def no_l2l_day_loan?\n # [10, 17, 23, 24].include? @type['id']\n [\n 'a00b928e-39ef-4c32-aec9-f57dfb588456', # '1 Day Loan'\n '558f30ed-8def-4af6-bf89-c93a69dd51b9' # '2 Day Loan'\n ].include? @type['id']\n end", "def check_special llorens_cliente_id\n specials = [\"4300999999\"]\n # 4300999999 is for non-company customers, not to be considered\n specials.include? llorens_cliente_id\n end", "def valid_invitation_sender?(program_slug, invitation_level)\n result={}\n\n # superuser\n if self.is_superuser?\n result[:valid] = true\n return result\n end\n\n # no program nor invitation level selected\n if ((program_slug.nil?) || (program_slug.empty?) || (program_slug == I18n.t('invitations.form.prompt.select_program')) || (invitation_level.nil?) || (invitation_level.blank?))\n result[:valid] = false\n result[:error_invitation_level]=I18n.t('invitations.form.errors.invitation_type_none') if (invitation_level.nil? || invitation_level.blank?)\n result[:error_program_id] = I18n.t('invitations.form.errors.program') if ((program_slug.nil?) || (program_slug.empty?) || (program_slug == I18n.t('invitations.form.prompt.select_program')))\n return result\n end\n\n # convert invitation_level\n if (!invitation_level.nil?)\n invitation_level = invitation_level.to_i \n end\n\n # verify that this user has proper permissions for sending out invitation\n program=Program.friendly.find(program_slug)\n matches = Role.where(\"program_id = ? and user_id = ?\", program.id, self.id)\n\n if matches.empty?\n # no matches\n result[:valid]=false\n result[:error_invitation_level]=I18n.t('invitations.form.errors.invitation_type_invalid')\n else\n user_level = matches.first.level\n if (user_level == ConstantsHelper::ROLE_LEVEL_ADMIN)\n if ((invitation_level == ConstantsHelper::ROLE_LEVEL_STUDENT) ||\n (invitation_level == ConstantsHelper::ROLE_LEVEL_STAFF) ||\n (invitation_level == ConstantsHelper::ROLE_LEVEL_ADMIN))\n result[:valid] = true\n else\n result[:valid] = false\n result[:error_invitation_level]=I18n.t('invitations.form.errors.privileges_superusers') if invitation_level == ConstantsHelper::ROLE_LEVEL_SUPERUSER\n end\n elsif (user_level == ConstantsHelper::ROLE_LEVEL_STAFF)\n if (invitation_level == ConstantsHelper::ROLE_LEVEL_STUDENT)\n result[:valid] = true\n else\n result[:valid] = false\n result[:error_invitation_level]=I18n.t('invitations.form.errors.privileges_superusers') if invitation_level == ConstantsHelper::ROLE_LEVEL_SUPERUSER\n result[:error_invitation_level]=I18n.t('invitations.form.errors.privileges_administrators') if invitation_level == ConstantsHelper::ROLE_LEVEL_ADMIN\n result[:error_invitation_level]=I18n.t('invitations.form.errors.privileges_staff') if invitation_level == ConstantsHelper::ROLE_LEVEL_STAFF\n end\n elsif (user_level == ConstantsHelper::ROLE_LEVEL_STUDENT)\n result[:valid] = false\n result[:error_invitation_level]=I18n.t('invitations.form.errors.privileges_superusers') if invitation_level == ConstantsHelper::ROLE_LEVEL_SUPERUSER\n result[:error_invitation_level]=I18n.t('invitations.form.errors.privileges_administrators') if invitation_level == ConstantsHelper::ROLE_LEVEL_ADMIN\n result[:error_invitation_level]=I18n.t('invitations.form.errors.privileges_staff') if invitation_level == ConstantsHelper::ROLE_LEVEL_STAFF\n result[:error_invitation_level]=I18n.t('invitations.form.errors.privileges_students') if invitation_level == ConstantsHelper::ROLE_LEVEL_STUDENT\n else\n result[:valid] = false\n result[:error_invitation_level]=I18n.t('invitations.form.errors.invalid_role_level') \n end\n end\n return result\n end", "def verify?(idno, vcode)\n if idno==''|| vcode==''\n flash[:error]=\"All fields are required.\"\n return false\n end\n\n #check if student exists\n begin\n student = Profile.find(idno)\n if student.idNo==2041575 #premade Profile for nonexistent students (check web service)\n flash[:error]=\"The student cannot be found. Please check the ID number and try again.\"\n return false\n end\n \n \n #need hash formula for vcode verification here!\n if vcode != hash(idno)[4..9]\n flash[:error]=\"Invalid Verification Code #{hash(idno)[4..9]}\"\n return false\n end\n rescue\n flash[:error]=\"The student cannot be found. Please check the ID number and try again.\"\n return false\n end\n\n return true\n end", "def invite?\r\n admin? or (user.id != user_record.id and streamer?)\r\n end", "def instructors_who_can_drink_legally(instructors)\n instructors.select do |instructor|\n instructor[:age] >= 21\n end\nend", "def court(mate)\n response = false\n if @sex == Male and mate.sex == Female\n response = mate.response_to(self)\n @rejections = (response==true) ? 0 : @rejections+=1\n # self esteem takes a dive if you get rejected too often\n @virility = 0 if @rejections >= RejectionThreshold\n end\n response\n end", "def verified_answer(user_response, list_of_responses)\n if list_of_responses.include? user_response\n user_response\n else\n invalid_return_mm\n end\n end", "def test_quarantined?(example)\n quarantine_map.key?(example.id)\n end", "def veteran_info; end", "def invite_by_registration_code?\n invitation_params.is_a?(TrueClass) || invitation_params.is_a?(FalseClass)\n end", "def not_show(c)\n if c == \"created_at\" || c == \"updated_at\" || c == \"bibtexkey\" || c == \"id\"\n return true;\n else\n return false;\n end\n end", "def has_verified_akismet_key?()\n return @verifiedKey\n end", "def metareviewed_by?(metareviewer)\n MetareviewResponse.find_all_by_reviewee_id_and_reviewer_id_and_reviewed_object_id(self.reviewer.id, metareviewer.id, self.id).count() > 0 #changed MetareviewResponseMap to MetareviewResponse\n end", "def loan_officers?\n\t\t!!current_admin || !!current_loan_manager || !!current_accountant\n\tend", "def patient_visit_types\n yes_concept = ConceptName.find_by_name('YES').concept_id\n hiv_reception_breakdown = {}\n\n (patient_visits || []).each do |v|\n visit_date = v['obs_datetime'].to_date\n visit_type = v['name']\n ans_given = v['value_coded'].to_i == yes_concept\n patient_id = v['patient_id'].to_i\n patient_present = (visit_type.match(/patient/i) && ans_given ? true : false)\n guardian_present = (visit_type.match(/person/i) && ans_given ? true : false)\n\n if hiv_reception_breakdown[visit_date].blank?\n hiv_reception_breakdown[visit_date] = {}\n hiv_reception_breakdown[visit_date][patient_id] = {\n patient_present: 0, guardian_present: 0\n }\n elsif hiv_reception_breakdown[visit_date][patient_id].blank?\n hiv_reception_breakdown[visit_date][patient_id] = {\n patient_present: false, guardian_present: false\n }\n end\n\n if visit_type.match(/patient/i)\n hiv_reception_breakdown[visit_date][patient_id][:patient_present] = patient_present\n end\n if visit_type.match(/person/i)\n hiv_reception_breakdown[visit_date][patient_id][:guardian_present] = guardian_present\n end\n end\n\n hiv_reception_breakdown\n end", "def awaiting_dean_approval?\n awarded? && !dean_approved?\n end", "def has_premium_transcripts?\n self.id.match(/_(business|enterprise|premium)_/) or self.id.match(/_(monthly|yearly)/) or self.is_community?\n end" ]
[ "0.6592609", "0.6357738", "0.60706544", "0.5881208", "0.5734849", "0.55024", "0.54333806", "0.54032403", "0.53919834", "0.5328937", "0.52663773", "0.52610284", "0.5257675", "0.5257263", "0.5257263", "0.5257221", "0.523365", "0.52276844", "0.5226714", "0.5207491", "0.5205826", "0.5203926", "0.5197855", "0.51968485", "0.5190647", "0.5168754", "0.51648456", "0.5119935", "0.5109899", "0.51021916", "0.5091351", "0.50866497", "0.5079517", "0.5058774", "0.50238055", "0.50144994", "0.501101", "0.50101024", "0.5010086", "0.500843", "0.5007352", "0.49778676", "0.49769285", "0.49767858", "0.4975467", "0.49752945", "0.49744943", "0.4973558", "0.497146", "0.4970178", "0.49658123", "0.49542478", "0.4951699", "0.49468616", "0.49444064", "0.4944081", "0.4934599", "0.49291", "0.49222964", "0.49153334", "0.49027985", "0.48960865", "0.4894382", "0.48895833", "0.48864388", "0.48864388", "0.488447", "0.48798072", "0.48790503", "0.48784485", "0.48740745", "0.48671147", "0.48665872", "0.4865151", "0.4865056", "0.4861842", "0.48546448", "0.48469278", "0.48443893", "0.48435917", "0.4837045", "0.4835856", "0.48321146", "0.4830892", "0.48284382", "0.4822901", "0.4822209", "0.4817956", "0.4815173", "0.48146006", "0.48123044", "0.48080453", "0.4807224", "0.48024827", "0.47977868", "0.47976276", "0.47932115", "0.47918344", "0.4785013" ]
0.70240396
1
array of allowed types (values) for params paths rubocop:disable Metrics/MethodLength
def types_and_paths [ [OBJECT, ["data"]], [["HigherLevelReview"], %w[data type]], [OBJECT, %w[data attributes]], [[String, nil], %w[data attributes receiptDate]], [BOOL, %w[data attributes informalConference]], [[Array, nil], %w[data attributes informalConferenceTimes]], [[String, nil], ["data", "attributes", "informalConferenceTimes", 0]], [[String, nil], ["data", "attributes", "informalConferenceTimes", 1]], [[nil], ["data", "attributes", "informalConferenceTimes", 2]], [[*OBJECT, nil], %w[data attributes informalConferenceRep]], *( if informal_conference_rep? # ... name and phoneNumber must be present [ [[String], %w[data attributes informalConferenceRep name]], [[String, Integer], %w[data attributes informalConferenceRep phoneNumber]] ] else [] end ), [[String, Integer, nil], %w[data attributes informalConferenceRep phoneNumberCountryCode]], [[String, Integer, nil], %w[data attributes informalConferenceRep phoneNumberExt]], [BOOL, %w[data attributes sameOffice]], [BOOL, %w[data attributes legacyOptInApproved]], [[String], %w[data attributes benefitType]], [OBJECT, %w[data attributes veteran]], [[String], %w[data attributes veteran ssn]], [[*OBJECT, nil], %w[data attributes claimant]], *( if claimant_object_present? # ... participantId and payeeCode must be present [ [[String], %w[data attributes claimant participantId]], [[String], %w[data attributes claimant payeeCode]] ] else [] end ), [[String, nil], %w[data attributes claimant addressLine1]], [[String, nil], %w[data attributes claimant addressLine2]], [[String, nil], %w[data attributes claimant city]], [[String, nil], %w[data attributes claimant stateProvinceCode]], [[String, nil], %w[data attributes claimant countryCode]], [[String, nil], %w[data attributes claimant zipPostalCode]], [[String, nil], %w[data attributes claimant phoneNumber]], [[String, nil], %w[data attributes claimant phoneNumberCountryCode]], [[String, nil], %w[data attributes claimant phoneNumberExt]], [[String, nil], %w[data attributes claimant emailAddress]], [[Array], ["included"]], # [OBJECT, ["included", 0]], # [["ContestableIssue"], ["included", 0, "type"]], # [[Integer, nil], ["included", 0, "attributes", "decisionIssueId"]], # [[String, nil], ["included", 0, "attributes", "ratingIssueId"]], # [[String, nil], ["included", 0, "attributes", "ratingDecisionIssueId"]], # [[Array, nil], ["included", 0, "attributes", "legacyAppealIssues"]] # [OBJECT, ["included", 1]], # [["ContestableIssue"], ["included", 1, "type"]], # [[Integer, nil], ["included", 1, "attributes", "decisionIssueId"]], # [[String, nil], ["included", 1, "attributes", "ratingIssueId"]], # [[String, nil], ["included", 1, "attributes", "ratingDecisionIssueId"]], # [[Array, nil], ["included", 1, "attributes", "legacyAppealIssues"]] # ... *for_array_at_path_enumerate_types_and_paths( # ^^^ array_path: ["included"], types_and_paths: [ [OBJECT, []], [["ContestableIssue"], ["type"]], [[String, Integer, nil], %w[attributes decisionIssueId]], [[String, Integer, nil], %w[attributes ratingIssueId]], [[String, Integer, nil], %w[attributes ratingDecisionIssueId]] ] ) ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def params() @param_types end", "def validate_paths(paths)\n paths = [paths] unless paths.is_a?(Array)\n raise 'The provided paths must all be Strings' \\\n unless paths.all? { |path| path.is_a?(String) }\n\n Wgit::Utils.process_arr(paths, encode: false)\n raise 'The provided paths cannot be empty' if paths.empty?\n\n paths\n end", "def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end", "def check_implied_type_params\n invalid = []\n found = {\n :static => 0,\n :dhcp => 0,\n :addrconf => 0,\n }\n\n # List of all address_type properties\n @check_props = [:address,:remote_address,:down,:seconds,\n :hostname, :interface_id,:remote_interface_id]\n @check_props.freeze\n\n # Address types with acceptable properties\n @type_props = {\n :static => [:address,:remote_address,:down],\n :dhcp => [:seconds,:hostname],\n :addrconf => [:interface_id,:remote_interface_id],\n :from_gz => [],\n :inherited => []\n }\n @type_props.freeze\n\n # Set found = 1 for each type\n @type_props.each_pair do |k,v|\n v.each do |cp| found[k] = 1 if self[cp]\n end end\n\n # If more than one type is found the configuration is invalid\n if found.values.inject(0){ |s,a| s+= a } > 1\n invalid.push(\"incompatible property combination #{found.inspect}\")\n end\n\n return invalid\n end", "def paramstype\n \"Array\"\n end", "def allowed_params\n ALLOWED_PARAMS\n end", "def allowed_formats (*formats)\n\t\tunless formats.empty?\n\t\t\traise_if_error C.glyr_opt_allowed_formats(to_native, formats.flatten.compact.uniq.join(';'))\n\t\telse\n\t\t\tto_native[:allowed_formats] && to_native[:allowed_formats].split(/\\s*;\\s*/)\n\t\tend\n\tend", "def content_type_allowlist\n Rails.configuration.x.file_upload_content_type_allowlist.split(/\\s*,\\s*/)\n end", "def routing_params_with_patterns\n @routing_params_with_patterns ||= begin\n Gapic::UriTemplate.parse_arguments(path).map do |name, pattern|\n [name, pattern.empty? ? \"*\" : pattern]\n end\n end\n end", "def param_types\n schema.param_types\n end", "def param_array(keys)\n puts \"Entering param_array '#{@sy}'\" if DEBUG\n type = nil\n \n if @sy.type == TokenType::ARRAY_TOKEN\n next_token\n if @sy.type == TokenType::OF_TOKEN\n next_token\n type = param_type(keys | Array.follow)\n else\n error(\"Line #{@sy.line_number} expected 'of', but saw '#{@sy.text}'\", keys | Array.follow)\n end\n else\n error(\"Line #{@sy.line_number} expected 'array', but saw '#{@sy.text}'\", keys | Array.follow)\n end\n puts \"Leaving param_array '#{@sy}'\" if DEBUG\n \n TypeNode.new \"array of #{type.type}\"\n end", "def for_array_at_path_enumerate_types_and_paths(array_path:, types_and_paths:)\n array = @params.dig(*array_path)\n\n array.each.with_index.reduce([]) do |acc, (_, index)|\n [\n *acc,\n *self.class.prepend_path_to_paths(\n prepend_path: [*array_path, index],\n types_and_paths: types_and_paths\n )\n ]\n end\n rescue StandardError\n []\n end", "def allowed_types\n\t\treturn [EmailAddress, Device, Domain, Organization, User, Location, Service, NetApplication, WebApplication]\n\tend", "def single_access_allowed_request_types(value = nil)\n config(:single_access_allowed_request_types, value, [\"application/rss+xml\", \"application/atom+xml\"])\n end", "def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::Domain, \n Entities::Host,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend", "def allowed_methods( path_components )\n\t\ttype = path_components.empty? ? :collection : :single\n\t\tallowed = HTTP_METHOD_MAPPING[ type ].keys.\n\t\t\tfind_all {|msym| self.respond_to?(msym) }.\n\t\t\tinject([]) {|ary,msym| ary << HTTP_METHOD_MAPPING[type][msym]; ary }\n\n\t\tallowed += ['HEAD'] if allowed.include?( 'GET' )\n\t\treturn allowed.uniq.sort\n\tend", "def type_params; end", "def type_params; end", "def type_params; end", "def type_params; end", "def type_params; end", "def allowed?(val)\n case ftype\n when 'string', 'url'\n val.is_a?(String)\n when 'number'\n val.is_a?(Integer) || val.is_a?(Float)\n when 'sample'\n allowable_field_types.collect { |aft| aft.sample_type.id }.member? val.sample_type_id\n when 'item'\n allowable_field_types.collect { |aft| aft.object_type.id }.member? val.object_type_id\n end\n end", "def types_not_permitted\n %w(City Region Country Activity Restaurant Hotel) - [@type]\n end", "def all(path, type); end", "def types\n @opt_types.values\n end", "def valid_args(type)\n case type\n when 'search' then %i[q format addressdetails extratags namedetails viewbox bounded exclude_place_ids limit accept-language email]\n when 'reverse' then %i[format lat lon zoom addressdetails extratags namedetails accept-language email]\n else []\n end\n end", "def allowed_types\n [SearchString]\nend", "def describe_types\n [@options[:type]].flatten.join('/')\n end", "def valid_types(record)\n Array(record.supported_mime_types)\n rescue NoMethodError\n Array.new\n end", "def allowed_file_types\n Rails.configuration.allowed_file_types\n end", "def valid_options\n %i(\n\n ) # end array\n end", "def required_param_types_present?\n @required_param_types.each do |string|\n return false unless param_classname_present?(string)\n end\n return true\n end", "def location_type_params\n params.require(:location_type).permit(:name,\n :location_types => [])\n end", "def allowed_types\n [ Entities::Domain, \n Entities::Host, \n Entities::Organization, \n Entities::SearchString, \n Entities::Person]\nend", "def types=(types)\n @types = Array(types) if types\n end", "def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::DnsRecord, \n Entities::Host,\n Entities::EmailAddress,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend", "def argument_types=(*value)\n end", "def request_type_params\n params.require(:request_type).permit(:name, :note, :requires_supervisor_approval, :requires_supervisor_supervisor_approval, :requires_dpe_approval, :requires_dpe_supervisor_approval, :cancel_url, :redirect_url, {virtual_object_attachments: [], virtual_object_attachments_cache: [], virtual_object_attachments_small: []})\n end", "def types(types); end", "def path_value_args(args)\n args.each_slice(2)\n .map { |p, v| [p, serialize_literal(v)] }.flatten(1)\n end", "def accepted_content_types\n return @content_types if @content_types\n @content_types = []\n if val = @ext_params[\"content_return_types\"]\n @content_types = val.split(',').map {|i| i.to_sym}\n end\n\n @content_types\n end", "def options_for_supported_types\n Mapping::SUPPORTED_TYPES.map do |type|\n [type.titleize.to_s, type]\n end\n end", "def validate_params(params)\n keys = params.keys.sort\n\n # Is this anywhere near a good idea or am I being too cute here?\n operation = caller[0][/`([^']*)'/, 1]\n\n case operation\n when 'create_content'\n keys - CREATE_PARAMS.sort == []\n when 'list_content'\n keys - LIST_PARAMS.sort == []\n when 'show_content'\n keys - SHOW_PARAMS.sort == []\n when 'update_content'\n keys - UPDATE_PARAMS.sort == []\n when 'delete_content'\n keys - DELETE_PARAMS.sort == []\n else raise ArgumentError, \"Operation: #{operation} not supported\"\n end\n end", "def allowed_types\n config.allowed_response_types\n end", "def valid_argument_list!(rest, *types)\n if rest.size == types.size\n result = rest.zip(types).collect do |arg, type|\n if String == type\n arg.to_s\n elsif Symbol == type\n arg.to_sym\n elsif Integer\n arg.to_i\n else\n raise OptionParser::InvalidArgument, arg\n end\n end\n result.size == 1 ? result[0] : result\n elsif rest.size < types.size\n raise OptionParser::MissingArgument\n else\n raise OptionParser::NeedlessArgument, rest\n end\n end", "def arrivaltype_params\n params.require(:arrivaltype).permit(:arrivalTypes)\n end", "def argument_types?(*value)\n true\n end", "def walk_params\n allowed_params = %w(time dog_ids)\n params.select {|param,value| allowed_params.include?(param)}\n end", "def validate_params\n data = endpoint_params\n errors = []\n errors << 'Invalid verb' if %w[GET POST PATCH DELETE].exclude?(data[:verb])\n # check for valid url\n begin\n URI.parse data[:path]\n rescue URI::InvalidURIError => e\n errors << 'Invalid Path'\n end\n render json: { errors: errors }, status: :unprocessable_entity if errors.present?\n end", "def types\n [\n { value: 'bus', name: 'Bus' },\n { value: 'coach', name: 'Coach' },\n { value: 'hgv', name: 'Heavy goods vehicle' },\n { value: 'van', name: 'Van' },\n { value: 'minibus', name: 'Minibus' },\n { value: 'private_car', name: 'Car' },\n { value: 'motorcycle', name: 'Motorcycle' }\n ]\n end", "def allowed_types\n [ Entities::Account,\n Entities::DnsRecord, \n Entities::DnsServer, \n Entities::DocFile,\n Entities::EmailAddress,\n Entities::FacebookAccount,\n Entities::Finding,\n Entities::Host, \n Entities::LocalImage,\n Entities::RemoteImage,\n Entities::KloutAccount,\n Entities::NetBlock,\n Entities::NetSvc,\n Entities::Organization,\n Entities::ParsableFile,\n Entities::ParsableText,\n Entities::PdfFile,\n Entities::Person,\n Entities::PhysicalLocation, \n Entities::SearchString, \n Entities::TwitterAccount,\n Entities::Username,\n Entities::WebApplication,\n Entities::WebForm,\n Entities::WebPage,\n Entities::XlsFile ]\n end", "def allowed_types\n\treturn [User]\nend", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def valid_types\n [:common, :email, :ipn]\n end", "def expected_params\n (defaults.keys | optional | required).map(&:to_s).uniq\n end", "def valid_path?(path)\n validations = []\n if @opts[:filter]\n validations << (path =~ @opts[:filter])\n end\n if @opts[:ignore]\n validations << (path !~ @opts[:ignore])\n end\n\n validations.all?\n end", "def mime_types(*types)\n types.flatten.each do |t|\n @mime_types << t\n end\n @mime_types\n end", "def format_itypes(itypes, params)\n case itypes\n when Array\n params['pio_itypes'] = itypes.join(\",\") if itypes.any?\n when String\n params['pio_itypes'] = itypes\n end\n end", "def check_input_types\n inputfiles = {}\n inputfiles[:required] = %i{assembly mut_bulk}\n inputfiles[:optional] = %i{bg_bulk}\n if @options[:input_format] == 'bam'\n inputfiles[:required] << %i{mut_bulk_vcf}\n inputfiles[:optional] << %i{bg_bulk_vcf}\n end\n if @options[:polyploidy]\n inputfiles[:either] = %i{mut_parent bg_parent}\n end\n check_input_files(inputfiles)\n end", "def mime_types\n safe_const_get(:MIME_TYPES) || []\n end", "def parse_enumerated_field(allowed_values, keys, params: {}, allow_nil: true)\n value = params.dig(*keys)\n\n if value.respond_to?(:each)\n raise InvalidValueError.new(keys.join('/')) unless value.all? { |v|\n allowed_values.include?(v)\n }\n else\n return nil if !value && allow_nil\n\n raise InvalidValueError.new(keys.join('/')) unless allowed_values.include?(value)\n end\n\n value\n end", "def acceptable_values?\n options_s_keys = options.keys.map(&:to_s)\n\n if @attributes[:multiple] && resolver.params[name].respond_to?(:map)\n (resolver.params[name].map(&:to_s) - options_s_keys).empty?\n else\n options_s_keys.include?(resolver.params[name].to_s)\n end\n end", "def route_type_params\n params.require(:route_type).permit(:name)\n end", "def expected_permitted_parameter_names; end", "def param_type\n param_type = type.to_sym\n param_type = fields.to_h { |field| [field.name.to_sym, field.param_type] } if record?\n param_type = [param_type] if repeated?\n param_type\n end", "def valid?(value, types)\n types.any? do\n case _1\n when :array then true if value.is_a?(Array)\n when :boolean then true # in Ruby everything is a boolean\n when :float then true if value.is_a?(Float) || value.is_a?(Integer)\n when :hash then true if value.is_a?(Hash)\n when :integer then true if value.is_a?(Integer)\n when :string then true if value.is_a?(String)\n when :symbol then true if value.is_a?(Symbol)\n when Class then true if value.is_a?(_1) # for custom checks\n else\n raise \"unknown flag type #{_1.inspect}\"\n end\n end\n end", "def selected_mime_types\n return [] if mime_types.blank?\n\n mime_types.split(',')\n end", "def permitted_params\n []\n end", "def endpoint_types\n %w()\n end", "def validate_params(params, klass)\n raise(ArgumentError, \"Options cannot be \" + params.class.name) unless params.is_a?(klass) || params.is_a?(Hash) || \n (ASSOCIATED_PARAMS[klass] && ASSOCIATED_PARAMS[klass].keys.include?(params.class))\n params.is_a?(Glassfrog::Base) ? params.hashify : params\n end", "def params\n # Normal cases\n # raise @params.values.inspect\n # return @params.values.length.inspect\n if %w{ready accesses list_subscribe list_unsubscribe}.include?(@action)\n @params\n elsif @params.values.first.is_a? Hash\n {@params.keys.first => @params.values.first.select{|k,v| v.present? }}\n elsif @params.values.first.is_a? Array\n {@params.keys.first => @params.values.first.select(&:present?)} rescue {}\n end\n # rescue => e\n # {}\n end", "def validate_params(wanted, got)\n arg_regex = {\n :integer => /\\A\\d+\\z/, # Integer (not range checked here)\n :character => /\\A[A-Z]\\z/, # Upper case letter\n }\n\n raise ArgumentError, \"Bad arguments for command\" if (wanted.length != got.length)\n\n actual_params = Array.new\n\n wanted.zip(got).each do |a,b|\n raise ArgumentError, \"Bad argument '#{b}'\" unless arg_regex[a] =~ b\n actual_params.push(a == :integer ? b.to_i : b.to_s)\n end\n\n return actual_params\n end", "def accepted_parameters\n required_parameters + optional_parameters\n end", "def test_paths_as_arrays\n path = %w{/usr/bin /usr/sbin /sbin}\n exec = nil\n assert_nothing_raised(\"Could not use an array for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => path)\n end\n assert_equal(path, exec[:path], \"array-based path did not match\")\n assert_nothing_raised(\"Could not use a string for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => path.join(\":\"))\n end\n assert_equal(path, exec[:path], \"string-based path did not match\")\n assert_nothing_raised(\"Could not use a colon-separated strings in an array for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => [\"/usr/bin\", \"/usr/sbin:/sbin\"])\n end\n assert_equal(path, exec[:path], \"colon-separated array path did not match\")\n end", "def type(types)\n types = [types] unless types.is_a?(Array)\n any_in(:_type => types)\n end", "def checktype_params\n params.require(:checktype).permit(:name, :description, :timeout, :enabled, :options, :image, :assets => [], :required_vars => [])\n end", "def preferred_types(supported_types)\n @preferred_auth_policies.select{|uri| supported_types.member? uri}\n end", "def fish_type_params\n ActiveModelSerializers::Deserialization.jsonapi_parse(params)\n end", "def parameter_types; end", "def get_form_filter_types\n [\n [\"From..To\", \"from_to\"],\n [\"Equals\", \"equals\"],\n [\"Not Equal To\", \"not_equals\"],\n [\"Is Greater Than\", \"greater_than\"],\n [\"Is Greater Than Or Equal To\", \"greater_than_or_equal\"],\n [\"Is Less Than\", \"less_than\"],\n [\"Is Less Than Or Equal To\", \"less_than_or_equal\"]\n\n ]\n end", "def validate_parameter_type\n if PRIMITIVE_PARAMETER_TYPES.include? self.parameter_type || self.parameter_type === 'Object'\n true\n elsif self.parameter_type.include?('[') # compound types have brackets []\n # extract primitives from complex type\n raw_primitives = self.parameter_type.split('[').last\n raw_primitives.gsub!(/]\\??/, '')\n primitives = raw_primitives.split(',').map(&:strip)\n if self.parameter_type.start_with?('Array')\n # there is only one primitive type from the control list\n unless primitives.size === 1 && PRIMITIVE_PARAMETER_TYPES.include?(primitives.first)\n errors.add(:parameter_type, \"has an invalid primitive type: #{(primitives - PRIMITIVE_PARAMETER_TYPES).join(', ')}\")\n end\n elsif self.parameter_type.start_with?('Map')\n # there are two primitive types, and the intersection is the same as the unique list of primitives\n unless primitives.size === 2 && (primitives & PRIMITIVE_PARAMETER_TYPES === primitives.uniq)\n errors.add(:parameter_type, \"has an invalid primitive type: #{(primitives - PRIMITIVE_PARAMETER_TYPES).join(', ')}\")\n end\n else\n errors.add(:parameter_type, \"has an invalid complex type: #{self.parameter_type.split('[').first}\")\n end\n else\n errors.add(:parameter_type, \"has an invalid value: #{self.parameter_type}\")\n end\n end", "def spec_type_params\n params[:spec_type]\n end", "def point_type_params\n params[:point_type]\n end", "def path(type)\n registry[type] || []\n end", "def bath_type_params\n params.permit(:name)\n end", "def relation_type_params\n params.require(:relation_type).permit(:name, :color, :num_nodes, :project_id, :entity_type => [])\n end", "def params(method_or_path, options = {})\n method_or_path = method_or_path.to_s\n [\n path_for(method_or_path, options),\n options_for(method_or_path, options)\n ]\n end", "def index_params\n params.permit(:type)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def departuretype_params\n params.require(:departuretype).permit(:departureTypes)\n end", "def validate_prerequisites_kinds\n allowed = [\"Job\", \"Pod\"]\n return if map_attributes(RoleConfigFile::PREREQUISITE).compact.empty?\n return if (map_attributes([:kind]) & allowed).any? || templates.empty?\n\n @errors << \"Prerequisites only support #{allowed.join(', ')}\"\n end", "def get_allowed_values\n allowed_values = {}\n #nyc value. keeping this first one around as an example, in case we follow suit with the subfield mappings here.\n allowed_values['archives'] = { b: 'BARCH', c: 'MAIN' }\n allowed_values['whatever'] = {}\n allowed_values['BRBL'] = {}\n allowed_values['Divinity'] = {}\n allowed_values\n end", "def allowed_types\n\t\t[Device, EmailAddress]\n\tend", "def routing_params\n routing_params_with_patterns.map { |param, _| param }\n end", "def optype_params\n params.require(:optype).permit(:name)\n end", "def params_array_from(raw_params); end", "def params_array_from(raw_params)\n raw_params.map { |param| param.split %r/=(.+)?/ }\n end", "def intervention_type_params\n params.require(:intervention_type).permit(:name, :obs)\n end", "def method_type_params\n params.require(:method_type).permit(:description, :macroscopy, :diagnosis)\n end", "def allowed_types\n [SearchString, User]\nend" ]
[ "0.682767", "0.6291914", "0.60052997", "0.5931734", "0.59296006", "0.5841406", "0.5835509", "0.58345854", "0.5827929", "0.58013344", "0.57973975", "0.57920426", "0.57650745", "0.5764036", "0.5717994", "0.5710983", "0.57043856", "0.5704126", "0.5704126", "0.5704126", "0.5704126", "0.5704126", "0.5694123", "0.56396264", "0.5635673", "0.56227386", "0.5620144", "0.5612845", "0.55973434", "0.55823636", "0.5581851", "0.55810386", "0.55678505", "0.5567372", "0.55607694", "0.5558994", "0.5549054", "0.54916656", "0.54862505", "0.54747117", "0.54743654", "0.54696304", "0.54408556", "0.5437451", "0.5436353", "0.54247457", "0.5400482", "0.540006", "0.5399068", "0.5363291", "0.5357739", "0.53392214", "0.53374434", "0.53354055", "0.5306887", "0.5299974", "0.52962095", "0.5290931", "0.52903986", "0.5277403", "0.52637064", "0.5257399", "0.5255105", "0.52487236", "0.5241558", "0.523154", "0.52266866", "0.5218654", "0.52167946", "0.5187952", "0.51796407", "0.51615965", "0.51547617", "0.5152636", "0.51520467", "0.5140264", "0.51399755", "0.51386255", "0.5135894", "0.51301056", "0.51269686", "0.5125793", "0.5124046", "0.511704", "0.5100805", "0.50964546", "0.5095301", "0.50906754", "0.50890124", "0.50884485", "0.5086828", "0.50863755", "0.5082094", "0.50802857", "0.5077425", "0.50729424", "0.50654817", "0.5063869", "0.50638545", "0.5063106", "0.50607115" ]
0.0
-1
rubocop:enable Metrics/MethodLength given the path to an array, prepends the path of each element of that array to types_and_paths given: array_path: [:class, :students], types_and_paths: [ [ [Hash], [] ], [ [String], [:first_name] ], [ [String], [:last_name] ], [ [Float], [:grade] ], ] returns: [ [ [Hash], [:class, :students, 0] ], [ [String], [:class, :students, 0, :first_name] ], [ [String], [:class, :students, 0, :last_name] ], [ [Float], [:class, :students, 0, :grade] ], [ [Hash], [:class, :students, 1] ], [ [String], [:class, :students, 1, :first_name] ], [ [String], [:class, :students, 1, :last_name] ], [ [Float], [:class, :students, 1, :grade] ], [ [Hash], [:class, :students, 2] ], [ [String], [:class, :students, 2, :first_name] ], [ [String], [:class, :students, 2, :last_name] ], [ [Float], [:class, :students, 2, :grade] ], ... ]
def for_array_at_path_enumerate_types_and_paths(array_path:, types_and_paths:) array = @params.dig(*array_path) array.each.with_index.reduce([]) do |acc, (_, index)| [ *acc, *self.class.prepend_path_to_paths( prepend_path: [*array_path, index], types_and_paths: types_and_paths ) ] end rescue StandardError [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def types_and_paths\n [\n [OBJECT, [\"data\"]],\n [[\"HigherLevelReview\"], %w[data type]],\n [OBJECT, %w[data attributes]],\n [[String, nil], %w[data attributes receiptDate]],\n [BOOL, %w[data attributes informalConference]],\n [[Array, nil], %w[data attributes informalConferenceTimes]],\n [[String, nil], [\"data\", \"attributes\", \"informalConferenceTimes\", 0]],\n [[String, nil], [\"data\", \"attributes\", \"informalConferenceTimes\", 1]],\n [[nil], [\"data\", \"attributes\", \"informalConferenceTimes\", 2]],\n [[*OBJECT, nil], %w[data attributes informalConferenceRep]],\n *(\n if informal_conference_rep? # ... name and phoneNumber must be present\n [\n [[String], %w[data attributes informalConferenceRep name]],\n [[String, Integer], %w[data attributes informalConferenceRep phoneNumber]]\n ]\n else\n []\n end\n ),\n [[String, Integer, nil], %w[data attributes informalConferenceRep phoneNumberCountryCode]],\n [[String, Integer, nil], %w[data attributes informalConferenceRep phoneNumberExt]],\n [BOOL, %w[data attributes sameOffice]],\n [BOOL, %w[data attributes legacyOptInApproved]],\n [[String], %w[data attributes benefitType]],\n [OBJECT, %w[data attributes veteran]],\n [[String], %w[data attributes veteran ssn]],\n [[*OBJECT, nil], %w[data attributes claimant]],\n *(\n if claimant_object_present? # ... participantId and payeeCode must be present\n [\n [[String], %w[data attributes claimant participantId]],\n [[String], %w[data attributes claimant payeeCode]]\n ]\n else\n []\n end\n ),\n [[String, nil], %w[data attributes claimant addressLine1]],\n [[String, nil], %w[data attributes claimant addressLine2]],\n [[String, nil], %w[data attributes claimant city]],\n [[String, nil], %w[data attributes claimant stateProvinceCode]],\n [[String, nil], %w[data attributes claimant countryCode]],\n [[String, nil], %w[data attributes claimant zipPostalCode]],\n [[String, nil], %w[data attributes claimant phoneNumber]],\n [[String, nil], %w[data attributes claimant phoneNumberCountryCode]],\n [[String, nil], %w[data attributes claimant phoneNumberExt]],\n [[String, nil], %w[data attributes claimant emailAddress]],\n [[Array], [\"included\"]],\n # [OBJECT, [\"included\", 0]],\n # [[\"ContestableIssue\"], [\"included\", 0, \"type\"]],\n # [[Integer, nil], [\"included\", 0, \"attributes\", \"decisionIssueId\"]],\n # [[String, nil], [\"included\", 0, \"attributes\", \"ratingIssueId\"]],\n # [[String, nil], [\"included\", 0, \"attributes\", \"ratingDecisionIssueId\"]],\n # [[Array, nil], [\"included\", 0, \"attributes\", \"legacyAppealIssues\"]]\n # [OBJECT, [\"included\", 1]],\n # [[\"ContestableIssue\"], [\"included\", 1, \"type\"]],\n # [[Integer, nil], [\"included\", 1, \"attributes\", \"decisionIssueId\"]],\n # [[String, nil], [\"included\", 1, \"attributes\", \"ratingIssueId\"]],\n # [[String, nil], [\"included\", 1, \"attributes\", \"ratingDecisionIssueId\"]],\n # [[Array, nil], [\"included\", 1, \"attributes\", \"legacyAppealIssues\"]]\n # ...\n *for_array_at_path_enumerate_types_and_paths( # ^^^\n array_path: [\"included\"],\n types_and_paths: [\n [OBJECT, []],\n [[\"ContestableIssue\"], [\"type\"]],\n [[String, Integer, nil], %w[attributes decisionIssueId]],\n [[String, Integer, nil], %w[attributes ratingIssueId]],\n [[String, Integer, nil], %w[attributes ratingDecisionIssueId]]\n ]\n )\n ]\n end", "def arrayofpathelements=(pathElements)\n arrayOfPathElements = pathElements\n if arrayOfPathElements.respond_to? \"patharray\"\n arrayOfPathElements = arrayOfPathElements.patharray\n end\n @elementHash[:arrayofpathelements] = arrayOfPathElements\n end", "def arrayofpathelements=(thePath)\n unless (@elementHash[:elementtype].eql? :strokepath) ||\n (@elementHash[:elementtype].eql? :fillpath) ||\n (@elementHash[:elementtype].eql? :fillandstrokepath)\n fail \"Allowed elementtype are: strokepath, fillpath, fillandstrokepath\"\n end\n thePath = thePath.patharray if thePath.respond_to? \"patharray\"\n @elementHash[:arrayofpathelements] = thePath\n end", "def append_paths(*paths)\n self.paths.push(*paths)\n end", "def by_path(field_arr)\n h = {}\n field_arr.each{ |f|\n path = [f.rectype, f.schema_path, f.name].flatten\n h[path] = f\n }\n return h\n end", "def paths_to_array\n [{:paths => paths.collect {|p| p.to_array}}]\n end", "def prepend_paths(*paths)\n self.paths.unshift(*paths)\n end", "def arrayofpathelements=(thePath)\n thePath = thePath.patharray if thePath.respond_to? \"patharray\"\n @elementHash[:arrayofpathelements] = thePath\n end", "def search_paths=(path_array)\n @search_paths = (@search_paths + path_array).uniq\n end", "def to_a = @paths.dup", "def toPathList(arr); arr.join(File::PATH_SEPARATOR) end", "def push_path(type, path, file_glob = \"**/*.rb\")\n enforce!(type => Symbol)\n slice_paths[type] = [path, file_glob]\n end", "def paths=(raw_paths)\n raw_paths = [raw_paths] unless raw_paths.respond_to? :each\n\n @paths = raw_paths.map { |path| Pathname.new(path) }\n end", "def test_paths_as_arrays\n path = %w{/usr/bin /usr/sbin /sbin}\n exec = nil\n assert_nothing_raised(\"Could not use an array for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => path)\n end\n assert_equal(path, exec[:path], \"array-based path did not match\")\n assert_nothing_raised(\"Could not use a string for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => path.join(\":\"))\n end\n assert_equal(path, exec[:path], \"string-based path did not match\")\n assert_nothing_raised(\"Could not use a colon-separated strings in an array for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => [\"/usr/bin\", \"/usr/sbin:/sbin\"])\n end\n assert_equal(path, exec[:path], \"colon-separated array path did not match\")\n end", "def append_path(*paths)\n @load_paths.push(*(paths.flatten))\n end", "def paths(arrs)\n arrs.inject([[]]) do |paths, arr|\n arr.map {|e| paths.map {|path| path + [e]}}.flatten(1)\n end\n end", "def prepend_path(*paths)\n path_values = Array(paths)\n path_values << ENV[path_key]\n\n separator = File::PATH_SEPARATOR || \":\"\n path_values.join(separator)\n end", "def path_arr()\n return @paths\n end", "def patharray\n return @pathArray\n end", "def []=(type, paths)\n map[type] = Path.split(paths, base)\n end", "def _preload_assets_array(assets)\n assets.map do |type|\n paths = assets_paths(type)\n type = type[0] if type.is_a?(Array)\n as = TYPE_AS[type]\n\n paths.map{|path| [path, as]}\n end.flatten(1)\n end", "def normalize_paths(paths)\n paths = [paths] unless paths.is_a?(Array)\n paths.map(&:dup).map do |path|\n raise ArgumentError.new(\"Invalid path: #{path}\") unless valid_path?(path)\n # Strip leading slash from extension path\n path.gsub!(/^\\/(?=\\*.)/, '')\n # Escape some valid special characters\n path.gsub!(/[.+$\"]/) {|s| '\\\\' + s}\n # Replace * wildcards with .* regex fragment\n path.gsub!(/\\*/, '.*')\n \"^#{path}#{END_URL_REGEX}\"\n end\nend", "def cspsearchpath=(array)\n eval @paths_key+\"= array\"\n end", "def unshift(*paths) = add(paths, position: :first)", "def relative_path(path)\n # replace array referenced IN the path\n first_pass = path.gsub(/\\/([^\\/]+)\\[\\d+\\]\\//i,\"/*/\")\n # replace array references AT THE END of the path too\n first_pass.gsub(/\\/([^\\/]+)\\[\\d+\\]$/,\"/*\")\n end", "def get_path_pins(path); end", "def get_path_pins(path); end", "def add_paths(paths)\n @paths.update(paths)\n end", "def path_with_keys()\n path = []\n\n for part in @path\n if part.is_a? String\n path << part\n elsif part.is_a? Symbol\n path << (yield part)\n else\n raise \"Invalid path part: #{part}\"\n end\n end\n '/' + path.join('/')\n end", "def path_array\n a = []\n each_filename { |ea| a << ea }\n a\n end", "def prepend(*paths) = add(paths, position: :first)", "def shorten_paths_in_backtrace(backtrace)\n return backtrace unless backtrace.is_a?(Array)\n return backtrace.compact.map { |trace|\n shorten_paths(trace)\n }\n end", "def path_prepend(path)\n path_set([File.expand_path(path)] + path_components)\n end", "def append(*paths)\n paths.each do |path|\n @paths << path.to_s\n end\n\n self\n end", "def internal_load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if File.exists?( expanded_path )\n @class_loader.addPath( expanded_path )\n \n load_paths << expanded_path\n end\n end\n \n load_paths\n end", "def getPathElements(path)\n #N Without this path as a single string won't be decomposed into a list of elements\n return path.is_a?(String) ? (path == \"\" ? [] : path.split(\"/\")) : path\n end", "def push_path(type, path, file_glob = \"**/*.rb\") \n\t\t enforce!(type => Symbol)\n\t\t load_paths[type] = [path, file_glob]\n\t\tend", "def load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if !@loaded_paths.include?( expanded_path ) && File.exists?( expanded_path )\n $CLASSPATH << expanded_path\n load_paths << expanded_path\n @loaded_paths << expanded_path\n end\n end\n \n load_paths\n end", "def points(*points_or_paths)\n points = points_or_paths.flat_map { |point_or_path|\n case point_or_path\n when Draught::Pathlike\n point_or_path.points\n else\n point_or_path\n end\n }\n path_points.append(*points)\n end", "def join_paths(*args)\n paths = []\n full_path = []\n temp_paths = []\n args.each {|x| temp_paths << x }\n temp_paths.flatten!\n temp_paths.each do |x|\n unless x.nil?\n paths << x.to_s.dup\n end\n end\n if paths[0].start_with?('/')\n absolute_path = true\n else\n absolute_path = false\n end\n paths.each do |path|\n unless path.nil?\n path.strip!\n path.slice!(0) while path.start_with?('/')\n path.chop! while path.end_with?('/')\n full_path << path\n end\n end\n full_path_string = full_path.join('/')\n full_path_string.slice!(0) while full_path_string.start_with?('/')\n full_path_string.chop! while full_path_string.end_with?('/')\n full_path_string.insert(0, '/') if absolute_path == true\n full_path_string\n end", "def collect_paths(*paths)\n raw = [] # all paths and globs\n plus = Set.new # all paths to expand and add\n minus = Set.new # all paths to remove from plus set\n\n # assemble all globs and simple paths, reforming our glob notation to ruby globs\n paths.each do |paths_container|\n case (paths_container)\n when String then raw << (FilePathUtils::reform_glob(paths_container))\n when Array then paths_container.each {|path| raw << (FilePathUtils::reform_glob(path))}\n else raise \"Don't know how to handle #{paths_container.class}\"\n end\n end\n\n # iterate through each path and glob\n raw.each do |path|\n\n dirs = [] # container for only (expanded) paths\n\n # if a glob, expand it and slurp up all non-file paths\n if path.include?('*')\n # grab base directory only if globs are snug up to final path separator\n if (path =~ /\\/\\*+$/)\n dirs << FilePathUtils.extract_path(path)\n end\n\n # grab expanded sub-directory globs\n expanded = @file_wrapper.directory_listing( FilePathUtils.extract_path_no_aggregation_operators(path) )\n expanded.each do |entry|\n dirs << entry if @file_wrapper.directory?(entry)\n end\n\n # else just grab simple path\n # note: we could just run this through glob expansion but such an\n # approach doesn't handle a path not yet on disk)\n else\n dirs << FilePathUtils.extract_path_no_aggregation_operators(path)\n end\n\n # add dirs to the appropriate set based on path aggregation modifier if present\n FilePathUtils.add_path?(path) ? plus.merge(dirs) : minus.merge(dirs)\n end\n\n return (plus - minus).to_a.uniq\n end", "def paths_s\n \"['#{paths.join(\"','\")}']\"\n end", "def paths(arr, s, d)\n if invalid?(arr, s, d)\n return\n end\n\n if s == d\n $path_count = $path_count + 1\n return\n end\n\n cells = valid_cells(arr, s)\n cells.each do |cell|\n paths(arr, cell, d)\n end\nend", "def initPaths( path )\n\t\t@path = Array::new(path) # ruby does assignments by reference\n\t\tif @type != 'text'\n\t\t\[email protected]_index { |i|\n\t\t\t\tif i-1 >= 0\n\t\t\t\t\t@content[i-1].next = @content[i]\n\t\t\t\tend\n\t\t\t\tif i+1 < @content.length\n\t\t\t\t\t@content[i+1].prev = @content[i]\n\t\t\t\tend\n\t\t\t\t@content[i].parent = self\n\t\t\t\t@content[i].initPaths( path.push(i) )\n\t\t\t\tpath.pop\n\t\t\t}\n\t\tend\n\tend", "def add_path(path)\n path.paths.each do |pt, value|\n @paths[pt] |= value\n end\n\n path.cells.each do |pt, value|\n @cells[pt] |= value\n end\n end", "def polymorphic_path(record_or_hash_or_array, options = T.unsafe(nil)); end", "def paths_to_json\n JSON.unparse(paths_to_array) \n end", "def path_array\n path = []\n yield_path do |x, y|\n path << [x,y]\n end\n path.reverse\n end", "def path_append(path)\n path_set(path_components + [File.expand_path(path)])\n end", "def partition(*paths)\n t = []; f = []\n traverse(*paths){|x| next t << f if yield f; f << x }\n [t, f]\n end", "def get_property_path(element, path)\n path = path.split('/') unless path.is_a?(Array)\n element = [element] unless element.is_a?(Array)\n unless path.size < 1\n path_piece = path.shift\n results = []\n element.each do |el|\n results << get_property(el, path_piece)\n end\n element = get_property_path(results.flatten, path)\n end\n return element\n end", "def resolveTypeBranch2(typeName, arrayComp = nil)\n puts \"typeName is #{typeName}: #{arrayComp}\"\n if not arrayComp then\n if @types.has_key?(typeName) then\n value = @types[typeName]\n case value.class.name\n when \"Array\"\n value.each{|a|\n puts \"in array of type branch #{typeName}|#{a}\"\n resolveTypeBranch(typeName, a)\n }\n when \"String\"\n puts \"should return typeName is #{typeName} and value is #{value}\"\n if cppType?(value) then\n return @genClasses[@filename] += (@@indent + cppCode(mapXMLToCpp(value), \"_\" + @elemName) + \"\\n\")\n else\n\n throw \"type #{typeName} has value #{value} not found in @types\n should have resolved to cpp type by now\" if not @types.has_key?(value)\n\n resolveTypeBranch(value, nil)\n end\n else\n\n throw \"Structure of @type tree is wrong as #{typeName} has hash type of\n #{@types[typeName].class.name}\"\n\n end #case\n else\n ## @elemName is a real hack\n @genClasses[@filename] += (@@indent + cppCode(mapXMLToCpp(typeName), \"_\" + @elemName) + \"\\n\")\n end\n else #arrayComp\n throw \"type #{typeName} not found in @types\" if not @types.has_key?(typeName)\n\n case arrayComp.class.name\n when \"Hash\"\n puts \"#{typeName}: #{arrayComp.values[0]}\"\n begin\n @elemName = arrayComp.keys[0]\n resolveTypeBranch(arrayComp.values[0])\n rescue\n @genClasses[@filename] += (@@indent + cppCode(mapXMLToCpp(arrayComp.values[0]), \"_\" + arrayComp.keys[0]) + \"\\n\")\n end\n\n #Cheating as no type component is a string only hashes but we call this\n #function with the elemName and arrayComp from element and we are really\n #looking to resolve arrayComp and at same time requiring the use of\n #elemName\n\n #when String #(Instead of this hack we can introduce a current element\n #name local variable for element/attribute name)\n\n else\n throw \"Unknown @type #{typeName} with ruby type of #{arrayComp.class.name}\"\n end\n\n end\n\n end", "def config_flatten_order(*path, depth: 0)\n result = []\n path.map! { |p| p.is_a?(Array) ? p.compact_blank : p }.compact_blank!\n while path.present? && !path.first.is_a?(Array)\n part = path.shift\n unless part.is_a?(Symbol) || (part.is_a?(String) && part.include?('.'))\n part = part.to_s.to_sym\n end\n result << part\n end\n if (branches = path.shift)\n down_one = depth + 1\n branches = config_flatten_order(*branches, depth: down_one).flatten(1)\n if path.present?\n remainder = config_flatten_order(*path, depth: down_one).flatten(1)\n branches = branches.product(remainder)\n end\n result = branches.map { |branch| [*result, *branch].flatten }\n else\n result = [result]\n end\n if depth.zero?\n result.uniq!\n result.map! do |entry|\n entry.flat_map do |item|\n if item.is_a?(String)\n item.split('.').compact_blank.map(&:to_sym)\n else\n item\n end\n end\n end\n end\n result\n end", "def concat(*paths) = add(paths, position: :last)", "def path_reader(*types)\n types.each do |type|\n m = :\"#{type}_path\"\n define_method(m) { Lesson.public_send m, self.name }\n end\n end", "def path_from_start_elements(start, elements = [])\n (start.empty? ? '/' : '') + elements.join('/')\nend", "def push_path(type, path, file_glob = \"**/*.rb\")\n enforce!(type => Symbol)\n load_paths[type] = [path, file_glob]\n end", "def push_path(type, path, file_glob = \"**/*.rb\")\n enforce!(type => Symbol)\n load_paths[type] = [path, file_glob]\n end", "def validate_paths(paths)\n paths = [paths] unless paths.is_a?(Array)\n raise 'The provided paths must all be Strings' \\\n unless paths.all? { |path| path.is_a?(String) }\n\n Wgit::Utils.process_arr(paths, encode: false)\n raise 'The provided paths cannot be empty' if paths.empty?\n\n paths\n end", "def remove_double_dots_from_path(path_array)\n while i = path_array.index('..')\n if i == 0\n path_array.shift\n else \n path_array.delete_at(i-1) \n path_array.delete_at(i-1)\n end\n end\nend", "def join_paths(paths)\n paths.join('/').gsub(%r{/+}, '/')\n end", "def set_paths(paths, namespace = MAIN_NAMESPACE)\n unless paths.is_a?(::Array)\n paths = [paths]\n end\n @paths[namespace] = []\n paths.each do |path|\n add_path(path, namespace)\n end\n end", "def path(type)\n registry[type] || []\n end", "def addPath(path)\r\n\t\tif @paths.nil?\r\n\t\t\t@paths = [path]\r\n\t\telse\r\n\t\t\t@paths << path\r\n\t\tend\r\n\tend", "def sanitize(path_array)\n path_array.map do |path|\n path = path.gsub(/{(.*) => (.*)}/, '\\2')\n path.strip\n end\n end", "def path_finder(value, structure, current_path = \"\", paths = [])\n\n if value.class == String && structure.class == String\n if structure =~ /\\b#{Regexp.quote(value)}\\b/i\n paths << current_path\n end\n elsif value == structure\n paths << current_path\n elsif structure.is_a?(Array)\n structure.each_with_index do |element, index|\n if path_finder(value, element, current_path + \"[#{index}]\") != nil\n paths << path_finder(value, element, current_path + \"[#{index}]\")\n end\n end\n elsif structure.is_a?(Hash)\n structure.each do |key, element|\n if key.class == Symbol\n if path_finder(value, key, current_path + \"[:#{key}]\") != nil\n paths << path_finder(value, key, current_path + \"[:#{key}]\")\n end\n if path_finder(value, element, current_path + \"[:#{key}]\") != nil\n paths << path_finder(value, element, current_path + \"[:#{key}]\")\n end\n else\n if path_finder(value, key, current_path + \"['#{key}']\") != nil\n paths << path_finder(value, key, current_path + \"['#{key}']\")\n end\n if path_finder(value, element, current_path + \"['#{key}']\") != nil\n paths << path_finder(value, element, current_path + \"['#{key}']\")\n end\n end\n end\n else\n return nil\n end\n paths.flatten\nend", "def array_to_nested_dirs(array, root_dir)\n addr = [root_dir]\n array.each {|x|\n addr << x\n create_dir(addr.join(\"/\"))\n }\n return true\n end", "def to_array_form(external_ref_path)\n # TODO: use regexp disjunction\n external_ref_path.gsub(/^node\\[/, '').gsub(/^service\\[/, '').gsub(/\\]$/, '').split('][')\n end", "def select(array, path=[], solutions=[])\n if path.size == 5 #|| array.size == 0\n solutions << path\n return solutions \n end\n\n 0.upto(array.size-1).each do |num|\n arr = array[num]\n if arr[0].is_a?(Array)\n arr.each do |a|\n select(array[(num+1..-1)], path + [a],solutions)\n end\n else\n select(array[(num+1..-1)], path + [arr], solutions)\n end\n end\n\n return solutions\nend", "def getTypeUrlFromTypesObject(types)\n return types.map {|x| x['type']['url']}.compact\nend", "def putPaths()\r\n\t\tif @paths.nil?\r\n\t\t\tputs \"Empty Path\"\r\n\t\telsif @paths.respond_to?(\"join\")\r\n\t\t\tputs \"Path: #{@paths.join(\", \")}\"\r\n\t\telse\r\n\t\t\tputs \"Path: #{@paths}\"\r\n\t\tend\r\n\tend", "def paths_for(object, requirements = T.unsafe(nil)); end", "def all(path, type); end", "def add(path, value)\n\n # Verify.\n path = Path.new(path) unless path.kind_of?(Path)\n meta = meta_walk(path)\n adding_dir = false\n if meta and meta.kind_of?(Hash)\n if meta[:dir]\n value = value.to_s\n raise Error.new(Error::IllegalName, value) if value.include?(?/)\n unless (meta = meta[value]) and meta.kind_of?(Hash) and meta[:dir]\n raise Error.new(Error::WrongType, path)\n end\n adding_dir = true\n else\n raise Error.new(Error::WrongType, path) unless meta[:type] == Array\n if (t = meta[:arraytype])\n value = convert_to(value, t, path) unless value.kind_of?(t)\n else\n value = value.to_s\n end\n end\n else\n raise Error.new(Error::WrongType, path)\n end\n\n # Creating a directory.\n if adding_dir\n mmap, cmap = dir_walk(path, DW_Create)\n return [TypeDirExists, path, value] if cmap.has_key?(value)\n dir = {}\n if (hook = mmap[:on_change])\n dir = d if (d = hook.call(HookSet, cmap, value, nil, dir))\n end\n cmap[value] = dir\n [TypeDirectory, path, value]\n\n # Adding an array item.\n else\n key = path.pop\n mmap, cmap = dir_walk(path, DW_Create)\n ihook = meta[:on_change]\n if (a = cmap[key])\n value = ihook.call(HookArrayAdd, a, value) || value if ihook\n a << value\n else\n a = [value]\n a = ihook.call(HookCreate, a) || a if ihook\n dhook = mmap[:on_change]\n a = dhook.call(HookSet, cmap, key, nil, a) || a if dhook\n cmap[key] = a\n end\n [TypeArray, path + key, value, a]\n\n end\n end", "def mungle_paths(paths)\n return paths if terraform.pre_0_12?\n\n paths.map do |path|\n File.directory?(path) ? path : File.dirname(path)\n end.uniq\n end", "def path_finder(value, structure, path = [])\n #i tracks the index of the current array\n if value == structure\n path << true\n end\n if !path.include?(true)\n # binding.pry\n if structure.respond_to?(:each)\n #test each element of the hash\n structure.each do |element_key, element_value|\n if !path.include?(true)\n #once we've captured \"true\", we don't need to add to the path anymore\n path << element_key\n end\n if element_value == value\n path << true\n else\n path = path_finder(value, element_value, path)\n if !path.include?(true)\n #if path comes back from a false branch, remove the last part\n path.pop\n end\n end\n end\n else\n return path\n end\n end\n path\nend", "def merge_id_hashes_helper(hash, array_of_refs, src, path = [])\n ref = array_of_refs.shift\n field = hash[ref]\n\n if array_of_refs.empty? && field\n value = value_from_hash(src, path + [ref])\n if value.is_a?(Array)\n hash[ref] = (field + value).uniq\n else\n hash.delete(ref)\n end\n else\n case field\n when Array\n field.each_with_index do |f, index|\n merge_id_hashes_helper(f, array_of_refs.dup, src, path + [ref, index])\n end\n when Hash\n merge_id_hashes_helper(field, array_of_refs, src, path + [ref])\n end\n end\n end", "def walk_path(dirs)\n (1..dirs.to_a.length).map do |k|\n File.join(*dirs.to_a.take(k))\n end\nend", "def append(*paths) = add(paths, position: :last)", "def encode_path_components(*components); end", "def init_paths(locations)\n locations['Enumerable Canyon'].add_paths_to(locations['Duck Type Beach'],\n locations['Monkey Patch City'])\n locations['Duck Type Beach'].add_paths_to(locations['Enumerable Canyon'],\n locations['Matzburg'])\n locations['Monkey Patch City'].add_paths_to(locations['Enumerable Canyon'],\n locations['Matzburg'],\n locations['Nil Town'])\n locations['Nil Town'].add_paths_to(locations['Monkey Patch City'],\n locations['Hash Crossing'])\n locations['Matzburg'].add_paths_to(locations['Duck Type Beach'],\n locations['Monkey Patch City'],\n locations['Hash Crossing'],\n locations['Dynamic Palisades'])\n locations['Hash Crossing'].add_paths_to(locations['Nil Town'],\n locations['Matzburg'],\n locations['Dynamic Palisades'])\n locations['Dynamic Palisades'].add_paths_to(locations['Matzburg'],\n locations['Hash Crossing'])\n rescue StandardError\n raise 'Locations not correctly initialized.'\n end", "def get_array(element, path='.')\n return unless element\n \n result = element/path\n if (result.is_a? Nokogiri::XML::NodeSet) || (result.is_a? Array)\n result.collect { |item| self.get(item) }\n else\n [self.get(result)]\n end\n end", "def files_of_type(*types)\n result = []\n return result if types.size == 0\n types.each do |type|\n unless files_by_type[type.to_s].nil?\n files_by_type[type.to_s].each {|file| result << file}\n break\n end\n end\n result\n end", "def set_tree_path(tree_path)\n if tree_path.is_a? String then\n @test_proj = tree_path\n @test_folder_path = []\n elsif tree_path.is_a? Array then\n @test_proj = tree_path.shift\n @test_folder_path = tree_path\n else\n raise ArgumentError, \"Must send a String or Array of Strings\"\n end\n end", "def effective_paths(type)\n smart_paths = @smart_paths\n loader = @loader\n effective_paths = smart_paths[type]\n unless effective_paths\n # type not yet processed, does the various directories for the type exist ?\n # Get the relative dirs for the type\n paths_for_type = LoaderPaths.relative_paths_for_type(type, loader)\n # Check which directories exist in the loader's content/index\n effective_paths = smart_paths[type] = paths_for_type.select { |sp| loader.meaningful_to_search?(sp) }\n end\n effective_paths\n end", "def path(*elements) #Create a path from the elements\n#-------------------------------------------------------------------------------\n path=elements.join('/').strip #Remove leading and trailing whitespace\n while path.gsub!('//','/'); end #Remove duplicate slashes\n return path\nend", "def split_paths(path)\n dir_list = path.split('/').drop(1) # drops the \"\" because of the first \"/\"\n path_list = ['/'+dir_list.first]\n dir_list.drop(1).each do |dir|\n path = path_list.last + '/' + dir\n path_list.push path\n end\n path_list\nend", "def filepaths_from *types, &block\n expr = last_option(types)[:matching]\n the_files = types.inject([]) do |files, type|\n method = :\"#{type}_files\"\n files_found = send(method, expr) if respond_to?(method)\n files_found = RailsAssist::Artifact::Files.send(method, expr) if RailsAssist::Artifact::Files.respond_to?(method)\n files + files_found\n end.compact\n yield the_files if block\n the_files\n end", "def iterate_over_file_paths\n parsed_file.each do |hit|\n file_path_array << hit[0]\n end\n file_path_array\n end", "def path_list(doc, reference, word)\n reset\n #Where the word and ref don't match and it\n #looks like a Class name switch to it.\n if reference != word\n if word =~ /^[A-Z]/\n reference = word\n end\n end\n\n type = find_type(doc, reference)\n\n return [] unless type\n\n paths = imported_class_to_file_path(doc, type)\n\n #If we searched any superclasses their paths have been stored\n @loaded_documents.each { |path|\n f = File.open(path,\"r\" ).read.strip\n paths << imported_class_to_file_path(strip_comments(f), type)\n }\n\n create_src_list()\n existing_paths = []\n\n @src_dirs.each do |d|\n\n paths.flatten.uniq.each do |path|\n\n uri = d.chomp + \"/\" + path.chomp\n as = \"#{uri}.as\"\n mx = \"#{uri}.mxml\"\n\n if File.exists?(as)\n existing_paths << as\n elsif File.exists?(mx)\n existing_paths << mx\n end\n\n end\n\n end\n\n return { :paths => existing_paths.uniq, :type => type }\n\n end", "def add_types(type, arr)\n lst = @shared[type]\n arr.each{ |t| lst.push(t) if !lst.include?(t) }\n end", "def polymorphic_path(record_or_hash_or_array, options = {})\n options[:routing_type] = :path\n polymorphic_url(record_or_hash_or_array, options)\n end", "def path_parts(input) # :nodoc:\n case input\n when /((?:@{1,2}|\\$|)\\w+(?:\\[[^\\]]+\\])*)([\\[\\/])(['\"])([^\\3]*)$/\n $~.to_a.slice(1, 4).push($~.pre_match)\n when /((?:@{1,2}|\\$|)\\w+(?:\\[[^\\]]+\\])*)(\\.)(\\w*)$/\n $~.to_a.slice(1, 3).push($~.pre_match)\n when /((?:@{1,2}|\\$|)\\w+)$/\n $~.to_a.slice(1, 1).push(nil).push($~.pre_match)\n else\n [ nil, nil, nil ]\n end\n end", "def expand_path(path)\n if Rscons.phony_target?(path)\n path\n elsif path.is_a?(Array)\n path.map do |path|\n expand_path(path)\n end\n else\n path.sub(%r{^\\^\\^(?=[\\\\/])}, Rscons.application.build_dir).sub(%r{^\\^(?=[\\\\/])}, @build_root).gsub(\"\\\\\", \"/\")\n end\n end", "def build_view_paths(paths); end", "def build_path(path_type, source, key_type, value, ext)\n raise \"Invalid type\" unless [:dir,:url].include?(path_type)\n File.join(@options[path_type], source.to_s, \"#{key_type}.#{value}#{ext}\")\n end", "def with_path(name = 'path', source: nil, as: nil)\n @path = [name.to_s, source&.to_s, as&.to_s] if recursive?\n end", "def entrance(*path_or_paths)\n return if @skip_set_entrance\n @paths += path_or_paths\n end", "def file_path(path, pathtype)\n treepath = tree.branch_path.append(File.basename(path))\n case pathtype\n when :absolute\n File.realpath path\n when :relative\n treepath[0] = directory\n treepath.join('/')\n when :branch\n treepath[1..-1].join('/')\n when :tree\n treepath.join('/')\n end\n end", "def assign_paths\n self.path = generate_path(self)\n end" ]
[ "0.56976634", "0.5675323", "0.5508577", "0.52846366", "0.5265201", "0.51762027", "0.5119185", "0.5113895", "0.5100205", "0.5023137", "0.50219154", "0.50132513", "0.4990891", "0.49866837", "0.49828255", "0.49808463", "0.49582413", "0.49100077", "0.48523682", "0.48475063", "0.48425704", "0.48285574", "0.48273087", "0.48203266", "0.48180756", "0.47997734", "0.47997734", "0.47877657", "0.47779688", "0.47760358", "0.47753623", "0.4771979", "0.47588307", "0.47511438", "0.475031", "0.46755472", "0.46679994", "0.46664256", "0.46636763", "0.4654365", "0.4647161", "0.46219265", "0.45927262", "0.45753235", "0.45729277", "0.45721763", "0.45531294", "0.45426783", "0.45396736", "0.45296043", "0.45279777", "0.4527167", "0.45217168", "0.45108625", "0.45050722", "0.44990748", "0.44986856", "0.44986856", "0.44919834", "0.4477752", "0.4476939", "0.44703928", "0.44676253", "0.4460611", "0.44006228", "0.43942344", "0.43894607", "0.4387081", "0.43761125", "0.43686572", "0.43679506", "0.43582806", "0.43578315", "0.43574992", "0.43393597", "0.433738", "0.43367496", "0.4336689", "0.43353724", "0.4332905", "0.43146032", "0.4311144", "0.4308868", "0.429113", "0.42820913", "0.42767096", "0.4268182", "0.42613444", "0.4238604", "0.42378235", "0.42370915", "0.42335367", "0.42331076", "0.42290133", "0.4227144", "0.4222367", "0.42209888", "0.42126605", "0.42091686", "0.42090073" ]
0.72319835
0
curl v H "Accept: application/vnd.healthy_lunch" H "Contenttype: application/application/xwwwformurlencoded" H "Authorization:authentication_token"
def lunch @menu = Menu.current_lunch if @menu render json: @menu.show_lunch else if [6,7].include? Date.today.wday notice = ENV['NOT_SERVING_WEEKEND'] else notice = ENV['NOT_SERVING_WEEKDAY'] end render json: {notice: notice} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_curl\n `curl -X \"POST\" -H \"Authorization: Basic #{_encode}\" -d grant_type=client_credentials https://accounts.spotify.com/api/token`\n end", "def curl(url,params)\n uri = URI.parse(url)\n https = Net::HTTP.new(uri.host,uri.port)\n https.use_ssl = true\n base64h = Base64.strict_encode64(\"#{APP_KEY}:#{APP_SECRET}\")\n headers = {'Authorization' => \"Basic #{base64h}\", 'Content-Type' =>'application/x-www-form-urlencoded'}\n request = Net::HTTP::Post.new(uri.request_uri, headers)\n request.set_form_data(params)\n response = https.request(request)\n\nend", "def cURL\n \"curl --get 'https://stream.twitter.com/1.1/statuses/sample.json' --header '#{oauth_header}' --verbose end\"\n end", "def post(opts = {})\n with_monitoring do\n connection.post(opts[:path]) do |req|\n prefix = opts[:access_token] ? 'Bearer' : 'Basic'\n suffix = opts[:access_token] || opts[:claims_token]\n req.headers = headers.merge('Authorization' => \"#{prefix} #{suffix}\")\n end\n end\n end", "def curl(path)\n `curl -k -u '#{username}:#{password}' -X GET -H \"Content-Type: application/json\" \"https://#{jira_host}/rest/api/2/#{path}\"`\n end", "def create_recipe_request(version, auth_headers, data = {})\n post \"/api/recipes\", params: data, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend", "def _build_request resource, request\n admin_token = resource.bootstrap_token\n request.add_field 'X-Auth-Token', admin_token\n request.add_field 'Content-type', 'application/json'\n request.add_field 'user-agent', 'Chef keystone_credentials'\n request\nend", "def _build_request resource, request\n admin_token = resource.bootstrap_token\n request.add_field 'X-Auth-Token', admin_token\n request.add_field 'Content-type', 'application/json'\n request.add_field 'user-agent', 'Chef keystone_register'\n request\nend", "def curl\n hs = \"\"\n self.context.header_decorator.headers.each_pair do |k,v|\n hs << \" -H '#{k}:#{v}' \"\n end\n\n \"curl #{hs} -v '#{Arrest::Source.source.url}/#{self.resource_location}'\"\n end", "def login(username, password)\n resp = post(data['hosts']['auth'] + '/login', {\n headers: {\n 'Content-Type' => 'application/json'\n },\n body: {\n username: username,\n password: password\n }\n }).expect {\n assert(code == 200)\n assert(body.is_a? Hash)\n assert(body.length > 0)\n assert(body.key?('token'))\n }\n\n # add this authorization header to all future requests\n add_header(:Authorization, \"Bearer #{resp.body['token']}\")\n resp\nend", "def grab_token(username, password)\n cmd = `curl -X POST -H \"Content-Type: application/json\" -d '{\"email\":\"#{username}\",\"password\":\"#{password}\"}' #{ENV[\"FDA_REST_ENDPOINT\"]}/login --insecure -s`\n return cmd\n end", "def api_call path, request, options = {}\n raw_request = request.to_json\n authenticity_token = options[:authenticity_token] || request[:authenticity_token]\n\n headers = {}\n # it's actually a 'Authorization: ' header that gets mapped internally by rack to HTTP_AUTHORIZATION\n authorizer_helper_options = {}\n if options[:secret]\n authorizer_helper_options[:secret] = options[:secret]\n authorizer_helper_options[:authenticity_token] = authenticity_token\n end\n headers['HTTP_AUTHORIZATION'] = InfoSig::Authorizer.mock_authorization_header(authenticity_token, path, raw_request, authorizer_helper_options)\n\n response = post path, raw_request, headers\n\n rv = nil\n begin\n rv = JSON.parse(response.body)\n rescue Exception\n fail \"expected to see a JSON body, got #{response.inspect}\"\n end\n\n rv.symbolize_keys\n end", "def fetchInstallations(token)\n url = URI(\"https://api.acceptance.hertekconnect.nl/api/v1/installations\")\n\n http = Net::HTTP.new(url.host, url.port);\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"Content-Type\"] = \"application/json\"\n request[\"Authorization\"] = \"Bearer #{token}\"\n\n response = http.request(request)\n puts response.read_body\nend", "def to_curl\n # NOTE: I consider we should use long options to avoid ambiguity of ones like `-u` etc.\n @curl ||= begin\n ar = [\n \"--request\", self.class.http_method.to_s.upcase,\n \"--url\", \"#{api_url}/#{api_version}/#{self.class.path}\",\n ]\n\n ar += headers.reject { |k,| k == \"User-Agent\" }.flat_map do |k, v|\n [\"--header\", \"#{k}: #{v}\"]\n end\n\n ar += [\"--data-binary\", to_h.to_json]\n\n ar\n end\n end", "def get_search_result(url)\n c = Curl::Easy.new(url)\n c.userpwd = BIBLE_KEY + ':X'\n c.perform\n return c.body_str\nend", "def get_search_result(url)\n c = Curl::Easy.new(url)\n c.userpwd = BIBLE_KEY + ':X'\n c.perform\n return c.body_str\nend", "def add_auth(auth, curl, params)\n if auth == 'basic'\n username, password = params.values_at(:username, :password)\n encoded = Base64.encode64(\"#{username}:#{password}\").strip\n curl.headers['Authorization'] = \"Basic #{encoded}\"\n end\n end", "def curl( opts={} )\n opts[:type] ||= 'yaml'\n\n if opts[:noauth]\n auth = '-k '\n else\n auth = \"--cert #{@configdir}/#{@certname}.pem --key #{@configdir}/#{@certname}.key --cacert #{@configdir}/ca_crt.pem\"\n end\n\n output = opts[:output] ? \"-o #{opts[:output]}\" : ''\n header = \"-H 'Accept: #{opts[:type]}'\"\n\n case opts[:method]\n when 'PUT'\n methodstr = '-X PUT'\n header = \"-H 'Content-Type: text/#{opts[:type]}'\"\n\n if opts[:file]\n filestr = \"--data-binary @#{opts[:file]}\"\n end\n\n if opts[:data]\n datastr = \"--data '#{opts[:data]}'\"\n end\n\n when 'DELETE'\n methodstr = '-X DELETE'\n when 'HEAD'\n methodstr = '-I'\n else\n # default to a GET request\n methodstr = ''\n end\n\n uri = \"https://#{@server}:8140/production/#{opts[:action]}/#{opts[:argument]}\"\n cmd = \"curl #{auth} #{methodstr} #{output} #{filestr} #{datastr} #{header} \\\"#{uri}\\\"\" #quoted uri for fact ampersands\n if @debug\n puts cmd\n else\n if not system(cmd)\n raise StandardError, 'cURL execution failed.'\n end\n puts # newline after curl output\n end\n end", "def cf_curl(*args)\n output = capture('cf', 'curl', *args)\n JSON.parse output\nend", "def ambari_request_header\n admin_password = node['ambari']['admin']['password']\n admin_user = node['ambari']['admin']['user']\n headers = { 'AUTHORIZATION' =>\n \"Basic #{Base64.encode64(\"#{admin_user}:#{admin_password}\")}\",\n 'Content-Type' => 'application/data',\n 'X-Requested-By' => 'ambari' }\n headers\nend", "def token\n request.headers['Authorization']\n end", "def request_token\n username = @credentials['username']\n password = @credentials['password']\n # app_name = @credentials['app_name']\n app_name = @credentials['app_name']\n vendor_name = @credentials['vendor_name']\n bus_num = @credentials['bus_num']\n scope = @credentials['scope']\n\n payload_hash = {\n 'grant_type' => 'password',\n 'username' => username,\n 'password' => password,\n 'scope' => scope\n }\n\n # The user name for inContact's API takes the form\n # app_api_name = \"#{app_name}\" + \"@\" + \"#{vendor_name}\" + \":\" + \"#{bus_num}\"\n api_app_name = \"#{app_name}\" + \"@\" + \"#{vendor_name}\"\n\n puts \"Authorizing... \\n\"\n\n # Specify token URL.\n url = URI('https://api.incontact.com/InContactAuthorizationServer/Token')\n # url = URI('https://api-c71.nice-incontact.com/InContactAuthorizationServer/Token')\n\n # Create connection object\n connection = Net::HTTP.new(url.host, url.port)\n # At *work*:\n # connection = Net::HTTP.new(url.host, url.port, 'asqproxy.vzbi.com', 80)\n # For *Fiddler*\n # connection = Net::HTTP.new(url.host, url.port, '127.0.0.1', 8888)\n\n connection.use_ssl = true\n # Uncomment the following line to tell Ruby to ignore invalid security certs.\n # connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n # Create post object\n post = Net::HTTP::Post.new(url)\n\n # OAuth 2 token requests are usually the 'user' + 'pass' base64 encoded\n post.basic_auth(api_app_name, bus_num)\n\n # get the POST post _fileheaders\n # post['Content-Type'] = 'audio/flac'\n post['Content-Type'] = 'application/json; charset=UTF-8'\n post['Accept'] = 'application/json'\n # \"Accept-Encoding\" => \"gzip, deflate, sdch, br\",\n post['Accept-Encoding'] = 'none'\n post['Connection'] = 'keep-alive'\n\n # Prepare the HTTP message body to be posted with the request.\n # Convert the payload_hash hash to a json string.\n payload = payload_hash.to_json\n # It will be the message body (payload) of the HTTP post.\n post.body = payload\n\n # Make the HTTP post request and store the response.\n # The 'begin' & 'rescue' is an aborted attempt to put\n # error/exception handling around the http post\n # *begin*\n # *rescue* StandardError\n # *end*\n response = connection.request(post)\n\n # http_status_code = response.code.to_i\n http_status_code = response.code.strip\n if http_status_code.chr != '2'\n # Show me http status code\n puts \"/n http_status_code: #{http_status_code}\"\n end\n\n if response.is_a?(Net::HTTPSuccess)\n puts \"response is a Net::HTTPSuccess object\"\n # if response is OK then parese it to a Ruby data structure\n access_token_hash = JSON.parse(response.body)\n # access_token = access_token_hash['access_token']\n end\n\n access_token_hash\n end", "def rest_headers\n { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => \"Token token=#{@user[:authentication_token]}\" }\n end", "def curlSearch_Header()\n\tputs `curl -D- -u #{$user} #{$url}#{$jira_key}?expand=renderedFields > #{$jql_header}`\nend", "def api_token_rest_headers\n {\n Authorization: \"basic #{api_token_authorization}\",\n 'Content-Type'.to_sym => 'application/x-www-form-urlencoded'\n }\n end", "def auth_header # gets the authorization header from the request\n # { Authorization: 'Bearer <token>' }\n request.headers['Authorization']\n end", "def postFlatpackLogoHd( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/logo/hd\",params)\n end", "def basic_authentication usr, pwd\n\t\t#str = Base64.encode64(\"#{usr}:#{pwd}\")\n\t\t#str = \"Basic #{str}\"\n \n\t\t#@request_headers[\"Authorization\"]= str\n @request_headers[\"Authorization\"]= 'Basic ' + [\"#{usr}:#{pwd}\"].pack('m').delete(\"\\r\\n\")\n\tend", "def upload_test(path)\n puts \"curl -F 'file=@#{path}' -F 'uKey=fc462b86df69a3373a1c657c68fa78ca' -F '_api_key=3a9cf2ef36199832fc96d03c4d870c42' https://www.pgyer.com/apiv1/app/upload\"\n puts \"uploading #{path}........\"\n puts `curl -F \"file=@#{path}\" -F \"uKey=fc462b86df69a3373a1c657c68fa78ca\" -F \"_api_key=3a9cf2ef36199832fc96d03c4d870c42\" https://www.pgyer.com/apiv1/app/upload`\n puts \"finish uploading #{path}........\"\nend", "def token\n request.headers[\"Authorization\"]\n end", "def post(data)\n uri = URI(@host)\n res = Net::HTTP.post_form(uri, {shell: data})\n # puts res.body\nend", "def basic_auth(opts); end", "def headers\n {:content_type => :json, :accept => :json, :authorization => \"TAuth realm=\\\"https://odg.t-online.de\\\",tauth_token=\\\"#{token}\\\"\"}\n end", "def do_the_get_call(args)\n\tputs \"----- GET: #{args[:url]} -----\"\n\tc = Curl::Easy.new(args[:url]) do |curl|\n\t\tcurl.http_auth_types = :basic\n\t\tcurl.username = args[:user]\n\tend\n\tc.perform\n\tc.body_str\nend", "def http_request(verb, path)\n klass = klass = Net::HTTP.const_get(verb.to_s.capitalize)\n request = klass.new(path)\n request.basic_auth(token, \"X\")\n request[\"Content-Type\"] = \"application/json\"\n request\n end", "def signed_get_request url\n token=jwt_get_signature url\n HTTParty.get('http://localhost:5000'+url,\n headers:{\n \"Authorization\"=>\"JWT token=\\\"#{token}\\\"\",\n \"Content-Type\"=> \"application/json;charset=utf-8\"\n }\n )\n end", "def send_request\n \t\taz = @args[:authorization] and az = \"Authorization: #{az}\\r\\n\"\n body = @args.delete(:body)\n headers = @args.delete(:headers)\n body.strip! if body\n content_type = @args[:content_type]\n \t\tr = [\n \t\t \t\"#{@args[:verb]} #{@args[:uri]} HTTP/#{@args[:version] || \"1.1\"}\\r\\n\",\n \t\t\t\"Host: #{@args[:host_header] || \"_\"}\\r\\n\",\n \t\t\taz || \"\",\n \t\t\t\"Content-Length: #{body.nil? ? 0 : body.size}\\r\\n\",\n \t\t\t\"Date: #{Time.now.httpdate}\\r\\n\",\n \t\t\tcontent_type.nil? ? \"\" : \"Content-Type: #{content_type}\\r\\n\"\n \t] + \n (headers.nil? ? [] : headers.keys.map{|key| \"#{key}: #{headers[key]}\\r\\n\"}) +\n [\"\\r\\n\", body]\n \n \t\[email protected]_data(r.join)\n \tend", "def request_post(path, data)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"POST\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Post.new(uri)\n\trequest.add_field(\"Content-Type\", \"application/json\")\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\trequest.add_field(\"x-hp-hmac-algorithm\", \"SHA256\")\n\trequest.body = data\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend", "def request_post(path, data)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"POST\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Post.new(uri)\n\trequest.add_field(\"Content-Type\", \"application/json\")\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\trequest.body = data\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend", "def post_with_curl\n url = @settings.webhook_url\n `curl -is -X POST -H \"Content-Type:application/json\" -d '#{get_body}' '#{url}'`\n end", "def useToken(subdomain, oauth_token)\n\tpayload = {ticket: {\n subject: \"Ruby OAuth Authenticated Ticket\", \n comment: {\n \tbody: \"Ticket Created!\"\n }\n }\n }\n header = {'Content-Type': 'application/json', 'Authorization': 'BEARER ' + oauth_token}\n puts header\n\turi = URI.parse(\"https://\"+subdomain+\".zendesk.com/api/v2/tickets.json\")\n\thttp = Net::HTTP.new(uri.host, uri.port)\n\thttp.use_ssl = true\n\trequest = Net::HTTP::Post.new(uri.request_uri, header)\n\trequest.body = payload.to_json\n\tputs \"Making authenticated request\"\n\tresponse = http.request(request)\n\tdata = JSON.parse(response.body)\n\tputs data\n\tputs \"Success!\"\n\nend", "def hit_api_local\n # Authentication info\n pass = ENV['stugov_api_user']\n priv = ENV['stugov_api_pass']\n # Our base URL hosted on stugov's server\n base_url = ENV['stugov_api_base_url']\n\n # We make a sha256 hash of this in binary format, then base64 encode that\n digest = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new(\"sha256\"), priv, pass)).chomp\n\n url = base_url + \"?resource=\" + @resource + @url_options\n return send_request(url, digest)\n end", "def post(url, token, params, headers)\n puts \"post to #{url}\"\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n req = Net::HTTP::Post.new(uri.path, headers)\n req['Authorization'] = \"token #{token}\" if token\n\n return http.request(req, params)\nend", "def head\n {\n \"Host\" => HOST,\n \"Content-Type\" => CONTENT_TYPE,\n \"Accept-Encoding\" => ACCEPT_ENCODINGS.join(','),\n \"User-Agent\" => USER_AGENT,\n \"Authorization\" => \"#{ authorization }\",\n }\n end", "def fill_header(response); end", "def formulate_headers(auth_header)\n {\n 'Content-Type' => 'application/json',\n 'Authorization' => auth_header,\n 'Content-Encoding' => 'gzip',\n 'Accept' => 'application/json'\n }\n end", "def postFlatpackAdminHDLogo( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/adminHDLogo\",params)\n end", "def vcd_session(vcd, username, password)\n vcd_session_link = RestClient::Resource.new(vcd + '/api/sessions', username, password )\n vcd_session_response = vcd_session_link.post({'Accept' => 'application/*+xml;version=5.5'})\n myvar = 'x_vcloud_authorization'\n @mysession = vcd_session_response.headers[myvar.to_sym]\nend", "def get_token\n request.headers[\"Authorization\"]\n end", "def r(verb, path, options = {})\n headers = options[:headers] || {}\n headers['HTTP_AUTHORIZATION'] =\n ActionController::HttpAuthentication::Basic.encode_credentials(\n ComfortableMexicanSofa::AccessControl::AdminAuthentication.username,\n ComfortableMexicanSofa::AccessControl::AdminAuthentication.password\n )\n options.merge!(headers: headers)\n send(verb, path, options)\n end", "def login_request(username, password)\n post(data['hosts']['auth'] + '/login', {\n headers: {\n 'Content-Type' => 'application/json'\n },\n body: {\n username: username,\n password: password\n }\n })\nend", "def login\n @rest.headers[:content_type] = \"application/json\"\n\n response = api_request { @rest[\"login\"].post({:username => @username, :password => @password}) }\n\n @rest.headers[:x_opsview_token] = response[:token]\n @rest.headers[:x_opsview_username] = @username\n\n response\n end", "def index_step_class_request(version, auth_headers)\n get \"/api/available_step_classes\", params: {}, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend", "def get_wechat_access_token\n res = RestClient.get \"https://foodtrust.cn/wx/get-access-token?badge=#{ENV['RDS_AGENT']}\"\n #ap res.code; res.cookies; ap res.headers; ap res.body\n return JSON.parse(res.body)['access_token']\nend", "def submit_curl_command(cmd, cert_symbol = :regular)\n # Derive the FTP host & path from the URL in config\n host = RedSkyConfig::SERVER[:red_sky_url].split(\"//\")[1].split(\":\")[0]\n host_short_form = host.split(\".\")[0]\n user = get_user_id(cert_symbol)\n pass = get_user_cert_pw(cert_symbol)\n\n output = \"\"\n Net::SSH.start(host, user, :password => pass) do |ssh|\n output = ssh.exec!(cmd)\n end\n\n # We expect a JSON response from the server\n # The recorded output will contain this inside curl's own SDTOUT, so we need to extract the JSON\n output = output[output.index(\"{\") .. output.index(\"}\")]\n JSON.parse(output)\n end", "def signed_post_request url, body\n body_json= body.to_json\n token = jwt_post_signature url, body_json\n HTTParty.post('http://localhost:5000'+url,\n {headers:{\n \"Authorization\"=>\"JWT token=\\\"#{token}\\\"\",\n \"Content-Type\"=> \"application/json;charset=utf-8\",\n },\n body: body_json}\n )\n\n end", "def auth_headers(name: 'viraj', password: 'password')\n credentials = \"#{name}:#{password}\"\n { 'Authorization' => \"Basic #{Base64.encode64(credentials)}\" }\n end", "def defaultHeaders(token)\n { 'Accept' => '*/*',\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Bearer ' + token }\nend", "def api(uri, request = :get)\n JSON.parse(\n `curl --request #{request.to_s.upcase} -s -S --header \"PRIVATE-TOKEN: $GITLAB_TOKEN\" \"$GITLAB_BASE_URL/api/v4/#{uri}\"`\n )\nend", "def respond_to_challenge(request, response)\n authenticate_header = response['www-authenticate'].downcase\n authenticate_header.sub!(/^digest /, '')\n\n @authentication_params = authenticate_header.split(\", \").inject({}) { |h, field|\n key, value = field.split(\"=\")\n h[key] = value.gsub(/^\"|\"$/, '') # strip quotes.\n \n h\n }\n add_cookies!(request)\n authenticate_request!(request)\n request.each{|k,v| puts \"#{k}: #{v}\" }\n # Resend the request\n @client.request(request)\n end", "def call_gh_api(url)\n auth = \"Bearer #{session[:access_token]}\"\n HTTParty.get(url, headers: { 'Authorization' => auth })\n end", "def preflight\n head 200\n end", "def get_request_via_curl( server_url, request_url, user_email = '', user_token = '' )\n system(\n \"curl -i \" <<\n \"-H \\\"X-User-Email: #{user_email}\\\" -H \\\"X-User-Token: #{user_token}\\\" \" <<\n \"-# http://#{server_url}#{request_url} > /dev/null\"\n )\n end", "def getHeader\n #updateToken\n {'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' + @token}\n end", "def digest\n @request.header('Authorization')\n end", "def setup\n @headers = {}\n @headers[\"User-Agent\"] = \"iPadApp\"\n @headers[\"Content-type\"] = \"application/json\"\n end", "def request_token\n json = cli.perform_quietly %Q(curl -u '#{username}:#{password}' -d '{\"scopes\": [\"repo\"], \"notes\": \"Octopolo\"}' https://api.github.com/authorizations)\n self.auth_response = JSON.parse json\n end", "def auth(key)\n\t\t#TODO\n\t\t#return response\n\t\tstatus 201\n\tend", "def headers\n {\"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/x-www-form-urlencoded\" }\n end", "def build_authorization(verb, resource_id, date, master_key)\r\n text = \"#{(verb || \"\").downcase}\\ndocs\\n#{(resource_id || \"\")}\\n#{date.downcase}\\n\\n\"\r\n\r\n key = Base64.urlsafe_decode64 master_key\r\n hmac = OpenSSL::HMAC.digest 'sha256', key, text\r\n signature = Base64.encode64(hmac).strip\r\n\r\n return ERB::Util.url_encode \"type=master&ver=1.0&sig=#{signature}\"\r\n end", "def parse(www_authenticate); end", "def request_post\n url = \"https://accounts.spotify.com/api/token\"\n\n options = {\n headers: {\n \"Authorization\" => encoding,\n },\n body: {\n \"grant_type\" => 'client_credentials',\n }\n }\n\n return my_request = HTTParty.post(url, options)\nend", "def curl(server, url, args:{}, file:\"\", post:false, json:false, getfile:nil)\n cmd = \"\"\n # Getfile needs json to remove html, but don't parse as json\n cmd << if getfile.nil? then '-i ' else '-H \"Accept: application/json\" ' end\n cmd << '-X POST ' if post\n cmd << '-H \"Accept: application/json\" ' if json\n cmd << \"-F \\'file=@#{file}\\' \" if file != \"\"\n args.each_pair { |k,v| cmd << \"-F \\'#{k}=#{v}\\' \" }\n\n pipe = getfile.nil? ? '' : '-o ' + File.join($workdir, getfile)\n url2 = !getfile.nil? ? url + getfile + \"/\" : url\n\n res = run(\"curl http://#{server}#{url2} #{cmd}#{pipe}\")\n # clean up json output\n if json\n i = res =~ /{/\n res = res[i..-1] if i\n res = JSON::parse(res)\n end\nend", "def query_for_upm_token(good_cookie)\r\n send_request_cgi({\r\n 'uri' => normalize_uri(target_uri.path.to_s, 'rest/plugins/1.0/'),\r\n 'method' => 'GET',\r\n 'cookie' => good_cookie.to_s\r\n })\r\n end", "def test_new_06\n Curl::Easy.new(TestServlet.url) do|curl|\n curl.http_post\n assert_equal \"POST\\n\", curl.body_str\n end\n end", "def response_for_inauthentic_request(env)\n handle_head(env) do\n body = { 'errors' => { 'mauth' => ['Unauthorized'] } }\n [401, { 'Content-Type' => 'application/json' }, [JSON.pretty_generate(body)]]\n end\n end", "def headers\n {'Authorization' => options[:header_format] % token}\n end", "def auth_password_healthcheck(payload)\n do_http_request(\n method: 'POST',\n url: AUTH_URL + '/healthcheck/oauth/token',\n headers: {\n 'Content-Type' => 'application/x-www-form-urlencoded',\n 'Accept' => 'application/json',\n 'X-Header' => ''\n },\n payload: payload,\n typeconsistent: true\n )\n end", "def perform_api_request(query) \n request = Net::HTTP::Post.new( \n $url.path + ($url.query != nil ? (\"?\" + $url.query) : \"\"), \n initheader = {\"Content-Type\" => \"application/json\", \n \"X-Replicon-Security-Context\" => \"User\"}) \n request.basic_auth($companyKey + \"\\\\\" + $loginname, $password) \n request.body = JSON.generate(query) \n \n server = Net::HTTP.new($url.host, $url.port) \n server.use_ssl = $url.scheme == \"https\" \n response = server.start {|http| http.request(request)} \n \n http_code = response.code.to_i \n if http_code != 200 \n puts response.body \n raise \"Expected success code 200, but was #{http_code}\" \n end \n \n return JSON.parse(response.body) \nend", "def get_search_result(sbi_url)\n return `curl -L -A #{K_User_Agent} #{sbi_url}` \nend", "def sign(request)\n oauth_params = { consumer: @access_token.consumer, token: @access_token }\n\n oauth_helper = OAuth::Client::Helper.new(request, oauth_params.merge(:request_uri => URI(\"https://#{@host}\")))\n\n request[\"Authorization\"] = oauth_helper.header\n end", "def api_request(name) \n\tresponse = HTTParty.post('https://api.talentiq.co/v2/person', \n :body => {:name => name }.to_json,\n :headers => { 'Content-Type' => 'application/json', \n \t\t\t'x-api-key:' => 'e058cdd334c69c31d45d87e44b405d128a9e8937939e7d0ab2496334',\n 'Accept' => 'application/json' })\n puts response.body\nend", "def authenticate_hmac\n key = Rails.application.credentials[Rails.env.to_sym][:clicksign][:webhook_hmac_key]\n puts\n data = request.body.read\n puts \"------ Our Hmac ------\"\n puts mac = OpenSSL::HMAC.hexdigest(\"SHA256\", key, data)\n puts \"------ ClickSing Hmac ------\"\n puts request.headers[\"Content-Hmac\"]\n end", "def http_post(curl, data, url)\n\n # Define the post data\n data2 = ''\n\n # Loop through the data[\"post_data\"] passed in to build up the post data string\n data[\"post_data\"].each do |key, value|\n if (data2 != '') then\n data2 = data2 + '&'\n end\n # If the value is null we don't just want it to look like: item=\n if (value.nil?) then\n data2 = data2 + CGI::escape(key.to_s) + '='\n else\n data2 = data2 + CGI::escape(key.to_s) + '=' + CGI::escape(value.to_s)\n end\n end\n\n # Define the url we want to hit\n curl.url = url\n # Specify the headers we want to hit\n curl.headers = data['header']\n\n # perform the call\n curl.post(data2)\n\n curl.headers = nil\n\n # Set headers to nil so none get reused elsewhere\n curl.headers = nil\n\n # return the curl object\n return curl\n\nend", "def get_token(azure_key)\n token_url = \"https://api.cognitive.microsoft.com/sts/v1.0/issueToken\"\n response = Curl.post(token_url) do |response|\n response.headers['Ocp-Apim-Subscription-key'] = azure_key\n end\n\n return response.body_str\nend", "def inputinject(funk, payload)\n\t\t#Build a chambered decision driven request builder so we can keep it open to options :)\n\t\tputs \"[\".light_yellow + \"*\".white + \"] Testing\".light_yellow + \": #{funk}\".white\n\t\tputs \"[\".light_yellow + \"*\".white + \"] Post data: \".light_yellow + \"#{payload}\".white\n\t\tc = Curl::Easy.new(funk) do |curl|\n\t\t\tcurl.useragent = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)'\n\t\t\tif not $module_optional['ProxyIp'] == 'nil'\n\t\t\t\tif $module_optional['Auth'].to_i == 1\n\t\t\t\t\t#NO PASS CAN BE USED B/C basic_auth in use!\n\t\t\t\t\tcurl.proxy_url = $module_optional['ProxyIp']\n\t\t\t\t\tcurl.proxy_port = $module_optional['ProxyPort'].to_i\n\t\t\t\telse\n\t\t\t\t\t#CAN USE AUTH HERE\n\t\t\t\t\tif $module_optional['Username'] == 'nil'\n\t\t\t\t\t\tcurl.proxy_url = $module_optional['ProxyIp']\n\t\t\t\t\t\tcurl.proxy_port = $module_optional['ProxyPort'].to_i\n\t\t\t\t\telse\n\t\t\t\t\t\tcurl.proxy_url = $module_optional['ProxyIp']\n\t\t\t\t\t\tcurl.proxy_port = $module_optional['ProxyPort'].to_i\n\t\t\t\t\t\tcurl.proxypwd = \"#{$module_optional['Username']}:#{$module_optional['Password']}\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tcurl.cookies = $module_optional['Cookie'] unless $module_optional['Cookie'] == 'nil'\n\t\t\tif $module_optional['Auth'].to_i == 1\n\t\t\t\tcurl.http_auth_types = :basic\n\t\t\t\tcurl.username = $module_optional['Username']\n\t\t\t\tcurl.password = $module_optional['Password']\n\t\t\tend\n\n\t\t\tcurl.http_post(funk, \"#{payload}\")\n\t\tend\n\t\tfoo=[]\n\t\tc.on_header do |x|\n\t\t\tfoo << x# Collect our headers to enumerate in a minute\n\t\t\tx.size #keep curl from freaking out\n\t\tend\n\t\tc.perform\n\t\t#Successful injection will match our regex, failure won't (concat on exec proves its working)\n\t\tif c.body_str =~ /:#{@rnd}:(.+):#{@rnd}:/ \n\t\t\t@success = $1 #make results available\n\t\telse\n\t\t\t@success = 'fail'\n\t\tend\n\tend", "def run_request(verb, method, options={})\n access_token.send(verb, method, :params => authorization_params.merge(options), :parse => :json)\n end", "def login(action, username, password, header = 'HTTP_AUTHORIZATION')\n @request.env[header] = \"Basic #{Base64.encode64(username << ':' << password)}\"\n get action\n end", "def valid_authentication_header\n\t\t\t\t\trequire \"cgi\"\n\n\t\t\t\t\talgorithm = \"sha256\";\n\t\t\t\t\turl = CGI.escape(self.url.to_s)\n\t\t\t\t\tclient_id = self.client_id\n\t\t\t\t\tsecret = self.secret\n\t\t\t\t\ttimestamp = (Time.now.to_i)*1000\n\t\t\t\t\tstr = \"algorithm=HmacSHA256&client_id=#{client_id}&service_url=#{url}&timestamp=#{timestamp}\";\n\t\t\t\t\tsignature = ::MicroService::SignedRequest::Utils.sign(str, secret, algorithm)\n\n\t\t\t\t\t# Header!\n\t\t\t\t\t\"#{str}&signature=#{CGI::escape(signature)}\"\n\t\t\t\tend", "def call env\n # => Ruby 1.8.7 does not support Base64.strict_encode64\n auth_enc = Base64.encode64(formatted_login).gsub(\"\\n\", '')\n env.request_headers['Authorization'] = \"Basic #{auth_enc}\"\n @app.call(env)\n end", "def hit_api_direct\n # CollegiateLink API needs some data to be hashed and sent for auth purposes\n time = (Time.now.to_f * 1000).to_i.to_s\n ipaddress = ENV['cl_ipaddress']\n apikey = ENV['cl_apikey']\n privatekey = ENV['cl_privatekey']\n random = SecureRandom.hex\n hash = Digest::SHA256.hexdigest(apikey + ipaddress + time + random + privatekey)\n\n url = ENV['cl_apiurl'] + @resource + \"?time=\" + time + \"&apikey=\" + apikey + \"&random=\" + random + \"&hash=\" + hash + @url_options\n return send_request(url, nil)\n end", "def headers\n {\n # Declare that you expect response in XML after a _successful_\n # response.\n \"Accept\" => \"application/xml\",\n\n # Promise to send XML.\n \"Content-Type\" => \"application/xml; charset=utf-8\",\n\n # All requests will be authenticated using HTTP Basic Auth, as\n # described in rfc2617. Your library probably has support for\n # basic_auth built in, I've passed the Authorization header\n # explicitly here only to show what happens at HTTP level.\n \"Authorization\" => \"Basic #{auth_string}\",\n\n # Tell Harvest a bit about your application.\n \"User-Agent\" => HarvestConfig.attrs[:user_agent]\n }\n end", "def postToolsCurl( method, path, filedata, email)\n params = Hash.new\n params['method'] = method\n params['path'] = path\n params['filedata'] = filedata\n params['email'] = email\n return doCurl(\"post\",\"/tools/curl\",params)\n end", "def astro_curl(url, params_hash)\n AstroPay::Curl.post(url, params_hash)\n end", "def enable_ssh_with_token(s1_ip,response_body)\n\n uri = URI.parse(\"https://#{s1_ip}/protected/sshservice.html\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n\n token_text=response_body.match(/enableSsh\\.cgi.*\\<\\/b\\>\\n/m).to_s\n\n# puts token_text\n timeStamp=token_text.match(/name=stamp\\svalue=\"\\d+\"/).to_s.match(/\\d+/)\n token=token_text.match(/name=token\\svalue=\".*\"/).to_s.match(/\".*\"/).to_s.gsub(/\\\"|\\\"/,\"\").to_s\n\n client=RestClient::Resource.new(\"https://#{s1_ip}/protected/enableSsh.cgi?stamp=#{timeStamp}&token=#{token}&frame=sshservice\",:user=>\"Nemuadmin\",:password=>\"nemuuser\",:verify_ssl => OpenSSL::SSL::VERIFY_NONE)\nbegin\n response=client.get\n if response.body.match(\"SSH Service Enabled Successfully\")\n # puts \"#{s1_ip} enable ssh succ!!\"\n return true\n else\n # puts \"#{s1_ip} enable ssh fail!!\"\n return false\n end\n\nrescue\n # puts $@\n #puts \"enable #{s1_ip} with token exception\"\n return false\nend\n\nend", "def headers\n {\n 'Authorization' => \"key=#{@server_key}\",\n 'Content-Type' => 'application/json'\n }\n end", "def authorise\n #FIRST SINGLE USE TOKEN WILL BE RECEIVED HERE..\n token = params[:token]\n #PREPAIRING FOR SECOND REQUEST WITH AUTH TOKEN IN HEADER.. WHICH WILL BE EXCHANED FOR PERMANENT AUTH TOKEN.\n uri = URI.parse(\"https://www.google.com\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n path = '/accounts/AuthSubSessionToken'\n headers = {'Authorization'=>\"AuthSub token=#{token}\"}\n\n #GET REQUEST ON URI WITH SPECIFIED PATH...\n resp, data = http.get(path, headers)\n #SPLIT OUT TOKEN FROM RESPONSE DATA.\n if resp.code == \"200\"\n token = ''\n data.split.each do |str|\n if not (str =~ /Token=/).nil?\n token = str.gsub(/Token=/, '')\n end\n end \n return redirect_to(:action => 'import', :token => token)\n else\n redirect_to root_url , :notice => \"fail\"\n end\n end", "def headers\n {\n \"Authorization\" => basic_auth,\n \"Content-Type\" => \"application/json\",\n \"Accept\" => \"application/json\"\n }\n end", "def post(hash)\n connection.post do |conn|\n if hash[:content_type]\n conn.headers[\"Content-Type\"] = hash[:content_type]\n end\n\n conn.url(hash[:path], :access_token => access_token)\n conn.body = hash[:body]\n end\n end", "def exec_api(json_req)\n begin\n req = sign_request(json_req)\n return HttpChannel.new(api_uri).execute(req)\n rescue Curl::Err::CurlError => ex\n return JsonResponse.new(\"fail\", ex.message)\n end\n end", "def build_header_auth(uri, version, httpmethod)\n response = get_auth_response(uri)\n @cnonce = Digest::MD5.hexdigest(\"%x\" % (Time.now.to_i + rand(65535)))\n @@nonce_count += 1\n\n response['www-authenticate'] =~ /^(\\w+) (.*)/\n challenge = $2\n params = {}\n challenge.gsub(/(\\w+)=\"(.*?)\"/) { params[$1] = $2 }\n\n a_1 = \"#{@app_id}:#{params['realm']}:#{@app_secret}\" #username, realm and password\n a_2 = \"#{httpmethod}:#{uri}\" #method and path\n request_digest = ''\n request_digest << Digest::MD5.hexdigest(a_1)\n request_digest << ':' << params['nonce']\n request_digest << ':' << ('%08x' % @@nonce_count)\n request_digest << ':' << @cnonce\n request_digest << ':' << params['qop']\n request_digest << ':' << Digest::MD5.hexdigest(a_2)\n\n header = []\n header << \"Digest username=\\\"#{@app_id}\\\"\"\n header << \"realm=\\\"#{params['realm']}\\\"\"\n\n header << \"qop=#{params['qop']}\"\n\n header << \"algorithm=MD5\"\n header << \"uri=\\\"#{uri}\\\"\"\n header << \"nonce=\\\"#{params['nonce']}\\\"\"\n header << \"nc=#{'%08x' % @@nonce_count}\"\n header << \"cnonce=\\\"#{@cnonce}\\\"\"\n header << \"response=\\\"#{Digest::MD5.hexdigest(request_digest)}\\\"\"\n header << \"opaque=\\\"#{params['opaque']}\\\"\"\n\n header_auth_str = header.join(', ')\n @header = {}\n @header[\"Content-Type\"] = \"application/json\"\n if version == API_VERSION_2\n @header[\"Accept\"] = \"application/vnd.com.zipmark.v2+json\"\n else\n @header[\"Accept\"] = \"application/vnd.com.zipmark.v1+json\"\n end\n @header[\"Authorization\"] = header_auth_str\n @header[\"Host\"] = \"curdbee.com\"\n end" ]
[ "0.6755993", "0.6453583", "0.6035082", "0.58551824", "0.5843421", "0.58262885", "0.5818238", "0.57883954", "0.5740022", "0.56689763", "0.5601905", "0.5584902", "0.557723", "0.5566509", "0.55436176", "0.55436176", "0.5534908", "0.55328643", "0.55216277", "0.5516322", "0.5516004", "0.54995596", "0.54981345", "0.5491917", "0.5482774", "0.5480737", "0.54700047", "0.54585", "0.54474133", "0.5445017", "0.5442453", "0.54400814", "0.5438196", "0.54366785", "0.5436574", "0.54364514", "0.5425966", "0.5419626", "0.54185283", "0.541568", "0.5410937", "0.54033315", "0.5398299", "0.5383565", "0.5383157", "0.5378579", "0.5377323", "0.5377308", "0.5355504", "0.530966", "0.5307343", "0.5299291", "0.5298676", "0.5292097", "0.52846813", "0.5281792", "0.52771", "0.5272222", "0.52713203", "0.52642274", "0.52412146", "0.52298105", "0.52187765", "0.52169913", "0.52156997", "0.52119744", "0.52043074", "0.5203198", "0.5197574", "0.51972806", "0.5189948", "0.518828", "0.51860964", "0.51831895", "0.5180728", "0.5177513", "0.517665", "0.5172214", "0.5169134", "0.5168082", "0.5151129", "0.514757", "0.5140344", "0.51388156", "0.5136606", "0.51334286", "0.5130899", "0.5130466", "0.51260793", "0.5125863", "0.5113184", "0.5113069", "0.50978166", "0.5093395", "0.5092828", "0.50927305", "0.50924176", "0.5083368", "0.508266", "0.5079413", "0.5079265" ]
0.0
-1
Adds specified username/password combination to current software instance
def add_user_password(username, password, options = {}) raise ArgumentError, "The new password cannot be nil" unless password raise ArgumentError, "The new username cannot be nil" unless username raise ArgumentError, "The new password cannot be empty" if password.empty? raise ArgumentError, "The new username cannot be empty" if username.empty? raise Exception, "Cannot add username password, a Software Password already exists for the provided username" if self.has_user_password?(username.to_s) add_user_pw_template = { 'softwareId' => self['id'].to_i, 'password' => password.to_s, 'username' => username.to_s } add_user_pw_template['notes'] = options['notes'].to_s if options.has_key?('notes') add_user_pw_template['port'] = options['port'].to_i if options.has_key?('port') softlayer_client[:Software_Component_Password].createObject(add_user_pw_template) @passwords = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_credential(db, username, password)\n @credentials ||= {}\n @credentials[db] = [ username, password ]\n apply_credentials\n end", "def add_password(password)\n @password = password\n end", "def register\n raw \"PASS #{@config[:password]}\" if @config.key? :password\n raw \"CAP LS\" if defined? MODULE_LOADED_CLIENT_CAPABILITIES\n\n raw \"NICK #{@nick}\"\n raw \"USER #{@user} 0 0 :#{@realname}\"\n end", "def create_user\n command = compile_command(\"useradd\") do |useradd|\n useradd << universal_options\n useradd << useradd_options\n end\n\n run_command(:command => command)\n\n # SmartOS locks new users by default until password is set\n # unlock the account by default because password is set by chef\n if check_lock\n unlock_user\n end\n end", "def enter_creds(username, password)\n touch(\"UITextField index:0\")\n keyboard_enter_text(username)\n array = touch(\"UITextField index:1\")\n keyboard_enter_text(password)\n tap_keyboard_action_key\n end", "def credentials=(target, scheme, username, password)\r\n\t\t\t`#{BITS::BITSADMIN} /setcredentials {#{@id}} #{target} #{scheme} #{username} #{password}`\r\n\t\tend", "def add_password(password)\n\t\tpassword_input.set(password)\n\tend", "def change_enable_password(username,password,new_password,quick=true)\n if (!username.kind_of?(String))\n raise ArgumentError, \"Expected String for username, but #{username.class} provided.\"\n end\n\n if (!password.kind_of?(String))\n raise ArgumentError, \"Expected String for password, but #{password.class} provided.\"\n end\n\n if (!new_password.kind_of?(String))\n raise ArgumentError, \"Expected String for new_password, but #{new_password.class} provided.\"\n end\n\n # open a socket to the server\n socket = open_socket()\n\n # make start packet\n header = TacacsPlus::TacacsHeader.new\n if (@session_id)\n header.session_id = @session_id\n else\n header.randomize_session_id!\n end\n body = TacacsPlus::AuthenticationStart.new\n body.action_chpass!\n body.authen_type_ascii!\n body.service_enable!\n body.priv_lvl = 1\n body.user = username if (quick)\n\n session = ClientSession.new()\n session.request = PacketStruct.new(header,body)\n session.type = :authentication\n session.getuser = username\n session.getpass = new_password\n session.getdata = password\n\n # process server dialog\n attempt = process_response(session, socket)\n\n return(attempt)\n end", "def add_user(args = {})\r\n clean_args(args)\r\n success = true\r\n\r\n # Opening in read/write so that we can make the changes to the file\r\n # while under protection of the system r/w lock.\r\n File.open(args[:file] || PASSWORDS_FILE, \"a+\") do |file|\r\n success = write_to_file(file, args[:username], args[:password],\r\n args[:environment], args[:override])\r\n end\r\n\r\n return success\r\n end", "def user_add(username, password,\n config = Hash.new)\n default_config = {\n :add_user => true,\n :password => password,\n :comment => \"\",\n :use_mail => true,\n :use_ftp => false,\n :use_file_sharing => false,\n :mail_quota => 200, # in MB\n :virus_check => false,\n :spam_filter => false\n }\n\n user_setting(username,\n default_config.merge(config))\n end", "def enter_password_shared\n end", "def _user_add argv = {}\n\t\tf\t\t\t\t= {}\n\t\tf[:tag]\t\t\t= argv[:tag] if argv.include?(:tag)\n\t\tf[:salt] \t\t= _random 5\n\n\t\t#username\n\t\t_throw Sl[:'the user is existing'] if _user? f[:name]\n\t\tf[:name] \t\t= argv[:name]\n\n\t\t#password\n\t\trequire \"digest/sha1\"\n\t\tf[:pawd] \t\t= Digest::SHA1.hexdigest(argv[:pawd] + f[:salt])\n\n# \t\tSdb[:user].insert(f)\n\t\t_submit :_user, :fkv => f, :uniq => true\n\t\tuid = Sdb[:_user].filter(:name => f[:name]).get(:uid)\n\t\tuid ? uid : 0\n\tend", "def add_password(user_password)\n\t\tpassword_field.set(user_password)\n\tend", "def new_user_password(username)\n password = @prompt.mask('Password >')\n raise RequirementError.new, 'Requirements not met' if password.match?(/[!@#$%^&*(),.?\":{}|<>]/)\n\n @user = User.new(username, password, gen_uid)\n @user_playlist = Playlist.new(@user)\n store_user\n rescue RequirementError\n puts 'Password cannot contain special characters. Please try again!'.colorize(:light_red)\n end", "def create(username, password)\n SecKeychainAddGenericPassword(nil, @service.length, @service, username.length, username, password.length, password, nil)\n end", "def deploy_password\n set :password, deploy_script_password rescue nil\nend", "def newPassword(newPass)\n\t\tDATABASE.edit(\"users\", \"password\", newPass, \"username\", @username)\n\tend", "def add_password(a_password)\n self.password_hash = Digest::SHA256.hexdigest(a_password + Rails.application.secrets.salt)\n self.save\n end", "def update_with_password(params, *options); end", "def login\n username.set 'tomsmith'\n password.set 'SuperSecretPassword!'\n end", "def password=(new_password); end", "def setup_credentials\n\n cmd = @config[:path] + @command_line_tool + \" \" + @@login_command\n\n Open3.popen3( cmd ) { |input, output, error|\n input.puts @config[:url]\n input.puts @config[:user]\n input.puts @config[:password]\n input.close\n } \n\n end", "def enter_login_credentials(username, password)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n login_email_field.value = username\n login_password_field.value = password\n end", "def user_add argv = {}\n\t\tfkv\t\t\t= {}\n\t\tfkv[:name]\t= argv[:name]\n\t\tfkv[:level]\t= argv[:level]\n\t\tfkv[:tag]\t= argv[:tag] if argv[:tag]\n\n\t\t# if the username is existed\n\t\t_throw Sl[:'the user is existed'] if user_has? fkv[:name]\n\n\t\t# password\n\t\trequire \"digest/sha1\"\n\t\tfkv[:salt] \t= _random 5\n\t\tfkv[:pawd] \t= Digest::SHA1.hexdigest(argv[:pawd] + fkv[:salt])\n\n# \t\tSdb[:user].insert(f)\n\t\tdata_submit :user_info, :fkv => fkv, :uniq => true\n\n\t\tuid = Sdb[:user_info].filter(:name => fkv[:name]).get(:uid)\n\t\tuid ? uid : 0\n\tend", "def passwd\r\n @password = \"12345\"\r\n end", "def password=(_arg0); end", "def password=(_arg0); end", "def password=(_arg0); end", "def password=(_arg0); end", "def add user, pin = nil\n command = aqhbci <<-CMD\n adduser \\\n --tokentype=#{user.tokentype} \\\n --context=#{user.context} \\\n --bank=#{user.bank} \\\n --user=#{user.userid} \\\n --server=#{user.server} \\\n --username=#{user.name} \\\n --hbciversion=#{user.hbciversion}\n CMD\n stdin, stdout, stderr, wait_thr = Open3.popen3(command.strip)\n success = wait_thr.value.success?\n\n if pin && success\n with_secure_pin user, pin do |f|\n sysid_command = aqhbci(\"getsysid --user=#{user.userid}\", \"--pinfile=#{f.path.strip}\").strip\n stdin, stdout, stderr, wait_thr = Open3.popen3(sysid_command)\n wait_thr.join\n success = success && wait_thr.value.success?\n end\n end\n return success\n end", "def add(username, password, algorithm = Algorithm::DEFAULT)\n raise PasswdFileError, \"Unable to add already existing user #{username}\" if has_entry?(username)\n new_entry = PasswdEntry.new(username, password, algorithm)\n new_index = @lines.size\n @lines << new_entry.to_s\n @entries[new_entry.key] = { 'entry' => new_entry, 'line_index' => new_index }\n dirty!\n return nil\n end", "def introduce\n write_(\"PASS #{@conf['pass']}\") if @conf['pass'] and !@use_sasl\n write_(\"CAP REQ :sasl\") if @use_sasl\n write_(\"NICK #{@conf['nick']}\")\n write_(\"USER #{@conf['user']} 0 * :#{@conf['rnam']}\")\n end", "def adduser(aNewUser,aPassword,aGroup=nil)\n\t\trun \"#{sudo} adduser --gecos '' #{aGroup ? '--ingroup '+aGroup : ''} #{aNewUser}\" do |ch, stream, out|\n\t\t\tch.send_data aPassword+\"\\n\" if out =~ /UNIX password:/\n\t\tend\n\tend", "def update_esx_passwd_file(esx_hostname,esx_username,esx_password)\n esx_passwd_file = Dir.home+\"/.esxpasswd\"\n FileUtils.touch(esx_passwd_file)\n File.chmod(0600,esx_passwd_file)\n output_text = esx_hostname+\":\"+esx_username+\":\"+esx_password\n File.open(esx_passwd_file, 'a') { |file| file.write(output_text) }\n return\nend", "def add_user env, username, pwd\n config[env] = {} unless env_exists? env\n abort \"The #{username} already exists!\".yellow if user_exists? env, username\n config[env][username] = { 'access_token' => '', 'password' => encrypt_password(username, pwd) }\n write_config\n end", "def identify(m, params)\n @registry[m.sourcenick + \"_username\"] = params[:username].to_s\n @registry[m.sourcenick + \"_password\"] = params[:password].to_s\n m.reply \"you're all set up!\"\n end", "def add_user(login, password)\n GoodData::Domain.add_user(name, login, password)\n end", "def do_secure_accounts(instance)\n client = Client.open(instance, :no_password => true)\n q1 = \"UPDATE mysql.user SET Password = PASSWORD(\\'#{ROOT_PASSWORD}\\') where User = \\'root\\'\"\n q2 = \"UPDATE mysql.user SET Password = PASSWORD(\\'#{ROOT_PASSWORD}\\') where User = \\'\\'\"\n # q3 = \"CREATE USER \\'root\\'@\\'%.#{REPLICATION_DOMAIN}\\' IDENTIFIED BY \\'#{ROOT_PASSWORD}\\'\"\n # For testing with clients whose DHCP assigned IP address is not in DNS.\n q3 = \"CREATE USER \\'root\\'@\\'%' IDENTIFIED BY \\'#{ROOT_PASSWORD}\\'\"\n q4 = \"GRANT ALL PRIVILEGES ON *.* to \\'root\\'@\\'%\\' WITH GRANT OPTION\"\n q5 = \"FLUSH PRIVILEGES\"\n if client\n [q1, q2, q3, q4, q5].each do |query|\n puts query\n client.query(query)\n end\n end\n rescue Mysql2::Error => e\n puts e.message\n ensure\n client.close if client\n end", "def createNagiosPasswd\n `touch /usr/local/nagios/etc/htpasswd.users`\n `echo nagiosadmin:uPODiTjNs5eaY >> /usr/local/nagios/etc/htpasswd.users` \n end", "def passwd(*) end", "def passwd(*) end", "def enable_privileged(password)\n @transport.cmd('String' => 'enable', 'Match' => /.+assword.+/)\n @transport.cmd(password)\n end", "def set_password(user, password)\n\t\t\t\t`echo \"#{shellescape(password)}\" | /usr/sbin/pw usermod #{shellescape(user)} -h 0`\n\t\t\tend", "def add_credentials(post = {})\n post[:ext_person_source_id] = credentials[:ext_person_source_id]\n post[:source_username] = credentials[:username]\n post[:source_password] = credentials[:password]\n post[:ext_policy_id] = credentials[:ext_policy_id]\n post\n end", "def setpwent\n ::Etc.setpwent\n end", "def add_or_update(username, password, algorithm = Algorithm::DEFAULT)\n if has_entry?(username) then\n update(username, password, algorithm)\n else\n add(username, password, algorithm)\n end\n end", "def update(username, password)\n key = self.find(username)\n SecKeychainItemModifyContent(key.item, nil, password.length, password)\n end", "def passwd=(p0) end", "def passwd=(p0) end", "def create_pw_client(opts = {})\n usr = opts[:user] || user()\n pw = opts[:password] || password()\n remote = opts[:remote_name] || self.remote_name\n\n logger.info(\"Authorizing #{usr} to work with #{remote}.\")\n\n configure_octokit(opts)\n\n Octokit::Client.new(:login => usr, :password => pw)\n end", "def finish_windows_configuration\n\n configure do\n\n user = add_parameter 'username', {type: 'string'}\n pwd = add_parameter 'password', {type: 'securestring'}\n\n end\n\n end", "def set_password(player, password)\n goid = nil\n name = nil\n if player.is_a? String\n name = player\n else\n name = player.name\n end\n\n open_store \"players\" do |gd|\n goid = gd[name.downcase]\n end\n\n open_store(\"passwords\", false) do |gd|\n gd[goid] = Digest::MD5.new.update(password).to_s\n end\n end", "def add_player(player, password)\n @storage.save_player(player, password)\n self.add_object(player)\n end", "def setup_session_with_username\n method = 'smugmug.login.withPassword'\n setup_session_with [\"method=#{method}\",\"EmailAddress=#{@smug_user.email}\",\"Password=#{@smug_user.password}\"]\n end", "def create_username_password(**args)\n\t\t\t\t\tjson_body = {\n\t\t\t\t\t\t'' => '0',\n\t\t\t\t\t\tcredentials: args.merge(\n\t\t\t\t\t\t\t'$class' => 'com.cloudbees.plugins.credentials.impl.'\\\n\t\t\t\t\t\t\t\t'UsernamePasswordCredentialsImpl'\n\t\t\t\t\t\t)\n\t\t\t\t\t}.to_json\n\t\t\t\t\tcreate_(\"json=#{::CGI.escape json_body}\")\n\t\t\t\tend", "def logon2(username, password, dbname, mode)\n #This is a stub, used for indexing\n end", "def create_app_user api_key\n upload_ssh_key = prompt(\"Y\", \"Do you want to upload your public ssh key to app user on VPS? (Y/n)\\n\")\n # TODO consider situation when there is no pub key\n pub_ssh = upload_ssh_key == \"Y\" ? File.read(\"#{ENV['HOME']}/.ssh/id_rsa.pub\") : \"\"\n\n options = @app_config.content.merge({ssh_key: pub_ssh})\n result = send_put_request \"#{Vpsmatrix::API_TEST_SERVER}/vps/create_new_user\", options, api_key\n if result.code == \"200\"\n result.body\n else\n puts \"Check your api_key in ~/.vpsx.yml; call support\" && abort\n end\n end", "def add_default_auth(user, password, domain = T.unsafe(nil)); end", "def create_new_password\n pass = generate_password\n set_password(pass)\n pass\n end", "def use_demo_credentials!\n self.username = 'demo'\n self.password = 'password'\n end", "def add_or_update(username, password, algorithm = Algorithm::DEFAULT, algorithm_args = {})\n if has_entry?(username) then\n update(username, password, algorithm, algorithm_args)\n else\n add(username, password, algorithm, algorithm_args)\n end\n end", "def passwd(host, password)\n # TODO(ody): If not the above this is resource_to_request. Can we call\n # from the provider?\n request = { name: @name, host: host, password: password }.to_json\n post_request = ::Google::Sql::Network::Post.new(\n gsql_user_collection, @cred, 'application/json', request\n )\n response = JSON.parse(post_request.send.body)\n raise Puppet::Error, response['error']['errors'][0]['message'] \\\n if response['error']\n\n # TODO(nelsonjr): Make this function wait for the operation to\n # complete\n end", "def enter_password\n end", "def []=(name, data)\n system.run(:add, \"user\", name, data, data.length, @keyring)\n end", "def setforwardingentitypassword(value)\r\n setvalue(SVTags::FORWARDING_ENTITY_PASSWORD, value)\r\n end", "def generate_mysql_password(user)\n key = \"server_#{user}_password\"\n encrypted_attribute_write([$php_appstack, 'mysql', key]) { secure_password }\nend", "def fAddPunter (name, email, pwd)\n @users.addPunter(name,email,pwd)\n end", "def add_credentials!\n @accessor.auth_manager.add_credentials(self)\n end", "def add_or_update(username, realm, password)\n if has_entry?(username, realm) then\n update(username, realm, password)\n else\n add(username, realm, password)\n end\n end", "def add_or_update(username, realm, password)\n if has_entry?(username, realm) then\n update(username, realm, password)\n else\n add(username, realm, password)\n end\n end", "def password; end", "def password; end", "def password; end", "def password; end", "def password; end", "def password; end", "def add(key, password = nil)\n if @pw_data[key]\n pa %[There is already a password stored for #{key}. You need to remove it before creating a new one!], :red\n return false\n else\n @pw_data[key] = password || ask_for_password(%[please enter a password for #{key}], :yellow)\n if @pw_data[key].empty?\n pa %[Cannot add an empty password!], :red\n return false\n else\n write_safe\n pa %[The password for #{key} has been added], :green\n return true\n end\n end\n end", "def register()\n\tentry = {\"userid\" => @userid, \"username\" => @username, \"email\" => @email, \"password\" => @password}\n\tDATABASE.newEntry(\"users\", entry)\n\tend", "def invite(user_params, email)\n raise StandardError, 'The account can not be activate' if email.nil?\n self.username = user_params[:username] # set the username\n self.passwd = user_params[:passwd] # set the password\n self.passwd_confirmation = user_params[:passwd_confirmation]\n\n # save user and activate\n User.save_user_and_email(self, email, true)\n end", "def get_password(host)\n # Retrieve password from OS X KeyChain.\n osx = (RUBY_PLATFORM =~ /darwin/)\n if(osx)then\n\n require 'osx_keychain'\n keychain = OSXKeychain.new\n user = ENV['USER']\n pass = keychain[host, user ]\n\n if(pass == nil) then\n puts \"Password for '#{host}' not found on OS X KeyChain. \"\n puts \"Enter password to store new password on OS X KeyChain.\"\n require 'highline/import'\n\n pass = ask(\"Password: \") {|q| q.echo = \"*\"} # false => no echo\n keychain[host, user] = pass\n puts \"Password for '#{user}' on '#{host}' stored on OS X KeyChain.\"\n end\n return pass\n\n else\n puts \"Warning: Not running on OS X.\"\n end\n\nend", "def login_with_proper_credentials\r\n\r\n set_text(USERNAME_TEXTFIELD_NAME, VALID_USERNAME)\r\n set_text(PASSWORD_TEXTFIELD_NAME, VALID_PASSWORD)\r\n\r\n click_on_button(SUBMIT_BUTTON_ID)\r\n\r\n end", "def new_user\n system('clear')\n File.open(userdata, 'w') { |f| f.write([].to_json) } unless File.exist?(userdata)\n puts 'Welcome! Please register for an account to continue.'.colorize(:light_green)\n username = @prompt.ask('Username >')\n raise RequirementError.new, 'Requirements not met' if username.match?(/[!@#$%^&*(),.?\":{}|<>]/)\n\n new_user_password(username)\n rescue RequirementError\n puts 'Username cannot contain special characters. Please try again!'.colorize(:light_red)\n new_user\n end", "def set_password; nil; end", "def addUser(stat,typ,email,pwhash)\n @conn.exec_prepared(\"add_user\",[stat,typ,email,pwhash])\n end", "def set_ssh_service(username = nil, password = nil, elevation_type = nil, elevation_user = nil, elevation_password = nil)\n @user_name = username\n @password = password\n @permission_elevation_type = elevation_type || ElevationType::NONE\n @permission_elevation_user = elevation_user\n @permission_elevation_password = elevation_password\n @service = Service::SSH\n end", "def set_auth(username, password)\r\n raise CLXException, 'Username must be a string' unless username.is_a? String\r\n raise CLXException, 'Password must be a string' unless password.is_a? String\r\n raise CLXException, 'Username can not be an empty string' unless username.length > 0\r\n raise CLXException, 'Password can not be an empty string' unless password.length > 0\r\n \r\n @username = username\r\n @password = password\r\n end", "def add_user(username, params)\n\t\t\t\t@session['datastore'][username] = params\n\t\t\tend", "def enable(username,password,quick=true)\n\n if (!username.kind_of?(String))\n raise ArgumentError, \"Expected String for username, but #{username.class} provided.\"\n end\n\n if (!password.kind_of?(String))\n raise ArgumentError, \"Expected String for password, but #{password.class} provided.\"\n end\n\n # open a socket to the server\n socket = open_socket()\n\n # make start packet\n header = TacacsPlus::TacacsHeader.new\n if (@session_id)\n header.session_id = @session_id\n else\n header.randomize_session_id!\n end\n body = TacacsPlus::AuthenticationStart.new\n body.action_login!\n body.priv_lvl = 15\n body.service_enable!\n body.user = username if (quick)\n\n session = ClientSession.new()\n session.request = PacketStruct.new(header,body)\n session.type = :authentication\n session.getuser = username\n session.getpass = password\n\n # process server dialog\n enable_attempt = process_response(session, socket)\n\n return(enable_attempt)\n end", "def change_temp_password\n\tend", "def password(value)\n @config[:password] = value\n end", "def service_password( password )\n\t\t\tself.password_digest = Digest::SHA2.hexdigest( password )\n\t\t\tDRbService.log.debug \"Setting encrypted password for %p to \"\n\t\tend", "def enable!(app, path)\n # TODO: This should eventually take the form of applescript and\n # login_item resources in the mac_os_x cookbook.\n cmd = \"osascript -e 'tell application \\\"System Events\\\" to make \" \\\n 'new login item at end with properties ' \\\n \"{name: \\\"#{app}\\\", path: \\\"#{path}\\\", hidden: false}'\"\n enabled_status = enabled?(app)\n execute \"enable #{app}\" do\n command cmd\n action :run\n only_if { !enabled_status }\n end\nend", "def session_chpasswd(password)\n nessus_rest_put('session/chpasswd', {:password => password})\n end", "def create_account\n system 'clear'\n puts \"--------LOGIN--------\"\n used_flag = false\n while !used_flag\n new_user = @prompt.ask(\"Enter username: \", required: true)\n if !User.all.map(&:name).include?(new_user)\n new_password = @prompt.mask(\"Enter password: \", required: true)\n used_flag = 1\n else\n puts \"Username already taken\"\n end\n end\n @current_user = User.create(name: new_user, password: new_password)\n main_menu\n end", "def pass(password)\n @socket << \"PASS #{password}\"\n end", "def change_password(username, new_password)\n perform_request({:action => \"client-updatepassword\", :username => username, :password => new_password})\n end", "def register(nicknam, realname, passwd = nil, mode = 0)\n pass(passwd) if passwd\n nick(nicknam)\n user(nicknam, realname, mode)\n end", "def register(command)\n args = command.split(\" \")[1..-1]\n params = { :name => args[0], :number => args[1], :email => args[2] }\n add_application(params)\nend", "def create_user(resource)\n session = Puppet::NetDev::CE::Device.session\n\n set_user_xml = '<rpc><edit-config><target><running/></target><default-operation>merge</default-operation><error-option>rollback-on-error</error-option><config><aaa xmlns=\"http://www.huawei.com/netconf/vrp\" content-version=\"1.0\" format-version=\"1.0\"><lam><users><user operation=\"merge\"><userName>' + (resource[:name]).to_s + '</userName>'\n\n if resource[:password]\n set_user_xml += '<password>' + (resource[:password]).to_s + '</password>'\n end\n\n set_user_xml += '</user></users></lam></aaa></config></edit-config></rpc>'\n\n session.rpc.do_config(set_user_xml)\n end", "def add_server(server_key, stateonly = true, power = 0, *flags)\r\n access = nil\r\n if power != 0 || flags.length != 0\r\n access = Access.new(power, *flags)\r\n end\r\n @servers[server_key] = ServerUser.new(server_key, stateonly, access)\r\n end" ]
[ "0.6591192", "0.65554434", "0.6377139", "0.6330864", "0.6289763", "0.6219732", "0.6216527", "0.6076121", "0.6065316", "0.6057965", "0.60131294", "0.6007186", "0.5989015", "0.59452933", "0.59267646", "0.591619", "0.58920234", "0.58640766", "0.5862162", "0.5855735", "0.5852864", "0.58503795", "0.584741", "0.58364695", "0.58258665", "0.57839954", "0.57839954", "0.57839954", "0.57839954", "0.5778007", "0.5772768", "0.5768939", "0.57571596", "0.57458466", "0.5739029", "0.57324", "0.57268256", "0.5723373", "0.57120043", "0.5710522", "0.5710522", "0.569416", "0.5682418", "0.568054", "0.5670726", "0.566521", "0.56466395", "0.5642561", "0.5642561", "0.56424344", "0.5631083", "0.56196696", "0.56195015", "0.56182694", "0.5604951", "0.5601618", "0.5589038", "0.5588215", "0.5583355", "0.5580492", "0.55773777", "0.55717796", "0.55656934", "0.5548526", "0.5547185", "0.55376786", "0.5535534", "0.55180997", "0.55173385", "0.55173385", "0.5516459", "0.5516459", "0.5516459", "0.5516459", "0.5516459", "0.5516459", "0.55150527", "0.5504476", "0.5503695", "0.54990286", "0.5498677", "0.54977906", "0.5484202", "0.54811627", "0.54663646", "0.5462663", "0.54528594", "0.54453075", "0.54425216", "0.54359233", "0.54291505", "0.54178405", "0.54158944", "0.54111224", "0.54085064", "0.5403474", "0.5398504", "0.5398182", "0.53808206", "0.5379271" ]
0.66988856
0
Deletes specified username password from current software instance This is a final action and cannot be undone. the transaction will proceed immediately. Call it with extreme care!
def delete_user_password!(username) user_password = self.passwords.select { |sw_pw| sw_pw.username == username.to_s } unless user_password.empty? softlayer_client[:Software_Component_Password].object_with_id(user_password.first['id']).deleteObject @passwords = nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy_with_password(current_password); end", "def delete_user(username)\n\t\t\t\t@session['datastore'][username] = nil\n\t\t\tend", "def delete_user(username)\n file_buffer = ''\n File.open(FTPUSERS_PATH, 'r') do |password_file|\n file_buffer = password_file.read\n end\n\n file_buffer.gsub!(/^#{username}.*$\\n/, '')\n\n File.open(FTPUSERS_PATH, 'w') do |password_file|\n password_file.write(file_buffer)\n end\n end", "def delete(username)\n if key = find(username)\n unless SecKeychainItemDelete(key.item) == 0\n raise \"Could not delete Keychain item by #{username} of #{@service}\"\n end\n end\n end", "def del_user login\n Command.new(\"deluser #{login} --remove-home -q\", check_file('/home/login', false))\n end", "def delete_user\n begin\n if @kernel_version_major < 11\n guid = @user['generateduid'][0].to_ruby\n password_hash_file = \"#{@@password_hash_dir}/#{guid}\"\n FileUtils.rm_rf(password_hash_file)\n end\n FileUtils.rm_rf(@file)\n rescue Puppet::ExecutionFailure => detail\n fail(\"Could not destroy the user account #{resource[:name]}: #{detail}\")\n end\n end", "def delete_user(username, removehome=false)\n\t\t\tend", "def remove_credential(username)\n raise ArgumentError, \"The username cannot be nil\" unless username\n raise ArgumentError, \"The username cannot be empty\" if username.empty?\n\n self.service.removeCredential(username.to_s)\n \n @credentials = nil\n end", "def delete(username)\n perform_request({:action => \"client-delete\", :username => username})\n end", "def delete(name)\n handle = system.run!(:search, \"user\", name, nil, @keyring)\n system.run!(:unlink, handle, @keyring)\n end", "def cdb_destroy\n couchdb.delete(\"webui_user\", @name, @couchdb_rev)\n end", "def delete_user(username = nil)\n # Check that user has authenticated\n @local_auth_error = local_auth_error\n return Hash[@error => @local_auth_error] if @local_auth_error\n\n unless username\n return Hash[@error =>\n 'missing username; please add to method call']\n end\n\n delete_object('users', username)\n end", "def delete\n connection.delete_user id\n nil\n end", "def delete_user(username, database)\n require 'rubygems'\n require 'mongo'\n\n connection = retrieve_db\n admin = connection.db('admin')\n db = connection.db(database)\n\n # Only try to authenticate with db if required\n if (@new_resource.connection['config']['auth'] == true) || (@new_resource.connection['mongos_create_admin'] == true)\n begin\n admin.authenticate(@new_resource.connection['authentication']['username'], @new_resource.connection['authentication']['password'])\n rescue Mongo::AuthenticationError => e\n Chef::Log.warn(\"Unable to authenticate as admin user: #{e}\")\n end\n end\n\n if user_exists?(username, connection)\n db.remove_user(username)\n Chef::Log.info(\"Deleted user #{username} on #{database}\")\n else\n Chef::Log.warn(\"Unable to delete non-existent user #{username} on #{database}\")\n end\nend", "def delete_account\n @connection.request({\n :method => 'DELETE'\n }) \n end", "def clear_password\n \t\tself.password = nil\n \tend", "def clear_password! \n self.password = nil \n end", "def clear_password\n self.password = nil\n end", "def clear_password!\n self.password = nil\n end", "def purge_partner(password, partner_name)\n partners_to_undelete_or_purge_input.check\n purge_btn.click\n password_tb.type_text(password)\n submit_purge_btn.click\n wait_until_bus_section_load\n end", "def delete_user (db, user_name)\n\tdb.execute(\"DELETE FROM users WHERE user_name=?\", [user_name])\nend", "def delete_account\n @connection.request({\n :method => 'DELETE'\n })\n end", "def delete\n params = self.class.prepare_params_for(:delete, \"userName\" => user_name)\n response = self.class.perform(params)\n self.class.check_response(response)\n end", "def delete_account_helper\n current_user = User.find(self.user.id)\n current_user.delete\n puts \"Your account has successfully been deleted.\"\n sleep(2)\n welcome\n end", "def destroy\n begin\n client = DiscourseApi::Client.new(\"https://intranet.cuhappycorner.com\")\n client.api_key = \"1729b13700d45e58d2e3d81c1bee5431a5167244e75389c07bb613fae54777ee\"\n client.api_username = \"ckho\"\n user = client.by_external_id(current_user.id)\n client.log_out(user[\"id\"]) if user\n rescue\n # nothing\n ensure\n super\n end\n end", "def destroy\n @pw_user = PwUser.find(params[:id])\n @pw_user.destroy\n\n respond_to do |format|\n format.html { redirect_to pw_users_url }\n format.json { head :no_content }\n end\n end", "def delete_user\n client.delete(user)\n end", "def delete(context, name)\n res = context.transport.delete_request(context, \"security/users/#{name}\")\n\n context.err(name, res.body) unless res.success?\n end", "def local_remove(body)\n key_hash = _user_keyhash(body)\n raise \"Invalid username\" unless key_hash\n raise \"That user is signed in!\" if @var[:presence][key_hash]\n @connection.comm.rsa_keys.delete(body)\n @connection.comm.names.delete(key_hash)\n @var[:user_keys].delete body\n _save_env\n _notice \"User '#{body}' has been removed from your key repository\"\nend", "def delete(username)\n perform_request({:action => 'reseller-delete', :username => username})\n end", "def delete\n execute_prlctl('delete', @uuid)\n end", "def delete_partner(password, expect_pass = true)\n wait_until_bus_section_load\n delete_partner_link.click\n\n password_tb = find(:css, 'form[id$=-delete_form] input[name=password]')\n submit_delete_btn = find(:css, 'div[class=popup-window-footer] input[value=Submit]')\n\n wait_until{ password_tb.visible? } # wait for load delete password div\n password_tb.type_text(password)\n submit_delete_btn.click\n if expect_pass\n wait_until{ has_no_link?(\"Delete Partner\") } # wait for delete partner\n else\n return_text = alert_text\n alert_accept\n return_text\n end\n end", "def destroy\n @user = User.find(params.require(:id))\n\n # delete user from zabbix\n z = @zabbix\n begin\n z.delete_user(@user.email)\n rescue => ex\n flash[:alert] = \"Zabbix 処理中にエラーが発生しました #{ex.message}\"\n redirect_to(action: :index) and return\n end\n\n #delete user from SkyHopper\n @user.destroy\n\n flash[:notice] = I18n.t('users.msg.deleted')\n redirect_to(action: :index)\n end", "def remove_password\n @user = User.find(params[:id])\n @user.password = \"temporarily_disabled\"\n @user.save\n respond_to do |format|\n format.html { redirect_to(\"/parametres_cabinets/#{@user.parametres_cabinet_id}/edit\") }\n format.xml { head :ok }\n end\n end", "def delete(username)\n perform_request(action: 'reseller-delete', username: username)\n end", "def destroy\n @user = User.find(params.require(:id))\n\n if @user == current_user\n flash[:alert] = t('users.msg.cannot_delete_yourself')\n raise 'Cannot delete yourself'\n end\n\n # delete user from zabbix\n begin\n @user.zabbix_servers.each do |s|\n z = Zabbix.new(s.fqdn, current_user.email, current_user.encrypted_password)\n z.delete_user(@user.email)\n end\n rescue StandardError => ex\n flash[:alert] = I18n.t('users.msg.error', msg: ex.message)\n raise\n end\n\n # delete user from SkyHopper\n @user.destroy\n\n flash[:notice] = t('users.msg.deleted', name: @user.email)\n redirect_to(action: :index)\n end", "def destroy\n if params[:admin_password] == ENV[\"ADMIN_PASSWORD\"]\n @operation.destroy\n amount = User.find(operation_params[:user_id]).initAmount\n Operation.where(user_id: operation_params[:user_id]).find_each do |operation|\n amount = amount + operation.sum\n end\n User.find(operation_params[:user_id]).update_attribute(:amount, amount)\n respond_to do |format|\n format.html { redirect_to Operation, notice: \"L'opération a bien été supprimée.\" }\n format.json { head :no_content }\n end\n end\n end", "def delete_user(user, removehome=false)\n\t\t\t\tusername = nil\n\t\t\t\tif(user.respond_to?(:username))\n\t\t\t\t\tusername = user.username\n\t\t\t\telse\n\t\t\t\t\tusername = user.to_s\n\t\t\t\tend\n\t\t\t\tCfruby.controller.attempt(\"Removing user \\\"#{username}\\\"\", 'nonreversible', 'destructive') {\n\t\t\t\t\tif(removehome == true)\n\t\t\t\t\t\t`pw userdel #{username} -r`\n\t\t\t\t\telse\n\t\t\t\t\t\t`pw userdel #{username}`\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend", "def destroy\n @auth_user.destroy\n end", "def delete_user\n end", "def delete_user\n print_status(\"Current MySQL Users & Host Info: \")\n query = @db.query('SELECT group_concat(0x0a,host,0x3a,user) FROM mysql.user;')\n query.each { |x| puts \"#{x[0]}\".white }\n print_line(\"\")\n user = Readline.readline(\"(Username to DROP)> \", true)\n host = Readline.readline(\"(Host Entry for #{user.chomp} to DROP)> \", true)\n answer = Readline.readline(\"(Confirm: DROP #{user.chomp}@#{host.chomp} (Y/N))> \", true)\n if \"#{answer.chomp.upcase}\" == \"YES\" or \"#{answer.chomp.upcase}\" == \"Y\"\n print_status(\"OK, sending DROP request.....\")\n begin\n query = @db_connection.query('USE mysql;')\n query = @db_connection.query(\"DROP USER '#{user.chomp}'@'#{host.chomp}';\")\n query = @db_connection.query('FLUSH PRIVILEGES;')\n rescue Mysql::Error => e\n print_error(\"Problem with DROP!\")\n print_error(\"#{e}\")\n end\n print_status(\"Updated MySQL Users & Host Info: \")\n query = @db.query('SELECT group_concat(0x0a,host,0x3a,user) FROM mysql.user;')\n query.each { |x| print_line(\"#{x[0]}\") }\n print_line(\"\")\n else\n print_error(\"OK, aborting User DROP and Returning to Main Menu...\")\n end\n end", "def destroy_user(username, host)\n user = ::MySQL::User.find_by_username_and_host(username, host)\n return false if user.nil?\n !!user.destroy\n end", "def delete_user(userid) \n $db.execute('DELETE FROM users WHERE userid=?', userid)\n end", "def delete_user nick\n $log.debug(\"Users.add_user\") { \"Removing user #{nick} on #{@connection.name}\" }\n\n delete nick\n end", "def clear_password\n self.password=nil\n end", "def delete\n CONNECTION.execute(\"DELETE FROM users WHERE id = #{self.id};\")\n end", "def delete_database\n options = {\n :query => {\n 'ZOHO_ACTION' => 'DELETEDATABASE',\n 'ZOHO_DATABASE_NAME' => database_name,\n }\n }\n send_request get_user_uri, 'post', options\n end", "def destroy\n @password = Password.find(params[:id])\n @password.destroy\n\n respond_to do |format|\n format.html { redirect_to(passwords_url) }\n format.xml { head :ok }\n end\n end", "def delete_user(id)\n elektron_identity.delete(\"users/#{id}\")\n end", "def destroy\n @secure_password.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path, notice: 'Secure password was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @password.destroy\n respond_to do |format|\n format.html { redirect_to passwords_url }\n format.json { head :no_content }\n end\n end", "def destroy account\n destroy_file File.join(@ssh_home, account + \".identity\")\n destroy_file File.join(@ssh_home, account + \".identity.pub\")\n end", "def cleanup_user(username)\n ServiceInstance.rdbi_drop_user(username);\nrescue\nend", "def destroy\r\n\t\t\tif @user != nil\r\n\t\t\t\[email protected]\r\n\t\t\tend\r\n\t\t\tsuper\r\n\t\tend", "def delete_user(user=nil,passwd=nil,message=\"\")\n\t\tconfirm = nil\n\t\tif(user==nil)\n\t\t\tprint('Enter username: ')\n\t\t\tuser = gets.chomp\n\t\t\tprint('Enter password for '+user.to_s+': ')\n\t\t\tpasswd = STDIN.noecho(&:gets).chomp\n\t\telsif(passwd==nil)\n\t\t\tprint('Enter password for '+user.to_s+': ')\n\t\t\tpasswd = STDIN.noecho(&:gets).chomp\n\t\tend\n\t\twhile(confirm==nil)\n\t\t\tprint('Confirm deletion of '+user.to_s+' (y/n): ')\n\t\t\tanswer = gets.chomp\n\t\t\tif(answer=='y')\n\t\t\t\tconfirm = true\n\t\t\telsif(answer=='n')\n\t\t\t\tconfirm = false\n\t\t\telse\n\t\t\t\tputs(\"Invalid input.\")\n\t\t\tend\n\t\tend\n\n\t\treturn @rubbit_poster.delete_user(user,passwd,confirm,message)\n\tend", "def destroy_ftp_account(username)\n ftp_account = ::Proftpd::FtpAccount.find_by_username(username)\n return false if ftp_account.nil?\n !!ftp_account.destroy\n end", "def clear_password\n self.password = nil\n self.password_verify = nil\n end", "def delete_user(username)\n groups = Avalon::RoleControls.user_roles username\n User.where(Devise.authentication_keys.first => username).destroy_all\n groups.each do |group|\n Avalon::RoleControls.remove_user_role(username, group)\n end\n end", "def clean_up_passwords\n self.password = nil\n end", "def clean_up_passwords\n self.password = nil\n end", "def clean_up_passwords\n self.password = nil\n end", "def clear_plaintext\n @password = @password_confirmation = nil\n end", "def remove(key)\n if @pw_data.delete key\n write_safe\n pa %[The password for #{key} has been removed], :green\n return true\n else\n pa %[No password found for #{key}!], :red\n return false\n end\n end", "def destroy\n Rails.logger.warn \"User #{current_user.id} - #{current_user.email} has requested account deletion\"\n password = profiles_controller_destroy_params[:password]\n if current_user.valid_password? password\n Rails.logger.warn \"User #{current_user.id} - #{current_user.email} provided correct password for account deletion\"\n current_user.delete_profile\n sign_out\n flash[:notice] = t 'devise.registrations.destroyed'\n redirect_to root_path\n else\n Rails.logger.error \"User #{current_user.id} - #{current_user.email} provided wrong password for account deletion\"\n flash[:alert] = t 'errors.messages.invalid_password'\n redirect_to edit_user_registration_path\n end\n end", "def destroy\n Rails.logger.warn \"User #{current_user.id} - #{current_user.email} has requested account deletion\"\n password = profiles_controller_destroy_params[:password]\n if current_user.valid_password? password\n Rails.logger.warn \"User #{current_user.id} - #{current_user.email} provided correct password for account deletion\"\n current_user.delete_profile\n sign_out\n flash[:notice] = t 'devise.registrations.destroyed'\n redirect_to root_path\n else\n Rails.logger.error \"User #{current_user.id} - #{current_user.email} provided wrong password for account deletion\"\n flash[:alert] = t 'errors.messages.invalid_password'\n redirect_to edit_user_registration_path\n end\n end", "def destroy\n\t\[email protected]\n\tend", "def delete_credential(db)\n return true unless @credentials\n @credentials.delete(db)\n apply_credentials\n end", "def delete\n appctrl_delete( 'User' )\n end", "def destroy\n # destroy not implemented - only admins may \"purge\" or \"delete\" users\n raise \"This action is not implemented\"\n end", "def delete_user(user_name)\n request(\n 'Action' => 'DeleteUser',\n 'UserName' => user_name,\n :parser => Fog::Parsers::AWS::IAM::Basic.new\n )\n end", "def delete_user_account\n # delete their favorites before deleting user\n # list_to_delete = Favorite.where(user_id:current_user.id)\n binding.pry\n User.all.destroy(current_user.id)\n puts \"Your account have been removed! I will never tell, xoxo\"\n end", "def delete_user\n system('clear')\n puts \"Type \" + \"DELETE\".red.underline + \" if you are sure you want to delete #{self.name}?\"\n puts \"User any other input to return to menu\\n\\n\"\n print \">> \"\n confirm = gets.chomp\n system('clear')\n if confirm.downcase == \"delete\"\n GameSession.all.each do |game|\n if game.user_id == self.id\n game.destroy\n end\n end\n self.destroy\n puts \"Your username has been deleted.\"\n end_program\n else\n menu(self)\n end\n end", "def delete!\n execute_as_user(\"rm -rf #{app_dir}\")\n end", "def destroy\n if(params[:operator][:password] == \"password\")\n @operator.destroy\n flash[:notice] = \"Operator was successfully destroyed.\"\n redirect_to home_index_path\n else\n flash[:warning] = \"Password incorrect\"\n redirect_to home_index_path\n end\n end", "def destroy\n @xmt_mgr_password.destroy\n respond_to do |format|\n format.html { redirect_to xmt_mgr_passwords_url, notice: 'Password was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n\t\tbegin\n\t\t\tFile.open(\"models/userDetails/#{@username}.txt\", \"r\") do |f|\n\t\t\t File.delete(f)\n\t\t\tend\n\t\trescue Errno::ENOENT\n\t\tend\n\tend", "def clear_password!\n self.password = nil\n self.password_confirmation = nil\n self.current_password = nil\n end", "def clear_password!\n self.password = nil\n self.password_confirmation = nil\n self.current_password = nil\n end", "def delete(username)\n if has_entry?(username) then \n ir = internal_record(username)\n line_index = ir['line_index']\n @entries.delete(ir['entry'].key)\n @lines[line_index] = nil\n dirty!\n end\n nil\n end", "def delete(username)\n if has_entry?(username) then \n ir = internal_record(username)\n line_index = ir['line_index']\n @entries.delete(ir['entry'].key)\n @lines[line_index] = nil\n dirty!\n end\n nil\n end", "def destroy\n user.destroy\n end", "def destroy\n @current_user.destroy\n end", "def destroy_with_password(current_password)\n result = if valid_password?(current_password)\n destroy\n else\n self.valid?\n self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)\n false\n end\n\n result\n end", "def destroy\n user = User.first(:username => params[:username])\n if user\n auth = Authorization.first(:provider => params[:provider], :user_id => user.id)\n auth.destroy if auth\n end\n redirect_to \"/users/#{params[:username]}/edit\"\n end", "def delete_user_account\n # delete their favorites before deleting user\n User.all.destroy(current_user.id)\n puts \"\n Your account have been removed! I will never tell, xoxo\n \"\n \n end", "def delete nick\n\t\[email protected] ['nick', nick]\n\tend", "def destroy\n return unless modifying_self?\n @hacker = current_user\n \n if @hacker.authenticate(params[:cancel_password])\n @hacker.cancel_account\n \n cookies.delete :auth_token\n session.delete :filter\n session.delete :current_tags\n\n @hacker.destroy\n \n redirect_to home_url\n else\n redirect_to(edit_hacker_path(@hacker), alert: 'Incorrect password supplied')\n end\n end", "def destroy\n if params[:admin_password] == ENV[\"ADMIN_PASSWORD\"]\n @keg.destroy\n respond_to do |format|\n format.html { redirect_to Keg, notice: \"Le fût a été supprimé.\"}\n format.json { head :no_content }\n end\n end\n end", "def delete_user(user_name:)\n validate_user_name(:user_name, user_name)\n\n wrap_response(@connection.delete(user_path(user_name))).fmap { |r| SftpgoClient::ApiResponse.new(r.body) }\n end", "def destroy account\n return unless valid_argument?(account, \"destroy\")\n shell.say \"Destroying Heroku credentials and SSH identities...\"\n @heroku_credentials.destroy account\n @ssh_identity.destroy account\n end", "def destroy\n\t\t\t\tparams.required(:email)\n params.required(:password)\n\n # Authenticate the user\n begin\n user = User.find_by(email: params[:email])\n\n raise ActiveRecord::RecordNotFound unless user && user.authenticate(params[:password])\n rescue ActiveRecord::RecordNotFound\n return handle_error('Invalid email and password combination.', 'invalid_request_error', 401);\n end\n\n user.destroy\n\n render nothing: true\n\t\t\tend", "def teardown\n # Reset the password\n @s.trustedauth = false\n admin2 = User.new(\"admin\",\"2admin2\")\n\[email protected]_user(admin2)\n\[email protected](\"401 is Ok\")\n\[email protected]_get(@s.url_for(\"/var/cluster/user.json?performing_teardown\"))\n\[email protected](\"401 is Ok\")\n\tadmin2.change_password(@s,\"admin\")\n\tsuper\n end", "def delete\n fail CoachClient::NotFound.new(self), 'User not found' unless exist?\n CoachClient::Request.delete(url, username: @username, password: @password)\n true\n end", "def delete_db_post account\n # Tell the user\n puts \"> Tar bort kontot från databasen\".green\n\n # Connect to the database\n conn = PG.connect( dbname: DB_DATABASE_NAME, user: DB_USER, password: DB_PASSWORD )\n\n # Delete the account\n res = conn.exec \"DELETE FROM #{DB_ACCOUNTS_TABLE} WHERE userid = '#{account['userid']}'\" unless $simulate\n\n # Close the connection\n conn.close\nend", "def destroy\n @user = User.find(params[:user_uuid])\n @user.destroy\n head :ok\n end", "def remove_credentials\n validate(\n infrastructure_name: :security_default,\n record_id: :security_default,\n credential_type: [:optional, :security_default]\n )\n\n begin\n facade = InfrastructureFacadeFactory.get_facade_for(params[:infrastructure_name])\n facade.remove_credentials(params[:record_id], current_user.id, params[:credential_type])\n render json: {status: 'ok', msg: I18n.t('infrastructures_controller.credentials_removed', name: facade.long_name)}\n rescue => e\n Rails.logger.error \"Remove credentials failed: #{e.to_s}\\n#{e.backtrace.join(\"\\n\")}\"\n render json: {status: 'error', msg: I18n.t('infrastructures_controller.credentials_not_removed', error: e.to_s)}\n end\n end", "def clear_password!\n self.password=nil\n self.password_confirmation = nil\n self.current_password = nil\n end", "def test_user_delete\n # Get the user info\n user = get_user_by_username('test-ruby-user12356')\n # Check to see if the returned user was the correct one.\n # Doubles to check whether the returned data exists in a proper form\n assert_equal('test-ruby-user12356', user['UserName'])\n # Delete the user based upon the returned user's id\n ap delete_user_data(user['UserId'])\n # assert if referencing this user, again, causes an error.\n user = get_user_by_username('test-ruby-user12356')\n assert_raise { delete_user_data(user['UserId']) }\n end", "def remove_user(username)\n TestLogger.info(\"Remove user #{username}...\")\n user_id = get_user_id(username)\n\n raise(Exception.new(\"User_id for #{username} not found\")) if user_id.nil?\n\n remove_user_by_id(user_id)\n end", "def destroy\n current_user.destroy\n redirect_to site_root_url\n end" ]
[ "0.7447966", "0.6738042", "0.66543317", "0.6545343", "0.65413666", "0.65098435", "0.6502362", "0.64505446", "0.6305423", "0.629811", "0.6285516", "0.6275266", "0.6230837", "0.61516327", "0.61307436", "0.61194587", "0.61050826", "0.6102537", "0.6098176", "0.60909337", "0.6088752", "0.60855895", "0.6047299", "0.60350454", "0.60306025", "0.60213304", "0.6014897", "0.6010499", "0.600016", "0.5973693", "0.5968404", "0.5967831", "0.59412885", "0.5922234", "0.59119624", "0.5910472", "0.59052145", "0.5895108", "0.5885927", "0.5874094", "0.58665246", "0.5859166", "0.5855674", "0.58512956", "0.5848091", "0.58294153", "0.5825664", "0.5806837", "0.57818496", "0.57724893", "0.5772069", "0.5771883", "0.5770848", "0.5766298", "0.57597464", "0.5751865", "0.5751201", "0.5749334", "0.57488227", "0.57488227", "0.57488227", "0.574833", "0.57479966", "0.5744534", "0.5744534", "0.5742617", "0.5739025", "0.57321924", "0.5726035", "0.57249177", "0.571122", "0.5711063", "0.57097584", "0.5702787", "0.5688968", "0.5682859", "0.56637514", "0.56637514", "0.56571686", "0.56571686", "0.56537443", "0.5620133", "0.56155205", "0.5611872", "0.5609892", "0.56096816", "0.56074244", "0.56070215", "0.55976707", "0.55930734", "0.5589013", "0.5583527", "0.5582221", "0.5578478", "0.5575965", "0.5571718", "0.5571544", "0.5566947", "0.55601704", "0.5556557" ]
0.7768837
0
Returns whether or not one of the Software Password instances pertains to the specified user
def has_user_password?(username) self.passwords.map { |sw_pw| sw_pw.username }.include?(username) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def passwords_match?\n context.user.password == context.password\n end", "def is_potential_user?\n\t\ttrue\n\tend", "def passwordy?\n # puts \"*****************----------------> Handling user as PASSWORDY.\"\n !self.has_oauth?\n end", "def user_check(resource)\n return true unless self[:name] == \"user\"\n return true unless self[:unless_system_user]\n\n resource[:audit] = :uid\n\n return false if system_users.include?(resource[:name])\n\n current_values = resource.retrieve_resource\n current_values[resource.property(:uid)] > self[:unless_system_user]\n end", "def registered(user)\n self.rsvped?(user) || self.isHost?(user)\n end", "def credential_match?(user, login, password)\n false unless user.email == login || user.phone == login\n false unless user.password == password\n true\n end", "def show_password(current_user)\n\t\tif (current_user.admin && !self.admin) || self.uid\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend", "def user?(user)\n\t\t\t\tusername = \"\"\n\t\t\t\tif(user.respond_to?(:username))\n\t\t\t\t\tusername = user.username\n\t\t\t\telse\n\t\t\t\t\tusername = user\n\t\t\t\tend\n\n\t\t\t\toutput = Exec::exec(\"/usr/sbin/pw showuser '#{shellescape(username)}'\")\n\t\t\t\tif(output[0][0] =~ /^#{Regexp.escape(username)}:/)\n\t\t\t\t\treturn(true)\n\t\t\t\telse\n\t\t\t\t\treturn(false)\n\t\t\t\tend\n\t\t\tend", "def user?(user)\n users.include? user\n end", "def credential_match?(user, login, password)\n return false unless user.phone == login || user.email == login\n return false unless user.password == password\n true\n end", "def accessible_by_user?(user)\n user_membership = space_memberships.active.find_by(user: user)\n\n user_membership.present? && (unactivated? || active? || locked? && user_membership.host?)\n end", "def credential_match?(user, login, password)\n return false unless user.phone == login || user.email == login\n return false unless user.password == password\n return true\n end", "def credential_match?(user, login, password)\n return false unless user.phone == login || user.email == login\n return false unless user.password == password\n return true\n end", "def credential_match?(user, login, password)\n return false unless user.phone == login || user.email == login\n return false unless user.password == password\n return true\n end", "def has_user_credential?(username)\n self.credentials.map { |credential| credential.username }.include?(username)\n end", "def enabled?\n user.present?\n end", "def user?\n get_mode == :user\n end", "def applies_to?(user); false end", "def mine?\n user && user.username == Codeplane.username\n end", "def user_registered?(user)\n user_key = \"users/#{user}\"\n @config[user_key] && @config[user_key][\"token\"] && @config[user_key][\"secret\"]\n end", "def user_registered?(user)\n user_key = \"users/#{user}\"\n @config[user_key] && @config[user_key][\"token\"] && @config[user_key][\"secret\"]\n end", "def system?\n id == User::SYSTEM_USER_ID\n end", "def system?\n id == User::SYSTEM_USER_ID\n end", "def password_being_changed?(user)\n user[:password].present? ||\n user[:password_confirmation].present?\n end", "def canBeExecutedBy? user\n unless user.class == Modeles::User\n username = user.to_s\n user = Modeles::User.find_by_name username\n unless user\n @errors << \"User #{username} doesn't exists\"\n return false\n end\n end\n if user.isAdmin == 1\n return true\n elsif user.name == @user\n if @userRights == 1 or @userRights == 5 or @userRights == 7\n return true\n else\n return false\n end\n elsif isIncludedIn? user.groups, @group\n if @groupRights == 1 or @groupRights == 5 or @groupRights == 7\n return true\n else\n return false\n end\n else\n if @othersRights == 1 or @othersRights == 5 or @othersRights == 7\n return true\n else\n return false\n end\n end\n end", "def user?(user)\n user.id == self.user_id if user\n end", "def hasuser? username\n\t\[email protected]? username\t\t\n\tend", "def User?(_Id, _Pwd)\r\n _Flag = 0\r\n _Users = YAML.load(File.read(\"_User_Info.yml\"))\r\n #puts \"_Users: #{_Users}\"\r\n if !(_Users)\r\n else\r\n\r\n _Users.each do |user|\r\n if user.has_value?(_Id.to_i) && user.has_value?(_Pwd)\r\n _Flag = 1 #existing user with matching password\r\n puts \"Welcome back #{user[:Name]}!!\"\r\n end\r\n end\r\n end\r\n return _Flag\r\nend", "def user?\n permissions == 'user'\n end", "def user_key?\n key_type == KEY_TYPE_USER\n end", "def has_user?(user)\n self.users.include?(user)\n end", "def exist_password(pwd)\n @passwords.value?(pwd)\n end", "def checkUser(user)\n\treturn getAllUsersWithRoster().include?(user)\nend", "def user?(user)\n self.user_id == user.id if user\n end", "def user?(user)\n self.user_id == user.id if user\n end", "def user?(user)\n self.user_id == user.id if user\n end", "def status_getuser?()\n return true if (@status == TAC_PLUS_AUTHEN_STATUS_GETUSER)\n return false\n end", "def shadow_user?\n return !session[:shadow_user_id].blank?\n end", "def is_user?\ncurrent_user.username == @userl.username\n end", "def user?(user, opts={})\n rs = self.fetch(\"select * from mysql.user where User = ? and Host = ?\", user, opts[:host] || \"%\")\n return rs.first\n end", "def managed_by? a_user\n program.owned_by? a_user\n end", "def show_service_providers?\n\n # Get the specific Setting for the key Setting::USER_SELECTION,\n # specific to this business.\n setting = Setting.business(business).key(Setting::USER_SELECTION).first\n\n # Return the result of checking if the setting\n # value == Setting::USER_SELECTION_EXPRESS_I\n setting.is? Setting::USER_SELECTION_EXPRESS_I\n end", "def operational?\n @user1_confirmed && @user2_confirmed\n end", "def same?(params)\n User.find(params[:user_id]).play(PasswordRole) { |user|\n user.same_password?(params[:password])\n }\n end", "def is_user?(_user)\n teacher = _user.class == User ? _user.portal_teacher : _user\n teachers.include? teacher\n end", "def is_user?\n usertype == 'user'\n end", "def allow_users_to_change_passwords?\n @policy.allow_users_to_change_password\n end", "def check_correct_user(user)\n \tcurrent_user?(user)\n end", "def check_password(v, user = @user)\n if @opaque\n raise InvalidURIError,\n \"can not set password with opaque\"\n end\n return v unless v\n\n if !user\n raise InvalidURIError,\n \"password component depends user component\"\n end\n\n if parser.regexp[:USERINFO] !~ v\n raise InvalidComponentError,\n \"bad password component\"\n end\n\n return true\n end", "def is_user?\n user ? true : false\n end", "def has_user(user_id)\n if self.user_id == user_id\n puts 'You are the mod!'\n return false\n end\n last_registered_player_id = self.last_registered_player_id.to_i\n if last_registered_player_id == -1\n puts \"No user are signed up for this game.\"\n return false\n end\n while last_registered_player_id != -1\n curr_player = Player.find(last_registered_player_id)\n if curr_player.user_id == user_id\n return true\n end\n last_registered_player_id = curr_player.prev_player_id\n end\n return false\n end", "def windows_user_exists?(user)\n if defined?(Win32)\n net_user = Chef::Util::Windows::NetUser.new(user)\n begin\n !!net_user.get_info\n rescue\n false\n end\n else\n false\n end\n end", "def updatable_by?(user)\n return true if user.has_role?(:admin, resource.unit)\n return true if user.has_role?(:wizard, resource.unit)\n user == resource\n end", "def staff_owned_gate?\n record.check_points.where(registrar: user).map(&:gate?).reduce(:|)\n end", "def matched?(other_user)\n matched.include?(other_user)\n end", "def is_approver?(user)\n\n self.users.include?(user)\n\n end", "def secure?\n user\n end", "def IsUserDev(user_id)\r\n return user_id == OWNER_ID || COBALT_DEV_ID.include?(user_id)\r\n end", "def check_user\n if self.admin?\n return 1\n end\n return (session[:user_id] && User.find(session[:user_id])) ? 1 : nil\n end", "def correct_user(user)\n user == current_user\n end", "def has_privates?\n super || userpass_file.present? || user_as_pass\n end", "def password_valid?\n user &&\n user.authenticate(password) &&\n user.confirmated_at?\n end", "def priviledge_check\n # If we are allowing everybody to connect, then just check the 'everybody' settings\n @users_to_repair = []\n if resource[:users].key?('all')\n unless @config.empty?\n\t return false unless @config['ARD_AllLocalUsersPrivs']\n return false unless resource[:users]['all'].eql?(@config['ARD_AllLocalUsersPrivs'].to_ruby)\n return false unless @config['ARD_AllLocalUsers'].boolValue\n return true\n end\n return false\n end\n # If operation mode is autocratic, check all unscoped users for naprivs \n @removals = []\n if resource[:autocratic]\n unscoped_users = all_users - resource[:users].keys\n unless unscoped_users.empty?\n unscoped_users.each do |user|\n user = get_user(user)\n @removals << user if user['naprivs']\n end\n end\n end\n # Always check scoped users\n @additions = []\n resource[:users].each do |k,v|\n user = get_user(k)\n if user['naprivs']\n\tunless user['naprivs'].to_ruby.to_s.eql?(v)\n\t @additions << user \n\tend\n else\n\t@additions << user \n end\n end\n @users_to_repair = @additions + @removals\n return false unless @config['ARD_AllLocalUsers']\n unless @config['ARD_AllLocalUsers'].boolValue.eql?(true)\n return @users_to_repair.empty? \n end\n false\n end", "def findlocal(user)\n\n if user_exists(user) then\n return true\n else\n return false\n end\n end", "def current_user?(user)\n user == current_person.user\n end", "def _user? name\n\t\tuid = DB[:_user].filter(:name => name).get(:uid)\n\t\tuid ? true : false\n\tend", "def key_match?(passed_key, user)\n return false unless passed_key\n passed_key == process_key(user.secret_key)\n end", "def accessible_for?(user)\n user_id == user.id && !user.anonimous?\n end", "def is_user_specific?\n false\n end", "def viewable_by?(user)\n Sugar.public_browsing? || user ? true : false\n end", "def app_user?\n member_type == MEMBER_TYPE[:app]\n end", "def same?(user,pass)\n if user == pass\n true\n else\n false\n end\nend", "def dummy_user?\n (user_id.split('/').first == 'gofreerev')\n end", "def dummy_user?\n (user_id.split('/').first == 'gofreerev')\n end", "def employs?(user)\n employees.include?(user) or (affiliate == user) or user.admin?\n end", "def true_user_can_impersonate?\n true_user and Rails.configuration.dm_unibo_common[:impersonate_admins] and Rails.configuration.dm_unibo_common[:impersonate_admins].include?(true_user.upn)\n end", "def current_user_is_pal?\n current_user && current_user.person && current_user.person.is_pal?\n end", "def superuser?(user, opts={})\n unh = self._user_and_host(user, opts[:host])\n row = self.user?(user, opts)\n return false unless row\n return row['Super_priv'] == 'Y'\n end", "def user?(name)\n eval(USER_CHECK, binding, __FILE__, USER_CHECK_LINE)\n nil\nend", "def has_entry?(username)\n test_entry = PasswdEntry.new(username)\n @entries.has_key?(test_entry.key)\n end", "def has_entry?(username)\n test_entry = PasswdEntry.new(username)\n @entries.has_key?(test_entry.key)\n end", "def user?\n type == :user_id\n end", "def user?\n type == :user_id\n end", "def current_user?(user)\n\t\tcurrent_user == user\n\tend", "def needs_password?(user, params)\n #user.email != params[:user][:email] ||\n params[:user][:password].present?\n end", "def current_user?(user)\r\n user == current_user\r\n end", "def super_user?\n user = check_user\n # user.email == '[email protected]'\n user.email == '[email protected]'\n end", "def user_exists?(user)\n @users.key?(user)\n end", "def current?(user)\n Process.uid == Etc.getpwnam(user).uid\n rescue\n false\n end", "def check_password(user)\n counter = 0\n while counter < 3\n password = PROMPT.mask(\"Enter your password:\")\n\n if user.get_password == password\n return true\n else\n puts \"Incorrect Password. Please try again.\"\n puts \"You have #{2 - counter} attempt#{counter == 1 ? \"\" : \"s\"} left.\"\n counter += 1\n end\n end\n return false\n end", "def user_exists(user)\n @users.key?(user)\n end", "def can_access user\n return self.users.include? user\n end", "def allow_login_as_specific_user?\n return self.class.allow_login_as_specific_user?\n end", "def username_present?(username)\n @hashers.key?(username) && @passwords.key?(username)\n end", "def needs_password?(user, params)\n user.email != params[:user][:email] ||\n params[:user][:password].present?\n end", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend" ]
[ "0.65706915", "0.64844984", "0.648344", "0.64729273", "0.64175785", "0.64132977", "0.64103395", "0.6385126", "0.633983", "0.6309101", "0.62633795", "0.6263048", "0.6263048", "0.6263048", "0.62436193", "0.6154879", "0.6151323", "0.6120912", "0.61185443", "0.6087042", "0.6087042", "0.60857636", "0.60857636", "0.6085286", "0.60516405", "0.60492337", "0.6046289", "0.6044832", "0.6031918", "0.60281736", "0.6023482", "0.6023037", "0.6013744", "0.6009189", "0.6009189", "0.6009189", "0.6008274", "0.6002713", "0.59974116", "0.5986245", "0.5982586", "0.5977572", "0.5977052", "0.5975281", "0.59671485", "0.5967009", "0.59646493", "0.59630394", "0.59611547", "0.5956095", "0.5951769", "0.5947117", "0.5941595", "0.5937702", "0.59351975", "0.5934148", "0.59325475", "0.59296453", "0.5929004", "0.5928283", "0.59245366", "0.5920368", "0.5917798", "0.59172624", "0.5917161", "0.59110165", "0.59091705", "0.59067714", "0.59018904", "0.59001225", "0.58926344", "0.5882239", "0.58791775", "0.58791775", "0.5878949", "0.58712196", "0.5868351", "0.5866791", "0.58640575", "0.5863255", "0.5863255", "0.58616656", "0.58616656", "0.58529323", "0.5852789", "0.58476424", "0.58474964", "0.5845492", "0.58439034", "0.58417135", "0.5838867", "0.5835094", "0.5834661", "0.58319974", "0.58297884", "0.58290327", "0.58290327", "0.58290327", "0.58290327", "0.58290327" ]
0.69828796
0
Returns the service for interacting with this software component through the network API
def service softlayer_client[:Software_Component].object_with_id(self.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service\n @service\n end", "def service\n return @service\n end", "def service\n @service ||= fetcher.get(Service, service_id)\n end", "def service\n return softlayer_client[\"Virtual_Guest\"].object_with_id(self.id)\n end", "def service\n return softlayer_client[:Virtual_Guest].object_with_id(self.id)\n end", "def connect\n service\n end", "def service\n @service ||= bus.service('com.dubstepdish.i3dstatus')\n end", "def service\n return softlayer_client[:Ticket].object_with_id(self.id)\n end", "def getHttpService()\n return @currentlyDisplayedItem.getHttpService()\n end", "def getHttpService()\r\n @currentlyDisplayedItem.getHttpService\r\n end", "def service\n softlayer_client[:Network_Message_Delivery].object_with_id(self.id)\n end", "def service\n softlayer_client[:Network_Storage].object_with_id(self.id)\n end", "def service\n softlayer_client[:Product_Package].object_with_id(self.id)\n end", "def get_service()\n data, _status_code, _headers = get_service_with_http_info()\n return data\n end", "def service\n options[:service]\n end", "def srv\n @service_finder\n end", "def service\n return @service if @service\n @service = ExchangeService.new(version)\n # TODO: make this whole URI configurable\n @service.url = java.net.URI.new(\"https://#{self.config['host']}:443/EWS/Exchange.asmx\")\n @service.credentials = credentials\n @service\n end", "def service\n @service ||=\n if (c = self_class)\n name = c.safe_const_get(:SERVICE_NAME)\n name ||= c.module_parent_name.underscore.remove(/_service$/)\n name&.to_sym || super\n end\n end", "def get_service_class\n return @m_service_class\n end", "def data_service\n DataServicesApi::Service.new(url: api_service_url)\n end", "def connection(service=:cci)\n SoftLayer::Service.new(\n SoftlayerBase.send(service),\n :username => Chef::Config[:knife][:softlayer_username],\n :api_key => Chef::Config[:knife][:softlayer_api_key],\n :user_agent => USER_AGENT\n )\n end", "def service\n context[:target]\n end", "def service\n @service ||= service_class.new(self, assessment: @assessment, submission: @submission)\n end", "def _service_type\n self.class.service_type\n end", "def read_nsx_ui_service_service_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_nsx_ui_service_service ...\"\n end\n # resource path\n local_var_path = \"/node/services/ui-service\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\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 => 'NodeServiceProperties')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_nsx_ui_service_service\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def service(nickname, reserved, distribution, type)\n end", "def get_service_with_http_info()\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DiagnosticsApi.get_service ...\"\n end\n # resource path\n local_var_path = \"/service_information\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ServiceInformation')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DiagnosticsApi#get_service\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def service_name\n return @service_name\n end", "def service\n softlayer_client[:User_Customer_External_Binding].object_with_id(self.id)\n end", "def service; services.first; end", "def driver\n Fc3Service\n end", "def service\n if !block_given?\n return @j_del.java_method(:service, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling service()\"\n end", "def service\n StockManagementService.new\n end", "def service(id)\n request :get, \"/services/#{id}\"\n end", "def service(name)\n name = name.to_sym\n\n service_info = SERVICES[name]\n if service_info.nil?\n raise ArgumentError, sprintf('No service found with name %s', name)\n end\n\n require_path = sprintf(SERVICE_PATH, @path_version,\n service_info.first)\n require require_path\n\n class_path = sprintf(SERVICE_CLASS_PATH, @version, service_info.last)\n return class_for_path(class_path)\n end", "def service; end", "def service_uri\n \"#{host}#{service_path}\"\n end", "def minter\n # Use Datacite if it has been activated\n return ExternalApis::DataciteService if ExternalApis::DataciteService.active?\n # Use the DMPHub if it has been activated\n return ExternalApis::DmphubService if ExternalApis::DmphubService.active?\n\n # Place additional DOI services here\n\n nil\n end", "def service\n Googlecal::Base.service\n end", "def service_endpoint; end", "def service_endpoint; end", "def service_name; end", "def service_request(service); end", "def to_s\n service\n end", "def service\n URI.parse(@config.split('<')[0].split('->')[1])\n end", "def service_name\n return @target.service_name\n end", "def get_service(nickname = nil)\n nickname ||= @nickname\n agent = get_web_agent()\n\n services_uri = ROOT_URI + (\"/%s/services\" % URI.encode(nickname))\n parser = agent.get(services_uri).parser\n\n active_servicelist = parser.xpath(\"//*[@class='active']//ul[@class='servicelist']\")\n\n if !active_servicelist.empty?\n services = active_servicelist.xpath(\"./li/a\").map { |a|\n {\n 'service' => a['class'].split.find { |a_class|\n a_class != 'l_editservice' && a_class != 'service'\n },\n 'serviceid' => a['serviceid'].to_s,\n }\n }\n else\n services = parser.xpath(\"//ul[@class='servicelist']/li/a\").map { |a|\n {\n 'service' => a['class'].split.find { |a_class|\n a_class != 'service'\n },\n 'profileUrl' => (services_uri + a['href'].to_s).to_s,\n }\n }\n end\n services\n end", "def read_proton_service_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_proton_service ...\"\n end\n # resource path\n local_var_path = \"/node/services/manager\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\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 => 'NodeProtonServiceProperties')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_proton_service\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def service_description\n resp = http.resource(service_descriptor_href).get(:accept => 'application/vnd.absolute-performance.sysshep+json')\n JSON.parse(resp.body)\n end", "def service_fwproxy!()\n @service = TAC_PLUS_AUTHEN_SVC_FWPROXY\n end", "def service; raise NotImplementedError; end", "def as_service\n @service ||= (plan.find_plan_service(self) || PlanService.new(self))\n end", "def as_service\n @service ||= (plan.find_plan_service(self) || PlanService.new(self))\n end", "def service(name)\n \"#{SERVICE_NAME} #{name}\"\n end", "def related_service_named(service_name)\n @client.service_named(service_name)\n end", "def find_service(id)\n self.class.get(\"/services/#{id}.json?apikey=#{apikey}\")\n end", "def info_service\n @info_service ||= GeoWorks::Derivatives::Processors::Vector::Info.new(dataset_path)\n end", "def service_nasi!()\n @service = TAC_PLUS_AUTHEN_SVC_NASI\n end", "def transport\n @transport ||= definition.transport_class.new(ui, transport_options)\n end", "def service_x25!()\n @service = TAC_PLUS_AUTHEN_SVC_X25\n end", "def search_service\n @search_service ||= SearchService.new do |service|\n service.namespace = NAMESPACE\n service.parent_service =\n Qa::Authorities::AssignFast.subauthority_for('all')\n end\n end", "def read_search_service_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_search_service ...\"\n end\n # resource path\n local_var_path = \"/node/services/search\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\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 => 'NodeServiceProperties')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_search_service\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def service_layer\n @sl ||= ServiceLayer.new\n end", "def wsdl\n log \"Retrieving WSDL from: #{@endpoint}\"\n http.endpoint @endpoint.host, @endpoint.port\n http.use_ssl = @endpoint.ssl?\n http.start { |h| h.request request(:wsdl) }\n end", "def client\n self.class.client\n end", "def client\n self.class.client\n end", "def api_service_uri\n api_service_host = API_SERVICE_HOST\n return \"https://#{api_service_host}/sendsms/\"\n end", "def hypernova_service\n @_hypernova_service ||= Hypernova::RequestService.new\n end", "def system\n JenkinsApi::Client::System.new(self)\n end", "def system\n JenkinsApi::Client::System.new(self)\n end", "def get_endpoint()\n end", "def resource_service\n @resource_service ||= resource_specification.singleton? ? SingletonResourceService.new(self) : ResourceService.new(self)\n end", "def network\n @_network\n end", "def service_socket(name)\n service_sockets[name] ||= \n begin\n socket = rz_socket(ZMQ::DEALER)\n socket.setsockopt(ZMQ::IDENTITY,@rz_identity) if @rz_identity\n socket.connect(service_address(name))\n socket\n end\n end", "def service=(value)\n @service = value\n end", "def info_service\n @info_service ||= GeoWorks::Derivatives::Processors::Raster::Info.new(dataset_path)\n end", "def service(nickname, info, distribution = '*')\n raw \"SERVICE #{nickname} * #{distribution} 0 0 :#{info}\\r\\n\"\n end", "def service\n softlayer_client[:User_Customer].object_with_id(self.id)\n end", "def api_endpoint\n Solusvm.api_endpoint.dup\n end", "def client\n @client ||= platform_klass::Client.new(@options)\n end", "def get_services()\n return get_request(address(\"/OS-KSADM/services\"), token())\n end", "def get_service(opts = {})\n data, _status_code, _headers = get_service_with_http_info(opts)\n data\n end", "def service_require\n ruby_file_path @api, service_name_full\n end", "def name\n @service.name.to_s\n end", "def start_service\n object = DBusObject.new(@main, self)\n service = @bus.request_service(SERVICE)\n service.export object\n end", "def api_client\n self.class.api_client\n end", "def initialize(service = :uic)\n raise 'bad argument' unless service.is_a? Symbol\n @service_path = SERVICES[service]\n @client = SOAP::NetHttpClient.new\n end", "def service_rcmd!()\n @service = TAC_PLUS_AUTHEN_SVC_RCMD\n end", "def service_key\n SERVICE_KEY\n end", "def method_missing(service_name, params = {})\n # remove user-friendly underscores from service names\n service_name = service_name.to_s.gsub('_', '')\n\n if respond_to?(service_name)\n send(service_name, params)\n else\n request(service_name, params)\n end\n end", "def services\n @services ||= Metaforce::Services::Client.new(@options)\n end", "def services\n @services_manager\n end", "def get_service_name\n\t\t\t\traise \"Should return the a service name from config.wsdl keys\"\n\t\t\tend", "def read_appliance_management_service_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_appliance_management_service ...\"\n end\n # resource path\n local_var_path = \"/node/services/node-mgmt\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\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 => 'NodeServiceProperties')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_appliance_management_service\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def network\n @network ||= eval(\"#{@occi_ver}::Network.new @connection\")\n end", "def remote_service(remote_service_name)\n configuration.find_remote_service(remote_service_name)\n end", "def install\n kit_klass = ServiceKit.const_get self.service_type.capitalize\n kit = kit_klass.new comms, container, host\n kit.configure_service!\n end", "def service_ppp!()\n @service = TAC_PLUS_AUTHEN_SVC_PPP\n end", "def api\n return @api\n end", "def service(service_name, api_client)\n klazz = service_class(service_name)\n\n # raise an error unless the class inherits from Service\n unless klazz < Core::ServiceLayer::Service\n raise ServiceParentError,\n \"service #{klazz.name} is not a subclass of \\\n Core::ServiceLayer::Service\"\n end\n\n # create an instance of the service class\n klazz.try(:new, api_client)\n end" ]
[ "0.70281386", "0.6914861", "0.6905515", "0.6841882", "0.6789678", "0.6738794", "0.6629946", "0.66140217", "0.6570975", "0.654383", "0.64628863", "0.63794637", "0.62201667", "0.61986864", "0.6152247", "0.6111111", "0.60840917", "0.60794586", "0.6012397", "0.5986052", "0.5984961", "0.598036", "0.5973517", "0.5840477", "0.5809137", "0.5746363", "0.56867194", "0.56722534", "0.56700534", "0.5635122", "0.56258816", "0.5610073", "0.55914336", "0.55875313", "0.55807644", "0.5575804", "0.556492", "0.5539307", "0.55389017", "0.55070496", "0.55070496", "0.55039924", "0.54798883", "0.5476097", "0.5469558", "0.5461419", "0.54586905", "0.5453608", "0.5452264", "0.54465735", "0.5431788", "0.54158646", "0.54158646", "0.5405251", "0.5380267", "0.5358543", "0.5352564", "0.5348609", "0.5346789", "0.53462946", "0.53394705", "0.5336631", "0.533335", "0.5331044", "0.5328529", "0.5328529", "0.5322529", "0.5315964", "0.53036463", "0.53036463", "0.52697384", "0.52694464", "0.5267806", "0.5257214", "0.52493715", "0.52441895", "0.5235256", "0.523281", "0.5216804", "0.5210072", "0.52092457", "0.520761", "0.5204521", "0.52044094", "0.52042186", "0.520254", "0.51968515", "0.5194352", "0.51924753", "0.5192201", "0.51918", "0.5184329", "0.5182648", "0.5180204", "0.51664484", "0.5165387", "0.5162218", "0.5158388", "0.51473916", "0.51441485" ]
0.7643177
0
Make an API request to SoftLayer and return the latest properties hash for this object.
def softlayer_properties(object_mask = nil) my_service = self.service if(object_mask) my_service = my_service.object_mask(object_mask) else my_service = my_service.object_mask(self.class.default_object_mask) end my_service.getObject() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n\t\t\t@hash\n\t\tend", "def hash\n @hash ||= @client.get_hash(path)\n @hash\n end", "def hash\n @hash ||= @client.get_hash(path)\n @hash\n end", "def hash\n [id, type, name, is_active, external_url, external_authorization_type, external_user_name, external_password, external_bearer_token, external_headers].hash\n end", "def hash\n @hash\n end", "def hash\n @hash.hash\n end", "def get_details\n return self if detailed?\n res = client.get(path_base).to_h\n update(res)\n res\n end", "def __getobj__\n @hashobj\n end", "def refresh_details(object_mask = nil)\n @softlayer_hash = self.softlayer_properties(object_mask)\n end", "def query\n @property_hash\n end", "def information\n begin\n gather_information if stale?\n self.json\n rescue Services::NotFoundException => e\n self.destroy\n {'error' => e.message}.to_json\n end\n end", "def hash\n [class_id, object_type, api_version, app_partition_number, connection_id, connection_reason, connection_status, connection_status_last_change_time, connector_version, device_external_ip_address, proxy_app].hash\n end", "def get_hash()\n return @@hash;\n end", "def fetch_hash!\n fetch0(Hash, true)\n end", "def fetch_hash\n fetch0(Hash, false)\n end", "def populate\n response = self.container.connection.cfreq(\"HEAD\",@storagehost,@storagepath)\n raise NoSuchObjectException, \"Object #{@name} does not exist\" if (response.code != \"204\")\n @bytes = response[\"content-length\"]\n @last_modified = Time.parse(response[\"last-modified\"])\n @etag = response[\"etag\"]\n @content_type = response[\"content-type\"]\n resphash = {}\n response.to_hash.select { |k,v| k.match(/^x-object-meta/) }.each { |x| resphash[x[0]] = x[1][0].to_s }\n @metadata = resphash\n true\n end", "def latest\n get_json('/latestblock')['hash']\n end", "def inspect()\n '#<#{self.class}:#{object_id} @url=\\'#{@resturl}\\' @sslcheck=#{@sslcheck} @timeout=#{@timeout}>'\n end", "def object_definition_metadata\n version = @account.api_version.nil? ? 'latest' : @account.api_version\n response = ap_client(version).metadata.fetch\n\n Rails.logger.info \"response: \" + response.inspect\n parsed_json = []\n case response.status\n when 200\n begin\n parsed_json = ActiveSupport::JSON.decode(response.body)\n rescue MultiJson::DecodeError\n raise \"Unable to decode the JSON message.\"\n end\n else\n raise \"Unable to get a response.\"\n end\n\n parsed_json\n end", "def full_details\n data = self.class\n .data_keys\n .map { |k| [k, send(\"#{k}\")] }\n .to_h\n { id: id,\n url: url }.merge(data)\n end", "def api_attributes(layers)\n h = {\n id: id,\n user_id: user_id,\n container_id: container_id,\n amount: amount,\n details: details,\n created_at: created_at,\n }\n\n h\n end", "def hash\n data.hash\n end", "def hash\n [custom_headers, encode_as, name, payload, url].hash\n end", "def object_definition_metadata\n version = self.api_version.nil? ? 'latest' : self.api_version\n response = ap_client(version).metadata.fetch\n\n Rails.logger.info \"response: \" + response.inspect\n parsed_json = []\n case response.status\n when 200\n begin\n parsed_json = ActiveSupport::JSON.decode(response.body)\n rescue MultiJson::DecodeError\n raise \"Unable to decode the JSON message.\"\n end\n else\n raise \"Unable to get a response.\"\n end\n\n parsed_json\n end", "def getRestforceObj()\n return @restForce\nend", "def info\n @info ||= client.try(:get, transaction_url)||{}\n end", "def api_hash\n api_hash ||= {}\n api_hash['id'] = api_options_id\n api_hash['status'] = \"available\"\n api_hash['location'] = location_for\n api_hash['registry_options'] = registry_options_for\n api_hash['machine_options'] = machine_options_for if (machine_options_for &&\n machine_options_for.is_a?(Hash) &&\n !machine_options_for.empty?)\n stringify_keys(api_hash)\n end", "def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end", "def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end", "def get\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.get do |req|\n req.url resource_uri\n resource_params.each { |key, value|\n req.params[key] = value\n }\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def hash\n attributes.hash\n end", "def hash\n attributes.hash\n end", "def hash\n attributes.hash\n end", "def get_hash_data\r\n return CallInitiate.decode_call_params(get_variable(\"CallInitiate_hashdata\"))\r\n\tend", "def object_metadata(key)\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n log \"Requesting metadata from #{object_path}\"\n\n response = storage_client.head(object_path)\n {\n :content_type => response[\"Content-Type\"],\n :bytes => response[\"Content-Length\"].to_i\n }\n end", "def my_fingerprint\n new_resource.unique_fields.map do |f|\n if !new_resource.properties[f].nil?\n new_resource.properties[f]\n else\n current_resource.default_properties[f]\n end\n end\n end", "def metadata\n self[:metadata] || {}\n end", "def latest\n Sibit::Json.new(http: @http, log: @log).get(\n URI('https://blockchain.info/latestblock')\n )['hash']\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n @object\n end", "def to_h\n res = {\n email: email,\n api_key: api_key,\n org_id: org_id,\n mkp_name: mkp_name,\n version: version,\n assemblyname: assemblyname,\n componentname: componentname,\n domain: domain,\n region: region,\n resource: resource,\n storage_hddtype: storage_hddtype,\n oneclick: oneclick,\n ipv4private: ipv4private,\n ipv4public: ipv4public,\n ipv6private: ipv6private,\n ipv6public: ipv6public,\n sshkey: keypairname,\n keypairoption: keypairoption,\n cattype: cattype,\n cpu: @flavor.cpu,\n ram: @flavor.ram,\n hdd: @flavor.hdd,\n options: options,\n envs: envs,\n provider: provider\n }\n\n set_git(res)\n res\n end", "def hash\n [allow_insecure_certificates, basic_auth, body, body_type, cookies, device_ids, follow_redirects, headers, locations, metadata, public_id, _retry, start_url, variables].hash\n end", "def __hash\n @hash\n end", "def metadata\n api_get(\"$metadata\").body\n end", "def to_hash\n hsh = {\n id: id,\n status: status.to_sym,\n connect: running? ? connect.to_h : nil,\n time: info.wallclock_time.to_i / 60 # only update every minute\n }\n Digest::SHA1.hexdigest(hsh.to_json)\n end", "def hash\n [__meta, created_at, updated_at, customer, reusable, status, token].hash\n end", "def fetch!\n response = @client.get(self.url)\n @params = response.parsed\n end", "def hash\n [description, routing_number, account_number, account_type, signatory, metadata, id, signature_url, bank_name, verified, date_created, date_modified, deleted, object].hash\n end", "def inspect\n @hash.inspect\n end", "def get_attributes\n from_server single_url do |response|\n payload_to_attributes(response.data)\n end\n end", "def latest\n hash = info2hash(@resource[:source])\n hash[:ensure]\n end", "def to_s\n\t\t\"#{@api_hash}\"\n\tend", "def fetch_properties(host)\n fetcher = Commands::PropertiesFetcher.new(credentials)\n fetcher.call(mc_id: host.identifier)\n end", "def hash\n [_hash, name, owner].hash\n end", "def retrieve\n return if retrieved_at && retrieved_at.utc > DateTime.now.utc - 1.hour\n \n rubygems_info = Gems.info name\n new_attributes = {\n name: rubygems_info['name'], \n version: rubygems_info['version'], \n info: rubygems_info['info'],\n retrieved_at: DateTime.now\n }\n update_attributes(new_attributes, as: :internal)\n end", "def call\n url = URI(\"https://api.covid19api.com/summary\")\n https = Net::HTTP.new(url.host, url.port);\n https.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n response = https.request(request).read_body\n\n data_hash = JSON.parse(response)\n end", "def merritt_object_info\n repo = APP_CONFIG[:repository]\n collection = repo.endpoint.match(%r{[^/]+$}).to_s\n enc_doi = ERB::Util.url_encode(to_s)\n resp = HTTP.basic_auth(user: repo.username, pass: repo.password)\n .headers(accept: 'application/json')\n .get(\"#{repo.domain}/api/#{collection}/local_id_search?terms=#{enc_doi}\")\n return resp.parse if resp.headers['content-type'].start_with?('application/json')\n\n {}\n rescue HTTP::Error, JSON::ParserError\n {}\n end", "def getData\n logger.debug(\"properties = #{properties}\")\n prop_hash = ActiveSupport::JSON.decode(properties)\n logger.debug(\"prop_hash = #{prop_hash}\")\n \n\n # TBD: This is hardcode, to be removed\n # Add user name to data_str (for table view widget)\n data_str = Hash.new\n if prop_hash[\"user\"].nil? then\n logger.debug(\"user val not present\")\n else\n logger.debug(\"user val present\")\n data_str[\"user\"] = prop_hash[\"user\"]\n end\n\n # TBD: This is ThingSpeak specific\n # TBD: Error catch, timeout\n json_str = Net::HTTP.get(URI.parse(prop_hash[\"url\"]))\n # data_str = Hash.new {\"NA\"}# TBD: Crude initialiser\n logger.debug(\"json_str = #{json_str}\")\n #logger.debug(\"data_str = #{data_str}\")\n data_str.merge!(ActiveSupport::JSON.decode(json_str))\n # Catch null, create empty string. Redundant? After addition of above Hash.new\n if data_str.nil? then \n data_str = Hash.new \n end\n logger.debug(\"data_str = #{data_str}\")\n \n\n # TBD: This is map specific, should go elsewhere\n # Add \"icon\" entry to hash, Get related icon, locally\t\n # Hardcoded, should get it from source properties\n #data_str[\"icon\"] = \"../../assets/glyphicons_003_user.png\"\n logger.debug(\"data_str = #{data_str}\")\n return data_str\n end", "def inspect\n JSON.pretty_generate to_h\n end", "def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end", "def inspect\n @h.inspect\n end", "def object\n object = {\n jsonapi: {\n version: ActiveModelSerializers.config.jsonapi_version,\n meta: ActiveModelSerializers.config.jsonapi_toplevel_meta\n }\n }\n object[:jsonapi].reject! { |_, v| v.blank? }\n\n object\n end", "def hash\n [id, name, address, timezone, capabilities, status, created_at, merchant_id, country, language_code, currency, phone_number, business_name, type, website_url].hash\n end", "def get_properties()\n return @properties\n end", "def properties\n @properties ||= Hash.new\n end", "def fetch_latest_user_info\n\t\t@user_info = @client.execute(api_method: @info.userinfo.get).data\n\tend", "def api\n self.well_info.api\n end", "def information\n begin\n # TODO HIGH prateekm: Update this section\n gather_info if stale?\n self\n rescue Services::NotFoundException => e\n #self.destroy\n {'error' => e.message}.to_json\n end\n end", "def inspect\n @hash.inspect\n end", "def hash\n [id, user, client, remote_ip, service_name, event_date, message, action, entity, entity_type, property_changes, context].hash\n end", "def get(header = {})\n url = \"#{ApiClient.config.path}#{self.class.resource_path}/#{id}\"\n response = ApiClient::Dispatcher.get(url, header)\n attributes = ApiClient::Parser.response(response, url)\n update_attributes(attributes)\n end", "def get_hash_extended\n rc = info_search(:extended => true)\n return rc if OpenNebula.is_error?(rc)\n to_hash\n end", "def hash\n [uri, parameters, username, password, verify_mode].hash\n end", "def info\n {\n :name => self.name,\n :signature => self.signature,\n }\n end", "def get_data\n response = proxy.get_data(handle)\n self.update_properties(response)\n self.partial = false\n self.persisted = true\n end", "def raw_info\n # This is a public API and does not need signing or authentication\n request = \"/services/rest/?format=json&method=flickr.people.getInfo&nojsoncallback=1&user_id=#{uid}\"\n @raw_info ||= MultiJson.decode(access_token.get(request).body)\n rescue ::Errno::ETIMEDOUT\n raise ::Timeout::Error\n end", "def to_httparty\n [\n self.class.http_method, # E.g. `:get`.\n \"#{api_url}/#{api_version}/#{self.class.path}\",\n {\n body: to_h.to_json,\n headers: headers,\n }\n ]\n end", "def fetch_custom_attributes\n endpoint = \"/api/#{@version}/custom-attributes/\"\n make_get_request(endpoint)\n end", "def hash\n return @revision.hash if @revision\n return object_id\n end", "def get_property\n @xml = client.call(url).parsed_response.css('property').first\n @attributes.merge!(parse_xml_to_hash)\n end", "def fetch_json\n # Get raw JSON of GitHub API\n api_page = open(@api_url, http_basic_authentication: @login)\n # Parse the JSON into a hash\n @api_hash = JSON.parse(api_page.read)\n end", "def api_data\n @api_data ||= {\n address: @ethereum_address,\n phase: 0,\n client_whitelist_detail_obj: get_client_whitelist_detail_obj\n }\n end", "def getblockchaininfo\n @api.request 'getblockchaininfo'\n end", "def raw_info\n @raw_info ||= MultiJson.decode(access_token.get('https://api.trademe.co.nz/v1/MyTradeMe/Summary.json').body)\n rescue ::Errno::ETIMEDOUT\n raise ::Timeout::Error\n end", "def to_hash\n @request\n end", "def to_hash\n @request\n end", "def latest\n url = @base_url + \"result/#{key}-latest#{format}\"\n response = RestClient.get(url)\n \n JSON.parse(response)\n end", "def properties\n _properties\n end", "def fetch\n response = RestClient.get \"http://pokeapi.co/#{resource_uri}\"\n update(resource_data: JSON.parse(response))\n end" ]
[ "0.63635004", "0.613282", "0.613282", "0.595216", "0.5857636", "0.58122736", "0.57377756", "0.5706588", "0.56365913", "0.56166387", "0.5572106", "0.55394036", "0.5508698", "0.5488298", "0.5473986", "0.5457117", "0.54497766", "0.54428065", "0.544006", "0.5431518", "0.54171795", "0.5409195", "0.53933924", "0.53875554", "0.53795356", "0.5375914", "0.5373591", "0.5355199", "0.5355199", "0.5347943", "0.5335563", "0.5335563", "0.5335563", "0.533154", "0.5330009", "0.5328463", "0.53263545", "0.5299465", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.5299314", "0.52898943", "0.52872247", "0.52861446", "0.5272809", "0.5270589", "0.5269238", "0.5260094", "0.5257621", "0.52546513", "0.5251007", "0.52479434", "0.52340895", "0.5229505", "0.5229461", "0.5218169", "0.52114284", "0.52102053", "0.52059895", "0.52013785", "0.5196039", "0.5194905", "0.5189893", "0.5188052", "0.5187787", "0.51872724", "0.5186665", "0.5182191", "0.5182136", "0.51806265", "0.51793444", "0.5176666", "0.517274", "0.51648915", "0.51639587", "0.5161128", "0.5158648", "0.5158398", "0.5156104", "0.51544356", "0.5154035", "0.5150887", "0.51503307", "0.5148934", "0.51477766", "0.5145056", "0.5145056", "0.5141368", "0.5140201", "0.51365924" ]
0.0
-1
GET /crew/category_partners GET /crew/category_partners.json
def index @crew_category_partners = CategoryPartner.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end", "def index\n @partners = Partner.all\n end", "def set_crew_category_partner\n @crew_category_partner = CategoryPartner.find(params[:id])\n end", "def create\n @crew_category_partner = CategoryPartner.new(crew_category_partner_params)\n\n respond_to do |format|\n if @crew_category_partner.save\n format.html { redirect_to crew_category_partners_path, notice: 'Category partner was successfully created.' }\n format.json { render :show, status: :created, location: @crew_category_partner }\n else\n format.html { render :new }\n format.json { render json: @crew_category_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_part_by_car_category\n @cars = PartsController::PartService.get_part_by_car_category(params[:paran_car], params[:paran_category]);\n respond_to do |format|\n format.json { render json: @cars }\n end \n end", "def index\n @partners = Partner.order(id: :desc).page(params[:page]).per(25)\n end", "def index\n if params[:term]\n @partners = Partner.scoped.order(:name).where(\"name ILIKE ?\", \"%#{params[:term]}%\")\n else\n @partners = Partner.scoped\n end\n @partner = Partner.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners.map(&:name) }\n end\n end", "def categories\n get('venues/categories').categories\n end", "def partners\n end", "def partners_categories(lang = default_locale_obj[:lang], withIndex: false)\n @partners_categories ||= {}\n @partners_categories[lang] ||= {}\n @partners_categories[lang][!!withIndex] ||= begin\n array = []\n collection = partners_collection(lang)\n categories = categories_collection(lang)\n\n if withIndex == true\n array.push({\n id: 'all',\n name: 'All',\n description: nil,\n _meta: nil,\n path: \"partners/all\",\n url_slug: \"all\",\n count: collection.length,\n set: collection\n })\n end\n\n collection = categories.each do |category|\n set = collection.select { |model|\n # models that have the category id\n model[:categories]&.find{ |model_category| model_category[:id].include?(category[:id]) }\n }\n\n array.push({\n id: category[:id],\n name: category[:name],\n description: category[:description],\n _meta: category[:_meta],\n path: \"partners/#{category[:url_slug]}\",\n url_slug: category[:url_slug],\n count: set.length,\n set: set\n })\n end\n\n # Stick the all category to the top.\n array.sort{ |a, b| sort_categories(a, b) }\n end\n end", "def crew_category_partner_params\n params.require(:category_partner).permit(:name)\n end", "def index\n render json: @owner.cats\n end", "def index\n offer_categories = Offer.where(name: params[:offer_name])\n .joins(:categories).pluck('DISTINCT(categories.name)')\n\n respond_with offer_categories\n end", "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend", "def show\n @category = Category.find(params[:id])\n @jobs = @category.jobs\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def index\n @contact_partners = ContactPartner.all\n @contact_partners = ContactPartner.paginate(:per_page => 15, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contact_partners }\n end\n end", "def display_partners\n\t\t# get an aggregate query of necessary info for the partnerships and their most recent encounter\n\t\tp_sorted = current_user_profile.partners_with_most_recent\n\t\tagg = p_sorted.map do |ship|\n\t\t\t# make a list item\n\t\t\tcontent_tag(:li, {class: \"button-list__item\"}) do\n\t\t\t\t# link to that partnership's show page\n\t\t\t\tlink_to(partnership_path(ship[\"_id\"]), class: 'cta cta--is-square partnership-link') do\n\t\t\t\t\tdisplay_partner(ship)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# join and nest\n\t\tcontent_tag(:ul, safe_join(agg), {class: \"button-list container--has-centered-child__centered-child\"})\n\tend", "def index\n if params[:category_id].present?\n @merchants = @merchants.where(:category_id => params[:category_id])\n end\n\n @merchants = @merchants.order(\"name ASC\")\n\n if params[:only_names] == '1'\n @merchants = @merchants.as_json(only: [:name, :id])\n end\n\n\n render json: @merchants, callback: params[:callback]\n end", "def show\n @consumer_category = ConsumerCategory.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consumer_category }\n end\n end", "def index\n @type_partners = TypePartner.all\n end", "def index\n @category_offers = CategoryOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @category_offers }\n end\n end", "def index\n @potential_partners = PotentialPartner.all\n end", "def trading_partners(params = {})\n trading_partner_id = params.delete :trading_partner_id\n\n response =\n default_scope.get(\"tradingpartners/#{trading_partner_id}\") do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end", "def show\n # @retailer_category = RetailerCategory.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retailer_category }\n end\n end", "def show\n render json: {teacher: @course.teacher, course: @course, categories: @course.categories, training_sessions: @course.training_sessions}\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @partners.to_xml }\n end\n end", "def find_partners_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PartnerApi.find_partners ...'\n end\n # resource path\n local_var_path = '/partners'\n\n # query parameters\n query_params = {}\n query_params[:'tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) if !opts[:'tags'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Partner>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PartnerApi#find_partners\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @parties = Party.order(:name).all\n\n respond_to do |format|\n format.html\n format.json { render json: @parties }\n format.xml { render xml: @parties }\n end\n end", "def index\n @manufacturer_partners = ManufacturerPartner.all.order(:name)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @manufacturer_partners }\n format.json { render json: @manufacturer_partners }\n end\n end", "def show\n render json: category\n end", "def new\n @partner_project = PartnerProject.new\n @partners = Partner.all\n @projects = Project.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_project }\n end\n end", "def subcategories\n\t\trespond_to do |format|\n\t \tformat.json {\n\t \t\tparam = params[:payload]\n\n\t\t\t\tcategory = RequirementCategory.find_by_id(param[:target_id])\n\t\t\t\tputs category.id\n\n\t\t\t\t@subcategory = category.requirement_subcategories\n\t \t\trender :json => @subcategory\n\t \t}\n\t end\t\t\n\tend", "def show\n render json: @category\n end", "def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend", "def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end", "def get_related_category_items(payload = {})\n request('getRelatedCategoryItems', payload)\n end", "def list\n categories = Meal.distinct.pluck(:category)\n meal_list = []\n categories.each { |category|\n obj = {\n groupName: category.capitalize,\n options: Meal.where(category: category).select(:id, :name)\n }\n meal_list.push(obj)\n }\n\n render json: meal_list\n end", "def show\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner }\n end\n end", "def index\n categories = Category.all\n render json:categories\n end", "def index\n categories = {\n \"categoryId\": params[:ids]\n }\n auction_categories = Auction::Category.list categories\n if auction_categories[:comm][:code] == \"200\"\n render json: {status: auction_categories[:comm][:code].to_i, msg: auction_categories[:comm][:msg], data: {auction_categories: auction_categories[:data]}}\n else\n render json: {status: auction_categories[:comm][:code].to_i, msg: auction_categories[:comm][:msg], data: {}}\n end\n end", "def crew\n crew_categories.map{ |category| parse_crew(category) }.flatten\n end", "def index\n @electors = Elector.all\n\n render json: @electors\n end", "def category\n client.categories.find(data[\"categoryId\"])\n end", "def show\n render json: @category, callback: params[:callback]\n end", "def partners\n @users = User.get_users(:partner, @page)\n end", "def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end", "def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end", "def destroy\n @crew_category_partner.destroy\n respond_to do |format|\n format.html { redirect_to crew_category_partners_url, notice: 'Category partner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def showArticlesCat\n @articles_from_cat = Article.select(\"articles.id,articles.name\").where(\"articles.articlecat_id = ? \", @articlecat)\n respond_to do |format|\n #format.html\n format.json { render json: @articles_from_cat }\n end\n end", "def index\n @waiters = @course.waiters.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @waiters }\n end\n end", "def new\n @current_page = 'recettes'\n @recette = Recette.new\n @categories = Category.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recette }\n end\n end", "def available_collaborators\n input = available_collaborators_input\n return unauthorized unless available_collaborators_auth(input)\n student_id = current_visitor.portal_student.id\n clazz = Portal::Offering.find(input[:offering_id]).clazz\n collaborators = clazz.students.select { |s| s.id != student_id }.map { |s| {:id => s.id, :name => s.name} }\n render json: collaborators\n end", "def show\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner_type }\n end\n end", "def index\n courses = Course.includes(:professors).includes(:ratings).all\n\n render json: courses.to_json(include: [:professors, :ratings])\n end", "def partners\n @page_title = I18n.t(:content_partners)\n # FIXME: missing association :content_partner below\n # content partners will have a username\n @partners = Agent.paginate(:conditions => 'username!=\"\" AND content_partners.show_on_partner_page = 1', :order => 'agents.full_name asc', :include => :content_partner, :page => params[:page] || 1)\n\n end", "def index\n @question_categories = QuestionCategory.with_questions()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_categories }\n end\n end", "def list_by_category\n category = Category.where(id: params[:category_id])\n if category.any? then\n @products = category.first.products\n if @products.any? then \n render json: @products, status: 200\n else\n render json: { message: \"Não há produtos associados a categoria informada\" }, status: 404\n end\n else\n render json: { message: \"Não foi encontrada a categoria informada\" }, status: 404\n end\n end", "def find_partners(opts = {})\n data, _status_code, _headers = find_partners_with_http_info(opts)\n data\n end", "def category_show_data\n category = Category.find(params[:category])\n\n @data = {\n name: category.full_name,\n vendors: vendors_data_from_category(category),\n protips: protips_from_category(category)\n }\n\n render json: @data\n end", "def show\n @partner = Partner.find(params[:id])\n\n # because you can review either a company or a partner, both company and partner are considered a reviewable.\n # each review belongs to this phantom reviewable object that is indeed a partner\n @reviewable = @partner\n @reviews = @reviewable.reviews\n @review = Review.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category_offer }\n end\n end", "def index\n\t\tcreator_categories\n\tend", "def new\n @partner = Partner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n end\n end", "def show\n render json: @category_subscription\n end", "def index\n @partenaires = Partenaire.all.group_by(&:category_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @partenaires }\n end\n end", "def index\n @communities = Community.all\n render json: {items: @communities}\n end", "def get_categories_list\n args = receive_should_validate?\n get('redtube.Categories.getCategoriesList', {}, [], args[:should_validate])\n end", "def show\n @qa_client = QaClient.find(params[:id])\n @qa_activities = @qa_client.qa_activities\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qa_client }\n end\n end", "def show\n @recipe_category = RecipeCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_category }\n end\n end", "def index\n @client = Client.find params[:client_id]\n @pets = @client.pets\n end", "def index\n respond_to do |format|\n format.html {\n @category = Category.find_or_create_by_name(ASSOCIATION.short_name)\n @unknowns = Category.find_all_unknowns\n }\n format.js {\n render(:partial => \"category\", :collection => Category.find(params[:category_id]).children.sort)\n }\n end\n end", "def index\n @section_categories = SectionCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @section_categories }\n end\n end", "def show\n @pcategory = Pcategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pcategory }\n end\n end", "def getcategories\n category_size = RequirementCategory.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n \tif current_offset + direction < category_size && current_offset + direction >= 0\n offset = current_offset + direction\n \t@categories = RequirementCategory.all.offset(offset).take(10) \n \trender :json => @categories\n else\n \trender :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\n\tend", "def show\n render json: @categoria\n end", "def division\n @divisions = @company.divisions\n respond_to do |format|\n format.json { render json: @divisions}\n end\n end", "def faculties\n @faculties = Faculty.where(university_id: params[:university_id]).order(:name)\n @courses = []\n respond_to do |format|\n format.json { render json: @faculties }\n end\n end", "def index\n @topics = @category.topics.preload(:category)\n render 'api/v1/topics/index'\n end", "def index\n @chargers = Charger.all\n render json: @chargers\n end", "def index\n professors = Professor.includes(:courses).all\n\n render json: professors.to_json(include: :courses)\n end", "def index\n categories = @vertical.catgories.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded categories', data:categories},status: :ok\n end", "def category\n @articles = Article.with_category(params[:category], params[:search] || \"top_requested\")\n respond_with(:articles, template: \"articles/index\")\n end", "def show\n @current_page = 'recettes'\n\n @recette = Recette.includes(:photo_files).find(params[:id])\n @categories = Category.all\n\n @comments = Recette.find(params[:id]).comments.limit(3).order('id desc')\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recette }\n end\n end", "def get_part_by_company_part\n @parts = PartsController::PartService.get_part_by_company_part(params[:param_part])\n if [email protected]?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend", "def index\n @profession_categories = ProfessionCategory.all\n end", "def get_company_by_company_part\n @parts = CompaniesController::CompanyService.get_company_by_company_part(params[:param_part])\n if [email protected]?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend", "def get_category\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def respond_with_categories(params)\n channel_id = params[:channel_id]\n key = \"current_categories:#{channel_id}\"\n categories = return_categories(key)\n response = stringify_remaining_questions(categories)\n response\nend", "def index\n @training_categories = @ministry.training_categories\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @training_categories }\n end\n end", "def index\n @categories = Category.order(\"name ASC\")\n @latest_reviews = Review.limit(3).order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def get_all_actors_for_movie(movie)\n url = \"http://movies.api.mks.io/actors\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def index\n # if params[:top_id] == \"reposts\"\n # @participants = Participant.all.slice(likes: -1).desc(\"likes.reposts\")\n # elsif params[:top_id] == \"likes\"\n # @participants = Participant.all.slice(likes: -1).desc(\"likes.likes\")\n # else\n @participants = Participant.all.slice(likes: -1)\n # end\n \n # @cities = City.all\n\n # @result = {}\n # @result['participants'] = @participants\n # @result['cities'] = @cities\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@participants, :mode => :compat) }\n # format.json { render json: @participants }\n end\n end", "def new\n @consumer_category = ConsumerCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @consumer_category }\n end\n end", "def index\n @partner_profiles = PartnerProfile.all\n end", "def show\n @course_category = CourseCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_category }\n end\n end", "def index\n @clients = current_user.clients\n render json: @clients\n end", "def index\n @prompt_categories = PromptCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prompt_categories }\n end\n end", "def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end" ]
[ "0.68312067", "0.6397773", "0.62918174", "0.60981846", "0.6052716", "0.6021558", "0.5998123", "0.5985139", "0.5850687", "0.58014077", "0.56765246", "0.56660914", "0.5639221", "0.56014854", "0.55738676", "0.5567411", "0.5550006", "0.55343676", "0.5525544", "0.5488449", "0.54762155", "0.54711884", "0.54518914", "0.5448189", "0.5421781", "0.5406273", "0.5391657", "0.53910756", "0.5388284", "0.5377738", "0.53702766", "0.53686833", "0.53534824", "0.5346879", "0.5346331", "0.5341022", "0.5337406", "0.5330711", "0.53270346", "0.5316049", "0.5306389", "0.53014", "0.5300143", "0.529872", "0.5277812", "0.52722573", "0.52674204", "0.52625805", "0.5257555", "0.52543604", "0.52535623", "0.52531433", "0.52528435", "0.52402097", "0.522698", "0.5218269", "0.521809", "0.5212714", "0.5208693", "0.5208314", "0.5207987", "0.51867", "0.51834005", "0.51783746", "0.51732606", "0.5167781", "0.51660895", "0.5155672", "0.5152241", "0.5151987", "0.51458097", "0.51426935", "0.5142419", "0.5141957", "0.5139033", "0.5138158", "0.51368916", "0.51352865", "0.512746", "0.51236814", "0.5123351", "0.5112149", "0.5107237", "0.51064414", "0.5104443", "0.5101936", "0.5100636", "0.50815094", "0.50800663", "0.5079942", "0.5079583", "0.50795394", "0.50682217", "0.5067593", "0.50658435", "0.50651294", "0.50648046", "0.5058924", "0.5058714", "0.50585514" ]
0.7164783
0
GET /crew/category_partners/1 GET /crew/category_partners/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @crew_category_partners = CategoryPartner.all\n end", "def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end", "def set_crew_category_partner\n @crew_category_partner = CategoryPartner.find(params[:id])\n end", "def get_part_by_car_category\n @cars = PartsController::PartService.get_part_by_car_category(params[:paran_car], params[:paran_category]);\n respond_to do |format|\n format.json { render json: @cars }\n end \n end", "def index\n @partners = Partner.all\n end", "def create\n @crew_category_partner = CategoryPartner.new(crew_category_partner_params)\n\n respond_to do |format|\n if @crew_category_partner.save\n format.html { redirect_to crew_category_partners_path, notice: 'Category partner was successfully created.' }\n format.json { render :show, status: :created, location: @crew_category_partner }\n else\n format.html { render :new }\n format.json { render json: @crew_category_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @partners = Partner.order(id: :desc).page(params[:page]).per(25)\n end", "def index\n if params[:term]\n @partners = Partner.scoped.order(:name).where(\"name ILIKE ?\", \"%#{params[:term]}%\")\n else\n @partners = Partner.scoped\n end\n @partner = Partner.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners.map(&:name) }\n end\n end", "def show\n @consumer_category = ConsumerCategory.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consumer_category }\n end\n end", "def show\n # @retailer_category = RetailerCategory.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retailer_category }\n end\n end", "def show\n @category = Category.find(params[:id])\n @jobs = @category.jobs\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end", "def crew_category_partner_params\n params.require(:category_partner).permit(:name)\n end", "def index\n render json: @owner.cats\n end", "def subcategories\n\t\trespond_to do |format|\n\t \tformat.json {\n\t \t\tparam = params[:payload]\n\n\t\t\t\tcategory = RequirementCategory.find_by_id(param[:target_id])\n\t\t\t\tputs category.id\n\n\t\t\t\t@subcategory = category.requirement_subcategories\n\t \t\trender :json => @subcategory\n\t \t}\n\t end\t\t\n\tend", "def category\n client.categories.find(data[\"categoryId\"])\n end", "def show\n render json: {teacher: @course.teacher, course: @course, categories: @course.categories, training_sessions: @course.training_sessions}\n end", "def show\n @recipe_category = RecipeCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_category }\n end\n end", "def show\n @pcategory = Pcategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pcategory }\n end\n end", "def show\n render json: category\n end", "def new\n @current_page = 'recettes'\n @recette = Recette.new\n @categories = Category.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recette }\n end\n end", "def categories\n get('venues/categories').categories\n end", "def show\n render json: @category\n end", "def index\n @category_offers = CategoryOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @category_offers }\n end\n end", "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend", "def new\n @partner_project = PartnerProject.new\n @partners = Partner.all\n @projects = Project.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_project }\n end\n end", "def index\n @contact_partners = ContactPartner.all\n @contact_partners = ContactPartner.paginate(:per_page => 15, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contact_partners }\n end\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def index\n offer_categories = Offer.where(name: params[:offer_name])\n .joins(:categories).pluck('DISTINCT(categories.name)')\n\n respond_with offer_categories\n end", "def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end", "def show\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner }\n end\n end", "def new\n @consumer_category = ConsumerCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @consumer_category }\n end\n end", "def show\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner_type }\n end\n end", "def showArticlesCat\n @articles_from_cat = Article.select(\"articles.id,articles.name\").where(\"articles.articlecat_id = ? \", @articlecat)\n respond_to do |format|\n #format.html\n format.json { render json: @articles_from_cat }\n end\n end", "def show\n @course_category = CourseCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_category }\n end\n end", "def show\n @current_page = 'recettes'\n\n @recette = Recette.includes(:photo_files).find(params[:id])\n @categories = Category.all\n\n @comments = Recette.find(params[:id]).comments.limit(3).order('id desc')\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recette }\n end\n end", "def partners_categories(lang = default_locale_obj[:lang], withIndex: false)\n @partners_categories ||= {}\n @partners_categories[lang] ||= {}\n @partners_categories[lang][!!withIndex] ||= begin\n array = []\n collection = partners_collection(lang)\n categories = categories_collection(lang)\n\n if withIndex == true\n array.push({\n id: 'all',\n name: 'All',\n description: nil,\n _meta: nil,\n path: \"partners/all\",\n url_slug: \"all\",\n count: collection.length,\n set: collection\n })\n end\n\n collection = categories.each do |category|\n set = collection.select { |model|\n # models that have the category id\n model[:categories]&.find{ |model_category| model_category[:id].include?(category[:id]) }\n }\n\n array.push({\n id: category[:id],\n name: category[:name],\n description: category[:description],\n _meta: category[:_meta],\n path: \"partners/#{category[:url_slug]}\",\n url_slug: category[:url_slug],\n count: set.length,\n set: set\n })\n end\n\n # Stick the all category to the top.\n array.sort{ |a, b| sort_categories(a, b) }\n end\n end", "def index\n categories = Category.all\n render json:categories\n end", "def index\n if params[:category_id].present?\n @merchants = @merchants.where(:category_id => params[:category_id])\n end\n\n @merchants = @merchants.order(\"name ASC\")\n\n if params[:only_names] == '1'\n @merchants = @merchants.as_json(only: [:name, :id])\n end\n\n\n render json: @merchants, callback: params[:callback]\n end", "def index\n @type_partners = TypePartner.all\n end", "def new\n @partner = Partner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n end\n end", "def partners\n end", "def new\n # @retailer_category = RetailerCategory.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retailer_category }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category_offer }\n end\n end", "def get_category\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def show\n render json: @category_subscription\n end", "def new\n @recipe = Recipe.new\n @categories=RecipeCategory.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n\n end\n end", "def new\n @category_offer = CategoryOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category_offer }\n end\n end", "def show\n render json: @category, callback: params[:callback]\n end", "def index\n @client = Client.find params[:client_id]\n @pets = @client.pets\n end", "def destroy\n @crew_category_partner.destroy\n respond_to do |format|\n format.html { redirect_to crew_category_partners_url, notice: 'Category partner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @qa_client = QaClient.find(params[:id])\n @qa_activities = @qa_client.qa_activities\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qa_client }\n end\n end", "def show\n @kategory = Kategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kategory }\n end\n end", "def new\n @c_video = CVideo.new\n\t@client_choice = Client.find(:all, :order => \"C_LName\").collect do |d| [d.C_LName + \", \" + d.C_FName, d.id] end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @c_video }\n end\n end", "def index\n @manufacturer_partners = ManufacturerPartner.all.order(:name)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @manufacturer_partners }\n format.json { render json: @manufacturer_partners }\n end\n end", "def new\n @c_blog = CBlog.new\n\t@client_choice = Client.find(:all, :order => \"C_LName\").collect do |d| [d.C_LName + \", \" + d.C_FName, d.id] end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @c_blog }\n end\n end", "def new\n @coligacao_partido = ColigacaoPartido.new\n @partidos = Partido.find(:all, :order => \"nome\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coligacao_partido }\n end\n end", "def index\n @potential_partners = PotentialPartner.all\n end", "def faculties\n @faculties = Faculty.where(university_id: params[:university_id]).order(:name)\n @courses = []\n respond_to do |format|\n format.json { render json: @faculties }\n end\n end", "def index\n @waiters = @course.waiters.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @waiters }\n end\n end", "def get_company_by_company_part\n @parts = CompaniesController::CompanyService.get_company_by_company_part(params[:param_part])\n if [email protected]?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend", "def index\n categories = {\n \"categoryId\": params[:ids]\n }\n auction_categories = Auction::Category.list categories\n if auction_categories[:comm][:code] == \"200\"\n render json: {status: auction_categories[:comm][:code].to_i, msg: auction_categories[:comm][:msg], data: {auction_categories: auction_categories[:data]}}\n else\n render json: {status: auction_categories[:comm][:code].to_i, msg: auction_categories[:comm][:msg], data: {}}\n end\n end", "def show\n @finding_category = FindingCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @finding_category }\n end\n end", "def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end", "def show\n @partner = Partner.find(params[:id])\n\n # because you can review either a company or a partner, both company and partner are considered a reviewable.\n # each review belongs to this phantom reviewable object that is indeed a partner\n @reviewable = @partner\n @reviews = @reviewable.reviews\n @review = Review.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner }\n end\n end", "def show\n @part_company = PartCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @part_company }\n end\n end", "def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end", "def new\n @recipe_category = RecipeCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_category }\n end\n end", "def get_part_by_company_part\n @parts = PartsController::PartService.get_part_by_company_part(params[:param_part])\n if [email protected]?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend", "def new\n #@owner = Owner.find(params[:owner_id])\n #@owner = current_owner\n\t\t@restaurant = Restaurant.new\n @categories = Category.where(\"name like ?\", \"%#{params[:q]}%\")\n respond_to do |format|\n format.html\n format.json { render :json => @categories.map(&:attributes) }\n end\n\n\tend", "def index\n @topics = @category.topics.preload(:category)\n render 'api/v1/topics/index'\n end", "def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend", "def index\n @electors = Elector.all\n\n render json: @electors\n end", "def index\n categories = @vertical.catgories.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded categories', data:categories},status: :ok\n end", "def index\n @categories = Category.order(\"name ASC\")\n @latest_reviews = Review.limit(3).order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @section_categories = SectionCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @section_categories }\n end\n end", "def index\n @parties = Party.order(:name).all\n\n respond_to do |format|\n format.html\n format.json { render json: @parties }\n format.xml { render xml: @parties }\n end\n end", "def show\n render json: @categoria\n end", "def show\n @question_category = QuestionCategory.with_questions(question_category_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_category }\n end\n end", "def find_partners_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PartnerApi.find_partners ...'\n end\n # resource path\n local_var_path = '/partners'\n\n # query parameters\n query_params = {}\n query_params[:'tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) if !opts[:'tags'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Partner>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PartnerApi#find_partners\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @partners.to_xml }\n end\n end", "def category\n @articles = Article.with_category(params[:category], params[:search] || \"top_requested\")\n respond_with(:articles, template: \"articles/index\")\n end", "def index\n @partenaires = Partenaire.all.group_by(&:category_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @partenaires }\n end\n end", "def index\n @question_categories = QuestionCategory.with_questions()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_categories }\n end\n end", "def new\n @partner_type = PartnerType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_type }\n end\n end", "def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end", "def list_by_category\n category = Category.where(id: params[:category_id])\n if category.any? then\n @products = category.first.products\n if @products.any? then \n render json: @products, status: 200\n else\n render json: { message: \"Não há produtos associados a categoria informada\" }, status: 404\n end\n else\n render json: { message: \"Não foi encontrada a categoria informada\" }, status: 404\n end\n end", "def index\n unless params[:category] && params[:category][:id] && !params[:category][:id].blank?\n @winecoolers = Winecooler.paginate(:page => params[:page], :per_page =>10)\n else\n @category = Category.find(params[:category][:id])\n @winecoolers = @category.winecoolers.paginate(:page => params[:page], :per_page =>10) if @category\n end\n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winecoolers }\n end\n end", "def new\n @category = Category.new\n\n # @categories = Category.all\n\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @category }\n # end\n end", "def show\n @job_category = JobCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_category }\n end\n end", "def new\n @pcategory = Pcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pcategory }\n end\n end", "def division\n @divisions = @company.divisions\n respond_to do |format|\n format.json { render json: @divisions}\n end\n end", "def new\n @category = Category.new\n @top_categories = Category.top_categories\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def getcategories\n category_size = RequirementCategory.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n \tif current_offset + direction < category_size && current_offset + direction >= 0\n offset = current_offset + direction\n \t@categories = RequirementCategory.all.offset(offset).take(10) \n \trender :json => @categories\n else\n \trender :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\n\tend", "def new\n @part_company = PartCompany.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @part_company }\n end\n end", "def find_client\n cliente = get_cliente(params[:id])\n\n respond_to do |format|\n format.json {render json: {client: cliente}}\n end\n end", "def category_show_data\n category = Category.find(params[:category])\n\n @data = {\n name: category.full_name,\n vendors: vendors_data_from_category(category),\n protips: protips_from_category(category)\n }\n\n render json: @data\n end", "def list\n categories = Meal.distinct.pluck(:category)\n meal_list = []\n categories.each { |category|\n obj = {\n groupName: category.capitalize,\n options: Meal.where(category: category).select(:id, :name)\n }\n meal_list.push(obj)\n }\n\n render json: meal_list\n end", "def show\n #@category = Category.find(params[:id])\n @products = @category.products.all\n @max = @category.products.maximum(:price)\n @colors = @category.products.select(:params).distinct\n respond_to do |format|\n format.json { render :json => {:category => @category,\n :products => @products,\n :colors => @colors,\n :maxprice => @max\n } }\n end\n end", "def new\n @kategory = Kategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kategory }\n end\n end", "def new\n @components_category = Components::Category.new\n respond_to do |format|\n format.html\n# format.json { render json: @components_category }\n format.js\n end\n end" ]
[ "0.7090048", "0.7060123", "0.6320533", "0.63172936", "0.6265342", "0.61632055", "0.61555827", "0.58971167", "0.58834684", "0.5874837", "0.5814553", "0.57189274", "0.5714947", "0.5676219", "0.56536263", "0.56192786", "0.5592234", "0.55876344", "0.5587398", "0.5583941", "0.5582234", "0.55774623", "0.5577253", "0.5545083", "0.5533547", "0.55200124", "0.55179167", "0.55076194", "0.5507428", "0.5507209", "0.5489661", "0.5487777", "0.5473556", "0.5464383", "0.5459197", "0.54368335", "0.5424153", "0.5421398", "0.5412691", "0.54101276", "0.54099524", "0.54092157", "0.5403554", "0.53854036", "0.538304", "0.53820616", "0.5380751", "0.53805095", "0.5378697", "0.5376672", "0.53759253", "0.53748286", "0.536993", "0.53675497", "0.5366406", "0.53609115", "0.5359474", "0.5356572", "0.5355507", "0.53417313", "0.5335151", "0.5333879", "0.53266937", "0.5326393", "0.53241813", "0.5324084", "0.5320787", "0.5311656", "0.5309031", "0.5302997", "0.53006524", "0.5300115", "0.52931327", "0.52917975", "0.5288925", "0.52885896", "0.5286824", "0.5285939", "0.5280084", "0.5274576", "0.52723163", "0.52716136", "0.52696496", "0.5266912", "0.52661705", "0.52656424", "0.52640706", "0.5257968", "0.5256299", "0.52492154", "0.5248601", "0.52482396", "0.5246285", "0.52408755", "0.524076", "0.5240106", "0.52329075", "0.5232661", "0.5230182", "0.522877", "0.5225347" ]
0.0
-1
POST /crew/category_partners POST /crew/category_partners.json
def create @crew_category_partner = CategoryPartner.new(crew_category_partner_params) respond_to do |format| if @crew_category_partner.save format.html { redirect_to crew_category_partners_path, notice: 'Category partner was successfully created.' } format.json { render :show, status: :created, location: @crew_category_partner } else format.html { render :new } format.json { render json: @crew_category_partner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crew_category_partner_params\n params.require(:category_partner).permit(:name)\n end", "def index\n @crew_category_partners = CategoryPartner.all\n end", "def create\n @practice = Practice.new(practice_params)\n if params[:recruiter_partner].present?\n @partner = Partner.find(params[:recruiter_partner])\n @practice.partners << @partner\n end\n\n @practice.site_id = @current_partner.site.id\n\n respond_to do |format|\n if @practice.save\n format.html { redirect_to partner_path(current_partner), notice: 'Practice was successfully created.' }\n format.json { render :show, status: :created, location: @practice }\n else\n format.html { render :new }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def create!\n if @options[:id]\n @id = @options[:id]\n @model = TestChamber::Models::Partner.find(@id)\n else\n # The entire partners page has to render after a new partner is created\n # before we can proceed which takes a while.\n # Just submit the form with the rest client A dirty hack\n # but we create a lot of partners so it gets very slow.\n name = @company_name\n contact_name = 'John Smith'\n phone = '827-5309'\n\n\n if @use_ui\n visit \"#{TestChamber.target_url}/partners/new\"\n fill_in('partner[name]', :with => name)\n fill_in('partner[contact_name]', :with => contact_name)\n fill_in('partner[contact_phone]', :with => phone)\n select(\"United States\", :from => \"partner[country]\")\n\n Util.wait_for(5,1) { first('#partner_submit') }\n Util.trigger_click(first('#partner_submit')) do\n first('#partner_submit').nil?\n end\n else\n # yes, this is horrible, but it is VASTLY faster than using the browser to do this so when\n # we create lots of partners, like one before each test, we can use this.\n html = Nokogiri::HTML(authenticated_request(:get, \"dashboard/partners/new\", format: :html)[:body])\n\n begin\n authenticity_token = html.css(\"input[name=authenticity_token]\")[0][\"value\"]\n rescue\n # Sometimes the authenticity token doesn't exist; we need to catch that situation.\n # Usually due to a redirect to the login page because user auth is not working 100% of the time.\n # Raising makes this more visible.\n raise \"Didn't have the authenticity token. Html: #{html}\"\n end\n\n submit_form_with_rest(action: \"#{TestChamber.target_url}/dashboard/partners\",\n params: {'partner[name]' => name,\n 'partner[contact_name]' => contact_name,\n 'partner[contact_phone]' => phone,\n 'partner[country]' => \"US\",\n 'utf8' => \"✓\",\n 'authenticity_token' => authenticity_token,\n 'commit' => \"Create Partner\"\n },\n expected_redirect: \"#{TestChamber.target_url}/dashboard/partners\")\n end\n\n Util.wait_for(TestChamber.default_wait_for_timeout,\n TestChamber.default_wait_for_interval,\n {:partner_name => @company_name, :options => @options}) do\n @model = TestChamber::Models::Partner.where(:name => @company_name).order(:created_at => :desc).first\n end\n\n @id = @model.id\n TestChamber.created_partners << @id\n\n # Set reseller_id manually since no reliable way to set via UI.\n set_reseller\n\n configure_partner\n approve_partner\n # cache_object\n\n verify_partner\n end\n end", "def set_crew_category_partner\n @crew_category_partner = CategoryPartner.find(params[:id])\n end", "def create\n @partner = Partner.new(params[:partner])\n @company = Company.find(params[:company_id])\n @partner.company = @company\n @partner.save\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner}\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end", "def create\n @partner = Partner.new(params[:partner])\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(params[:partner])\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def partners\n end", "def create\n json_create(category_params, Category)\n end", "def create\n @partner = Partner.new(partner_params)\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render :show, status: :created, location: @partner }\n else\n format.html { render :new }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t \n @part = @chaper.parts.create(part_params)\n @part.user_id = current_user.id \n respond_to do |format|\n if @part.save\n format.html { redirect_to chaper_path(@chaper), notice: 'Part was successfully created.' }\n format.json { render action: 'show', status: :created, location: @part }\n else\n format.html { render action: 'new' }\n format.json { render json: chaper_path(@chaper).errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(partner_params)\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'You are partnered up!' }\n format.json { render :show, status: :created, location: @partner }\n else\n format.html { render :new }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @optinpartner = Optinpartner.new(params[:optinpartner])\n\n respond_to do |format|\n if @optinpartner.save\n format.html { redirect_to @optinpartner, notice: 'Optinpartner was successfully created.' }\n format.json { render json: @optinpartner, status: :created, location: @optinpartner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @optinpartner.errors, status: :unprocessable_entity }\n end\n end\n end", "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n # @retailer_category = RetailerCategory.new(params[:retailer_category])\n respond_to do |format|\n if @retailer_category.save\n format.html { redirect_to @retailer_category, notice: 'Retailer category was successfully created.' }\n format.json { render json: @retailer_category, status: :created, location: @retailer_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retailer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner_type = PartnerType.new(params[:partner_type])\n\n respond_to do |format|\n if @partner_type.save\n format.html { redirect_to @partner_type, notice: 'Partner type was successfully created.' }\n format.json { render json: @partner_type, status: :created, location: @partner_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @partners = Partner.all\n end", "def create\n category = Category.create!(category_params)\n render json: {\n :html => render_to_string(\n :partial => \"setups/category\",\n :layout => false,\n :locals => {:category => category})\n }\n end", "def create\n @profession_category = ProfessionCategory.new(profession_category_params)\n\n respond_to do |format|\n if @profession_category.save\n format.html { redirect_to profession_categories_path, notice: 'Profession category was successfully created.' }\n format.json { render :show, status: :created, location: @profession_category }\n else\n format.html { render :new }\n format.json { render json: @profession_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @models = self.class.model_class.new(params[:partners])\n\n respond_to do |format|\n if @models.save\n flash[:notice] = 'Model was successfully created.'\n format.html { redirect_to(@models) }\n format.xml { render :xml => @models, :status => :created, :location => @models }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @models.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end", "def create\n @training_category = @ministry.training_categories.new(params[:training_category])\n \n respond_to do |format|\n if @training_category.save\n flash[:notice] = 'Training Category was successfully created.'\n format.html { redirect_to(training_categories_path) }\n format.js\n format.xml { render :xml => @training_category, :status => :created, :location => @training_category }\n else\n format.js { render :action => \"new\" }\n format.html { render :action => \"new\" }\n format.xml { render :xml => @training_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n cat = Cat.find(params[:cat_id])\n @adopted_pet = @selection.add_cat(cat.id)\n\n respond_to do |format|\n if @adopted_pet.save\n format.html { redirect_to adoption_url}\n format.js\n format.json { render action: 'show', status: :created, location: @adopted_pet }\n else\n format.html { render action: 'new' }\n format.json { render json: @adopted_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend", "def create\n course = Course.includes(:professors).new(course_params)\n course.professor_ids=(params[:professors])\n\n if course.save\n render json: course.to_json(include: :professors)\n else\n render :json => { :errors => course.errors }, :status => 422\n end\n end", "def category_params\n params.require(:category).permit(:selected_category_id, :selected_part_id)\n end", "def create\n current_account.parties.create(params[:parties].values)\n @date = params[:parties].values.first[:created_at].to_time\n @parties = current_account.parties.by_month(@date.month, :year => @date.year)\n @daily = @parties.select{|p| p.created_at.to_date == @date.to_date}.group_by(&:game)\n @count = @parties.size\n find_yours(@parties)\n @games = compute_monthly_played(@parties, @date.beginning_of_month)\n respond_to do |format|\n format.js\n end\n end", "def create\n @coach_category = CoachCategory.new(coach_category_params)\n\n respond_to do |format|\n if @coach_category.save\n format.html { redirect_to @coach_category, notice: 'Categoria de treinador foi criada com sucesso.' }\n format.json { render action: 'show', status: :created, location: @coach_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @coach_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @available_category = AvailableCategory.new(available_category_params)\n\n respond_to do |format|\n if @available_category.save\n format.html { redirect_to admin_available_categories_path, notice: 'Available category was successfully created.' }\n format.json { render :show, status: :created, location: @available_category }\n else\n format.html { render :new }\n format.json { render json: @available_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @type_partner = TypePartner.new(type_partner_params)\n\n respond_to do |format|\n if @type_partner.save\n format.html { redirect_to @type_partner, notice: 'Type partner was successfully created.' }\n format.json { render :show, status: :created, location: @type_partner }\n else\n format.html { render :new }\n format.json { render json: @type_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if can?(:>=, \"3\")\n @cup_count = params[:cup_count].to_boolean\n @part = Kitting::Part.new(params[:part])\n @part_response = get_part_numbers current_user, params[:part][:part_number].upcase\n if @part_response\n if @part_response[\"errCode\"] == \"1\"\n flash.now[:notice] = @part_response[\"errMsg\"]\n render :new\n else\n @part.name = @part_response['partName']\n @part.prime_pn = @part_response[\"primePNList\"].reject(&:blank?).first\n # @part.customer_name = session[:customer_Name]\n # @part.customer_number = session[:customer_number]\n respond_to do |format|\n if @part.save\n flash.now[:message] = \"Part #{@part.part_number} created successfully.\"\n format.html { redirect_to part_path(@part.id) }\n else\n format.js\n format.html { render action: \"new\" }\n end\n end\n\n end\n else\n flash.now[:notice] = \"Service temporary unavailable\"\n render :new\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end", "def create\n @category = Category.new(category_params)\n @category.save\n render json: { params: params, notice: 'Categoria registrada exitosamente' }\n end", "def create\n authorize! :create, CompetenceTierGroup\n \n @competence_tier_group = CompetenceTierGroup.new(competence_tier_group_params)\n @competence_tier_group.save!\n render json: {status: :ok}\n end", "def create\n category = @current_user.categories.create!(category_params)\n render json: { category: category }\n end", "def user_category\n # byebug\n @user = User.where(contact: params[:contact]).first\n params[:category_ids].each do |category|\n @user.user_categories.create!(category_id: category, user_id: @user.id)\n end\n render json: {status: \"SUCCESS\", message: \"user-data\", data: \"category saved\"}, status: :ok\n end", "def create\n @category_offer = CategoryOffer.new(params[:category_offer])\n\n respond_to do |format|\n if @category_offer.save\n format.html { redirect_to @category_offer, notice: 'Category offer was successfully created.' }\n format.json { render json: @category_offer, status: :created, location: @category_offer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category_offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categorie_competence = CategorieCompetence.new(categorie_competence_params)\n\n respond_to do |format|\n if @categorie_competence.save\n format.html { redirect_to @categorie_competence, notice: 'Categorie competence was successfully created.' }\n format.json { render :show, status: :created, location: @categorie_competence }\n else\n format.html { render :new }\n format.json { render json: @categorie_competence.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @consumer_category = ConsumerCategory.new(params[:consumer_category])\n\n respond_to do |format|\n if @consumer_category.save\n format.html { redirect_to @consumer_category, notice: 'Consumer category was successfully created.' }\n format.json { render json: @consumer_category, status: :created, location: @consumer_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @consumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_division\n \t@division = @company.divisions.create(name: params[:division][:name])\n respond_to do |format|\n format.json { render json: @division }\n end\n end", "def create\n @cliente = Cliente.new(cliente_params)\n\n respond_to do |format|\n if @cliente.save\n #--ADICIONADO\n if params[:cliente][:perfil_ids]\n \t\t params[:cliente][:perfil_ids].each do |ss|\n \t\t\t @cliente.perfilclientes.create(:cliente_id => @cliente.id, :perfil_id => ss)\n \t\t end\n end\n #--ADICIONADO\n format.html { redirect_to clientes_url, notice: 'Cliente criado com sucesso.' }\n format.json { render action: 'show', status: :created, location: @cliente }\n else\n format.html { render action: 'new' }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n \n respond_to do |format|\n if @room.save\n trivia_category = (@room.category.eql? \"any\") ? '' : \"category=\" + @room.category\n \n questions_response = RestClient::Request.execute(\n method: :get,\n url: 'https://opentdb.com/api.php?amount=7&type=multiple&' + trivia_category\n )\n questions = JSON.parse(questions_response)['results']\n\n questions.each do |question|\n Question.create(\n :problem => question['question'],\n :category => question['category'],\n :correct_answer => question[\"correct_answer\"],\n :incorrect_answer_one => question[\"incorrect_answers\"][0],\n :incorrect_answer_two => question[\"incorrect_answers\"][1],\n :incorrect_answer_three => question[\"incorrect_answers\"][2],\n :room_id => @room.id\n )\n end\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @prv_category = Category.new(prv_category_params)\n\n respond_to do |format|\n if @prv_category.save\n format.html { redirect_to prv_categories_path, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @prv_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @prv_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categoria = Categoria.new(categoria_params)\n if @categoria.save\n render json: @categoria\n else\n render json: @categoria.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @crew_category_partner.destroy\n respond_to do |format|\n format.html { redirect_to crew_category_partners_url, notice: 'Category partner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @quest = Quest.new(params[:quest])\n\t@categories = find_all_categories\n\n respond_to do |format|\n if @quest.save\n\t\tcurrent_user.join!(@quest)\n format.html { redirect_to @quest, notice: 'Quest was successfully created.' }\n format.json { render json: @quest, status: :created, location: @quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end", "def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion International\", \"United States Fund for UNICEF\"]\n\tcharity_list.each do |charity|\n\t\tRestClient.post 'http://api.reimaginebanking.com/merchants?key=e0486a76005721ee6d86b140eaea2a40', { \"name\": \"#{charity}\"}.to_json, :content_type => :json, :accept => :json\n\tend\nend", "def create\n get_supplier\n @supplier_category = @supplier.categories.create(params[:supplier_category])\n end", "def create\n params[:interview][:scheduler_id] = current_user.id\n @interview = @candidate.interviews.new(params[:interview])\n params[:other_interviewers].split(\",\").each do |interviewer|\n @interview.interviewers.new({:user_id => interviewer})\n end\n respond_to do |format|\n if @interview.save\n format.html { redirect_to candidate_path(@candidate), notice: 'Interview was successfully created.' }\n format.js { render :index }\n format.json { render json: @interview, status: :created, location: @interview }\n else\n format.html { render action: \"new\" }\n format.js { render :index }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room_category = RoomCategory.new(room_category_params)\n\n respond_to do |format|\n if @room_category.save\n format.html { redirect_to @room_category, notice: 'Room category was successfully created.' }\n format.json { render :show, status: :created, location: @room_category }\n else\n format.html { render :new }\n format.json { render json: @room_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:id]\n begin\n check_admin\n course = Course.find(params[:course_id])\n teacher = User.find(params[:id])\n course.teachers << teacher\n if course.save\n json_successful\n else\n json_failed\n end\n rescue ActiveRecord::RecordNotFound\n json_failed(REASON_RESOURCE_NOT_FOUND)\n end\n else\n json_failed(REASON_NOT_IMPLEMENTED)\n end\n end", "def update\n respond_to do |format|\n # TODO: Make this more efficient, this is a little hacky\n if params[:category_ids]\n PartnerCategory.where(partnering_organization_id: @partnering_organization.id).delete_all\n params[:category_ids].each do |i|\n @po_cat = PartnerCategory.create(partnering_organization_id: @partnering_organization.id, category_id: i)\n end\n end\n if @partnering_organization.update(partnering_organization_params)\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @partnering_organization }\n else\n format.html { render :edit }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create2\n @person= Person.find_by_upid(params[:person_upid])\n @pet = Pet.new(params[:pet])\n\n respond_to do |format|\n if @pet.save\n @pp = @person.as_json(:include => :addresses)\n @pp[:pets] = Pet.joins(:caretakers).includes(:petphotos).where(\"caretakers.primary_role = 'Owner' and caretakers.person_id = ?\", @person.id).all.as_json(:include => :petphotos)\n\n if @person.status.eql? \"active mobile\"\n # add pet to related peeps (f&f, pet_pros)\n @person.person_connections.each do |fandf|\n famfrnd = Person.find(fandf.person_b_id)\n if fandf.category.eql? 'Spouse-Partner'\n prim_role = 'Owner'\n else # category in Family, Friend, Dog Walker\n prim_role = fandf.category\n end\n famfrnd.caretakers.build(:pet_id => @pet.id, :primary_role => prim_role, :status => 'active', :started_at => Time.now)\n famfrnd.save\n end\n end\n\n format.json { render json: @pp }\n else \n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize!(@cookbook, :create_collaborator?)\n collaborator_params = params.require(:cookbook_collaborator).permit(:user_id)\n users = eligible_collaborators.where(id: collaborator_params[:user_id].split(','))\n\n users.each do |user|\n cookbook_collaborator = CookbookCollaborator.create! cookbook: @cookbook, user: user\n CollaboratorMailer.delay.added_email(cookbook_collaborator)\n end\n\n redirect_to cookbook_path(@cookbook), notice: 'Collaborators added'\n end", "def create\n @idea = current_member.ideas.new(idea_params) \n respond_to do |format|\n sectors_params.delete(\"\")\n if @idea.save\n sectors_params.each do |k|\n @idea.sectors << Sector.find_by(id:k)\n end\n format.json { head :no_content }\n format.js\n else\n\n format.json { render :json => { :error => @idea.errors.full_messages }, :status => 422 }\n end\n \n end\n end", "def create\n @partner_profile = PartnerProfile.new(partner_profile_params)\n\n respond_to do |format|\n if @partner_profile.save\n format.html { redirect_to @partner_profile, notice: 'Partner profile was successfully created.' }\n format.json { render :show, status: :created, location: @partner_profile }\n else\n format.html { render :new }\n format.json { render json: @partner_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = current_user.categories.new(name: params[:name])\n if @category.save\n render \"create.json.jbuilder\", status: :created\n else\n render json: { errors: @category.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\n @elector = Elector.new(elector_params)\n\n if @elector.save\n render json: @elector, status: :created, location: @elector\n else\n render json: @elector.errors, status: :unprocessable_entity\n end\n end", "def create\n @specialization_category = SpecializationCategory.new(specialization_category_params)\n\n respond_to do |format|\n if @specialization_category.save\n format.html { redirect_to @specialization_category, notice: 'Specialization category was successfully created.' }\n format.json { render :show, status: :created, location: @specialization_category }\n else\n format.html { render :new }\n format.json { render json: @specialization_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tier = Tier.new(params[:tier])\n @tier.member = current_member\n\n respond_to do |format|\n if @tier.save\n if params[:endeavor_id]\n @tier.tierings.create :endeavor_id => params[:endeavor_id]\n end\n format.html { redirect_to @tier, :notice => \"Your #{current_member.tiers.count.ordinalize} tier.\" }\n format.json { render :json => @tier, :status => :created, :location => @tier }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tier.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @company_part = CompanyPart.new(company_part_params)\n\n respond_to do |format|\n if @company_part.save\n format.html { redirect_to company_parts_path, notice: 'Company part was successfully created.' }\n format.json { render :show, status: :created, location: @company_part }\n else\n format.html { render :new }\n format.json { render json: @company_part.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @membership_clerk = MembershipClerk.new(membership_clerk_params)\n\n respond_to do |format|\n if @membership_clerk.save\n format.html { redirect_to @membership_clerk, notice: 'Membership clerk was successfully created.' }\n format.json { render :show, status: :created, location: @membership_clerk }\n else\n format.html { render :new }\n format.json { render json: @membership_clerk.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n karyalay_lists_id = params[:karyalay_caterer_params][:karyalay_lists_id]\n kl = KaryalayList.find_by_id(karyalay_lists_id)\n if !kl.nil?\n @karyalay_caterer = KaryalayCaterer.find_or_create_by(karyalay_caterer_params)\n unless @karyalay_caterer.karyalay_lists.map(&:id).include? karyalay_lists_id\n @karyalay_caterer.karyalay_lists << kl\n end\n if @karyalay_caterer.save\n render json: @karyalay_caterer\n else\n render json: { id: nil,\n message: 'Karyalay Caterer Not Created Try Again' }\n end\n else\n render json: { id: nil, message: 'Karyalay Not Found, Try Again' }\n end\n end", "def add_partner_with_http_info(partners, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PartnerApi.add_partner ...'\n end\n # verify the required parameter 'partners' is set\n if @api_client.config.client_side_validation && partners.nil?\n fail ArgumentError, \"Missing the required parameter 'partners' when calling PartnerApi.add_partner\"\n end\n # resource path\n local_var_path = '/partners'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(partners)\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Partner')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PartnerApi#add_partner\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @part_company = PartCompany.new(params[:part_company])\n\n respond_to do |format|\n if @part_company.save\n format.html { redirect_to @part_company, notice: 'Part company was successfully created.' }\n format.json { render json: @part_company, status: :created, location: @part_company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @part_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:categoria_producto]\n p = Producto.find(params[:producto_id])\n c = Categoria.find(params[:categoria_id])\n\n if p.categorias << c\n render json: c, status: :created\n else\n render json: {:errors => {categoria: [\"No se ha podido agregar categoria\"]}}, status: :unprocessable_entity\n end\n\n else\n @categoria = Categoria.new(parametros_categoria)\n\n if @categoria.save\n render json: @categoria, status: :created\n else\n render json: @categoria.errors, status: :unprocessable_entity\n end\n end\n end", "def create\n @partner = Partner.new(partner_params)\n @partner.user.skip_confirmation_notification!\n\n respond_to do |format|\n if @partner.save!\n format.html { redirect_to [:admin, @partner], notice: 'Partner was successfully created.' }\n format.json { render action: 'show', status: :created, location: @partner }\n else\n format.html { render action: 'new' }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @caterer = current_merchant.caterers.new(caterer_params)\n\n respond_to do |format|\n if @caterer.save\n format.html { redirect_to @caterer, notice: 'Caterer was successfully created.' }\n format.json { render :show, status: :created, location: @caterer }\n else\n format.html { render :new }\n format.json { render json: @caterer.errors, status: :unprocessable_entity }\n end\n end\n @caterer.caterer_type_ids = params[:caterer][:caterer_type_ids]\n @caterer.cuisine_type_ids = params[:caterer][:cuisine_type_ids]\n end", "def create\n @proyectos_categoria = ProyectosCategoria.new(proyectos_categoria_params)\n\n respond_to do |format|\n if @proyectos_categoria.save\n format.html { redirect_to @proyectos_categoria, notice: 'Proyectos categoria was successfully created.' }\n format.json { render :show, status: :created, location: @proyectos_categoria }\n else\n format.html { render :new }\n format.json { render json: @proyectos_categoria.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categoria_proveedor = CategoriaProveedor.new(categoria_proveedor_params)\n\n respond_to do |format|\n if @categoria_proveedor.save\n format.html { redirect_to @categoria_proveedor, notice: 'Categoria proveedor was successfully created.' }\n format.json { render :show, status: :created, location: @categoria_proveedor }\n else\n format.html { render :new }\n format.json { render json: @categoria_proveedor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @part = @product.parts.new(params[:part])\n\n respond_to do |format|\n if @part.save\n format.html { redirect_to [@product,@part], notice: 'Part was successfully created.' }\n format.json { render json: [@product,@part], status: :created, location: [@product,@part] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @part.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n user_session[:category_id] = @candidate.category_id\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate , notice: 'Candidato creado correctamente.' }\n format.json { render 'show', status: :created , location: @candidate }\n else\n format.html { render 'new' }\n format.json { render json: @candidate.errors , status: :unprocessable_entity }\n end\n end\n end", "def create\n @potential_partner = PotentialPartner.new(potential_partner_params)\n\n respond_to do |format|\n if @potential_partner.save\n PartnerNotifier.partner_subscription_confirmation(@potential_partner).deliver\n format.html { redirect_to @potential_partner, notice: 'Potential partner was successfully created.' }\n format.json { render :show, status: :created, location: @potential_partner }\n else\n format.html { render :new }\n format.json { render json: @potential_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n if params[:project][:category_list].present?\n @project.category_list = []\n params[:project][:category_list].each do |cat|\n @project.category_list.add(cat)\n end \n end\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner_person = PartnerPerson.new(params[:partner_person])\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n if @partner_person.save\n format.html { redirect_to(@partner_person, :notice => 'PartnerPerson was successfully created.') }\n format.xml { render :xml => @partner_person, :status => :created, :location => @partner_person }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @partner_person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def recipe_category_params\r\n params.require(:recipe_category).permit(:recipe_id, :category_id)\r\n end", "def receipe_category_params\n params.require(:receipe_category).permit(:name)\n end", "def create\n @recipe_category = RecipeCategory.new(params[:recipe_category])\n\n respond_to do |format|\n if @recipe_category.save\n format.html { redirect_to @recipe_category, notice: 'Recipe category was successfully created.' }\n format.json { render json: @recipe_category, status: :created, location: @recipe_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ledger_category = LedgerCategory.new(ledger_category_params)\n\n respond_to do |format|\n if @ledger_category.save\n format.html { redirect_to @ledger_category, notice: 'Ledger category was successfully created.' }\n format.json { render :show, status: :created, location: @ledger_category }\n else\n format.html { render :new }\n format.json { render json: @ledger_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exhibitior_category = ExhibitiorCategory.new(params[:exhibitior_category])\n\n respond_to do |format|\n if @exhibitior_category.save\n format.html { redirect_to @exhibitior_category, notice: 'Exhibitior category was successfully created.' }\n format.json { render json: @exhibitior_category, status: :created, location: @exhibitior_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exhibitior_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n professor = Professor.new(professor_params)\n \n if professor.save\n render json: professor.to_json(include: :courses)\n else\n render :json => { :errors => professor.errors }, :status => 422\n end\n end", "def create\n #Creates the category to be saved in the db\n @category = Category.new(params[:category])\n @all_categories = Category.all\n\n #Set Component Group to nil\n if([email protected]_id.nil?)\n @category.parent_id = nil\n end\n #Sets Component Group with new params\n if(!params[:parent_ids].nil?)\n for id in params[:parent_ids]\n @category.parent_id = id\n end\n end\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @partner = Partner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n end\n end", "def create\n @clientsOffers = ClientsOffers.new(params[:clientsOffers])\n\n respond_to do |format|\n if @clientsOffers.save\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully created.' }\n format.json { render json: @clientsOffers, status: :created, location: @clientsOffers }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end", "def create\n @one_recipe_for_category = Recipe.new(recipe_params)\n if Category.exists?(@one_recipe_for_category.category_id)\n if @one_recipe_for_category.save\n render :json => {\n :response => \"Success! Created your new recipe.\",\n :data => @one_recipe_for_category\n }\n else\n render :json => {\n :error => \"Cannot save data.\"\n }\n end\n end\n end", "def create\n @post_category = current_user.post_categories.build(params[:post_category])\n\n respond_to do |format|\n if @post_category.save\n format.html { redirect_to [:client,:post_categories], notice: 'Post category was successfully created.' }\n format.json { render json: @post_category, status: :created, location: @post_category }\n else\n format.html { render action: \"index\" }\n format.json { render json: @post_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trip = Trip.new(trip_params)\n @trip.category_id = params[:category_id]\n @trip.author = current_user\n @categories = Category.all.map{|c| [ c.name, c.id ] }\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: \"L'itinéraire a été crée.\" }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vessel_category = VesselCategory.new(vessel_category_params)\n\n respond_to do |format|\n if @vessel_category.save\n format.html { redirect_to @vessel_category, notice: 'Vessel class was successfully created.' }\n format.js\n format.json { render action: 'show', status: :created, location: @vessel_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @vessel_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @choice = Choice.new(choice_params)\n\n if @choice.save\n render json: @choice, status: :created, location: @choice\n else\n render json: @choice.errors, status: :unprocessable_entity\n end\n end", "def new\n @partner_project = PartnerProject.new\n @partners = Partner.all\n @projects = Project.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_project }\n end\n end", "def create\n @desserts_category = DessertsCategory.new(desserts_category_params)\n\n respond_to do |format|\n if @desserts_category.save\n format.html { redirect_to @desserts_category}\n format.json { render :show, status: :created, location: @desserts_category }\n else\n format.html { render :new }\n format.json { render json: @desserts_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @technology = Technology.new(params[:technology])\n @categories = Category.find(:all)\n\n respond_to do |format|\n if @technology.save\n flash[:success] = 'Technology was successfully created.'\n format.html { redirect_to @technology }\n format.json { render json: @technology, status: :created, location: @technology }\n else\n format.html { render action: \"new\" }\n format.json { render json: @technology.errors, status: :unprocessable_entity }\n end\n end\n end", "def createSection(section)\r\n uri = sprintf(\"/api/v1/courses/%d/sections/\", $tocid) \r\n \r\n dbg(\"POST #{uri}\")\r\n dbg(\"course_section[name]=#{section[\"name\"]}\")\r\n newSection = $canvas.post(uri, {'course_section[name]' => section[\"name\"]})\r\n dbg(newSection)\r\n return newSection\r\nend", "def create\n @kid = Kid.create(kid_params)\n @parent = Parent.find(params[:parent_id])\n @parent.kids << @kid\n redirect_to parent_kids_path\n # render json: @kid, status: 201\n end", "def election_params\n params.require(:election).permit(:title, :start_date, :finish_date, :status, :category_id)\n end", "def create\n @external_partnership = ExternalPartnership.new(params[:external_partnership])\n\n respond_to do |format|\n if @external_partnership.save\n format.html { redirect_to @external_partnership, notice: 'External partnership was successfully created.' }\n format.json { render json: @external_partnership, status: :created, location: @external_partnership }\n else\n format.html { render action: \"new\" }\n format.json { render json: @external_partnership.errors, status: :unprocessable_entity }\n end\n end\n end", "def addservice\n\n @service = ServiceProvider.find_by(username: params[:serviceprovider][:username]);\n permitted = params[:serviceprovider].permit( :description, :category_id);\n @service.services.create(permitted);\n\n render json: @service\n\n\nend", "def new\n @category = Category.find(params[:category_id])\n @server = @category.servers.build\n respond_to do |format|\n format.html # show.html.erb\n format.js { render :layout => false }\n format.xml { render :xml => @server }\n end\n end", "def index\n if params[:term]\n @partners = Partner.scoped.order(:name).where(\"name ILIKE ?\", \"%#{params[:term]}%\")\n else\n @partners = Partner.scoped\n end\n @partner = Partner.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners.map(&:name) }\n end\n end" ]
[ "0.64640003", "0.6269952", "0.6052953", "0.60497016", "0.5964296", "0.5837719", "0.58303094", "0.5791857", "0.5791857", "0.57849234", "0.5783859", "0.5773217", "0.5721865", "0.5719794", "0.567816", "0.56750023", "0.56669843", "0.5649162", "0.5581409", "0.5579151", "0.556906", "0.5541537", "0.55358976", "0.55330753", "0.5530408", "0.55299604", "0.5517836", "0.55038375", "0.54892373", "0.54860425", "0.5473337", "0.5445167", "0.54326123", "0.5424282", "0.54218334", "0.5419268", "0.54107326", "0.5410339", "0.53904897", "0.53899777", "0.5388078", "0.53788394", "0.5372834", "0.53718996", "0.53585327", "0.53562826", "0.5354916", "0.53493285", "0.53479904", "0.534753", "0.5344292", "0.5342939", "0.5339948", "0.5336816", "0.5334998", "0.5324446", "0.5321159", "0.531293", "0.5310916", "0.53108126", "0.53078777", "0.53039247", "0.53030366", "0.53023314", "0.52983123", "0.5295494", "0.52933145", "0.52846396", "0.5284137", "0.52838576", "0.5283409", "0.5282466", "0.5274446", "0.5260424", "0.5250401", "0.52384555", "0.5236552", "0.522702", "0.5222906", "0.5221814", "0.52191615", "0.5214023", "0.5207657", "0.52062124", "0.51919305", "0.51914823", "0.5184831", "0.5179295", "0.51763004", "0.5175536", "0.51676637", "0.516591", "0.51636785", "0.516254", "0.5158514", "0.5157485", "0.5153389", "0.5152629", "0.5151399", "0.51487505" ]
0.70171136
0
PATCH/PUT /crew/category_partners/1 PATCH/PUT /crew/category_partners/1.json
def update respond_to do |format| if @crew_category_partner.update(crew_category_partner_params) format.html { redirect_to @crew_category_partner, notice: 'Category partner was successfully updated.' } format.json { render :show, status: :ok, location: @crew_category_partner } else format.html { render :edit } format.json { render json: @crew_category_partner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n json_update(category,category_params, Category)\n end", "def update\n respond_to do |format|\n # TODO: Make this more efficient, this is a little hacky\n if params[:category_ids]\n PartnerCategory.where(partnering_organization_id: @partnering_organization.id).delete_all\n params[:category_ids].each do |i|\n @po_cat = PartnerCategory.create(partnering_organization_id: @partnering_organization.id, category_id: i)\n end\n end\n if @partnering_organization.update(partnering_organization_params)\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @partnering_organization }\n else\n format.html { render :edit }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, CompetenceTierGroup\n \n @competence_tier_group.update!(competence_tier_group_params)\n render json: {status: :ok}\n end", "def update\n respond_to do |format|\n if @catched.update(catched_params)\n format.html { redirect_to @catched, notice: 'Catched was successfully updated.' }\n format.json { render :show, status: :ok, location: @catched }\n else\n format.html { render :edit }\n format.json { render json: @catched.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n respond_to do |format|\n if @practice.update(practice_params)\n # Delete the currently associated partner\n if params[:original_recruiter].present?\n delete_sql = \"DELETE FROM partners_practices WHERE \" +\n \"partner_id = #{params[:original_recruiter]} AND practice_id = #{@practice.id};\"\n ActiveRecord::Base.connection.execute delete_sql\n end\n # Add the new associated partner (if any)\n if params[:recruiter_partner].present?\n insert_sql = \"INSERT INTO partners_practices (partner_id, practice_id) \" +\n \"VALUES (#{params[:recruiter_partner]}, #{@practice.id});\"\n ActiveRecord::Base.connection.execute insert_sql\n end\n format.html { redirect_to partner_path(current_partner), notice: 'Practice was successfully updated.' }\n format.json { render :show, status: :ok, location: @practice }\n else\n format.html { render :edit }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @retailer_category = RetailerCategory.find(params[:id])\n respond_to do |format|\n if @retailer_category.update_attributes(params[:retailer_category])\n format.html { redirect_to @retailer_category, notice: 'Retailer category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @retailer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # recipe_params[:ingredient_lists_attributes].each do |list|\n # list.each do |item|\n # item[:ingredient_attributes] = Ingredient.where(name: item[:ingredient_attributes].name).first_or_create\n # end\n # end\n \n # category_ids = params[:recipe][:categories_attributes].map { |k,v| v[:id] }\n # #pry.debugger\n \n # recipe_params.merge({ category_ids: category_ids })\n \n\n respond_to do |format|\n \n if @recipe.update(recipe_params)\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @specialization_category.update(specialization_category_params)\n format.html { redirect_to @specialization_category, notice: 'Specialization category was successfully updated.' }\n format.json { render :show, status: :ok, location: @specialization_category }\n else\n format.html { render :edit }\n format.json { render json: @specialization_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client.update(client_params)\n render json: @client\n end", "def update\n course = Course.includes(:professors).find(params[:id])\n course.update!(course_params)\n \n course.professor_ids=(params[:professors])\n\n render json: course.to_json(include: :professors)\n end", "def update\n respond_to do |format|\n if @coach_category.update(coach_category_params)\n format.html { redirect_to @coach_category, notice: 'Categoria de treinador foi actualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @coach_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @profession_category.update(profession_category_params)\n format.html { redirect_to profession_categories_path, notice: 'Profession category was successfully updated.' }\n format.json { render :show, status: :ok, location: @profession_category }\n else\n format.html { render :edit }\n format.json { render json: @profession_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @optinpartner = Optinpartner.find(params[:id])\n\n respond_to do |format|\n if @optinpartner.update_attributes(params[:optinpartner])\n format.html { redirect_to @optinpartner, notice: 'Optinpartner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @optinpartner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\n end", "def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end", "def update\nlogger.debug \"update discipline: \"[email protected]\n discipline_params.each_pair do |property,value|\n @discipline.send(property+'=',value)if @discipline.respond_to?(property+'=')\n end\n @discipline.updater_id = current_user\n if @discipline.save\n set_discipline\n #respond_with @discipline\n render json: @discipline, status: :ok\n else\n ##render json: @discipline.errors, status: :unprocessable_entity\n respond_with @discipline.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @company_part.update(company_part_params)\n format.html { redirect_to company_parts_path, notice: 'Company part was successfully updated.' }\n format.json { render :show, status: :ok, location: @company_part }\n else\n format.html { render :edit }\n format.json { render json: @company_part.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe.allergies.destroy_all\n params[:recipe][:allergy].each do |key,value|\n if value[\"name\"] == \"1\"\n allergy = Allergy.find(key)\n @recipe.allergies << allergy\n end\n end\n\n if params[:recipe][:concentrate] == '1' || params[:recipe][:recipe_category_id] == RecipeCategory.find_by(name: \"Concentrates\").id\n @recipe.concentrate = true\n else\n @recipe.concentrate = false\n end\n\n respond_to do |format|\n if @recipe.update(recipe_params)\n @allergies = Allergy.all\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n @allergies = Allergy.all\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @headline = t(:update_category)\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: t(:updated_category_success) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @part.update(part_params)\n format.html { redirect_to chaper_path(@chaper), notice: 'Part was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: chaper_path(@chaper).errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @models = self.class.model_class.find(params[:id])\n\n respond_to do |format|\n if @models.update_attributes(params[:partners])\n flash[:notice] = 'Partners was successfully updated.'\n format.html { redirect_to(@models) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @models.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n if @partner_type.update_attributes(params[:partner_type])\n format.html { redirect_to @partner_type, notice: 'Partner type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n @categories=RecipeCategory.all\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n\n # Set the original profession ID attribute to match the profession id of\n # the recipe group.\n @original_profession_id = recipe_group.profession.id\n\n respond_with(recipe_group)\n\n end", "def update\n if can?(:>=, \"3\")\n @cup_count = params[:cup_count].to_boolean\n @part = Kitting::Part.find(params[:id])\n if @part.name.blank? || @part.prime_pn.blank?\n get_part_name_rbo = get_part_numbers current_user, params[:part][:part_number].try(:upcase)\n @get_part_name = get_part_name_rbo['partName'] || \"\"\n @part.update_attribute(:name, @get_part_name)\n @part.update_attribute(:prime_pn, get_part_name_rbo[\"primePNList\"].reject(&:blank?).first)\n end\n\n respond_to do |format|\n if @part.update_attributes(params[:part])\n format.html { redirect_to(@part,:notice => \"Part #{@part.part_number} is updated successfully.\") }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @part.errors,\n :status => :unprocessable_entity }\n end\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end", "def update\n\t@vehicle_categories = VehicleCategory.all\n\t@vehicle_category = VehicleCategory.find(params[:id])\n respond_to do |format|\n if @vehicle_category.update(vehicle_category_params)\n format.html { redirect_to @vehicle_category, notice: 'Vehicle category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vehicle_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @interviewcategory.update(interviewcategory_params)\n format.html { redirect_to @interviewcategory, notice: \"Interviewcategory was successfully updated.\" }\n format.json { render :show, status: :ok, location: @interviewcategory }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @interviewcategory.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @part_company = PartCompany.find(params[:id])\n\n respond_to do |format|\n if @part_company.update_attributes(params[:part_company])\n format.html { redirect_to @part_company, notice: 'Part company was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @part_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_crew_category_partner\n @crew_category_partner = CategoryPartner.find(params[:id])\n end", "def update\n respond_to do |format|\n if @cetegory.update(cetegory_params)\n format.html { redirect_to @cetegory, notice: 'Cetegory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cetegory.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @current_page = 'recettes'\n @recette = Recette.find(params[:id])\n # params[:recette][:category_ids] ||= []\n\n @recette.update_attributes!(recette_params)\n redirect_to @recette\n end", "def update\n respond_to do |format|\n if @category_offer.update_attributes(params[:category_offer])\n format.html { redirect_to @category_offer, notice: 'Category offer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category_offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @post_category = current_user.post_categories.find(params[:id])\n\n respond_to do |format|\n if @post_category.update_attributes(params[:post_category])\n format.html { redirect_to [:client,@post_category], notice: 'Post category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @category.update(category_params)\n render json: @category, status: :ok\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def update\n if @categoria.update(categoria_params)\n render json: @categoria\n else\n render json: @categoria.errors, status: :unprocessable_entity \n end\n end", "def update\n @recipe_category = RecipeCategory.find(params[:id])\n\n respond_to do |format|\n if @recipe_category.update_attributes(params[:recipe_category])\n format.html { redirect_to @recipe_category, notice: 'Recipe category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category.update_attributes(params[:category])\n respond_with(@category)\n end", "def update\n respond_to do |format|\n if @complaint_client_satisfaction.update(complaint_client_satisfaction_params)\n format.html { redirect_to @complaint_client_satisfaction.complaint, notice: 'client feedback was successfully updated.' }\n format.json { render :show, status: :ok, location: @complaint_client_satisfaction }\n else\n format.html { render :edit }\n format.json { render json: @complaint_client_satisfaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # byebug\n authorize @demand\n\n # @demand.competences.build()\n respond_to do |format|\n if @demand.update(demand_params)\n @demand.competence_ids = params[:demand][:competence_ids].first.split(',')\n @demand.criterion_ids = params[:demand][:criterion_ids].first.split(',')\n puts \"\n params[:demand][:criterion_ids]: #{params[:demand][:criterion_ids]}\n @demand.criterion_ids: #{@demand.criterion_ids}\n \"\n format.html { redirect_to @demand, notice: 'Demand was successfully updated.' }\n format.json { render :show, status: :ok, location: @demand }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @demand.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n respond_to do |format|\n if @partnership.update(partnership_params)\n format.html { redirect_to @partnership, notice: 'Partnership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @partnership.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @consumer_category = ConsumerCategory.find(params[:id])\n\n respond_to do |format|\n if @consumer_category.update_attributes(params[:consumer_category])\n format.html { redirect_to @consumer_category, notice: 'Consumer category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @consumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @food_court.update(food_court_params)\n format.html { redirect_to @food_court, notice: 'Food court was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_court }\n else\n format.html { render :edit }\n format.json { render json: @food_court.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @kickoff = Kickoff.find(params[:id])\n\n respond_to do |format|\n if @kickoff.update_attributes(params[:kickoff])\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kickoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @trip = Trip.find(params[:id])\n \n \n params[:trip][:category_ids] ||= []\n params[:trip][:type_ids] ||= []\n \n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, :notice => 'Trip was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n if @clientsOffers.update_attributes(params[:clientsOffers])\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @company_client.update(company_client_params)\n format.html { redirect_to company_clients_path, notice: 'Клиент успешно отредактирован' }\n format.json { render :show, status: :ok, location: @company_client }\n else\n format.html { render :edit }\n format.json { render json: @company_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = current_user\n if @user.commission_request_template_json.nil? \n @user.commission_request_template_json = {\"categories\" => []}.to_json\n end\n json = build_json_from_params \n @user.commission_request_template_json = nil\n @user.save\n @user.commission_request_template_json = json\n if @user.save\n flash[:notice] = \"Commission Template Saved!\"\n else\n flash[:alert] = \"Error Saving Template\"\n end \n redirect_to root_url\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.json { render :show, status: :ok, location: @category }\n else\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contractor_category.update(contractor_category_params)\n format.html { redirect_to @contractor_category, notice: 'Contractor category was successfully updated.' }\n format.json { render :show, status: :ok, location: @contractor_category }\n else\n format.html { render :edit }\n format.json { render json: @contractor_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def variables_for_edit\r\n @path = administration.article_cluster_category_path\r\n @method = :patch\r\n end", "def update\n respond_to do |format|\n if @receipe_category.update(receipe_category_params)\n format.html { redirect_to @receipe_category, notice: 'Receipe category was successfully updated.' }\n format.json { render :show, status: :ok, location: @receipe_category }\n else\n format.html { render :edit }\n format.json { render json: @receipe_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner_person = PartnerPerson.find(params[:id])\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n if @partner_person.update_attributes(params[:partner_person])\n format.html { redirect_to(@partner_person, :notice => 'PartnerPerson was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partner_person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @vessel_category.update(vessel_category_params)\n format.html { redirect_to @vessel_category, notice: 'Vessel class was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vessel_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n @permit.category_id = params[:category_id]\n @permit.employee_id = params[:employee_id]\n @permit.site_id = params[:site_id]\n\n respond_to do |format|\n if @permit.update(permit_params)\n format.html { redirect_to @permit, notice: 'Permit was successfully updated.' }\n format.json { render :show, status: :ok, location: @permit }\n else\n format.html { render :edit }\n format.json { render json: @permit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @available_category.update(available_category_params)\n format.html { redirect_to admin_available_categories_path, notice: 'Available category was successfully updated.' }\n format.json { render :show, status: :ok, location: @available_category }\n else\n format.html { render :edit }\n format.json { render json: @available_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @membership_clerk.update(membership_clerk_params)\n format.html { redirect_to @membership_clerk, notice: 'Membership clerk was successfully updated.' }\n format.json { render :show, status: :ok, location: @membership_clerk }\n else\n format.html { render :edit }\n format.json { render json: @membership_clerk.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room_category.update(room_category_params)\n format.html { redirect_to @room_category, notice: 'Room category was successfully updated.' }\n format.json { render :show, status: :ok, location: @room_category }\n else\n format.html { render :edit }\n format.json { render json: @room_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @personality_category.update(personality_category_params)\n format.html { redirect_to @personality_category, notice: 'Personality category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @personality_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n\n respond_to do |format|\n if @competence.update(competence_params)\n format.html { redirect_to '/profile#addMoreCompetences', notice: t('competences_controller.competences_update_success') }\n format.json { render :show, status: :ok, location: @competence }\n else\n format.html { render :edit }\n format.json { render json: @competence.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to @cookbook, notice: 'Cookbook was successfully updated.' }\n format.json { render :show, status: :ok, location: @cookbook }\n else\n format.html { render :edit }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prv_category.update(prv_category_params)\n format.html { redirect_to prv_categories_path, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prv_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @participant_bkp = Participant.new(@participant.attributes)\n respond_to do |format|\n if @participant.update(participant_params)\n @participant.competences.delete_all\n @competence.each {|competence| competence.participant = @participant; competence.save}\n @participant_bkp.id = nil\n @participant_bkp.original_participant_id = @participant.id\n @participant_bkp.save(validate: false)\n @participant_bkp.delete\n format.html { redirect_to add_to_list_participant_url(@participant), notice: 'Participant was successfully updated.' }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end", "def update\n respond_to do |format|\n if @pit_category.update(pit_category_params)\n format.html { redirect_to @pit_category, notice: 'Pit category was successfully updated.' }\n format.json { render :show, status: :ok, location: @pit_category }\n else\n format.html { render :edit }\n format.json { render json: @pit_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n professor = Professor.find(params[:id])\n professor.update!(professor_params)\n\n render json: professor.to_json(include: :courses)\n end", "def update\n respond_to do |format|\n if @ledger_category.update(ledger_category_params)\n format.html { redirect_to @ledger_category, notice: 'Ledger category was successfully updated.' }\n format.json { render :show, status: :ok, location: @ledger_category }\n else\n format.html { render :edit }\n format.json { render json: @ledger_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @frontend_critic.update(frontend_critic_params)\n format.html { redirect_to @frontend_critic, notice: 'Critic was successfully updated.' }\n format.json { render :show, status: :ok, location: @frontend_critic }\n else\n format.html { render :edit }\n format.json { render json: @frontend_critic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n\n respond_to do |format|\n if @admin_collaborator.update_attributes(params[:admin_collaborator])\n format.html { redirect_to @admin_collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_collaborator.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @categorie_competence.update(categorie_competence_params)\n format.html { redirect_to @categorie_competence, notice: 'Categorie competence was successfully updated.' }\n format.json { render :show, status: :ok, location: @categorie_competence }\n else\n format.html { render :edit }\n format.json { render json: @categorie_competence.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @collection = current_user.collections.find(params[:collection_id]) \n @recommender = @collection.recommenders.find(params[:id])\n\n respond_to do |format|\n if @recommender.update_attributes(params[:recommender])\n format.html { redirect_to collection_recommenders_path(@collection), notice: 'Recommender was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recommender.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @potluck_recipe.update(potluck_recipe_params)\n format.html { redirect_to @potluck_recipe, notice: 'Potluck recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @potluck_recipe }\n else\n format.html { render :edit }\n format.json { render json: @potluck_recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exhibitior_category = ExhibitiorCategory.find(params[:id])\n\n respond_to do |format|\n if @exhibitior_category.update_attributes(params[:exhibitior_category])\n format.html { redirect_to @exhibitior_category, notice: 'Exhibitior category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exhibitior_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @groupgrant_category.update(groupgrant_category_params)\n format.html { redirect_to @groupgrant_category, notice: 'Groupgrant category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @groupgrant_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @partner.update(partner_params)\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { render :show, status: :ok, location: @partner }\n else\n format.html { render :edit }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @incidentcategory.update(incidentcategory_params)\n json_response(@incidentcategory)\n else\n render json: @incidentcategory.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n respond_to do |format|\n if @suggested_category.update(suggested_category_params)\n format.html { redirect_to @suggested_category, notice: 'Suggested category was successfully updated.' }\n format.json { render :show, status: :ok, location: @suggested_category }\n else\n format.html { render :edit }\n format.json { render json: @suggested_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @category_step.update(category_step_params)\n format.html { redirect_to @category_step, notice: 'Category step was successfully updated.' }\n format.json { render :show, status: :ok, location: @category_step }\n else\n format.html { render :edit }\n format.json { render json: @category_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @effort_category.update(effort_category_params)\n format.html { redirect_to @effort_category, notice: 'Effort category was successfully updated.' }\n format.json { render :show, status: :ok, location: @effort_category }\n else\n format.html { render :edit }\n format.json { render json: @effort_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @rubric.update(rubric_params)\n if params[\"rubric\"][\"course_id1\"] != \"\"\n @course = Course.find(params[\"rubric\"][\"course_id1\"])\n @course.rubrics << @rubric\n end\n if params[\"rubric\"][\"course_id2\"] != \"\"\n @course = Course.find(params[\"rubric\"][\"course_id2\"])\n @course.rubrics << @rubric\n end\n if params[\"rubric\"][\"course_id3\"] != \"\"\n @course = Course.find(params[\"rubric\"][\"course_id3\"])\n @course.rubrics << @rubric\n end\n format.html { redirect_to my_rubrics_path, notice: 'Rubric was successfully updated.' }\n format.json { render :show, status: :ok, location: @rubric }\n else\n format.html { render :edit }\n format.json { render json: @rubric.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @partner.update(partner_params)\n format.html { redirect_to [:admin, @partner], notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @external_partnership = ExternalPartnership.find(params[:id])\n\n respond_to do |format|\n if @external_partnership.update_attributes(params[:external_partnership])\n format.html { redirect_to @external_partnership, notice: 'External partnership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @external_partnership.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @company = Company.find(params[:id])\n params[:company][:category_ids] ||= []\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to(@company, :notice => 'Company was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @caterer.update(caterer_params)\n format.html { redirect_to @caterer, notice: 'Caterer was successfully updated.' }\n format.json { render :show, status: :ok, location: @caterer }\n else\n format.html { render :edit }\n format.json { render json: @caterer.errors, status: :unprocessable_entity }\n end\n end\n @caterer.caterer_type_ids = params[:caterer][:caterer_type_ids]\n @caterer.cuisine_type_ids = params[:caterer][:cuisine_type_ids]\n 5.times { @caterer.caterer_packages.build }\n end", "def update\n respond_to do |format|\n if @prosumer_category.update(prosumer_category_params)\n format.html { redirect_to @prosumer_category, notice: 'Prosumer category was successfully updated.' }\n format.json { render :show, status: :ok, location: @prosumer_category }\n else\n format.html { render :edit }\n format.json { render json: @prosumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to api_v1_category_path(@category), notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update\n respond_to do |format|\n if @court_complex.update(court_complex_params)\n format.html { redirect_to @court_complex, notice: 'Court complex was successfully updated.' }\n format.json { render :show, status: :ok, location: @court_complex }\n else\n format.html { render :edit }\n format.json { render json: @court_complex.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cliente.update(cliente_params)\n #--ADICIONADO\n \t @cliente.perfilclientes.destroy_all()\n if params[:cliente][:perfil_ids]\n \t\tparams[:cliente][:perfil_ids].each do |ss|\n \t\t\[email protected](:cliente_id => @cliente.id, :perfil_id => ss)\n \t\tend\n end\n #--ADICIONADO\n format.html { redirect_to clientes_url, notice: 'Cliente actualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to admin_good_categories_url, notice: 'GoodCategory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize :question_resquest_criminal, :update?\n respond_to do |format|\n if @question_resquest_criminal.update(question_resquest_criminal_params)\n format.html { redirect_to @question_resquest_criminal, notice: 'Question resquest criminal was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_resquest_criminal }\n else\n format.html { render :edit }\n format.json { render json: @question_resquest_criminal.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.68012464", "0.65082127", "0.6375713", "0.6292651", "0.61903816", "0.6137904", "0.6137127", "0.6120709", "0.61085415", "0.6091655", "0.6066401", "0.6055703", "0.6040047", "0.6005197", "0.6001784", "0.5997817", "0.59958637", "0.59955984", "0.5989613", "0.59893596", "0.5962527", "0.59624577", "0.5961644", "0.5961644", "0.5941429", "0.5935736", "0.59176487", "0.59077185", "0.5890832", "0.5887953", "0.58843035", "0.5884007", "0.5884006", "0.58831173", "0.5882168", "0.5875606", "0.58749014", "0.58654374", "0.5860742", "0.5857621", "0.5833198", "0.58266014", "0.58218575", "0.58205754", "0.5820269", "0.58157426", "0.5814365", "0.58083683", "0.57954395", "0.5792771", "0.57890993", "0.5788381", "0.57858783", "0.57850707", "0.5784624", "0.57802683", "0.5780223", "0.5780084", "0.57776326", "0.57769793", "0.5770891", "0.57598114", "0.5750371", "0.5747409", "0.57471794", "0.5742493", "0.57398784", "0.5739305", "0.5738826", "0.5731202", "0.5729599", "0.57263005", "0.57221794", "0.5721841", "0.5720645", "0.57150006", "0.5713981", "0.5712439", "0.5712093", "0.571", "0.5708318", "0.56983817", "0.56961274", "0.56906563", "0.5687954", "0.5682558", "0.5682434", "0.56823975", "0.5680504", "0.5678961", "0.56788623", "0.56777227", "0.5671616", "0.5669541", "0.56682074", "0.56676763", "0.5666406", "0.56633955", "0.5657485", "0.5651438" ]
0.68432015
0
DELETE /crew/category_partners/1 DELETE /crew/category_partners/1.json
def destroy @crew_category_partner.destroy respond_to do |format| format.html { redirect_to crew_category_partners_url, notice: 'Category partner was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n # @retailer_category = RetailerCategory.find(params[:id])\n @retailer_category.destroy\n respond_to do |format|\n format.html { redirect_to retailer_categories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @coach_category.destroy\n respond_to do |format|\n format.html { redirect_to coach_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_studio_client = MyStudio::Client.find(params[:id])\n @my_studio_client.destroy\n\n respond_to do |format|\n format.html { redirect_to my_studio_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @qa_client = QaClient.find(params[:id])\n @qa_client.destroy\n\n respond_to do |format|\n format.html { redirect_to qa_clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end", "def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @part.destroy\n respond_to do |format|\n format.html { redirect_to chaper_path(@chaper) }\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n render json: @category, status: :ok\n end", "def destroy\n @company_client.destroy\n respond_to do |format|\n format.html { redirect_to company_clients_url, notice: 'Клиент был успешно удален' }\n format.json { head :no_content }\n end\n end", "def destroy\n @partner = Partner.find(params[:id])\n @partner.destroy\n\n respond_to do |format|\n format.html { redirect_to partners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @partner = Partner.find(params[:id])\n @partner.destroy\n\n respond_to do |format|\n format.html { redirect_to partners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_client.destroy\n respond_to do |format|\n format.html { redirect_to group_clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cetegory.destroy\n respond_to do |format|\n format.html { redirect_to cetegories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Данные по клиенту удалены.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @cateroty.destroy\n respond_to do |format|\n format.html { redirect_to cateroties_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def destroy\n @competency.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @client_has_employeur.destroy\n respond_to do |format|\n format.html { redirect_to client_has_employeurs_url, notice: 'Client has employeur was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exhibitior_category = ExhibitiorCategory.find(params[:id])\n @exhibitior_category.destroy\n\n respond_to do |format|\n format.html { redirect_to exhibitior_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @partnership.destroy\n respond_to do |format|\n format.html { redirect_to partnerships_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ledger_category.destroy\n respond_to do |format|\n format.html { redirect_to ledger_categories_url, notice: 'Ledger category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @optinpartner = Optinpartner.find(params[:id])\n @optinpartner.destroy\n\n respond_to do |format|\n format.html { redirect_to optinpartners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n clients_delete(@entity)\n @entity.destroy\n respond_to do |format|\n format.html { redirect_to clients_path }\n format.json { render json: {success: true} }\n end\n end", "def destroy\n @desserts_category = @dessert.desserts_category\n @dessert.destroy\n respond_to do |format|\n format.html { redirect_to @desserts_category}\n format.json { head :no_content }\n end\n end", "def destroy\n @alien_category.destroy\n respond_to do |format|\n format.html { redirect_to alien_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client a été supprimer.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_type.destroy\n respond_to do |format|\n format.html { redirect_to client_types_url, notice: 'Tipo de Cliente deletado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, CompetenceTierGroup\n \n @competence_tier_group.destroy!\n render json: {status: :ok}\n end", "def destroy\n @client_info.destroy\n respond_to do |format|\n format.html { redirect_to client_infos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_info.destroy\n respond_to do |format|\n format.html { redirect_to client_infos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @desserts_category.destroy\n respond_to do |format|\n format.html { redirect_to desserts_categories_url}\n format.json { head :no_content }\n end\n end", "def destroy\n @part_company = PartCompany.find(params[:id])\n @part_company.destroy\n\n respond_to do |format|\n format.html { redirect_to part_companies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @partner_type = PartnerType.find(params[:id])\n @partner_type.destroy\n\n respond_to do |format|\n format.html { redirect_to partner_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @category_licor.destroy\n respond_to do |format|\n format.html { redirect_to category_licors_url, notice: 'Category licor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @categorie_competence.destroy\n respond_to do |format|\n format.html { redirect_to categorie_competences_url, notice: 'Categorie competence was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @company_part.destroy\n respond_to do |format|\n format.html { redirect_to company_parts_url, notice: 'Company part was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #--ADICIONADO\n @cliente.perfilclientes.destroy\n #--ADICIONADO\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_category = RecipeCategory.find(params[:id])\n @recipe_category.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cage.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\r\n @client = Client.find(params[:id])\r\n @client.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to clients_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @client_need = ClientNeed.find(params[:id])\n @client_need.destroy\n\n respond_to do |format|\n format.html { redirect_to client_needs_url }\n format.json { head :no_content }\n end\n end", "def deleteEntityCategory( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/category\",params)\n end", "def destroy\n @crowd = Crowd.find(params[:id])\n @crowd.destroy\n\n respond_to do |format|\n format.html { redirect_to crowds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @interviewcategory.destroy\n respond_to do |format|\n format.html { redirect_to interviewcategories_url, notice: \"Interviewcategory was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @categorie_droit.destroy\n respond_to do |format|\n format.html { redirect_to categorie_droits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @clonet = Clonet.find(params[:id])\n @clonet.destroy\n\n respond_to do |format|\n format.html { redirect_to clonets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dynamic_field_group_category.destroy\n respond_to do |format|\n format.html { redirect_to dynamic_field_group_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end", "def delete_from_entzumena\n headline = Headline.where({:source_item_type => params[:source_item_type], :source_item_id => params[:source_item_id]}).first\n if headline.destroy\n render :json => true, :status => 200\n else\n render :json => false, :status => :error\n end\n end", "def destroy\n @clientsOffers = ClientsOffers.find(params[:id])\n @clientsOffers.destroy\n\n respond_to do |format|\n format.html { redirect_to clientsOffers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n story_part_id = @story_part.id\n @story_part.destroy\n render :json => story_part_id\n end", "def destroy\n @consumer_category = ConsumerCategory.find(params[:id])\n @consumer_category.destroy\n\n respond_to do |format|\n format.html { redirect_to consumer_categories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @groupgrant_category.destroy\n respond_to do |format|\n format.html { redirect_to groupgrant_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @data = @recipe.delete(params[:id])\n render json: @data\n end", "def destroy\n @potential_partner.destroy\n respond_to do |format|\n format.html { redirect_to potential_partners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @food_court.destroy\n respond_to do |format|\n format.html { redirect_to food_courts_url, notice: 'Food court was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @candy.destroy\n respond_to do |format|\n format.html { redirect_to candies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n# redirect_to activacionclientets_path # ted esto para evitar que borren por la web. ok. Que valla al index. provisional ok.\n \n #@activacionclientet.destroy\n respond_to do |format|\n format.html { redirect_to activacionclientets_url, notice: 'Activacionclientes no se puede eliminar por esta via. Contacte el administrador.' } # ted esto para evitar que borren por la web\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n render json: { notice: 'Categoria eliminada exitosamente' }\n end", "def destroy\n @criterio.destroy\n respond_to do |format|\n format.html { redirect_to criterios_url, notice: 'Criterio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_category = SectionCategory.find(params[:id])\n @section_category.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @featured_client.destroy\n respond_to do |format|\n format.html { redirect_to featured_clients_url, notice: 'Featured client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'El Cliente fue Eliminado Exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @contestant = Contestant.find(params[:id])\n @contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to contestants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @cate_item = CateItem.find(params[:id])\n @cate_item.destroy\n\n respond_to do |format|\n format.html { redirect_to '/cate_items' }\n format.json { head :no_content }\n end\n end", "def soccer_delete\n base_delete(params, \"Soccer\")\n end", "def destroy\n @rail_company.destroy\n respond_to do |format|\n format.html { redirect_to rail_companies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n @uuid = params[:uuid]\n respond_to do |format|\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid }\n format.json { head :no_content }\n end\n end", "def destroy\n @confession = Confession.find(params[:id])\n @confession.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_confessions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @colaborattor.destroy\n respond_to do |format|\n format.html { redirect_to colaborattors_url, notice: I18n.t('messages.destroyed_with', item: @colaborattor.colaborattorname) }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @client_accessory.destroy\n respond_to do |format|\n format.html { redirect_to client_accessories_url, notice: 'Client accessory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @patrimony_item_category.destroy\n respond_to do |format|\n format.html { redirect_to patrimony_item_categories_url, notice: 'Patrimony item category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente apagado com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @grupocliente.destroy\n respond_to do |format|\n format.html { redirect_to grupoclientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @profession_category.destroy\n respond_to do |format|\n format.html { redirect_to profession_categories_url, notice: 'Profession category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @complaint_client_satisfaction.destroy\n respond_to do |format|\n format.html { redirect_to complaint_client_satisfactions_url, notice: 'Complaint client satisfaction was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.6806315", "0.6795338", "0.67820114", "0.67805576", "0.6740692", "0.6726948", "0.6722321", "0.665271", "0.66501826", "0.66387033", "0.6634389", "0.6634389", "0.66263354", "0.66174185", "0.6615655", "0.6599572", "0.6585356", "0.6557574", "0.6548899", "0.6545354", "0.6537073", "0.65311545", "0.65182936", "0.6515342", "0.6515188", "0.65147036", "0.65105045", "0.6505258", "0.649859", "0.6493911", "0.64934784", "0.6491944", "0.6487596", "0.6487117", "0.64867383", "0.647825", "0.6477083", "0.6476916", "0.6473914", "0.6472514", "0.6464006", "0.6462019", "0.6459578", "0.64582574", "0.64582574", "0.64582574", "0.64582574", "0.64582574", "0.64582574", "0.64582574", "0.64582574", "0.64582574", "0.6456278", "0.64542145", "0.6451844", "0.64508075", "0.6443877", "0.6441277", "0.643822", "0.6431817", "0.6424182", "0.6423147", "0.6423147", "0.64227873", "0.6420316", "0.64187336", "0.6418343", "0.6413963", "0.64139116", "0.64134145", "0.6412714", "0.6411133", "0.6408235", "0.64070195", "0.64050794", "0.6404923", "0.640111", "0.64008313", "0.640045", "0.63972116", "0.6396212", "0.63961077", "0.63936824", "0.6391007", "0.6390245", "0.63897854", "0.6387359", "0.6384211", "0.63827527", "0.6382587", "0.63825506", "0.63825506", "0.63825506", "0.63781935", "0.6378062", "0.6375501", "0.63748133", "0.63731635", "0.6368342", "0.63679326" ]
0.7066283
0
Use callbacks to share common setup or constraints between actions.
def set_crew_category_partner @crew_category_partner = CategoryPartner.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def crew_category_partner_params params.require(:category_partner).permit(:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
A hash of label to value for all the properties we want to display
def resource_properties { 'Path' => @resource.path, 'Output Path' => File.join(@resource.app.build_dir, @resource.destination_path), 'Url' => content_tag(:a, @resource.url, :href => @resource.url), #'Metadata' => @resource.metadata, 'Source' => @resource.source_file } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def values_for_properties; end", "def hash\n @label.hash\n end", "def formatted_attributes\n Hash[display_key.downcase.to_sym, values.collect { |el| el[:displayValue] }]\n end", "def property_label_text(property)\n case property.to_sym\n when :image_default then t(:image_url)\n when :web_default then t(:website_url)\n when :web_blog then t(:blog_url)\n else t(property.to_sym)\n end\n end", "def inspect\n s = ''\n @props.each do |key,val|\n s << sprintf(\"%-20.20s : %-40.40s\\n\", key.to_s, val.inspect)\n end\n s\n end", "def property_label_method\n\t\tself.property_category ? self.property_category.category_name + \": \" + self.property_name : self.property_name\n\tend", "def label_value_pairs\n result = @defaults.values.select {|default| default.item_label}\n .map {|default| [\"#{default.item_label}:\", default.value_printable]}\n yield result if block_given?\n result\n end", "def label_details\n attributes.fetch(:labelDetails)\n end", "def hash_representation\n all_defaults.select {|d| d.item_label}\n .collect { |d| [d.name, d.value] }.to_h\n end", "def to_h\n { \"label\" => label, \"value\" => value }\n end", "def label\n self['label']\n end", "def label\n attributes.fetch(:label)\n end", "def label\n attributes.fetch(:label)\n end", "def label\n attributes.fetch(:label)\n end", "def label\n attributes.fetch(:label)\n end", "def label\n attributes.fetch(:label)\n end", "def label\n attributes.fetch(:label)\n end", "def inspect\n %{<#{self.class.name} #{self.class.props.reduce([]) do |s, d| \n s << [d.first, send(d.first).inspect].join(\"=\")\n end.join(\" \")}>}\n end", "def property_map\n self.class.properties.map do |name, opts|\n if opts\n yreq = opts[:req] ? :req : :opt\n [\"@#{ name }\", yreq] if yreq\n end\n end.compact\n end", "def property_details(separator = ': ')\n variant_properties.collect {|vp| [vp.property.display_name ,vp.description].join(separator) }\n end", "def inspect\n elements = {:label => label.inspect, :terms => terms.map{|t| \"<#{t.class.name.demodulize} label:#{t.label}, value:#{t.value.inspect}>\"}}\n attr_list = elements.map {|k,v| \"#{k}: #{v}\" } * ', '\n \"<#{self.class.name} #{attr_list}>\"\n end", "def properties\n pairs_properties = @pairs.map { |key, value| { 'key' => key.properties, 'value' => value.properties } }\n { 'object_type' => 'map', 'pairs' => pairs_properties }\n end", "def raw_properties\n parse_raw_map descriptor.values\n end", "def property_details\n @property_details ||= Hash.new.tap do |result|\n details.each do |detail|\n detail.group_content.each do |group|\n title = group.title.text\n key = title.titleize.delete(' ').underscore\n break unless keys_white_list.include? key\n items = []\n group.items.each { |item| items << item.text }\n result[key.to_sym] = items unless items.empty?\n end\n end\n end\n end", "def inspect\n properties.to_yaml\n end", "def labels\n @labels = {}\n self.keys.collect do |k|\n x = { :key => k.to_sym, :label => k.to_s.capitalize }\n @labels[x[:key]] = x[:label]\n x\n end\n end", "def to_hash(nested = true)\n # no need of _position and _visible (unless it's false)\n hash = super.delete_if { |k, v| k == '_position' || (k == '_visible' && v == true) }\n\n # also no need of the content type\n hash.delete('content_type')\n\n # dynamic attributes\n hash.merge!(self.dynamic_attributes.deep_stringify_keys)\n\n # no need of the translation of the field name in the current locale\n label_field = self.content_type.label_field\n\n if label_field.localized\n if !hash[label_field.name].empty?\n hash[label_field.name].delete(Locomotive::Mounter.locale.to_s)\n\n hash.delete(label_field.name) if hash[label_field.name].empty?\n end\n else\n hash.delete(label_field.name)\n end\n\n nested ? { self._label => hash } : hash\n end", "def show_value_label_method\n value.to_s\n end", "def label\n attribute :label\n end", "def properties\n map(element_type: :hash) { |v| v.properties }\n end", "def setup_option_label(lbl,val)\n if lbl.nil?\n lbl = {:val => val,:value => val,:class => \"inline\"}\n else\n lbl_class = lbl[:class].nil? ? \"inline\" : (lbl[:class] << \" inline\")\n # allows you to pass lbl => \"String\"\n if lbl.is_a?(String)\n lbl = {:class => lbl_class,:val => lbl,:value => lbl}\n elsif lbl.is_a?(Hash)\n lbl.update(:class => lbl_class, :val => lbl[:val], :value => val)\n end\n end\n return lbl\n end", "def proptext(name) #:nodoc:\n prop = @properties.detect { |f| f.name? name }\n if prop\n prop = prop.to_text\n end\n prop\n end", "def property_name\n property.display_name\n end", "def all_attributes_labeled(label_name)\n to_return = {}\n @fields.each do |key, field|\n if field.has_label?(label_name.to_sym)\n to_return[key] = field.human_name\n end\n end\n to_return\n end", "def hash\n [ current_value , incremental_change , is_horizontal , max , min , page_change , shadow , name , mso_drawing_type , auto_shape_type , placement , upper_left_row , top , upper_left_column , left , lower_right_row , bottom , lower_right_column , right , width , height , x , y , rotation_angle , html_text , text , alternative_text , text_horizontal_alignment , text_horizontal_overflow , text_orientation_type , text_vertical_alignment , text_vertical_overflow , is_group , is_hidden , is_lock_aspect_ratio , is_locked , is_printable , is_text_wrapped , is_word_art , linked_cell , z_order_position , font , hyperlink , link ].hash\n end", "def properties\n self.persistent_class.property_iterator.to_a.inject({}) do |h, value|\n if !value.respond_to?(:getRubyValue)\n h[value.name] = value\n end\n h\n end\n end", "def jsonProperties\n\t\t\tallItems = {\n\t\t\t\t:labelStates\t=> @labelStates,\n\t\t\t\t:initialState\t=> @initialState,\n\t\t\t\t:size\t\t\t=> @size,\n\t\t\t\t:javascript\t\t=> @javascript,\n\t\t\t}\n\t\t\treturn allItems\n\t\tend", "def get_labels_properties(labels) # :nodoc:\n return nil unless labels\n\n position = labels[:position]\n if position.nil? || position.empty?\n labels.delete(:position)\n else\n # Map user defined label positions to Excel positions.\n positions = {\n :center => 'ctr',\n :right => 'r',\n :left => 'l',\n :top => 't',\n :above => 't',\n :bottom => 'b',\n :below => 'b',\n :inside_end => 'inEnd',\n :outside_end => 'outEnd',\n :best_fit => 'bestFit'\n }\n\n labels[:position] = value_or_raise(positions, position, 'label position')\n end\n\n labels\n end", "def consolidate_under_labels(fields)\n results = {}\n fields.each do |mdv| # ModsDisplay::Values\n results[mdv.label] ||= []\n results[mdv.label] << mdv.values\n results[mdv.label].flatten!\n end\n results\n end", "def render_options\n hsh = {}\n if minval = @minimalize\n @units = ABBREVIATED_DECIMAL_UNITS\n @format = \"%n%u\"\n @precision = minval\n @strip_insignificant_zeros = true\n @delimiter = ''\n @significant = true\n end\n\n\n hsh[:number_to_human] = HUMAN_ACCESSORS.inject({}) do |h, att|\n if val = self.instance_variable_get(\"@#{att}\")\n h[att] = val\n end\n\n h\n end\n\n return hsh\n end", "def property_options\n return @array.map {|property|\n {\n name: property.print_list,\n value: property.property_id\n }\n }\n end", "def generate_label_for_attribute?; end", "def label\n read_attr :label\n end", "def fields\n properties.keys.map(&:to_sym)\n end", "def fields\n properties.keys.map(&:to_sym)\n end", "def property_description (property) \n ret = {:name => property.name}\n ext_type = EXT_TYPE_TRANSLATIONS[property.primitive.to_s] || EXT_TYPE_TRANSLATIONS[\"String\"]\n \n if property.respond_to? :flag_map\n ret[:type] = EXT_TYPE_TRANSLATIONS[\"String\"][:type]\n else\n ret[:type] = ext_type[:type]\n end\n \n if dateFormat = ext_type[:dateFormat]\n ret[:dateFormat] = dateFormat\n end\n ret\n end", "def field_names\n label_fields.to_h\n end", "def property_names\n properties.symbolize_keys.keys\n end", "def property_map\n map = {}\n\n current_resource.class.state_properties.each do |property|\n name = property.options[:name]\n\n map[name] = current_resource.send(name)\n end\n\n map[id_property] = current_resource.send(id_property)\n\n map\n end", "def properties\n self.values\n end", "def data\n @data ||= { @label => format(@hash) }.to_plist\n end", "def to_s\n result = []\n all_properties_hash.each do |k, v|\n result << \"#{k} = #{v}\"\n end\n result.join(\"; \")\n end", "def property_names\n @properties.values.map(&:name)\n end", "def property_details(separator = ': ')\n product_sku_properties.collect {|vp| [vp.property.display_name ,vp.description].join(separator) }\n end", "def labels() = @labels ||= labels_hash", "def label\n @attributes[:label]\n end", "def jsonProperties\n\t\t\tallItems = {\n\t\t\t\t:labelStates\t\t=> @labelStates,\n\t\t\t\t:initialState\t\t=> @initialState,\n\t\t\t\t:size\t\t\t\t=> @size,\n\t\t\t}\n\t\t\tallItems.merge!( { :bindings => @bindings } ) unless @bindings.nil?\n\t\t\tallItems.merge!( { :javascriptActions => @javascriptActions } ) unless @javascriptActions.nil?\n\t\t\treturn allItems\n\t\tend", "def display_property_details(separator = '<br/>')\n property_details.join(separator)\n end", "def display_property_details(separator = '<br/>')\n property_details.join(separator)\n end", "def labels\n return \"Title: #{@title}; Description: #{@desc}; #{@complete}\"\n end", "def inspect\n \"#<#{self.class.name.split('::').last} - #{@properties}>\"\n end", "def display_attributes\n self.class.display_attribute_names.map do |name|\n [name.to_s, self.send(name)]\n end.to_h\n end", "def hash\n [sort_key, type, tooltip, label, field, sort_ascending, drilldown_id, hidden, navigation, column_identifier, render_configuration].hash\n end", "def OPRLabel(text:)\n {\n type: \"label\",\n text: text\n }\nend", "def labels\n fields[\"labels\"]\n end", "def meta_data(r)\n { :association_values => get_association_values(r).literalize_keys }\n end", "def text_properties\n color_properties.select {|key, value| key == \"color\" }\n end", "def properties(hash)\n @properties_from_attributes.merge!(ensure_all_hash_keys_are_symbols(hash))\n end", "def labels\n inject_block(:name, :label)\n end", "def properties; end", "def properties; end", "def properties; end", "def properties; end", "def properties; end", "def properties; end", "def properties; end", "def properties; end", "def hash\n [self.start, self.end, self.label].hash\n end", "def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end", "def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end", "def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end", "def to_h\n hash = {}\n instance_variables.each do |label|\n object = instance_variable_get(label)\n # If it's a plural msgstr\n if object.is_a? Array\n object.each do |entry|\n hash[entry.type] = entry.to_s if not entry.nil?\n end\n else\n hash[object.type] = object.to_s if not object.nil?\n end\n end\n hash\n end", "def props\n ret = {\"_neo_id\" => getId()}\n iter = getPropertyKeys.iterator\n while (iter.hasNext) do\n key = iter.next\n ret[key] = getProperty(key)\n end\n ret\n end", "def display_value(obj)\n case\n when obj && observed_name\n \"#{obj.name} (#{observed_name})\"\n when obj\n \"#{obj.name}\"\n when observed_name\n \"#{observed_name}\"\n else\n \"\"\n end\n end", "def formatted_props\n props.map do |name, flags|\n formatted_flags = flags\n .inspect\n .gsub(\"=>\", \" => \")\n .gsub(\"{\", \"{ \")\n .gsub(\"}\", \" }\")\n \"#{name.inspect} => #{formatted_flags}\"\n end.join(\",\\n \")\n end", "def descriptive_label\n @attributes[:descriptive_label]\n end", "def custom_label\n \"#{self.name}\"\n end", "def properties\n return @values['properties'] if @values.key?('properties')\n @values['properties'] = {}\n @values['properties']\n end", "def link_labels\n {}\n end", "def to_s\n p = @properties.merge({}) do |_k, _o, n|\n if n.is_a?(Array)\n n.flatten.map(&:to_s).join(',')\n else\n n\n end\n end\n p.map { |kv| kv.join('=') }.join(\"\\n\")\n end", "def to_s\n label\n end", "def true_label_id\n self[:value] ||= {}\n self[:value][:true_label_id]\n end", "def inspect\n @colors.map(&:inspect).join(' -> ').tap do |base|\n break \"#{base} (#{@label})\" if @label\n end\n end", "def custom_label(key, value)\n return if value == false\n return Allure::ResultUtils.tag_label(value.to_s) if value.is_a?(String) || value.is_a?(Symbol)\n\n Allure::ResultUtils.tag_label(key.to_s)\n end", "def custom_label\n \"#{self.name}\"\n end", "def display\n to_h.fetch(:display)\n end", "def display\n to_h.fetch(:display)\n end", "def _describe_property(name)\n resolved_name = _resolve_property(name)\n described_name = super(resolved_name)\n aliases = aliases_by_property.fetch(resolved_name, [])\n\n if aliases.any?\n \"#{described_name} (#{aliases.map(&:inspect).join(', ')})\"\n else\n \"#{described_name}\"\n end\n end", "def label\n \"#{@name} (#{@id})\"\n end", "def properties\n @properties ||= {}\n end", "def document_show_field_labels\n Blacklight.config[:show_fields][:labels]\n end" ]
[ "0.7063521", "0.673239", "0.67084926", "0.6521323", "0.63689876", "0.6330536", "0.63224155", "0.63149774", "0.63108414", "0.62955683", "0.6270023", "0.6207364", "0.6207364", "0.6207364", "0.6207364", "0.6207364", "0.6207364", "0.6070271", "0.6053446", "0.604648", "0.60286576", "0.60198337", "0.6016916", "0.6014553", "0.5995085", "0.59920645", "0.5970736", "0.5961196", "0.5957935", "0.59364873", "0.59325963", "0.5916366", "0.58996284", "0.58692163", "0.5868178", "0.58663046", "0.58495146", "0.5842911", "0.58413965", "0.5840049", "0.5831066", "0.5825567", "0.5824544", "0.5823031", "0.5823031", "0.5819177", "0.5817261", "0.5812272", "0.58119076", "0.5809155", "0.57799137", "0.5778102", "0.576259", "0.57592094", "0.5758523", "0.57474977", "0.5739308", "0.5737455", "0.5730999", "0.5727641", "0.57269186", "0.57174397", "0.57117057", "0.5700275", "0.56987613", "0.56788397", "0.56779623", "0.56759804", "0.5670929", "0.5670869", "0.5670869", "0.5670869", "0.5670869", "0.5670869", "0.5670869", "0.5670869", "0.5670869", "0.5656374", "0.5654703", "0.5654703", "0.5654703", "0.56538314", "0.5627477", "0.56261027", "0.5624547", "0.56184053", "0.5614035", "0.5611351", "0.5607947", "0.56028587", "0.5597021", "0.55914366", "0.5583386", "0.55756164", "0.5574042", "0.5572554", "0.5572554", "0.55707383", "0.55592906", "0.5558046", "0.5548462" ]
0.0
-1
some very, very simple testing utilities
def colorize(text, color_code); "\e[#{color_code}m#{text}\e[0m"; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests; end", "def tests; end", "def testing\n # ...\n end", "def my_tests\n end", "def test \n end", "def test_basic\n testbase = 'help'\n op = StringIO.new('', 'w')\n Dir.chdir(SRC_DIR) do \n script = File.join('data', \"#{testbase}.cmd\")\n Debugger.const_set('Version', 'unit testing')\n Debugger.run_script(script, op)\n got_lines = op.string.split(\"\\n\")\n right_file = File.join('data', \"#{testbase}.right\")\n correct_lines = File.readlines(right_file)\n result = cheap_diff(got_lines, correct_lines)\n unless result\n puts '-' * 80\n puts got_lines \n puts '-' * 80\n end\n assert result \n end\n end", "def test_should_eat()\n yay_or_nay = should_eat(\"ice cream\", \"winter\")\n assert_equal(\"False\", should_eat)\n end", "def test_case; end", "def test_cases; end", "def test\n end", "def test\n end", "def test\n end", "def test\n\n end", "def self_test; end", "def self_test; end", "def test_how_it_works \n get :how_it_works\n assert_response :success\n assert_template 'how_it_works'\n end", "def __dummy_test__\n end", "def test_truth\n end", "def test_twenty_five\n assert_equal(\"Fizz\", fizbuzz(25))\n end", "def test_make_sure_the_testing_structure_works\n make_controller :mock\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_response :success\n end", "def test_the_truth\n assert true\nend", "def test_this_works\n assert true\n end", "def test_1_good_basic_instantiation\n\n assert_nothing_raised do\n @app = Rouster.new(:name => 'app', :unittest => true)\n end\n\n assert_equal('app', @app.name)\n assert_equal(false, @app.is_passthrough?())\n assert_equal(true, @app.uses_sudo?())\n end", "def test_nothing\n end", "def assertions; end", "def assertions; end", "def test_running\n assert_equal(\"Huff puff huff puff\", Human.new(\"Zelda\").run)\n assert_equal(\"Huff puff huff puff\", Human.new(\"Mary\").run)\n end", "def self_test(switches)\n #Visual test to see if we loaded data correctly.\n switches.each do |s|\n pp s\n end\nend", "def test_nothing; end", "def spec; end", "def spec; end", "def test_setup\r\n \r\n end", "def test\n require File.expand_path(File.join(File.dirname(__FILE__), \"tests/tests\"))\n Test.run\nend", "def simpletest_tests(bs)\n #check to see if our internal description is correct.\n assert_equal [:simpletest], bs.tables.keys\n assert_equal [:id, :test], bs.tables[:simpletest].columns.keys\n #check to see if our database description is correct\n bs.connect do |db|\n assert_equal [:simpletest], db.tables\n assert_equal [:id, :test], db[:simpletest].columns\n end\n end", "def test_the_truth\n assert true\n end", "def test_the_truth\n assert true\n end", "def test_truth\r\n assert true\r\n end", "def test_truth\r\n assert true\r\n end", "def test_truth\r\n assert true\r\n end", "def test_nothing\n end", "def test_truth\n assert true\n end", "def default_test; end", "def test_bin\n Dir.chdir(File.expand_path(__dir__))\n assert_command('../bin/chuckle url_file.txt')\n end", "def default_test\r\n end", "def test_it_can_add_two_number\n calc = Calculator.new\n\n result = calc.add(2, 4)\n\n assert_equal 6, result\nend", "def test_BooksForAnAuthor\n loginRegisterBazzarVoice\n writeReview \n assert true \n end", "def testName\r\n name = Names::Name.new(\"John\", \"Paul\", \"Jones\")\r\n\r\n assert name.first == \"John\", \r\n \"first failed\"\r\n assert name.middle == \"Paul\",\r\n \"middle failed\"\r\n assert name.last == \"Jones\",\r\n \"last failed\"\r\n assert name.fullName == \"John Paul Jones\",\r\n \"fullName failed\"\r\n assert name.print == \"John Paul Jones\",\r\n \"print failed\"\r\n \r\n print \"All tests passed!\\n\"\r\nend", "def test_0_dummy\n\t\tend", "def test_results_victory\r\n assert_output(\"Going home victorious!\\n\") { @g.results(10) }\r\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end" ]
[ "0.7621492", "0.7621492", "0.74522614", "0.7120814", "0.68665767", "0.68299735", "0.6815783", "0.68124396", "0.67885554", "0.67736477", "0.67736477", "0.67736477", "0.6753268", "0.6730533", "0.6730533", "0.665581", "0.6653117", "0.6633084", "0.6626436", "0.6618002", "0.6616593", "0.6615201", "0.66019297", "0.6590921", "0.65785897", "0.65785897", "0.65757704", "0.656072", "0.6557887", "0.6541021", "0.6541021", "0.65237117", "0.65115637", "0.6494444", "0.64667416", "0.64667416", "0.6458273", "0.6458273", "0.6458273", "0.64496034", "0.64224946", "0.6420965", "0.6419603", "0.6414037", "0.6409668", "0.6407094", "0.63989985", "0.6385824", "0.637765", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695", "0.63600695" ]
0.0
-1
This is the same test but sampling with a different set of arrays that more closely resemble the data from the products table.
def test_integrate_calculation_methods_2b x = [["Router", "3", "Scan", "SLA1", "3", "99.99"], ["PC", "4", "Alert", "SLA2", "6", "199.99"]] assert_equal(1180.77, StubIntegration.new.integrate_calculation_methods_2(x)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fill_products\n i = 0\n while(i < @sample_size)\n product = possible_products[next_rand]\n @products[product.id] = product\n i += 1\n end\n @products = @products.values\n end", "def mk_products\n # create some test products\n @first_product = Product.create!(:name => \"Test product 1\")\n @second_products = Product.create!(:name => \"Test product 2\") \n @product_ids = Product.all.map(&:id)\n assert_equal(2,Product.all.size)\n [@first_product,@second_product]\n end", "def sampling_data(fun, v1=vv1, v2=vv2, repeat1=30, plan=NULL)\n len = v1.length\n data1 = Array.new(len, 0)\n len.times {|factor1|\n data1[factor1] = make_data_set(fun, v1, v2, factor1, repeat1, plan)\n }\n\n print \"sampling_data data is \\n\"\n p data1\n\n data1\nend", "def sample_products( facturama )\n sample_products_list(facturama) # Listar todos los productos\n\n sample_products_create(facturama) # Agregar producto y eliminarlo\n end", "def set_up_test(input_plates)\n input_plates.each do |plate|\n sample = plate.parts.first.sample\n plate.add_samples(Array.new(plate.get_empty.length, sample))\n end\n end", "def products\n @product = Product.includes(:images).find(params[:id])\n @products = []\n\n # Cross-Selling: derzeit noch zufällig.\n 6.times do\n offset = rand(Product.count)\n @products << Product.includes(:images).offset(offset).first\n end\n end", "def db_queries_update_generator__samples\n sample_1 = [\n \"table_sample\",\n [\n [\"A\", \"B\"], nil # set A = B\n ],\n [\n [[\"C\", \"D\"], \"<\"] # where C < D\n ]\n ]\n other_samples = db_queries_table__samples.product(\n [db_queries_operate__samples[0]], # only A = B operation makes sense\n db_queries_where__samples,\n )\n [sample_1] + other_samples\n end", "def test_calculate_total_weight\n x = [[1, 3, 3, 4, 2, 6], [1, 2, 3, 4, 3, 6]] #sample array used as product Table.\n assert_equal(12, Stub.new.calculate_total_weight(x))\n end", "def test_producto\n \t\tassert_equal(@pro3, (@pro1*@pro2))\n\t assert_equal((@ma * @a).to_s,('[[4/3,13/8],[8/3,13/4]]')) \n \tend", "def find_like_samples(collection_a, collection_b)\n collection_a.parts.map!(&:sample) & collection_b.parts.map!(&:sample)\n end", "def load_products\n @products_type[\"watermelon\"] = Creator.createProduct(:watermelon, \"watermelon\")\n @products_type[\"watermelon\"].add_pack(3, 6.99)\n @products_type[\"watermelon\"].add_pack(5, 8.99)\n\n @products_type[\"pineapple\"] = Creator.createProduct(:pineapple, \"pineapple\")\n @products_type[\"pineapple\"].add_pack(2, 9.95)\n @products_type[\"pineapple\"].add_pack(5, 16.95)\n @products_type[\"pineapple\"].add_pack(8, 24.95)\n\n @products_type[\"rockmelon\"] = Creator.createProduct(:rockmelon, \"rockmelon\")\n @products_type[\"rockmelon\"].add_pack(3, 5.95)\n @products_type[\"rockmelon\"].add_pack(5, 9.95)\n @products_type[\"rockmelon\"].add_pack(9, 16.99)\n end", "def generate_test_data\n headerrow = ['foo', 'bar', 'baz', 'qux', 'quy', 'quz'] # contents inconsequential\n merchant_name = \"foo bar\" # use for occassional repetition\n item_description = \"baz qux\"\n item_price = 100\n # proc to generate a row of data with occassional repetition as per values above\n rowgen = Proc.new { [Faker::Name.name, [Faker::Commerce.product_name, item_description].sample, [Faker::Number.number(3), item_price].sample, (1..100).to_a.sample, Faker::Address.street_address, [Faker::Company.name, merchant_name].sample] }\n data = [ headerrow ]\n (0..(rand(100)+20)).each{ data << rowgen.call } # generate random number of rows\n data\nend", "def create_sample_array\n sample_array = []\n\n\n # add songs to sample-array in correct ratios\n @spins_per_week.each do |k,v|\n v.times { sample_array.push(PL::db.get_song(k)) }\n end\n\n sample_array\n end", "def pending_test_prod_tr_ids\r\n prods = Product.find(1, 2)\r\n assert_equal 2, prods.length\r\n assert_equal \"first-product\", prods[0].code\r\n assert_equal \"second-product\", prods[1].code\r\n assert_equal \"these are the specs for the first product\",\r\n prods[0].specs \r\n assert_equal \"This is a description of the first product\",\r\n prods[0].description \r\n assert_equal \"these are the specs for the second product\",\r\n prods[1].specs\r\n end", "def build_sample\n sample = Array.new(8) {Array.new(8)}\n sample[0][0] = King.new(0, 0, 0)\n sample[7][7] = King.new(7, 7, 1)\n sample[0][4] = Rook.new(0, 4, 1)\n sample[4][0] = Rook.new(4, 0, 1)\n sample[4][4] = Bishop.new(4, 4, 1)\n sample\nend", "def fill_in_products\n products = []\n @data.products.all_products.each_with_index do |p, i|\n prod = {}\n prod['index'] = i\n prod['qty'] = @data.product_qty[p.prd_id]\n prod['desc'] = p.prd_long_desc\n prod['price'] = \"$\" + p.fmt_total_price\n prod['prd_id'] = p.prd_id\n products << prod\n end\n \n products\n end", "def choose_from_things(array_of_items)\n array_of_items.sample\n end", "def products_data\n $products_hash[\"items\"].each do |toy|\n # toy_result = calculate_products_data(toy)\n print_products_data(toy)\n end\n end", "def pending_test_prod_tr_ids\n prods = Product.find(1, 2)\n assert_equal 2, prods.length\n assert_equal \"first-product\", prods[0].code\n assert_equal \"second-product\", prods[1].code\n assert_equal \"these are the specs for the first product\",\n prods[0].specs\n assert_equal \"This is a description of the first product\",\n prods[0].description\n assert_equal \"these are the specs for the second product\",\n prods[1].specs\n end", "def test_all_products\n all_products = @product.get_all_products\n # test returns array\n assert_instance_of(Array, all_products)\n end", "def ProductTablesTest()\n puts \"\\n Products:\"\n Init()\n ViewProducts()\n end", "def remix(ingredient_arrays)\n \n mixers = []\n \n ingredient_arrays.each do |array|\n mixers << array[1]\n end\n \n ingredient_arrays.each do |array|\n idx = rand(mixers.length)\n array[1] = mixers[idx]\n mixers.delete_at(idx)\n end\n \n return ingredient_arrays\n \nend", "def test_products()\n assert_equal(1, @manufacturer1.products.length())\n end", "def sample_data\n %w(A,B,1 A,C,2 B,C,3 B,D,3 C,D,1 B,E,2 D,F,3 D,E,3 E,G,3 F,G,1)\n end", "def samples; end", "def samples; end", "def test_should_sample_evenly\n buffer = NewRelic::Agent::SampledBuffer.new(5)\n results = []\n\n 10000.times do\n buffer.reset\n 10.times { |i| buffer << i }\n results << buffer.to_a\n end\n\n (0...10).each do |v|\n num_results_including_v = results.select { |r| r.include?(v) }.size\n assert_in_delta(0.5, num_results_including_v.to_f / results.size, 0.05)\n end\n end", "def setup_test(operations, ot_type_name)\n operations.make\n operations.each do |op|\n output_collection = op.output('PCR Plate').collection\n rows = output_collection.dimensions[0]\n sample_names = ['RP', '2019-nCoVPC_N1', '2019-nCoVPC_N2']\n (rows/(sample_names.length)).times do\n sample_names.each do |name|\n collection = Collection.new_collection(ot_type_name)\n samples = Array.new(collection.dimensions[0], Sample.find_by_name(name))\n collection.add_samples(samples)\n end\n end\n end\n end", "def initialize_deck\n SUITS.product(VALUES).shuffle\nend", "def sample_question\n get_all_from_database.sample\n end", "def search_for_products_modified(n = 1000)\n if n > Product.count\n puts puts \"Number of queries requested was greater than number of product records, using maximum number\"\n n = Product.count\n end\n\n disable_activerecord_sql_logging()\n keywords_arrays = ALL_BRANDS.map { |brand| brand.split(\" \") }\n keywords_arrays = Product.all.pluck(:name).shuffle.take(n).map { |name| name.downcase.split(\" \") }\n keywords_arrays = keywords_arrays.map { |kw_arr| kw_arr.take(rand(5..kw_arr.length)) }\n\n puts \"\\nBenchmark for performing #{n} queries:\"\n puts \"Sample query: #{keywords_arrays.first}\", \"\"\n\n benchmark_block(keywords_arrays)\n\n enable_activerecord_sql_logging()\nend", "def initialize_deck\n VALUES.product(SUITS).shuffle\nend", "def test_2022_batch_values\n hash = extract_result\n\n assert_includes hash[2][6], \"Daris\"\n assert_includes hash[3][5], \"Aurika\"\n assert_includes hash[3][17], \"Gerhards\"\n assert_includes hash[4][6], \"Dzintis\"\n assert_includes hash[4][20], \"Meija\"\n assert_includes hash[4][23], \"Jurgita\"\n assert_includes hash[9][17], \"Vaiva\"\n assert_includes hash[9][29], \"Jumis\"\n assert_includes hash[11][7], \"Pērle\"\n assert_includes hash[12][3], \"Ako\"\n end", "def generateCart\n cart = []\n rand(20).times do\n cart.push(ITEMS.sample)\n end\n ap cart \nend", "def productify(array)\n\nend", "def products\n @products.map{|prouduct, num| (1..num).map{|i| prouduct}}.flatten\n end", "def product_photo\n photos = []\n self.products.each do |product|\n photos << product.photo\n end\n return photos.sample\n end", "def sample\n @data.keys.sample\n end", "def db_seed\n\tbrand = []\n\tproducts_names = []\n\tprices = []\n\tarray = []\n\t10.times do |i|\n\t\tbrand.push(Faker::Commerce.department)\n\t\tproducts_names.push(Faker::Commerce.product_name)\n\t\tprices.push(Faker::Commerce.price)\n\t\tProduct.create(id:i,brand:brand[i],name:products_names[i],price:prices[i])\n\tend\t\nend", "def test_should_show_different_display_price_if_have_variations\n # Test a product without variations.\n a_grenade = items(:holy_grenade)\n assert_equal a_grenade.variations.count, 0\n assert_equal a_grenade.display_price, a_grenade.price\n # Test a product with variations.\n a_lightsaber = items(:lightsaber)\n assert_equal a_lightsaber.variations.count, 3\n assert_equal a_lightsaber.quantity, a_lightsaber.variations.sum(:quantity)\n a_lightsaber_0 = a_lightsaber.variations[0]\n a_lightsaber_1 = a_lightsaber.variations[1]\n a_lightsaber_2 = a_lightsaber.variations[2]\n # Test with different prices.\n assert_not_equal a_lightsaber_0.price, a_lightsaber_1.price\n assert_not_equal a_lightsaber_0.price, a_lightsaber_2.price\n assert_not_equal a_lightsaber_1.price, a_lightsaber_2.price\n assert_equal a_lightsaber.display_price[0], a_lightsaber.variations.min {|a,b| a.price <=> b.price }.price\n assert_equal a_lightsaber.display_price[1], a_lightsaber.variations.max {|a,b| a.price <=> b.price }.price\n # Test with equal prices.\n a_lightsaber_0.price = 10.00\n assert a_lightsaber_0.save\n a_lightsaber_1.price = 10.00\n assert a_lightsaber_1.save\n a_lightsaber_2.price = 10.00\n assert a_lightsaber_2.save\n assert_equal a_lightsaber.display_price, a_lightsaber.variations.min {|a,b| a.price <=> b.price }.price\n end", "def generate_related_products\n related_product_scores.delete_all\n\n purchase_counts = Hash.new(0)\n\n orders.uniq.each do |order|\n order\n .order_lines\n .where(\"product_id != #{id} AND product_id IS NOT NULL\")\n .pluck(:product_id)\n .uniq\n .each { |product_id| purchase_counts[product_id] += 1 }\n end\n\n scores = purchase_counts.map { |product_id, purchased|\n [product_id, relatedness(orders.count, purchased)]\n }.to_h\n\n scores.each_pair do |related_id, score|\n RelatedProductScore.create(product_id: id, related_product_id: related_id, score: score)\n end\n end", "def multiply_all_pairs(array_1, array_2)\n products = []\n array_1.each do |item_1|\n array_2.each do |item_2|\n products << item_1 * item_2\n end\n end\n products.sort\nend", "def test_grouping_bundle_multiple\n\n i1 = CartItem.create(:product_id => 3)\n i2 = CartItem.create(:product_id => 2)\n i3 = CartItem.create(:product_id => 4)\n i4 = CartItem.create(:product_id => 5)\n\n groups = CartGroup.groups_for_items([i1, i2, i3, i4])\n\n assert_equal(1, groups.size)\n\n assert_equal(4, groups[0].size)\n assert_equal(3, groups[0][0].product_id)\n assert_equal(2, groups[0][1].product_id)\n assert_equal(4, groups[0][2].product_id)\n assert_equal(5, groups[0][3].product_id)\n assert_equal(3, groups[0].sorted_items[0].product_id)\n assert_equal(2, groups[0].sorted_items[1].product_id)\n assert_equal(5, groups[0].sorted_items[2].product_id)\n assert_equal(4, groups[0].sorted_items[3].product_id)\n assert(groups[0].bundle_discount?)\n assert(!groups[0].set_discount?)\n assert_equal(BigDecimal('43.97'), groups[0].total)\n assert_equal(ApplicationHelper.round_currency(BigDecimal('10.99')), ApplicationHelper.round_currency(groups[0].savings))\n groups[0].items_with_prices do |item, price|\n assert_equal(BigDecimal('0.00'), price) if item.product.id == 2\n assert_equal(BigDecimal('0.00'), price) if item.product.id == 3\n assert_equal(BigDecimal('0.00'), price) if item.product.id == 5\n assert_equal(BigDecimal('43.97'), price) if item.product.id == 4\n end\n\n end", "def multiply_all_pairs(array1, array2)\n products = []\n array1.each do |item1|\n array2.each do |item2|\n products << item1 * item2\n end\n end\n products.sort\nend", "def pick_test_set\n $all_avail_genes = deep_copy_hash $all_genes\n $all_avail_pat = deep_copy_hash $all_pat\n \n # randomly withhold 10% of the patients\n $HIDE_PERCENT = 0.1\n pick_patients\n \n # use the remaining 90% for range alpha runs\n $all_avail_genes = deep_copy_hash $genes\n $all_avail_pat = deep_copy_hash $avail_pat\n $test_pat = deep_copy_hash $hide_pat\n \n # next hide 20% for validation set\n $HIDE_PERCENT = 0.2\nend", "def test_that_grid_generation_is_accurate\n end", "def e1334_random_bag (values)\n end", "def benchmark_block(keywords_arrays)\n Benchmark.bmbm do |x|\n x.report(\"relation w/ 2 joins:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_tags(*kw_arr) } }\n x.report(\"relation w/ 3 queries:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_tags_v2(*kw_arr) } }\n x.report(\"relation w/ 2 subq:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_tags_v3(*kw_arr) } }\n x.report(\"relation w/ 1 subq, 2 joins:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_tags_with_subqueries(*kw_arr) } }\n x.report(\"jsonb w/ 1 subq:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_jsonb_v2(kw_arr) } }\n x.report(\"array w/ 1 subq:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_array_v2(kw_arr) } }\n x.report(\"hstore w/ 1 subq:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_hstore_v2(kw_arr) } }\n x.report(\"jsonb w/ 2 queries:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_jsonb(kw_arr) } }\n x.report(\"hstore w/ 2 queries:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_hstore(kw_arr) } }\n x.report(\"array w/ 2 queries:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_array(kw_arr) } }\n end\nend", "def test_should_associate_products_by_ids\n # Load some products and see if it really don't have any related products.\n a_coat = items(:chinchilla_coat)\n a_towel = items(:towel)\n a_stuff = items(:the_stuff)\n assert_equal a_coat.related_products.count, 0\n assert_equal a_towel.related_products.count, 0\n assert_equal a_stuff.related_products.count, 0\n\n# # Associate one with the others and all must know about that.\n# # TODO: a_soap.related_product_ids should receive ids but its not doing that.\n# a_coat.related_product_ids = [ a_towel.id, a_stuff.id ]\n# assert_equal a_coat.related_products.count, 2\n# assert_equal a_towel.related_products.count, 1\n# assert_equal a_stuff.related_products.count, 1\n\n # Clear all and verify.\n a_coat.related_products.clear\n assert_equal a_coat.related_products.count, 0\n assert_equal a_towel.related_products.count, 0\n assert_equal a_stuff.related_products.count, 0\n end", "def generate_products\n departments = Department.all\n promo_codes = PromoCode.all\n prng = Random.new\n\n 10_000.times do\n promo_code = promo_codes.first\n\n if prng.rand(1..2) == 1\n promo_code = promo_codes[prng.rand(promo_codes.length)]\n end\n\n Product.create(\n name: Faker::Commerce.unique.product_name,\n price: Faker::Commerce.price,\n department: departments[prng.rand(departments.length)],\n promo_code: promo_code\n )\n end\n# Just in case Faker has less data than I imagine\nrescue Faker::UniqueGenerator::RetryLimitExceeded\nend", "def db_queries_table__samples\n [\n \"table1\",\n \"table2\"\n ]\n end", "def random_products_by_product_type(n=8)\n skope = presentable.randomize.limit(n)\n \n (ActiveSupport::OrderedHash.new).tap do |hasz|\n taxon_names.each do |taxon_name|\n taxon = Spree::Taxon.find_by_name(taxon_name)\n hasz[taxon] = skope.in_taxon(taxon) unless taxon.nil?\n end\n end\n end", "def sample_variance\n @mutex.synchronize do\n @M_2 / (@items - 1)\n end\n end", "def gather_data\n\t\tmain_data = $products_hash['items'][0..-1]\n\t\tunique_brands = main_data.map { |item| item['brand']}.uniq # only unique brands for the brands section\n\t\tbrands_data_hash = [] # empty array which will be filled with data from products ...\n products_data_hash = [] # ... and brands\n unique_brands.each do |brands|\n\t\t\tall_brand_products = main_data.select { |product| product['brand'] == brands} # only select one brand\n\t\t\tbrand_stocks = brand_total_purchases = brand_total_sales = 0\n\t\t\tall_brand_products.each do |brand_product| # loop through product of the brand\n\t\t\t\t\t\t### creating products hash\n\t\t\t\t\t\tproducts_data_hash.push(_products_data(brand_product))\n\t\t\t\t\t\t### brand aggregations for later use\n\t\t\t\t\t\tbrand_stocks += products_data_hash[-1][:stock]\n\t\t\t\t\t\tbrand_total_purchases += products_data_hash[-1][:total_purchases]\n\t\t\t\t\t\tbrand_total_sales += products_data_hash[-1][:total_sales]\n\t\t\tend\n\t\t\t### creating brand hash\n\t\t\tbrands_data_hash.push(_brands_hash(brands,brand_stocks,brand_total_purchases,brand_total_sales))\n\t\tend\n return products_data_hash, brands_data_hash\nend", "def products\n @products ||= [].tap { |prods| each { |prod| prods << prod } }\n end", "def multiply_all_pairs(arr1, arr2)\n\tproducts = []\n\n\tarr1.each do |num1|\n\t\tarr2.each do |num2|\n\t\tproducts << num1 * num2\n\t\tend\n\tend\n\tproducts.sort\nend", "def get_products_section_data(products) # No Side Effects\n products.map do |product|\n {\n product_title: product_title(product), \n retail_price: retail_price(product),\n total_purchases: total_purchases(product),\n total_sales: total_sales(product),\n avg_price: avg_price(product),\n avg_discount: avg_discount(product).round(2)\n }\n end\nend", "def test_using_random_sample\n @filelist = nil\n sublist = sample_from( self.filelist ) \n results = test_using_sublist( sublist )\n output.puts \"Test Using Random Sample\".center(72)\n output.puts \"=\" * 72\n report_results( results )\n\n end", "def sample_with_replacement(sample=1)\n if @data.respond_to? :sample_with_replacement\n @data.sample_with_replacement sample\n else\n valid = indexes(*Daru::MISSING_VALUES).empty? ? self : reject_values(*Daru::MISSING_VALUES)\n vds = valid.size\n (0...sample).collect { valid[rand(vds)] }\n end\n end", "def compute_matching_product(among_products) among_products.select { |product| concern?(product, among_products) } end", "def multiply_all_pairs(array1, array2)\n # using 2 loops\n # products = []\n # array_1.each do |item_1|\n # array_2.each do |item_2|\n # products << item_1 * item_2\n # end\n # end\n # products.sort\n array1.product(array2).map { |subarray| subarray.reduce(:*) }.sort\nend", "def multiply_all_pairs(arr1, arr2)\n products = []\n arr1.each do |arr1_num|\n arr2.each do |arr2_num|\n products << arr1_num * arr2_num\n end\n end\n products.sort\nend", "def cartProd\n @items = []\n @arr1.each{ |a|\n @arr2.each{ |b|\n item = [] << a << b\n @items << item\n }\n }\n end", "def get_products_improved(arr)\n product_array = Array.new(arr.length)\n product = 1\n\n i = 0\n while i < arr.length\n product_array[i] = product\n product *= arr[i]\n i += 1\n end\n\n product = 1\n i = arr.length - 1\n while i >= 0\n product_array[i] *= product\n product *= arr[i]\n i -= 1\n end\n\n product_array\n\nend", "def multiply_all_pairs(array1, array2)\n products = []\n array1.each do |num1|\n array2.each do |num2|\n products << num1 * num2\n end\n end\n products.sort\nend", "def multiply_all_pairs(num_arr1, num_arr2)\n product_arr = []\n\n num_arr1.each do |x|\n num_arr2.each do |y|\n product_arr << x * y\n end\n end\n product_arr.sort\nend", "def real_variants\n Product.where(openerp_id: product_variants.collect(&:openerpid)).order('id ASC').uniq\n end", "def product_array(pixel_array_1,pixel_array_2)\n \tpixel_array_sq_img1x2 = []\n \tpixel_array_1.each_with_index do |array_pixel,i|\n \t\tnew_array = []\n \t\tarray_pixel.each_with_index do |number,j|\n \t\t\tnew_array[j] = pixel_array_1[i][j] * pixel_array_2[i][j]\n \t\t\t#pixel_array_sq_img1x2[i][j] = \n \t\tend\n \t\tpixel_array_sq_img1x2[i] = new_array\n \tend\n\n \treturn pixel_array_sq_img1x2\n end", "def expand\r\n @ary.sample\r\n end", "def generateCart\n cart = []\n rand(20).times do\n cart.push(ITEMS.sample) \n end\n cart\nend", "def diff_digests(old_products, new_products)\n # create maps of product sets\n old_map, new_map = [old_products, new_products].map do |products|\n return [] unless products\n Hash[*products.flat_map { |d| [d.product, d] }]\n end\n\n build_diff(new_map, old_map)\n end", "def test_valid_products\n trello = load_conf(TrelloHelper, @config.trello, true)\n assert_equal(['product2', 'product3', 'product1'], trello.valid_products)\n end", "def products_of_all_ints_except_index_on2(int_arr=[])\n\t\tproducts = []\n\t\t# iterate over int_array\n\t\t# calculate the products except index and shuffle in\n\t\t#[1, 7, 3, 4]\n\n\t\tint_arr.each_with_index do |outer_int, outer_index|\n\t\t\t#[1, 7, 3, 4]\n\t\t\tproduct = 1\n\t\t\tint_arr.each_with_index do |inner_int, inner_index|\n\t\t\t\tnext if outer_index == inner_index\n\t\t\t\tproduct *= inner_int\n\t\t\tend\n\t\t\tproducts << product\n\t\tend\n\t\tproducts\n\tend", "def test_scenario1\n data = [\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\", \n \"method\" => 0,\n \"prediction\" => \"a\",\n\t \"confidence\" => 0.450471270879},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\",\n \"method\" => 1,\n \"prediction\" => \"a\",\n \"confidence\" => 0.552021302649},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\",\n \"method\" => 2,\n \"prediction\" => \"a\",\n \"confidence\" => 0.403632421178},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 0,\n \"prediction\" => 1.55555556667, \n \"confidence\" => 0.400079152063},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 1,\n \"prediction\" => 1.59376845074,\n \"confidence\" => 0.248366474212},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 2,\n \"prediction\" => 1.55555556667,\n \"confidence\" => 0.400079152063}\n ]\n\n puts \"Scenario: Successfully computing predictions combinations\"\n data.each do |item|\n puts\n\n puts \"Given I create a MultiVote for the set of predictions in file <%s>\" % item[\"filename\"]\n multivote = BigML::MultiVote.new(JSON.parse(File.open(item[\"filename\"], \"rb\").read))\n\n puts \"When I compute the prediction with confidence using method <%s>\" % item[\"method\"]\n combined_results = multivote.combine(item[\"method\"], nil, true)\n\n puts \"And I compute the prediction without confidence using method <%s>\" % item[\"method\"] \n combined_results_no_confidence = multivote.combine(item[\"method\"])\n\n if multivote.is_regression() \n puts \"Then the combined prediction is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results[\"prediction\"].round(6), item[\"prediction\"].round(6))\n puts \"And the combined prediction without confidence is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results_no_confidence.round(6), item[\"prediction\"].round(6))\n else\n puts \"Then the combined prediction is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results[\"prediction\"], item[\"prediction\"])\n puts \"And the combined prediction without confidence is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results_no_confidence,item[\"prediction\"])\n end\n puts \"And the confidence for the combined prediction is %s \" % item[\"confidence\"]\n assert_equal(combined_results[\"confidence\"].round(5), item[\"confidence\"].round(5)) \n end\n\n end", "def test_grouping_bundle\n\n i1 = CartItem.create(:product_id => 1)\n i2 = CartItem.create(:product_id => 2)\n i3 = CartItem.create(:product_id => 4)\n i4 = CartItem.create(:product_id => 5)\n\n groups = CartGroup.groups_for_items([i1, i2, i3, i4])\n\n assert_equal(2, groups.size)\n\n assert_equal(1, groups[0].size)\n assert_equal(1, groups[0][0].product_id)\n\n assert_equal(3, groups[1].size)\n assert_equal(2, groups[1][0].product_id)\n assert_equal(4, groups[1][1].product_id)\n assert_equal(5, groups[1][2].product_id)\n assert(groups[1].bundle_discount?)\n assert(!groups[1].set_discount?)\n assert_equal(ApplicationHelper.round_currency(BigDecimal('31.98')), ApplicationHelper.round_currency(groups[1].total))\n assert_equal(ApplicationHelper.round_currency(BigDecimal('7.99')), ApplicationHelper.round_currency(groups[1].savings))\n groups[1].items_with_prices do |item, price|\n assert_equal(BigDecimal('0.00'), price) if item.product.id == 2\n assert_equal(BigDecimal('0.00'), price) if item.product.id == 5\n assert_equal(BigDecimal('31.98'), price) if item.product.id == 4\n end\n\n end", "def tested_products\n return self.products.select do |product|\n product.incomplete_tests.count == 0\n end\n end", "def test_scenario2\n data = [{'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'tlp' => 1,\n 'local_file' => File.dirname(__FILE__)+'/tmp/batch_predictions.csv',\n 'predictions_file' => File.dirname(__FILE__)+'/data/batch_predictions_e.csv',\n 'params' => {\"combiner\" => 0}},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'tlp' => 1,\n 'local_file' => File.dirname(__FILE__)+'/tmp/batch_predictions.csv',\n 'predictions_file' => File.dirname(__FILE__)+'/data/batch_predictions_e_c1.csv',\n 'params' => {\"combiner\" => 1, \"confidence\" => true}},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'tlp' => 1,\n 'local_file' => File.dirname(__FILE__)+'/tmp/batch_predictions.csv',\n 'predictions_file' => File.dirname(__FILE__)+'/data/batch_predictions_e_c2.csv',\n 'params' => {\"combiner\" => 2, \"confidence\" => true}},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'tlp' => 1,\n 'local_file' => File.dirname(__FILE__)+'/tmp/batch_predictions.csv',\n 'predictions_file' => File.dirname(__FILE__)+'/data/batch_predictions_e_o_k_v.csv',\n 'params' => {\"operating_kind\" => \"votes\", \"confidence\" => true}},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'tlp' => 1,\n 'local_file' => File.dirname(__FILE__)+'/tmp/batch_predictions.csv',\n 'predictions_file' => File.dirname(__FILE__)+'/data/batch_predictions_e_o_k_p.csv',\n 'params' => {\"operating_kind\" => \"probability\", \"probability\" => true}},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'tlp' => 1,\n 'local_file' => File.dirname(__FILE__)+'/tmp/batch_predictions.csv',\n 'predictions_file' => File.dirname(__FILE__)+'/data/batch_predictions_e_o_k_c.csv',\n 'params' => {\"operating_kind\" => \"confidence\", \"confidence\" => true}}\n ]\n\n puts\n puts \"Scenario: Successfully creating a batch prediction for an ensemble\"\n\n data.each do |item|\n puts\n puts \"Given I create a data source uploading a #{item['filename']} file\"\n source = @api.create_source(item[\"filename\"], {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset with local source\"\n [email protected]_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"And I create an ensemble of #{item['number_of_models']} models and #{item['tlp']} tlp\"\n # \"tlp\"=> item[\"tlp\"]\n ensemble = @api.create_ensemble(dataset, {\"number_of_models\"=> item[\"number_of_models\"], \"seed\" => 'BigML', 'ensemble_sample'=>{'rate' => 0.7, 'seed' => 'BigML'}, 'missing_splits' => false})\n\n puts \"And I wait until the ensemble is ready\"\n assert_equal(BigML::HTTP_CREATED, ensemble[\"code\"])\n assert_equal(@api.ok(ensemble), true)\n\n puts \"When I create a batch prediction for the dataset with the ensemble and params <%s>\" % JSON.generate(item['params'])\n batch_prediction = @api.create_batch_prediction(ensemble, dataset, item['params'])\n\n puts \"And I wait until the batch prediction is ready\"\n assert_equal(BigML::HTTP_CREATED, batch_prediction[\"code\"])\n assert_equal(@api.ok(batch_prediction), true) \n\n puts \"And I download the created predictions file to #{item['local_file']}\"\n filename = @api.download_batch_prediction(batch_prediction, item[\"local_file\"])\n assert_not_nil(filename)\n\n puts \"Then the batch prediction file is like #{item['predictions_file']}\"\n assert_equal(FileUtils.compare_file(item[\"local_file\"], item[\"predictions_file\"]), true)\n\n\n end\n\n end", "def test_create_product_formula\n \n end", "def create_group(array)\nunit1=array.shuffle!.each_slice(4).to_a\nunit2=array.shuffle!.each_slice(4).to_a\nunit3=array.shuffle!.each_slice(4).to_a\nputs \"Unit1: #{unit1.to_s} Unit2: #{unit2.to_s} Unit3: #{unit3.to_s}\"\nend", "def selector(array)\n array.sample\n end", "def random\n @shop = Shop.find(params[:shop_id])\n @random = @shop.items.all.sample\n end", "def expected_results_with_all_supplemental_codes\n # Since this is a CMS IG requirement, only do this for CVU+ or C3 tests\n return expected_results unless product.cvuplus? || product.c3_test?\n\n required_codes = { 'PAYER' => %w[1 2 6 349], 'SEX' => %w[M F], 'RACE' => %w[2106-3 2076-8 2054-5 2028-9 1002-5 2131-1],\n 'ETHNICITY' => %w[2135-2 2186-5] }.freeze\n new_hash = expected_results\n new_hash.each do |_measure_id, pop_set_hash|\n pop_set_hash.each do |_pop_set_id, pop_set|\n sup_data = pop_set['supplemental_data']\n %w[IPP DENOM NUMER NUMEX DENEX DENEXCEP MSRPOPL MSRPOPLEX].each do |pop_key|\n next unless pop_set[pop_key]\n\n sup_data[pop_key] = { 'RACE' => {}, 'ETHNICITY' => {}, 'SEX' => {}, 'PAYER' => {} } unless sup_data[pop_key]\n required_codes.each do |sup_data_type, codes|\n codes.each do |code|\n sup_data[pop_key][sup_data_type][code] = 0 unless sup_data[pop_key][sup_data_type][code]\n end\n end\n end\n end\n end\n new_hash\n end", "def generate_inventory(products, below_threshold = false, new_form_warehouse = false)\n products.each do |product|\n count = if new_form_warehouse\n 0\n elsif below_threshold\n rand(1..THRESHOLD_LIMIT - 1)\n else\n rand(THRESHOLD_LIMIT + 1..50)\n end\n inventory.create!(product: product, item_count: count, low_item_threshold: THRESHOLD_LIMIT)\n end\n end", "def find_subsampled_data_arrays\n self.find_all_data_arrays.where(:subsample_threshold.nin => [nil], :subsample_annotation.nin => [nil])\n end", "def test_with_irregular_array2D1; show([[0.1,0.9], [0.5]]) end", "def samples_values\n %w(\n 7-84794-00160-2\n 0-85798-02872-6\n 8-92675-00010-8\n 0-97546-10200-8\n 7-29469-63104-3\n 7-26299-10020-6\n 0-87447-21872-4\n 0-88593-12002-2\n 0-80696-09642-6\n 7-33952-99710-3\n 0-87110-31277-3\n 0-13357-80199-2\n 6-64228-48662-8\n 0-29679-36042-0\n 0-83085-30096-8\n 0-85000-01163-8\n 7-26299-10020-6\n 8-53739-00002-1\n 6-52935-10001-2\n 0-83085-90701-3\n 0-89819-79688-5\n 0-10986-00303-2\n 0-85000-01213-0\n 8-43700-203230\n 1-88985-00013-7\n 8-437004-998163\n 0-87396-00410-2\n 8-435053-384036\n 0-82896-78040-2\n 0-89636-46000-6\n 0-85000-01211-6\n 0-18138-20902-8\n 0-87512-92005-7\n 0-80887-49374-4\n 0-80732-24701-0\n 0-85000-01054-9\n 0-83300-09551-8\n 0-85000-0103702\n 0-88534-00143-4\n 0-81308-83747-5\n 0-31259-01849-2\n 8-92186-00025-3\n 0-88593-10005-5\n 8-51718-00002-4\n 0-83837-00616-2\n 0-83085-20022-0\n 0-40426-99251-0\n 8-53763-00102-5\n 0-88553-09349-6\n 0-96619-66555-6\n 7-26319-10001-8\n 0-87356-40512-3\n 0-00579-00005-0\n 0-71570-02009-5\n 0-81753-05020-7\n 0-85155-00003-7\n 7-28691-44674-6\n 0-21130-51506-6\n 0-87512-92005-7\n 0-12894-84511-7\n 7-15126-00001-7\n 0-18138-20902-8\n 0-80887-49385-0\n 0-12354-08770-5\n 0-12354-08765-1\n 7-24826-02125-3\n 0-89121-18852-1\n 0-80696-05750-2\n 0-98652-90000-7\n 8-58517-00043-9\n 8-58517-00048-4\n 0-18138-20903-5\n 7-18742-00005-8\n 0-00579-00005-0\n 0-88232-00261-0\n 0-99988-07109-6\n 0-88534-00143-4\n 8-19960-00021-6\n 7-17888-79112-7\n \n )\n end", "def g5_games(teams)\n games = Array.new\n teams.each do |team|\n 2.times do\n games << [team, G5_RATINGS.sample]\n end\n end\n\n games\nend", "def array_product_bruteforce(a)\r\n\tprod = Array.new(a.size)\r\n\ti = 0\r\n\r\n\twhile i < a.size\r\n\t\tc = a[0..a.size]\r\n\t\tc.delete_at(i)\r\n\t\tprod[i] = c.inject(:*)\r\n\t\ti += 1\r\n\tend\r\n\treturn prod\r\nend", "def multiply_all_pairs(arr1, arr2)\n product = []\n count = 0\n\n until count == arr1.size\n arr2.each do |item|\n product << arr1[count] * item\n end\n count +=1\n end\n product.sort\nend", "def get_brands_section_data(products) # No Side Effects\n products_brands(products).map do |brand_name|\n products_in_brand = products_in_brand(products, brand_name)\n {\n brand_name: brand_name,\n no_of_products: products_no_of_products(products_in_brand),\n avg_price: products_avg_price(products_in_brand).round(2),\n total_sales: products_total_sales(products_in_brand).round(2)\n }\n end \nend", "def product( *other_arrays, & block )\n\n load_parent_state\n \n return super\n\n end", "def get_other_products(nums)\n nums_copy = nums.dup\n other_products = Array.new(nums.length)\n\n nums.each_with_index do | num, curr_idx |\n nums_copy.delete_at(curr_idx)\n other_products[curr_idx] = nums_copy.reduce(:*)\n nums_copy = nums.dup\n end\n return other_products\nend", "def test_should_show_different_quantity_if_have_variations\n # Test a product without variations.\n a_grenade = items(:holy_grenade)\n assert_equal a_grenade.variations.count, 0\n assert_equal a_grenade.quantity, a_grenade.attributes['quantity']\n # Test a product with variations.\n a_lightsaber = items(:lightsaber)\n assert_equal a_lightsaber.variations.count, 3\n assert_equal a_lightsaber.quantity, a_lightsaber.variations.sum(:quantity)\n end", "def fill_catalogue()\n @@products.clear\n add_product(Fruit.new(\"Apples\", 10))\n add_product(Fruit.new(\"Oranges\", 5))\n add_product(Fruit.new(\"Banana\", 20))\n add_product(Fruit.new(\"Watermelon\", 1))\n add_product(Houseware.new(\"Vacuum cleaner\", 150))\n add_product(Product.new(\"Anchovies\",2))\n end", "def getInts(pep)\n rt_helper = RetentionTime::Helper\n pep_id = pep[0]\n p_int = pep[7] + rt_helper.RandomFloat(-5,2)\n if p_int > 10\n p_int -= 10\n end\n predicted_int = (p_int * 10**-1) * 14183000.0 \n low = 0.1*predicted_int\n relative_ints = (@db.execute \"SELECT ints FROM core_spec WHERE pep_id=#{pep_id}\").flatten[0].gsub(/\\[/,\"\").split(/,/).map{|val| val.to_f}\n core_mzs = (@db.execute \"SELECT mzs FROM core_spec WHERE pep_id=#{pep_id}\").flatten[0].gsub(/\\[/,\"\").split(/,/).map{|val| val.to_f}\n avg = pep[5] #p_rt\n\n sampling_rate = @opts[:sampling_rate].to_f\n wobA = Distribution::Normal.rng(@opts[:wobA].to_f,0.0114199604).call #0.0014199604 is the standard deviation from Hek_cells_100904050914 file\n wobB = Distribution::Normal.rng(@opts[:wobB].to_f,0.01740082).call #1.20280082 is the standard deviation from Hek_cells_100904050914 file\n tail = Distribution::Normal.rng(@opts[:tail].to_f,0.018667495).call #0.258667495 is the standard deviation from Hek_cells_100904050914 file\n front = Distribution::Normal.rng(@opts[:front].to_f,0.01466692).call #4.83466692 is the standard deviation from Hek_cells_100904050914 file\n # These number didn't work. May need to get more samples or figure something else out. For now this will give us some\n # meta variance in any case\n mu = @opts[:mu].to_f\n\n index = 0\n sx = pep[9]\n sy = (sx**-1) * Math.sqrt(pep[8]) #abu\n\n shuff = rt_helper.RandomFloat(0.05,1.0)\n core_mzs.each_with_index do |mzmu,core_idx|\n\n relative_abundances_int = relative_ints[index]\n\n t_index = 1\n\n (Mspire::Simulator::Spectra::r_times[pep[10]..pep[11]]).each_with_index do |rt,i| \n\n\n if !@one_d\n #-------------Tailing-------------------------\n shape = (tail * (t_index / sx)) + front\n int = (rt_helper.gaussian((t_index / sx) ,mu ,shape,100.0))\n t_index += 1\n #---------------------------------------------\n\n else\n #-----------Random 1d data--------------------\n int = (relative_abundances_int * ints_factor) * shuff\n #---------------------------------------------\n end\n\n if int < 0.01\n int = rt_helper.RandomFloat(0.001,0.4)\n end\n\n=begin\n if !@one_d\n #-------------M/Z Peak shape (Profile?)-------\n fraction = rt_helper.gaussian(fin_mzs[i],mzmu,0.05,1)\n factor = fraction/1.0\n fin_ints[i] = fin_ints[i] * factor\n #---------------------------------------------\n end\n=end\t \n\n if int > 0.4\n #-------------Jagged-ness---------------------\n sd = (@opts[:jagA] * (1-Math.exp(-(@opts[:jagC]) * int)) + @opts[:jagB])/2\n diff = (Distribution::Normal.rng(0,sd).call)\n int += diff\n #---------------------------------------------\n end\n\n #-------------mz wobble-----------------------\n wobble_mz = nil\n if int > 0\n wobble_int = wobA*int**wobB\n wobble_mz = Distribution::Normal.rng(mzmu,wobble_int).call\n if wobble_mz < 0\n wobble_mz = 0.01\n end\n end\n #---------------------------------------------\n\n\n int = int*(predicted_int*(relative_abundances_int*10**-2)) * sy\n if int > low.abs and wobble_mz > 0\n @db.execute \"INSERT INTO spectra VALUES(#{@cent_id},#{pep_id},#{rt},#{wobble_mz},#{int},NULL,#{core_idx})\"\n# @db.execute \"INSERT INTO spectra VALUES(#{@cent_id},#{pep_id},#{rt},#{wobble_mz},#{int},NULL)\"\n @cent_id += 1\n if @max_mz < wobble_mz\n @max_mz = wobble_mz\n end\n end\n end\n index += 1\n end\n end", "def test_with_irregular_array3D4; show([[[0,1,0.5,0.7]]]) end", "def products_of_all_other_nums(array)\n\n\tresult = Array.new() { [] }", "def multiple_variable_crossover(datacollection, colums, rows)\n porcent = datacollection.count\n\n puts \"#{colums}\"\n puts \"#{rows}\"\n data_collection_advanced = []\n datacollection.each_with_index do |data, index|\n id = index + 1\n data['id'] = id\n data_collection_advanced.push(data)\n end\n\n\n last_group_array = []\n rows.each do |column|\n agroup_array_x = []\n @hashx.each_with_index do |h, index|\n data_collection = {}\n groped_x = h[column]\n data_collection[column] = groped_x\n agroup_array_x.push(data_collection)\n end\n\n hashedART = {}\n group_hash = agroup_array_x.group_by { |u| u[column] }.map { |k, v| \n hashedART[ if !k.nil?\n \"#{k}\".downcase \n else\n \"null\"\n end\n ] = v.size.to_f/porcent.to_f }\n group_hash = hashedART\n group_array = agroup_array_x.group_by { |u| u[column] }.map { |k, v| [\n if !k.nil?\n \"#{k}\".downcase \n else\n \"null\"\n end, v.size.to_f/porcent.to_f] }\n heads = hashedART.keys\n hx = {\"hash\": hashedART, \"array\": group_array, \"heads\": heads}\n\n last_group_array.push(hx)\n end\n\n values_in_col = []\n\n\n colums.each do |col|\n @hashx.each_with_index do |h, index|\n values_in_col.push(h[col])\n end\n end\n\n values_in_col = values_in_col.uniq{|x| x}\n\n values_in_row = []\n adv_array = []\n last_group_array.each do |op|\n op[:heads].each do |px|\n values_in_row.push(px)\n rows.each do |row|\n values_in_col.each do |vin|\n colums.each do |col|\n hashed = {}\n hashed[\"row\"] = row\n hashed[\"rowvin\"] = px\n hashed[\"col\"] = col\n hashed[\"colvin\"] = vin\n selected = data_collection_advanced.select {|hash| hash[\"#{row}\"] == px if hash[\"#{col}\"] == \"#{vin}\"}\n hashed[\"q\"]= selected.count\n adv_array.push(hashed)\n end\n end\n end\n end\n end\n\n\n @crossover = {data: adv_array,values_in_row: values_in_row , values_in_col: values_in_col}\n\n end", "def populate1(matrix)\n\t(0..5).each do |x|\n\t\t(0..5).each do |y|\n\t\t\tmatrix[x][y] = (@cols[y] & @rows[x]).sample\n\t\t\t@cols[y].delete(matrix[x][y])\n\t\t\t@rows[x].delete(matrix[x][y])\n\t\tend\n\tend\n\n# \tp z = matrix.flatten\n# \tif z.include?(nil)!=true\n# \t\treturn matrix\n# \telse\n# \t\tp \"has nil(s)\"\n# \tend\nend", "def set_product_detail\n @product_detail = @shoping_card.product_details.where(source_id: params[:source_id], source_type: params[:source_type]).sample\n end", "def weighted_expected_sample(players, expected_salary)\n weighted_sample(players.map do |p|\n p.buy_price = p.buy_price / (p.buy_price - expected_salary).abs\n p\n end)\n end" ]
[ "0.6489358", "0.6267017", "0.6182372", "0.61586934", "0.6105622", "0.6020658", "0.58149725", "0.5778381", "0.57311255", "0.57225126", "0.5720943", "0.57160264", "0.57153857", "0.569251", "0.5650448", "0.56434536", "0.56396466", "0.56035376", "0.5601785", "0.55267507", "0.55258137", "0.5524459", "0.5510177", "0.54905874", "0.54843974", "0.54843974", "0.5482005", "0.5459015", "0.54188263", "0.54134786", "0.538194", "0.5366722", "0.5342355", "0.53404367", "0.53400964", "0.53370667", "0.5334744", "0.53339493", "0.5332184", "0.53141046", "0.53140473", "0.5297799", "0.5296507", "0.52935183", "0.5286168", "0.52784693", "0.52743167", "0.52726364", "0.52706254", "0.5261777", "0.52452004", "0.5237028", "0.52331376", "0.5226431", "0.5221255", "0.52166027", "0.5216179", "0.52129334", "0.52065045", "0.5204335", "0.5199345", "0.51908755", "0.519063", "0.5189249", "0.5183635", "0.5166271", "0.516517", "0.5154079", "0.5144911", "0.5127571", "0.512265", "0.5118276", "0.51171315", "0.51153255", "0.5101861", "0.5098537", "0.50962174", "0.50919634", "0.5088426", "0.5086761", "0.50856805", "0.50815904", "0.50803715", "0.50784254", "0.50754833", "0.5074378", "0.5066842", "0.50658447", "0.50657743", "0.5060706", "0.5060026", "0.50557303", "0.5051916", "0.50513786", "0.5047962", "0.5037518", "0.5035981", "0.50348175", "0.50299644", "0.50290716", "0.5017683" ]
0.0
-1
Returns a Tempfile. Up to caller to close/unlink tempfile when done with it.
def create comment_file = tmp_comment_file! tmp_zipfile = tmp_zipfile! derivative_files = [] Zip::File.open(tmp_zipfile.path, Zip::File::CREATE) do |zipfile| # Add attribution as file and zip comment text zipfile.comment = comment_text zipfile.add("about.txt", comment_file) members_to_include.each_with_index do |member, index| filename = "#{format '%03d', index+1}-#{DownloadFilenameHelper.filename_base_from_parent(member)}.jpg" uploaded_file = file_to_include(member.leaf_representative) # While it would be nice to stream directly from remote storage into the zip, we couldn't # get this to work with the combo of ruby-zip and shrine api's without downloading it # to local disk first. There may be a way we haven't figured out. May be able # to pass derivative.file.open to it instead for slightly better perf # once https://github.com/janko/down/issues/26 file_obj = uploaded_file.download derivative_files << file_obj # We want to add to zip as "STORED", not "DEFLATE", since our JPGs # won't compress under DEFLATE anyway, save the CPU. Ruby zip does not # give us a GREAT api to do that, but it gives us a way. # # https://github.com/rubyzip/rubyzip/blob/05af1231f49f2637b577accea2b6b732b7204bbb/lib/zip/file.rb#L271 # https://github.com/rubyzip/rubyzip/blob/05af1231f49f2637b577accea2b6b732b7204bbb/lib/zip/entry.rb#L53 entry = ::Zip::Entry.new(zipfile.name, filename, nil, nil, nil, nil, ::Zip::Entry::STORED) zipfile.add(entry, file_obj) # We don't really need to update on every page, the front-end is only polling every two seconds anyway if callback && (index % 3 == 0 || index >= members_to_include.count - 1) callback.call(progress_total: members_to_include.count, progress_i: index + 1) end end end # tell the Tempfile to (re)open so it has a file handle open that can see what ruby-zip wrote tmp_zipfile.open return tmp_zipfile ensure (derivative_files || []).each do |tmp_file| tmp_file.close tmp_file.unlink end if comment_file comment_file.close comment_file.unlink end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_tempfile\n io = Tempfile.new(@basename, @tmpdir, @open_options)\n io.unlink\n io\n end", "def tempfile\n unless @tempfile\n @tempfile = Tempfile.new(binmode: true)\n @tempfile.write(@read || read_from(closest))\n @tempfile.open\n end\n @tempfile\n end", "def tempfile\n ::Tempfile.new(filename, tempfile_path).tap do |tmp|\n tmp.binmode\n tmp.write(blob)\n tmp.close\n end\n end", "def tempfile\n ::Tempfile.new(filename, tempfile_path).tap do |tmp|\n tmp.write s3obj.value\n tmp.close\n end\n end", "def tempfile\n @tempfile ||= ::Tempfile.new(filename, tempfile_path).tap do |t|\n t.close\n image.write(t.path)\n end\n end", "def tmpfile\n \n unless @tmpfile\n \n return download\n \n end\n \n return @tmpfile\n \n end", "def tempfile content\n Tempfile.new(@NAME).tap do |body_io|\n body_io.unlink\n body_io.write content\n body_io.flush\n body_io.rewind\n end\n end", "def temp_file\n f = Tempfile.new('')\n $files_to_delete.push(f.path)\n return f\nend", "def close; @tempfile.close; end", "def gen_tempfile_path\n tf = Tempfile.new('filechanges.tgz')\n tf_path = tf.path\n tf.close\n tf.unlink\n tf_path\n end", "def tmpio\n fp = begin\n TmpIO.open(\"#{Dir::tmpdir}/#{rand}\",\n File::RDWR|File::CREAT|File::EXCL, 0600)\n rescue Errno::EEXIST\n retry\n end\n File.unlink(fp.path)\n fp.binmode\n fp.sync = true\n fp\n end", "def create_tempfile(output = render_template)\n tempfile = Tempfile.new([SecureRandom.uuid, \".#{@template_details[:template_extension]}\"], encoding: 'utf-8')\n tempfile.write(output)\n ObjectSpace.undefine_finalizer(tempfile) # force garbage collector not to remove automatically the file\n tempfile.close\n tempfile_details(tempfile).slice(:filename, :path).values\n end", "def temporary_file(contents=nil)\n f = Tempfile.new(\"vagrant-unit\")\n\n if contents\n f.write(contents)\n f.flush\n end\n\n # Store the tempfile in an instance variable so that it is not\n # garbage collected, so that the tempfile is not unlinked.\n @_temp_files << f\n\n return Pathname.new(f.path)\n end", "def create_tmp_file(comment)\n file = Tempfile.new('foo')\n file.write(comment)\n file.close\n\n file.path\nend", "def open\n @tmpfile.close if @tmpfile\n @tmpfile = File.open(@tmpname, @mode, @opts)\n __setobj__(@tmpfile)\n end", "def download_to_temp_file\n source_key = self.effective_key\n ext = self.format&.extensions&.first || \"tmp\"\n tempfile = Tempfile.new([\"#{self.class}-download_to_temp_file-#{self.id}\", \".#{ext}\"])\n begin\n ObjectSpace.undefine_finalizer(tempfile)\n PersistentStore.instance.get_object(key: source_key,\n response_target: tempfile.path)\n rescue => e\n tempfile.unlink\n raise e\n end\n tempfile\n end", "def temporary_file(path)\n tmp_path = temporary_path(path)\n file = open(tmp_path)\n files_to_close << file\n file\n end", "def with_temp_file\n raise ArgumentError, 'A block must be supplied' unless block_given?\n now = Time.now\n yield(tmp = Tempfile.new(\"#{now.to_i}.#{now.usec}.#{Process.pid}\", options[:tempfile_base] || Dir::tmpdir))\n ensure\n tmp.close true if tmp\n end", "def temp_file(prefix_suffix = nil, *args, &block)\n prefix_suffix = fix_prefix_suffix(prefix_suffix || 'f')\n Tempfile.open(self, prefix_suffix, *args, &block)\n end", "def with_tmpfile\n path = [@file, $$.to_s(36), Thread.current.object_id.to_s(36)].join\n file = File.open(path, 'wb')\n yield(path, file)\n ensure\n file.close unless file.closed?\n File.unlink(path) if File.exists?(path)\n end", "def create_temp_file\n copy_to_temp_file full_filename\n end", "def tempfile; end", "def tempfile; end", "def tempfile(string)\n file = Tempfile.new([name, '.html'])\n begin\n file.write(string)\n ensure\n file.close\n end\n yield(file).tap { file.unlink }\n end", "def get_free_file_path\n tempfile = Tempfile.new('foo', \"#{Rails.root}/test/fixtures/data/upload\")\n res = tempfile.path\n tempfile.close\n tempfile.unlink\n res\n end", "def next_tempfile\n p = nil\n Tempfile.open(\"onix\") do |tf|\n tf.close\n p = tf.path\n end\n p\n end", "def mktemp\n f = Tempfile.new('tmp', @temp_dir)\n [f, f.path]\n end", "def create_tempfile(basename)\n tmpfile = nil\n Dir::Tmpname.create(basename) do |tmpname|\n mode = File::WRONLY | File::CREAT | File::EXCL\n tmpfile = File.open(tmpname, mode, 0600)\n end\n tmpfile\n end", "def create_temp_file(basename = '__pdf.html.object',ext = 'html',tmpdir = Dir::tmpdir,mode = 'wb')\r\n @@_temp_file_mutex ||= Mutex.new\r\n\r\n failures = n = 0\r\n begin\r\n @@_temp_file_mutex.lock\r\n begin\r\n tmpname = File.join(tmpdir, sprintf('%s.%d.%d.%s', basename, $$, n, ext))\r\n n += 1\r\n end while File.exists?(tmpname)\r\n return File.open(tmpname,mode)\r\n rescue\r\n failures += 1\r\n retry if failures < 10\r\n raise ZPdf::RenderError.new(\"ZPdf::HtmlPdfObject cannot create temp file\")\r\n ensure\r\n @@_temp_file_mutex.unlock\r\n end\r\n end", "def generate_temp_path\n path = Tempfile.new($$).path\n rm_f path\n path\n end", "def path\n tempfile.path\n end", "def open\n _close\n mode = @mode & ~(File::CREAT|File::EXCL)\n @tmpfile = File.open(@tmpfile.path, mode, **@opts)\n __setobj__(@tmpfile)\n end", "def temp_file(text)\n file = Tempfile.new(\"ari\")\n file << text\n file.close\n file.path\nend", "def temp_file(ext='.rb')\n file = Tempfile.new(['pry', ext])\n yield file\nensure\n file.close(true) if file\n File.unlink(\"#{file.path}c\") if File.exists?(\"#{file.path}c\") # rbx\nend", "def new_tempfile\n intopdir = Pathname.new(Tempfile.new('dummy').path)\n subdir = intopdir.parent + 'manual/'\n subdir.mkpath\n Pathname.new(Tempfile.new(['data-ids', '.csv'], subdir).path)\nend", "def temp_file(*args, &block)\n self.class.temp_file(prefix_suffix, *args, &block)\n end", "def create_temp_file\n write_to_temp_file current_data\n end", "def with_tmp_zip_file\n file = Tempfile.new('retrieve')\n begin\n file.binmode\n file.write(zip_file)\n file.rewind\n yield file\n ensure\n file.close\n file.unlink\n end\n end", "def temp_file(ext = '.rb')\n file = Tempfile.new(['pry', ext])\n yield(file)\n ensure\n file.close(true)\n end", "def destroy\n File.delete(temp_path)\n end", "def temp_value #:nodoc:\n if tempfile?\n if original_filename\n %(#{@temp_name}/#{filename};#{original_filename})\n else\n %(#{@temp_name}/#{filename})\n end\n end\n end", "def get_tmp_path\n \"#{Dir.tmpdir}/#{Time.now.to_i * rand}\"\n end", "def close\n FileUtils.rm_rf @temp_dir\n end", "def create_temp_file(params={})\n params = {:base => 'rand', :ext => '.pdf'}.merge(params)\n Tempfile.new([params[:base], params[:ext]], Rails.root.join(CONFIG[:pdftool_temp_dir])).path\n end", "def tmp # :nodoc:\n @tmp ||= begin\n tmp = Unicorn::TmpIO.new\n tmp.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)\n tmp\n end\n end", "def get_tempfile(content)\n tmp = ASUtils.tempfile(\"doc-#{Time.now.to_i}\")\n tmp.write(content)\n tmp.flush\n $icky_hack_to_avoid_gc ||= []\n $icky_hack_to_avoid_gc << tmp\n tmp\n end", "def cleanup(tempfile)\n return if tempfile.nil?\n tempfile.unlink\n tempfile = nil\n end", "def temp_file(ext='.rb')\n file = Tempfile.new(['pry', ext])\n yield file\n ensure\n file.close(true) if file\n end", "def mktemp(filename, mask=true)\n fh = nil\n\n begin \n loop do\n fn = mask ? tmpnam(filename) : filename\n\n if File.exist? fn\n fail \"Unable to create a temporary filename\" unless mask\n next\n end\n\n fh = File.new(fn, \"a\", 0600)\n fh.seek(0, IO::SEEK_END)\n break if fh.pos == 0 \n \n fail \"Unable to create a temporary filename\" unless mask\n fh.close\n end\n rescue Exception => e\n # in the case that we hit a locked file...\n fh.close if fh\n raise e unless mask\n end\n \n return fh\n end", "def open_without_block(opt)\n file = Tempfile.new(TEMPORARY_FILE_PREFIX, Dir.tmpdir, **opt)\n file.write(contents)\n file.seek(0)\n file\n rescue StandardError\n file&.close!\n raise\n end", "def generate_tmp_file\n FileUtils.mkdir_p(local_tmp_dir) unless File.exists?(local_tmp_dir)\n #TODO avoid name collision\n stored = File.new(local_file_pathname, 'wb')\n stored.write s3_obj.read\n stored.close\n # Download and write the file in blocks off the HTTP Response (see S3Object.read in aws-sdk docs)\n # File.open(local_file_pathname, 'w') do |file|\n # s3_obj.read do |chunk|\n # file.write(chunk)\n # end\n # file\n # end\n end", "def with_temp_file offset = 0\n temp_file = Tempfile.new 'picky'\n \n temp_path = temp_file.path\n `tail -n +#{offset} #{@path} > #{temp_path}`\n yield temp_path\n \n temp_file.delete\n end", "def to_file\n replace_with_tempfile unless @tempfile_in\n flush\n self\n end", "def tempdir #:doc:\n Dir.tmpdir\n end", "def get_tmp_dir\n return \"#{Dir.tmpdir}/FilesRebuilder\"\n end", "def tempfile=(_arg0); end", "def get_tmp_path(temp_path)\n if not temp_path\n temp_path = Dir.tmpdir\n end\n\n Mongolicious.logger.info(\"Using #{temp_path} as root for our temp backup.\")\n return \"#{temp_path}/#{Time.now.to_i}\"\n end", "def mktemp\n FileUtils.rm_rf(TMPDIR)\n FileUtils.mkdir(TMPDIR)\nend", "def open(*args)\n tempfile = new(*args)\n \n if block_given?\n begin\n yield(tempfile)\n ensure\n tempfile.close\n end\n \n nil\n else\n tempfile\n end\n end", "def create_tempfile extension = \"txt\"\n file = Tempfile.new [ @file_name, \".#{extension}\" ]\n @tempfiles << file\n file\n end", "def delete\n @lock.synchronize do\n ::File.unlink(@tmpfile) if ::File.exist?(@tmpfile)\n end\n end", "def buffer\n @buffer ||= Tempfile.new(\"#{SecureRandom.hex(4)}.csv\")\n end", "def write_temp_file(contents, prefix: 'tempfile')\n t = Tempfile.new prefix\n t.write contents\n t.close\n\n @tempfile_hospital << t\n # Mason 2016-03-15: You MUST keep a ref to a Tempfile-created temp file around; if not, the file will be deleted when instance is GC'd. Caused shitty 30 min headache bug, where SSH connection failed because the key disappeared during connecting!\n\n FileUtils.chmod 0600, t.path # Mason 2016-03-15: may not be necessary (?), but doesn't hurt.\n\n t.path\n end", "def download_file\n tmp_file = Tempfile.new '', SimplyRets.configuration.temp_folder_path\n content_disposition = raw.headers['Content-Disposition']\n if content_disposition\n filename = content_disposition[/filename=['\"]?([^'\"\\s]+)['\"]?/, 1]\n path = File.join File.dirname(tmp_file), filename\n else\n path = tmp_file.path\n end\n # close and delete temp file\n tmp_file.close!\n\n File.open(path, 'w') { |file| file.write(raw.body) }\n SimplyRets.logger.info \"File written to #{path}. Please move the file to a proper folder for further processing and delete the temp afterwards\"\n return File.new(path)\n end", "def process(&blk)\n result = tempfile(&blk)\n\n # Should we add destroy to an ensure block? Im not sure if it makes sense\n # to delete failed files.\n file.destroy\n\n result\n end", "def get_temp_directory\n defined?(Rails) ? \"#{Rails.root}/tmp\" : \"/tmp\"\n end", "def temp_file_path(prefix_suffix = nil, *args)\n if block_given?\n temp_file(prefix_suffix, *args) do |file|\n file.close\n yield file.path\n end\n else\n file = temp_file(prefix_suffix, *args)\n file.close\n path = file.path\n path.instance_variable_set(:@__temp_file, file)\n path\n end\n end", "def temporary_path(filename)\n Global.temporary_directory + filename\n end", "def make_tmpdir\n unless @tmpdir\n @tmpdir = Dir.tmpdir\n at_exit { FileUtils.rm_rf(@tmpdir) }\n end\n @tmpdir\n end", "def tmp_dir\n return Dir.tmpdir if path_of('tmp_dir').nil?\n return path_of('tmp_dir')\n end", "def temporary_file(base_name = '', extension = CONVERTED_FILE_EXTENSION)\n FileUtils.mkdir_p(FILE_DUMPER_TMP_SUBFOLDER) unless File.directory?(FILE_DUMPER_TMP_SUBFOLDER)\n\n temps_full_path = FILE_DUMPER_TMP_SUBFOLDER + @temporary_folder + '/'\n FileUtils.mkdir_p(temps_full_path)\n\n # For the default scenario force encoding, for original files don't touch anything\n if extension == CONVERTED_FILE_EXTENSION\n Tempfile.new([base_name.gsub(' ', '_'), extension], temps_full_path, encoding: OUTPUT_ENCODING)\n else\n Tempfile.new([base_name.gsub(' ', '_'), extension], temps_full_path)\n end\n end", "def path\n Path.new(@tmpname)\n end", "def tmpfile(*args); end", "def unlink_tempfile\n File.unlink(@tempfile.path)\n @tempfile = nil\n end", "def cleanup\n File.delete(temp_file_path)\n end", "def temp_file(ext = '.rb')\n file = Tempfile.new(['editors', ext])\n yield file\n ensure\n file.close(true) if file\n end", "def temporary_output_path\n Gym.cache[:temporary_output_path] ||= File.join(\"/tmp\", Time.now.to_i.to_s)\n end", "def mk_tmp_dir\n Dir.mktmpdir('janna-tmp-download-', '/tmp')\n end", "def tmp_filename(user = current_user)\n \"#{ENCLOSURE_PATH}tmp_#{user.login}\"\n end", "def tmpdir\n @tmpdir ||= begin\n Dir.mktmpdir\n end\n end", "def temp_file(extension)\n File.join(@temp_dir, ::SecureRandom.hex(7) + '.' + extension.trim('.', '')).to_s\n end", "def create_temp_file(file_name)\n if file_name.rindex(\"/\") != nil \n directory = file_name[0, file_name.rindex(\"/\")+1] # ASSUMING ONLY UNIX!\n if !File.exists?(directory)\n FileUtils.mkdir_p(\"#{@tmp_file_path}#{directory}\")\n end\n end\n tmp_file = File.new(\"#{@tmp_file_path}#{file_name}\", \"w\")\n tmp_file.close()\n end", "def tmp_file\n counter = 1\n path = nil\n dir = Rails.root + \"/tmp/pdfs\"\n FileUtils.mkdir_p(dir)\n dir = Pathname.new(dir).realpath\n while path.nil? || File.file?(path)\n path = \"#{dir}/pdf-#{counter}\"\n counter += 1\n end\n path\n end", "def path\n @tmpname\n end", "def tmp_path\n File.join gem_root, 'tmp'\n end", "def temp (extension)\n path = \"#{FileUtils::Config.tmp_dir}/tmp.#{extension}\"\n id = 1\n while File.exists?(path)\n path = \"#{FileUtils::Config.tmp_dir}/tmp.#{id}.#{extension}\"\n id += 1\n end\n\n path\n end", "def remote_tmp_path\n '/tmp'\n end", "def render_to_tmp(source)\n basename = File.basename(source)\n output_path = \"tmp/#{basename}\"\n FileUtils.mkdir_p(\"tmp\")\n File.open(output_path, 'w') { |file| file.write(render_tmpl(source, **$vars)) }\n output_path\nend", "def temporary_directory\n \"#{ROOT}/spec/tmp\"\n end", "def uploaded_file(path, content_type=\"application/octet-stream\", filename=nil)\n filename ||= File.basename(path)\n t = Tempfile.new(filename)\n FileUtils.copy_file(path, t.path)\n (class << t; self; end;).class_eval do\n alias local_path path\n define_method(:original_filename) { filename }\n define_method(:content_type) { content_type }\n end\n return t\n end", "def uploaded_file(path, content_type=\"application/octet-stream\", filename=nil)\n filename ||= File.basename(path)\n t = Tempfile.new(filename)\n FileUtils.copy_file(path, t.path)\n (class << t; self; end;).class_eval do\n alias local_path path\n define_method(:original_filename) { filename }\n define_method(:content_type) { content_type }\n end\n return t\n end", "def temp_file_from_name(file_name)\n File.join(@temp_dir, file_name).to_s\n end", "def close\n if @io\n io.close\n io.delete if io.class.name == \"Tempfile\"\n end\n end", "def prepare_cache_path\n cache = Tempfile.new(\"\", Global.file_cache_directory)\n path = cache.path\n cache.close(true)\n return path\n end", "def temp_path\n @temp_path ||= generate_temp_path\n FileUtils.cp(polei.path, @temp_path) unless File.exist?(@temp_path)\n @temp_path\n end", "def write_to_tempfile(txt)\n @report_file = File.new('/tmp/mxmlc_error_report.html', 'w+')\n @report_file.write(txt)\n @report_file.close\n end", "def mktmpdir\n prefix = File.basename($0).sub(/\\.rb$/, '-')\n dir = Dir.mktmpdir(prefix)\n at_exit do\n FileUtils.rm_rf dir, secure: true\n end\n dir\nend", "def make_tempfile(input, options = {})\n tempfile = Tempfile.new('image-upload')\n tempfile.set_encoding(Encoding::BINARY) if tempfile.respond_to?(:set_encoding)\n tempfile.binmode\n buffer = \"\"\n while input.read(1024 * 4, buffer)\n entire_buffer_written_out = false\n while !entire_buffer_written_out\n written = tempfile.write(buffer)\n entire_buffer_written_out = written == Rack::Utils.bytesize(buffer)\n if !entire_buffer_written_out\n buffer.slice!(0 .. written - 1)\n end\n end\n end\n tempfile.rewind\n {:tempfile => tempfile}.merge(options)\n end", "def initialize\n @tmp_dir = Dir.mktmpdir(file_name)\n end", "def write_temporary_file(prefix, extension='', tmpdir=Dir::tmpdir)\n\tmax_tries=10\n\n\tfailure=0\n\tbegin\n\t\t# Make a filename which does not yet exist\n\t\tn=0\n\t\tbegin\n\t\t\tt=Time.now.strftime(\"%Y%m%d\")\n\t\t\tfilename=\"#{prefix}-#{t}-#{$$}-#{rand(0x100000000).to_s(36)}-#{n}#{extension}\"\n\t\t\ttmpname=File.join(tmpdir, filename)\n\n\t\t\tlock=tmpname+'.lock'\n\t\t\tn+=1\n\t\tend while File.exist?(lock) or File.exist?(tmpname)\n\n\t\tDir.mkdir(lock)\n\trescue => ex\n\t\tfailure+=1\n\t\tretry if failure < max_tries\n\t\traise \"Cannot generate tempfile: #{ex}\"\n\tend\n\n\n\tbegin\n\t\ttmpfile=File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)\n\t\tDir.rmdir(lock)\n\n\t\tyield(tmpfile)\n\tensure\n\t\ttmpfile.close\n\tend\n\n\ttmpname\nend", "def tmp &block\n tmp_dir = \"/tmp_#{rand(10**6)}\"\n if block\n begin\n create_dir tmp_dir\n block.call tmp_dir\n ensure\n delete_dir tmp_dir\n end\n else\n create_dir tmp_dir\n tmp_dir\n end\n end" ]
[ "0.8147029", "0.80323064", "0.7826578", "0.76249504", "0.75759447", "0.7504523", "0.74470645", "0.73152196", "0.7309935", "0.7263598", "0.71887934", "0.71417385", "0.70666546", "0.703381", "0.70140636", "0.69620425", "0.68869805", "0.68850535", "0.68810004", "0.68633974", "0.6845581", "0.68401647", "0.68401647", "0.68240017", "0.67725176", "0.6748169", "0.6733528", "0.6730089", "0.66927683", "0.6688869", "0.66029125", "0.65509015", "0.6541458", "0.65381104", "0.64889383", "0.63843143", "0.6367767", "0.63415045", "0.6338247", "0.63230646", "0.6322653", "0.6320853", "0.6302737", "0.629535", "0.62921524", "0.62853295", "0.6271279", "0.62647295", "0.6262938", "0.62374765", "0.62185466", "0.6160216", "0.6156078", "0.61405337", "0.61384976", "0.6137551", "0.61352193", "0.61295295", "0.6103244", "0.605511", "0.60263336", "0.60225075", "0.5999793", "0.5989523", "0.59885", "0.59863746", "0.5977738", "0.59483397", "0.5941103", "0.59297234", "0.59278387", "0.59271777", "0.5907084", "0.589446", "0.5892036", "0.58794826", "0.58757395", "0.58752406", "0.5853865", "0.58532447", "0.5838709", "0.58380246", "0.58288634", "0.57623243", "0.57564056", "0.5739087", "0.5717635", "0.57111216", "0.57093275", "0.5706265", "0.5706265", "0.56815547", "0.56778073", "0.56686217", "0.56682986", "0.56661665", "0.5656767", "0.56396484", "0.56281525", "0.56248677", "0.5620913" ]
0.0
-1
published members. preloads leaf_representative derivatives. Limited to members whose leaf representative has a download_full derivative Members will have derivatives preloaded.
def members_to_include @members_to_include ||= work. members. includes(:leaf_representative). where(published: true). order(:position). select do |m| m.leaf_representative.content_type == "image/jpeg" || m.leaf_representative&.file_derivatives(:download_full) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_members\n @all_members ||= begin\n members = work.members.includes(:leaf_representative)\n\n unless can_see_unpublished_records?\n members = members.where(published: true)\n end\n\n members = members.strict_loading # prevent accidental n+1 lazy-loading.\n members.order(:position).to_a\n end\n end", "def ordered_viewable_members(current_user:)\n\n\n members = self.members.includes(:leaf_representative)\n\n unless AccessPolicy.new(current_user).can_see_unpublished_records?\n members = members.where(published: true)\n end\n\n members = members.order(:position)\n\n # the point of this is to avoid n+1's, so let's set strict_loading, which\n # it turns out you can do on an association/relation\n members = members.strict_loading\n\n members.to_a\n end", "def create_or_update_lease_on_members(members, work)\n # TODO: account for all members and levels, not just file sets. ref: #6131\n\n members.each do |member|\n member_lease_needs_updating = work.lease.updated_at > member.lease&.updated_at if member.lease\n\n if member.lease && member_lease_needs_updating\n member.lease.lease_expiration_date = work.lease['lease_expiration_date']\n member.lease.visibility_during_lease = work.lease['visibility_during_lease']\n member.lease.visibility_after_lease = work.lease['visibility_after_lease']\n member.lease = Hyrax.persister.save(resource: member.lease)\n else\n work_lease_manager = Hyrax::LeaseManager.new(resource: work)\n work_lease_manager.copy_lease_to(target: member)\n member = Hyrax.persister.save(resource: member)\n end\n\n user ||= ::User.find_by_user_key(member.depositor)\n # the line below works in that it indexes the file set with the necessary lease properties\n # I do not know however if this is the best event_id to pass\n Hyrax.publisher.publish('object.metadata.updated', object: member, user: user)\n end\n end", "def full_jpg_url_for_member(member)\n leaf_representative = member&.leaf_representative\n if leaf_representative && leaf_representative.file_derivatives.has_key?(:download_full)\n \"#{ScihistDigicoll::Env.lookup!(:app_url_base)}/downloads/deriv/#{leaf_representative.friendlier_id}/download_full?disposition=inline\"\n else\n nil\n end\n end", "def min_up_members_state\n super\n end", "def load_members\n unless @loaded or @owner.unsaved?\n @members = @owner.send(@find_proc, @find_options)\n @loaded = true\n end\n @members\n end", "def share_representative_derivative\n @share_representative_deriative ||= work&.leaf_representative&.file_derivatives&.dig(:download_medium) ||\n work&.leaf_representative&.file_derivatives&.dig(:download_small) ||\n work&.leaf_representative&.file_derivatives&.dig(:thumb_large_2x) ||\n work&.leaf_representative&.file_derivatives&.dig(:thumb_large)\n end", "def populateLeafSideObjects(memberIDs, project, leafMember=1)\n groupMember = 1\n memberIDs.each_with_index do | memberID, index | \n if memberID[0] == \"G\"\n @groups[memberID] = {\"memberOrder\": groupMember}\n populateLeafSideObjects(project.groups.find(memberID).memberIDs, project, leafMember)\n groupMember += 1\n elsif memberID[0] == \"L\"\n if not @leafIDs.include? memberID\n leaf = project.leafs.find(memberID)\n @leafIDs.push(memberID)\n @leafs[memberID] = leaf\n @leafs[memberID][\"memberOrder\"] = leafMember\n @rectos[leaf.rectoID] = project.sides.find(leaf.rectoID)\n @versos[leaf.versoID] = project.sides.find(leaf.versoID)\n leafMember += 1\n end\n end\n end\n end", "def min_up_members\n super\n end", "def create_derivatives\n GeoMetadataExtractor.new(change_set: parent_change_set, file_node: resource, persister: change_set_persister).extract\n end", "def make_public\n self.private = false\n save\n self.collaborators.clear # remove collaborators when user is downgraded, and wiki is made public\n end", "def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n @uplines = Member.where.not(id: @member.self_and_descendants.collect(&:id)).order(\"fullname\")\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def complete min_visibility\n update_aliases\n remove_nodoc_children\n update_includes\n remove_invisible min_visibility\n end", "def member_discovered; end", "def update_house\n get_rep_from_api[\"results\"][0][\"members\"].each do |rep|\n Representative.create(\n pp_id: rep[\"id\"],\n first_name: rep[\"first_name\"],\n last_name: rep[\"last_name\"],\n party: rep[\"party\"],\n in_office: rep[\"in_office\"],\n state: rep[\"state\"],\n votes_with_party_pct: rep[\"votes_with_party_pct\"],\n district: rep[\"district\"]\n )\n end\nend", "def init_public_members\n rm_extender_init_public_members\n setup_eHandler\n @trails = 0\n @trails_signal = false\n end", "def generate_derivatives\n get_and_unlock(derivatives_subdirectory)\n\n # Create 'thumbnails' and 'access' directories if they arent present already.\n access_dir_path = File.join(clone_location, derivatives_subdirectory, 'access')\n thumbnail_dir_path = File.join(clone_location, derivatives_subdirectory, 'thumbnails')\n\n [access_dir_path, thumbnail_dir_path].each do |dir|\n FileUtils.mkdir(dir) unless File.exist?(dir)\n end\n\n # Create derivatives for jpeg and tiff files. For any audio files, link any assets, that are found.\n assets.each do |asset|\n if asset.mime_type == 'audio/vnd.wave' # Only linking access derivatives for wave files.\n access_derivative_path = File.join(access_dir_path, \"#{File.basename(asset.filename, '.*')}.mp3\")\n access_derivative_relative_path = Pathname.new(access_derivative_path).relative_path_from(Pathname.new(clone_location)).to_s\n\n if File.exist?(access_derivative_path)\n asset.access_file_location = clone.annex.lookupkey(access_derivative_relative_path)\n asset.save!\n end\n elsif asset.mime_type == 'image/jpeg' || asset.mime_type == 'image/tiff'\n relative_file_path = File.join(assets_subdirectory, asset.filename)\n get_and_unlock(relative_file_path)\n\n file_path = File.join(clone_location, relative_file_path)\n\n access_filepath = Bulwark::Derivatives::Image.access_copy(file_path, access_dir_path)\n access_relative_path = Pathname.new(access_filepath).relative_path_from(Pathname.new(clone_location)).to_s\n version_control_agent.add({ content: access_relative_path, include_dotfiles: true }, clone_location)\n asset.access_file_location = version_control_agent.look_up_key(access_relative_path, clone_location)\n\n thumbnail_filepath = Bulwark::Derivatives::Image.thumbnail(file_path, thumbnail_dir_path)\n thumbnail_relative_path = Pathname.new(thumbnail_filepath).relative_path_from(Pathname.new(clone_location)).to_s\n version_control_agent.add({ content: thumbnail_relative_path, include_dotfiles: true }, clone_location)\n asset.thumbnail_file_location = version_control_agent.look_up_key(thumbnail_relative_path, clone_location)\n\n asset.save!\n\n version_control_agent.lock(relative_file_path, clone_location)\n version_control_agent.drop({ content: relative_file_path }, clone_location)\n end\n end\n\n metadata_builder.update!(last_file_checks: DateTime.current)\n\n version_control_agent.lock(derivatives_subdirectory, clone_location)\n version_control_agent.commit(I18n.t('version_control_agents.commit_messages.generated_all_derivatives', object_id: names.fedora), clone_location)\n version_control_agent.push({ content: derivatives_subdirectory }, clone_location)\n end", "def members; end", "def members; end", "def members; end", "def members; end", "def members; end", "def members; end", "def members; end", "def update_inherited_members\n if parent\n if inherit_members? && !inherit_members_before_last_save\n remove_inherited_member_roles\n remove_inherited_member_functions # PATCH\n add_inherited_member_roles\n add_inherited_member_functions # PATCH\n elsif !inherit_members? && inherit_members_before_last_save\n remove_inherited_member_roles\n remove_inherited_member_functions # PATCH\n end\n end\n end", "def hack_members_for_newsletter\n member_hash = {}\n hack_members.name_seq.each do | member |\n member_hash[member.informal_name] = {:name => member.informal_name,\n :grp_with => member.group_with_id.nil? ? nil : member.group_with.informal_name,\n :subnodes => []}\n end\n member_hash.each do |_, item|\n parent = member_hash[item[:grp_with]]\n parent[:subnodes] << item if parent\n end\n unique_array = member_hash.reject {|_, item| member_hash.has_key? item[:grp_with] }.values\n ar = []\n collect_names(ar, unique_array)\n\n leader = self.hack_leader.informal_name\n if ar.include? leader\n ar.delete leader\n ar.push leader\n end\n\n ar.blank? ? 'None.' : ar.to_sentence(:last_word_connector => ' and ')\n end", "def representative_member\n # memoize with a value that could be nil....\n return @representative_member if defined?(@representative_member)\n\n @representative_member = all_members.find { |m| m.id == work.representative_id }\n end", "def create\n @member = Member.new(member_params)\n unless @member.set_region_admin == \"1\"\n @member.region_id = current_member.region_id\n end\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n @uplines = Member.order(\"fullname\")\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @publication.page_views += 1\n @publication.save\n @publication_attachments = @publication.publication_attachments.all\n\n @publications = Publication.all\n end", "def first_public_child\n children.published.first\n end", "def fetch\n @members = []\n page = 0\n\n begin\n page += 1\n url = open(\"#{base_url}/memberslistxml?p=#{page}\", {:proxy => true})\n member_data = REXML::Document.new(url.read).root\n\n @group_id64 = member_data.elements['groupID64'].text.to_i if page == 1\n total_pages = member_data.elements['totalPages'].text.to_i\n\n member_data.elements['members'].elements.each do |member|\n @members << SteamId.new(member.text.to_i, false)\n end\n end while page < total_pages\n\n super\n end", "def each(&block)\n load_members\n @members.each(&block)\n end", "def members_as_dn\n @members_dn ||= recursive_members().uniq\n end", "def members(refresh = false)\n @members = nil if refresh\n @members ||= safe_members.sort{|a,b| a.to_s <=> b.to_s}\n end", "def unload\n @members.clear\n @loaded = false\n end", "def members\n fetch if @members.nil? || @members[0].nil?\n @members\n end", "def local_update_members\n if self.respond_to?(:members)\n self.members.each do |member|\n member.reload.update_index\n end\n end\n end", "def local_update_members\n if self.respond_to?(:members)\n self.members.each do |member|\n member.reload.update_index\n end\n end\n end", "def fetch\n self.get(:pages).each do |attributes|\n page = self.add(attributes['fullpath'], attributes)\n\n self.mounting_point.locales[1..-1].each do |locale|\n # if not translated, no need to make an api call for that locale\n next unless page.translated_in?(locale)\n\n Locomotive::Mounter.with_locale(locale) do\n localized_attributes = self.get(\"pages/#{page._id}\", locale)\n\n # remove useless non localized attributes\n localized_attributes.delete('target_klass_slug')\n\n # isolate the editable elements\n editable_elements = self.filter_editable_elements(localized_attributes.delete('editable_elements'))\n\n page.attributes = localized_attributes\n\n page.set_editable_elements(editable_elements)\n end\n end\n end\n end", "def min_up_members_action\n super\n end", "def show\n @development_load = @member.calc_development_load\n @management_load = @member.calc_managing_load\n end", "def retrieve_members\n @root_member = nil\n @members = []\n shared = []\n @member_lookup = {}\n log.finer \"Retrieving members of dimension '#{@name}'\"\n alias_tbls = try{ @cube.get_alias_table_names.to_a }\n mbr_sel = try{ @cube.open_member_selection(\"MemberQuery\") }\n begin\n spec = %Q{@IDESCENDANTS(\"#{self.name}\")}\n query = <<-EOQ.strip\n <OutputType Binary\n <SelectMbrInfo(MemberName, MemberAliasName, ParentMemberName,\n MemberGeneration, MemberLevel, Consolidation,\n ShareOption, MemberFormula, UDAList)\n EOQ\n @cube.instrument 'retrieve_members', dimension: self do\n try{ mbr_sel.execute_query(query, spec) }\n end\n mbr_sel.get_members.get_all.each do |ess_mbr|\n mbr = Member.new(self, ess_mbr, alias_tbls)\n @members << mbr\n if mbr.shared?\n shared << mbr\n else\n @member_lookup[mbr.name.upcase] = mbr\n end\n end\n # Link shared members to non-shared member (and vice versa)\n shared.each do |smbr|\n mbr = @member_lookup[smbr.name.upcase]\n smbr.instance_variable_set(:@non_shared_member, mbr)\n mbr.instance_variable_get(:@shared_members) << smbr\n end\n @root_member = @member_lookup[self.name.upcase]\n # Convert parent names to references to the parent Member object\n # This can only be done after we've seen all members, since the\n # member selection query returns parents after children\n @members.each do |mbr|\n par = @member_lookup[mbr.parent.upcase]\n mbr.instance_variable_set(:@parent, par)\n par.instance_variable_get(:@children) << mbr if par\n end\n ensure\n try{ mbr_sel.close }\n end\n log.finer \"Retrieved #{@members.size} members\"\n end", "def waterfall\n children = @level.make_children\n names = if children.all? { |x| x.is_a? LevelZero }\n AffixSet.instance.sampler @name, children.size\n else\n Namer.instance\n end\n @contents = children.collect { |lvl| Node.new(names.sample, lvl) }\n @contents.each &:waterfall\n end", "def private_visibility!\n super\n set_discover_groups([], discover_groups)\n end", "def disable_publication\n find_flat\n @flat.pap = false\n @flat.bienici = false\n @flat.leboncoin = false\n @flat.seloger = false\n @flat.facebook = false\n @flat.update!(flat_params)\n redirect_to flat_path(@flat)\n end", "def index\n #@members = member.all\n #@members = member.with_restricted_access_access\n @members = policy_scope(Member)\n end", "def private_to_public\n current_user.wikis.each do |wiki|\n wiki.update_attributes(:private => false)\n end\n end", "def update(peer, proxy)\n\t super(peer, proxy)\n\n\t if proxy.root_object?\n\t\tif self.plan\n\t\t plan = peer.local_object(self.plan)\n\t\t return if proxy.plan == plan\n\t\t Distributed.update_all([plan, proxy]) do\n\t\t\tplan.add(proxy)\n\t\t end\n\t\tend\n\t end\n\tend", "def index\n @title = \"Members\"\n @fullwith_page = true\n\n authorize! :index, Member\n\n if params[:per_page] == 'all'\n Member.per_page = 100000\n else\n Member.per_page = params[:per_page] || 30\n end\n\n case sort_column\n when 'payments'\n @members = Member.search(params[:search]).accessible_by(current_ability).includes(:payments).all.sort_by {|m| m.payments.size * (sort_direction == 'asc' ? 1 : -1)}.paginate(:page => params[:page], per_page: Member.per_page)\n when 'debtor?'\n @members = Member.search(params[:search]).accessible_by(current_ability).includes(:payments).all.sort_by {|m| (m.debtor? ? 1 : 0) * (sort_direction == 'asc' ? 1 : -1)}.paginate(:page => params[:page], per_page: Member.per_page)\n when 'paid_upto'\n @members = Member.search(params[:search]).accessible_by(current_ability).includes(:payments).all.sort_by {|m| (m.paid_upto.nil? ? 0 : m.paid_upto.to_time.to_i) * (sort_direction == 'asc' ? 1 : -1)}.paginate(:page => params[:page], per_page: Member.per_page)\n else\n @members = Member.search(params[:search]).accessible_by(current_ability).page(params[:page]).order(sort_column => sort_direction)\n end\n\n @skipped_members_count = params[:page].nil? ? 0 : (params[:page].to_i - 1) * Member.per_page\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n format.csv { render csv: Member.all, :filename => 'members' }\n end\n end", "def archive\n next_offset = params[:offset].to_i + MEDITATIONS_PER_PAGE\n @meditations = Meditation.publicly_visible.preload_for(:preview).offset(params[:offset]).limit(MEDITATIONS_PER_PAGE)\n return unless stale?(@meditations)\n\n if Meditation.publicly_visible.count <= next_offset\n @loadmore_url = nil\n else\n @loadmore_url = archive_meditations_path(format: 'js', offset: next_offset)\n end\n\n respond_to do |format|\n format.html do\n @breadcrumbs = [\n { name: StaticPage.preview(:home).name, url: root_path },\n { name: StaticPage.preview(:meditations).name, url: meditations_path },\n { name: translate('meditations.title'), url: archive_meditations_path },\n { name: translate('meditations.archive.title') },\n ]\n\n set_metadata({ 'title' => translate('meditations.title') })\n render :archive\n end\n\n format.js do\n render :archive\n end\n end\n end", "def incomplete\n if self.state != INCOMPLETE or self.state != EXPIRED\n # only set as incomplete if before expiration\n if self.expiration_date.nil? or \n self.expiration_date >= Date.current \n self.state = INCOMPLETE\n else\n self.state = EXPIRED\n end\n self.completed_date = nil\n self.save!\n\n # refresh parent's completeness\n if !parent.nil?\n parent.is_complete?\n end\n end\n\n # call incomplete on each child\n self.children.each do |child|\n child.incomplete\n end\n end", "def index\n @new_publication = User::Publication.new user: @user\n breadcrumb\n end", "def init_public_members\n super\n @move_route_forcing = false\n end", "def show\n deposit = Deposit\n unless (current_user) # && current_user.ozmin?)\n deposit = deposit.public\n end\n @deposit = deposit.find(params[:id].to_i)\n \n \n # TODO When fetching resource records check if public\n @[email protected]\n current_zones = @zones.includes(:resources).merge(Resource.recent.nonzero).references(:resources).all\n zeroed_zones = @zones.includes(:resources).merge(Resource.recent.zeroed).references(:resources).all\n empty_zones = @zones.includes(:resources).where(:resources => {:eno => nil}).references(:resources).all\n @zone_array = [current_zones,zeroed_zones,empty_zones]\n @current_resources = @deposit.resources.recent.nonzero.all\n @provinces = @deposit.provinces\n \n \n @weblinks = @deposit.weblinks\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @deposit }\n format.kml\n end\n end", "def populate_for_fund_request( request )\n return if proxy_association.owner.node.blank?\n last = for_request( request ).last\n if last.blank? || ( last.persisted? && last.perspective != FundEdition::PERSPECTIVES.last )\n next_edition = build_next_for_fund_request( request )\n end\n end", "def divide_if_needed(defer_update = false)\n if children.size > MAX_SIZE\n raise \"node is not lowest level and can therefore not be divided: #{self}\" unless lowest_level?\n @children = (0...MAX_SIZE).collect do |i|\n leaves = children.find_all {|leaf| leaf.shash_array[level] == i}\n NonLeafNode.new(self, leaves)\n end\n children.each {|child| child.divide_if_needed(defer_update)}\n end\n update_shash(false) unless defer_update\n end", "def update_memberships\n update_children\n update_parents\n end", "def stable!(recursive = false, is_stable = true)\n @stable = is_stable\n if recursive\n @members.each { |name, object| object.stable!(recursive, is_stable) if object.respond_to?(:stable!) }\n end\n end", "def members(*) end", "def tiny_members\n return @members unless large?\n\n @members.select { |e| e.status != :offline }\n end", "def generate_logical_structure_members\n members_with_parents.map do |member|\n wayfinder = Wayfinder.for(member)\n if wayfinder.respond_to?(:decorated_scanned_maps) && wayfinder.decorated_scanned_maps.empty?\n wayfinder.geo_members.first\n else\n member\n end\n end.compact\n end", "def rewrite_members members\n (fspath + '.members').open('w') {|f| members.each {|m| f.puts(m)}}\n return\n end", "def become_public\n page.touch(:published_at)\n activate!\n end", "def export_nodes\n existing_hiera = Dir.glob(Path.named_path([:hiera, '*'], @provider_dir))\n existing_files = Dir.glob(Path.named_path([:node_files_dir, '*'], @provider_dir))\n updated_hiera = []\n updated_files = []\n self.each_node do |node|\n filepath = Path.named_path([:node_files_dir, node.name], @provider_dir)\n updated_files << filepath\n hierapath = Path.named_path([:hiera, node.name], @provider_dir)\n updated_hiera << hierapath\n Util::write_file!(hierapath, node.dump)\n end\n (existing_hiera - updated_hiera).each do |filepath|\n Util::remove_file!(filepath)\n end\n (existing_files - updated_files).each do |filepath|\n Util::remove_directory!(filepath)\n end\n end", "def place_members_only?\n false\n end", "def place_members_only?\n false\n end", "def show\n if !current_member.the_admin? && current_member.region_id != @member.region_id\n redirect_to \"/\", notice: \"Access denied\"\n return\n end\n\n @network_commisions_limit = 10\n @network_commisions = @member.network_commisions.joins(:member).order(\"id desc\").limit(@network_commisions_limit)\n @show_view_all_network_commisions = @member.network_commisions.count > @network_commisions_limit\n\n @total_network_commisions = @member.total_network_commisions\n @total_descendants = @member.descendants.count\n\n @transactions = @member.transactions.where(referral: false).order(\"id DESC\")\n @referral_transactions = @member.transactions.where(referral: true).order(\"id DESC\")\n @total_referral_commisions = @member.transactions.where(referral: true).sum(:referral_commision)\n\n if @member.web_dev?\n @latest_members_limit = 10\n @latest_members = Member.where.not(member_id: Member::CORE_MEMBER_IDS).order(\"id desc\").limit(@latest_members_limit)\n @show_view_all_network_commisions = Member.where.not(member_id: Member::CORE_MEMBER_IDS).count > @latest_members_limit\n @total_web_dev_commisions = WalletTransaction.where(member_id: @member.id, transaction_type: \"web development commision\").sum(:amount)\n end\n end", "def create_derivatives\n if transformation_schemes.present?\n transformation_schemes.each do |transform_scheme|\n if transform_scheme.instance_of?(Proc)\n transform_scheme.call(self)\n else\n send(transform_scheme)\n end\n end\n #This is the line we're adding and its for the creation of watermarks upon ingest or updated file\n Osul::Watermark.new(self, 'content', nil).create_derivative if self.requires_watermark?\n else\n logger.warn \"`create_derivatives' was called on an instance of #{self.class}, but no derivatives have been requested\"\n end\n end", "def calculate_members_only_places!\n standings.event.disable_notification!\n begin\n non_members = 0\n for result in results.sort\n # Slight optimization. Most of the time, no point in saving a result that hasn't changed\n place_before = result.members_only_place\n result.members_only_place = ''\n if result.place.to_i > 0\n if result.racer.nil? or (result.racer and result.racer.member?(result.date))\n result.members_only_place = (result.place.to_i - non_members).to_s\n else\n non_members = non_members + 1\n end\n end\n result.update_attribute('members_only_place', result.members_only_place) if place_before != result.members_only_place\n end\n ensure\n standings.event.enable_notification!\n end\n end", "def children(reload=false)\n reload = true if !@children\n reload ? child_nodes(true) : @children\n end", "def build\n attributes = { contains: build_file_sets }\n attributes[:hasMemberOrders] = [{ viewingDirection: reading_order }] if reading_order\n\n cocina_dro.structural.new(attributes)\n end", "def init_public_members\n @id = 0\n @x = 0\n @y = 0\n @real_x = 0.0\n @real_y = 0.0\n @tile_id = 0\n @character_name = \"\"\n @character_index = 0\n @move_speed = 4\n @move_frequency = 6\n @walk_anime = true\n @step_anime = false\n @direction_fix = false\n @opacity = 255\n @blend_type = 0\n @direction = 2\n @pattern = 1\n @priority_type = 1\n @through = false\n @bush_depth = 0\n @animation_id = 0\n @balloon_id = 0\n @transparent = false\n end", "def update\n respond_to do |format|\n if @household.update(household_params)\n\n params[:household][:household_members_attributes].each do |member|\n predecessor_name = member[1][:name]\n successor_name = member[1][:name_related]\n relationship_kind = member[1][:relationship]\n\n @household.add_household_member(@household.household_members.find_by_name(predecessor_name))\n @household.add_relationship(predecessor_name, successor_name, relationship_kind)\n #byebug\n end\n format.html { redirect_to @household, notice: 'Household was successfully updated.' }\n format.json { render :show, status: :ok, location: @household }\n else\n format.html { render :edit }\n format.json { render json: @household.errors, status: :unprocessable_entity }\n end\n end\n end", "def members\n self.u_members + self.g_members\n end", "def members\n if @memorial\n @pagination = {\n q: params[:q].nil? ? \"\" : params[:q],\n p: params[:p].nil? ? \"1\" : params[:p],\n per_p: params[:per_p].nil? ? \"10\" : params[:per_p],\n total: 0,\n order: {\n column: @order.column,\n dir: @order.direction\n }\n }\n @users = @memorial.users\n .reorder(@order.column => @order.direction)\n .ransack(first_name_or_last_name_or_email_cont_any: @pagination[:q].split(\" \")).result\n @pagination[:total] = @users.length\n @users = @users\n .paginate(page: @pagination[:p], per_page: @pagination[:per_p])\n user_memorials = []\n @users.each do |u|\n user_memorials << u.user_memorials.find_by(memorial_id: @memorial[:uuid])\n end\n user = user_memorials.as_json({\n include: [{user: {only: [:uuid, :first_name, :last_name, :email]}}, {role: {only: [:uuid, :name]}}]\n })\n users = []\n user.each do |u|\n entity = {\n uuid: u['user']['uuid'],\n first_name: u['user']['first_name'],\n last_name: u['user']['last_name'],\n email: u['user']['email'],\n roles: [u['role']]\n }\n users << entity\n end\n response = {\n organization: @memorial[:organization_id].present? ? Organization.where(uuid: @memorial[:organization_id]).select(\"uuid, name, address, image, posY, posX, scale, rot\") : nil,\n results: users,\n pagination: @pagination\n }\n render json: response\n else\n render json: {error: 'You do not have access to this memorial'}, status: 422\n end\n end", "def perform_cu_post_processing\n # Reload to get all fields (including member extracted_text and mime_type) \n # loaded properly\n curation_concern.reload \n\n set_extent\n set_format\n set_doi\n\n curation_concern.save!\n \n # Reindex the members to get them into solr properly\n curation_concern.members.each{ |member| member.update_index } \n end", "def run_major_districts(parties, delete_only=false)\n view_name = \"#{self.analysis_table_name} - #{@@shapes[:major_district]}\"\n @@client.execute(\"drop view if exists `#{@@analysis_db}`.`#{view_name}`\")\n if !delete_only\n sql = \"create view `#{@@analysis_db}`.`#{view_name}` as\n select `raw`.`region` AS `region`,\n `raw`.`district_id` AS `district_id`,\n `raw`.`district_name` AS `district_Name`,\n `raw`.`major_district_id` AS `major_district_id`,\n `raw`.`major_district_id` AS `major_district_name`,\n sum(`raw`.`num_possible_voters`) AS `possible voters`,\n sum(`raw`.`num_votes`) AS `total ballots cast`,\n sum(`raw`.`num_valid_votes`) AS `total valid ballots cast`,\n ifnull(sum(`invalid_ballots_01`.`num_invalid_ballots`),\n 0) AS `num invalid ballots from 0-1%`,\n ifnull(sum(`invalid_ballots_13`.`num_invalid_ballots`),\n 0) AS `num invalid ballots from 1-3%`,\n ifnull(sum(`invalid_ballots_35`.`num_invalid_ballots`),\n 0) AS `num invalid ballots from 3-5%`,\n ifnull(sum(`invalid_ballots_>5`.`num_invalid_ballots`),\n 0) AS `num invalid ballots >5%`,\n (100 * (sum(`raw`.`num_valid_votes`) / sum(`raw`.`num_possible_voters`))) AS `percent voters voting`,\n sum(`raw`.`logic_check_fail`) AS `num precincts logic fail`,\n (100 * (sum(`raw`.`logic_check_fail`) / count(0))) AS `percent precincts logic fail`,\n (sum(`raw`.`logic_check_difference`) / sum(`raw`.`logic_check_fail`)) AS `avg precinct logic fail difference`,\n sum(`raw`.`more_ballots_than_votes_flag`) AS `num precincts more ballots than votes`,\n (100 * (sum(`raw`.`more_ballots_than_votes_flag`) / count(0))) AS `percent precincts more ballots than votes`,\n (sum(`raw`.`more_ballots_than_votes`) / sum(`raw`.`more_ballots_than_votes_flag`)) AS `avg precinct difference more ballots than votes`,\n sum(`raw`.`more_votes_than_ballots_flag`) AS `num precincts more votes than ballots`,\n (100 * (sum(`raw`.`more_votes_than_ballots_flag`) / count(0))) AS `percent precincts more votes than ballots`,\n (sum(`raw`.`more_votes_than_ballots`) / sum(`raw`.`more_votes_than_ballots_flag`)) AS `avg precinct difference more votes than ballots`,\n sum(`raw`.`supplemental_documents_flag`) AS `num precincts with supplemental documents`,\n (100 * (sum(`raw`.`supplemental_documents_flag`) / count(0))) AS `percent precincts with supplemental documents`,\n (sum(`raw`.`supplemental_document_count`) / sum(`raw`.`supplemental_documents_flag`)) AS `avg precinct supplemental document count`,\n sum(`raw`.`amendment_flag`) AS `num precincts with amendment`,\n (100 * (sum(`raw`.`amendment_flag`) / count(0))) AS `percent precincts with amendment`,\n sum(`raw`.`explanatory_note_flag`) AS `num precincts with explanatory note`,\n (100 * (sum(`raw`.`explanatory_note_flag`) / count(0))) AS `percent precincts with explanatory note`,\n sum(`raw`.`num_at_12`) AS `votes 8-12`,\n sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) AS `votes 12-17`,\n sum((`raw`.`num_votes` - `raw`.`num_at_17`)) AS `votes 17-20`,\n (sum(`raw`.`num_at_12`) / count(0)) AS `avg votes/precinct 8-12`,\n (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / count(0)) AS `avg votes/precinct 12-17`,\n (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / count(0)) AS `avg votes/precinct 17-20`,\n (sum(`raw`.`num_at_12`) / 240) AS `vpm 8-12`,\n (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) AS `vpm 12-17`,\n (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 300) AS `vpm 17-20`,\n ((sum(`raw`.`num_at_12`) / 240) / count(0)) AS `avg vpm/precinct 8-12`,\n ((sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) / count(0)) AS `avg vpm/precinct 12-17`,\n ((sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 200) / count(0)) AS `avg vpm/precinct 17-20`,\n ifnull(sum(`vpm1`.`vpm > #{@@vpm_limit}`),\n 0) AS `num precincts vpm 8-12 > #{@@vpm_limit}`,\n ifnull(sum(`vpm2`.`vpm > #{@@vpm_limit}`),\n 0) AS `num precincts vpm 12-17 > #{@@vpm_limit}`,\n ifnull(sum(`vpm3`.`vpm > #{@@vpm_limit}`),\n 0) AS `num precincts vpm 17-20 > #{@@vpm_limit}`,\n ((ifnull(sum(`vpm1`.`vpm > #{@@vpm_limit}`),\n 0) + ifnull(sum(`vpm2`.`vpm > #{@@vpm_limit}`),\n 0)) + ifnull(sum(`vpm3`.`vpm > #{@@vpm_limit}`),\n 0)) AS `num precincts vpm > #{@@vpm_limit}`,\n `precinct_count`.`num_precincts` AS `num_precincts_possible`,\n count(`raw`.`precinct_id`) AS `num_precincts_reported_number`,\n ((100 * count(`raw`.`precinct_id`)) / `precinct_count`.`num_precincts`) AS `num_precincts_reported_percent`,\n \"\n party_sql = []\n parties.each do |party|\n party_name = \"#{party[:id]} - #{party[:name]}\"\n party_sql << \"sum(`raw`.`#{party_name}`) AS `#{party_name} count`,\n (100 * (sum(`raw`.`#{party_name}`) / sum(`raw`.`num_valid_votes`))) AS `#{party_name}`\"\n end\n sql << party_sql.join(', ')\n if self.has_indepenedent_parties?\n sql << \", sum(`raw`.`#{Election::INDEPENDENT_MERGED_ANALYSIS_NAME}`) AS `#{Election::INDEPENDENT_MERGED_ANALYSIS_NAME} count`,\n (100 * (sum(`raw`.`#{Election::INDEPENDENT_MERGED_ANALYSIS_NAME}`) / sum(`raw`.`num_valid_votes`))) AS `#{Election::INDEPENDENT_MERGED_ANALYSIS_NAME}` \"\n end\n\n sql << \" from ((((((((`#{@@analysis_db}`.`#{self.analysis_table_name} - raw` `raw`\n join `#{@@analysis_db}`.`#{self.analysis_table_name} - precinct count by major district` `precinct_count` on((`raw`.`district_id` = `precinct_count`.`district_id`) and (`raw`.`major_district_id` = `precinct_count`.`major_district_id`)))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - vpm 8-12>#{@@vpm_limit}` `vpm1` on(((`raw`.`region` <=> `vpm1`.`region`) and (`raw`.`district_id` = `vpm1`.`district_id`) and(`raw`.`major_district_id` = `vpm1`.`major_district_id`) and (`raw`.`precinct_id` = `vpm1`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - vpm 12-17>#{@@vpm_limit}` `vpm2` on(((`raw`.`region` <=> `vpm2`.`region`) and (`raw`.`district_id` = `vpm2`.`district_id`) and (`raw`.`major_district_id` = `vpm2`.`major_district_id`) and (`raw`.`precinct_id` = `vpm2`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - vpm 17-20>#{@@vpm_limit}` `vpm3` on(((`raw`.`region` <=> convert(`vpm3`.`region` using utf8)) and (`raw`.`district_id` = `vpm3`.`district_id`) and (`raw`.`major_district_id` = `vpm3`.`major_district_id`) and (`raw`.`precinct_id` = `vpm3`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - invalid ballots 0-1` `invalid_ballots_01` on(((`raw`.`region` <=> `invalid_ballots_01`.`region`) and (`raw`.`district_id` = `invalid_ballots_01`.`district_id`) and (`raw`.`major_district_id` = `invalid_ballots_01`.`major_district_id`) and (`raw`.`precinct_id` = `invalid_ballots_01`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - invalid ballots 1-3` `invalid_ballots_13` on(((`raw`.`region` <=> `invalid_ballots_13`.`region`) and (`raw`.`district_id` = `invalid_ballots_13`.`district_id` and (`raw`.`major_district_id` = `invalid_ballots_13`.`major_district_id`) and (`raw`.`precinct_id` = `invalid_ballots_13`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - invalid ballots 3-5` `invalid_ballots_35` on(((`raw`.`region` <=> `invalid_ballots_35`.`region`) and (`raw`.`district_id` = `invalid_ballots_35`.`district_id`) and (`raw`.`major_district_id` = `invalid_ballots_35`.`major_district_id`) and (`raw`.`precinct_id` = `invalid_ballots_35`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - invalid ballots >5` `invalid_ballots_>5` on(((`raw`.`region` <=> `invalid_ballots_>5`.`region`) and (`raw`.`district_id` = `invalid_ballots_>5`.`district_id`) and (`raw`.`major_district_id` = `invalid_ballots_>5`.`major_district_id`) and (`raw`.`precinct_id` = `invalid_ballots_>5`.`precinct_id`)))))\n where `raw`.`is_annulled` = 0\n and (`raw`.`district_id` not between 1 and 10)\n group by `raw`.`region`, `raw`.`district_name`, `raw`.`district_id`, `raw`.`major_district_id`\"\n\n sql << \" union \"\n\n sql << \"select `raw`.`region` AS `region`,\n 999 AS `district_id`,\n 'Tbilisi' AS `district_Name`,\n 999 AS `major_district_id`,\n 'Tbilisi' AS `major_district_name`,\n sum(`raw`.`num_possible_voters`) AS `possible voters`,\n sum(`raw`.`num_votes`) AS `total ballots cast`,\n sum(`raw`.`num_valid_votes`) AS `total valid ballots cast`,\n ifnull(sum(`invalid_ballots_01`.`num_invalid_ballots`),\n 0) AS `num invalid ballots from 0-1%`,\n ifnull(sum(`invalid_ballots_13`.`num_invalid_ballots`),\n 0) AS `num invalid ballots from 1-3%`,\n ifnull(sum(`invalid_ballots_35`.`num_invalid_ballots`),\n 0) AS `num invalid ballots from 3-5%`,\n ifnull(sum(`invalid_ballots_>5`.`num_invalid_ballots`),\n 0) AS `num invalid ballots >5%`,\n (100 * (sum(`raw`.`num_valid_votes`) / sum(`raw`.`num_possible_voters`))) AS `percent voters voting`,\n sum(`raw`.`logic_check_fail`) AS `num precincts logic fail`,\n (100 * (sum(`raw`.`logic_check_fail`) / count(0))) AS `percent precincts logic fail`,\n (sum(`raw`.`logic_check_difference`) / sum(`raw`.`logic_check_fail`)) AS `avg precinct logic fail difference`,\n sum(`raw`.`more_ballots_than_votes_flag`) AS `num precincts more ballots than votes`,\n (100 * (sum(`raw`.`more_ballots_than_votes_flag`) / count(0))) AS `percent precincts more ballots than votes`,\n (sum(`raw`.`more_ballots_than_votes`) / sum(`raw`.`more_ballots_than_votes_flag`)) AS `avg precinct difference more ballots than votes`,\n sum(`raw`.`more_votes_than_ballots_flag`) AS `num precincts more votes than ballots`,\n (100 * (sum(`raw`.`more_votes_than_ballots_flag`) / count(0))) AS `percent precincts more votes than ballots`,\n (sum(`raw`.`more_votes_than_ballots`) / sum(`raw`.`more_votes_than_ballots_flag`)) AS `avg precinct difference more votes than ballots`,\n sum(`raw`.`supplemental_documents_flag`) AS `num precincts with supplemental documents`,\n (100 * (sum(`raw`.`supplemental_documents_flag`) / count(0))) AS `percent precincts with supplemental documents`,\n (sum(`raw`.`supplemental_document_count`) / sum(`raw`.`supplemental_documents_flag`)) AS `avg precinct supplemental document count`,\n sum(`raw`.`amendment_flag`) AS `num precincts with amendment`,\n (100 * (sum(`raw`.`amendment_flag`) / count(0))) AS `percent precincts with amendment`,\n sum(`raw`.`explanatory_note_flag`) AS `num precincts with explanatory note`,\n (100 * (sum(`raw`.`explanatory_note_flag`) / count(0))) AS `percent precincts with explanatory note`,\n sum(`raw`.`num_at_12`) AS `votes 8-12`,\n sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) AS `votes 12-17`,\n sum((`raw`.`num_votes` - `raw`.`num_at_17`)) AS `votes 17-20`,\n (sum(`raw`.`num_at_12`) / count(0)) AS `avg votes/precinct 8-12`,\n (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / count(0)) AS `avg votes/precinct 12-17`,\n (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / count(0)) AS `avg votes/precinct 17-20`,\n (sum(`raw`.`num_at_12`) / 240) AS `vpm 8-12`,\n (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) AS `vpm 12-17`,\n (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 300) AS `vpm 17-20`,\n ((sum(`raw`.`num_at_12`) / 240) / count(0)) AS `avg vpm/precinct 8-12`,\n ((sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) / count(0)) AS `avg vpm/precinct 12-17`,\n ((sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 200) / count(0)) AS `avg vpm/precinct 17-20`,\n ifnull(sum(`vpm1`.`vpm > #{@@vpm_limit}`),\n 0) AS `num precincts vpm 8-12 > #{@@vpm_limit}`,\n ifnull(sum(`vpm2`.`vpm > #{@@vpm_limit}`),\n 0) AS `num precincts vpm 12-17 > #{@@vpm_limit}`,\n ifnull(sum(`vpm3`.`vpm > #{@@vpm_limit}`),\n 0) AS `num precincts vpm 17-20 > #{@@vpm_limit}`,\n ((ifnull(sum(`vpm1`.`vpm > #{@@vpm_limit}`),\n 0) + ifnull(sum(`vpm2`.`vpm > #{@@vpm_limit}`),\n 0)) + ifnull(sum(`vpm3`.`vpm > #{@@vpm_limit}`),\n 0)) AS `num precincts vpm > #{@@vpm_limit}`,\n `precinct_count`.`num_precincts` AS `num_precincts_possible`,\n count(`raw`.`precinct_id`) AS `num_precincts_reported_number`,\n ((100 * count(`raw`.`precinct_id`)) / `precinct_count`.`num_precincts`) AS `num_precincts_reported_percent`,\n \"\n party_sql = []\n parties.each do |party|\n party_name = \"#{party[:id]} - #{party[:name]}\"\n party_sql << \"sum(`raw`.`#{party_name}`) AS `#{party_name} count`,\n (100 * (sum(`raw`.`#{party_name}`) / sum(`raw`.`num_valid_votes`))) AS `#{party_name}`\"\n end\n sql << party_sql.join(', ')\n if self.has_indepenedent_parties?\n sql << \", sum(`raw`.`#{Election::INDEPENDENT_MERGED_ANALYSIS_NAME}`) AS `#{Election::INDEPENDENT_MERGED_ANALYSIS_NAME} count`,\n (100 * (sum(`raw`.`#{Election::INDEPENDENT_MERGED_ANALYSIS_NAME}`) / sum(`raw`.`num_valid_votes`))) AS `#{Election::INDEPENDENT_MERGED_ANALYSIS_NAME}` \"\n end\n\n sql << \" from ((((((((`#{@@analysis_db}`.`#{self.analysis_table_name} - raw` `raw`\n join `#{@@analysis_db}`.`#{self.analysis_table_name} - precinct count by major district` `precinct_count` on((`raw`.`district_id` = `precinct_count`.`district_id`) and (`raw`.`major_district_id` = `precinct_count`.`major_district_id`)))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - vpm 8-12>#{@@vpm_limit}` `vpm1` on(((`raw`.`region` <=> `vpm1`.`region`) and (`raw`.`district_id` = `vpm1`.`district_id`) and(`raw`.`major_district_id` = `vpm1`.`major_district_id`) and (`raw`.`precinct_id` = `vpm1`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - vpm 12-17>#{@@vpm_limit}` `vpm2` on(((`raw`.`region` <=> `vpm2`.`region`) and (`raw`.`district_id` = `vpm2`.`district_id`) and (`raw`.`major_district_id` = `vpm2`.`major_district_id`) and (`raw`.`precinct_id` = `vpm2`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - vpm 17-20>#{@@vpm_limit}` `vpm3` on(((`raw`.`region` <=> convert(`vpm3`.`region` using utf8)) and (`raw`.`district_id` = `vpm3`.`district_id`) and (`raw`.`major_district_id` = `vpm3`.`major_district_id`) and (`raw`.`precinct_id` = `vpm3`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - invalid ballots 0-1` `invalid_ballots_01` on(((`raw`.`region` <=> `invalid_ballots_01`.`region`) and (`raw`.`district_id` = `invalid_ballots_01`.`district_id`) and (`raw`.`major_district_id` = `invalid_ballots_01`.`major_district_id`) and (`raw`.`precinct_id` = `invalid_ballots_01`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - invalid ballots 1-3` `invalid_ballots_13` on(((`raw`.`region` <=> `invalid_ballots_13`.`region`) and (`raw`.`district_id` = `invalid_ballots_13`.`district_id` and (`raw`.`major_district_id` = `invalid_ballots_13`.`major_district_id`) and (`raw`.`precinct_id` = `invalid_ballots_13`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - invalid ballots 3-5` `invalid_ballots_35` on(((`raw`.`region` <=> `invalid_ballots_35`.`region`) and (`raw`.`district_id` = `invalid_ballots_35`.`district_id`) and (`raw`.`major_district_id` = `invalid_ballots_35`.`major_district_id`) and (`raw`.`precinct_id` = `invalid_ballots_35`.`precinct_id`))))\n left join `#{@@analysis_db}`.`#{self.analysis_table_name} - invalid ballots >5` `invalid_ballots_>5` on(((`raw`.`region` <=> `invalid_ballots_>5`.`region`) and (`raw`.`district_id` = `invalid_ballots_>5`.`district_id`) and (`raw`.`major_district_id` = `invalid_ballots_>5`.`major_district_id`) and (`raw`.`precinct_id` = `invalid_ballots_>5`.`precinct_id`)))))\n where `raw`.`is_annulled` = 0\n and (`raw`.`district_id` between 1 and 10)\n # group by `raw`.`region`, `raw`.`district_name`, `raw`.`district_id`, `raw`.`major_district_id`\"\n\n @@client.execute(sql)\n end\n end", "def members\n @source.get_elements('//Member').map { |item| Member.new(item) }\n end", "def init_public_members\r\n @id = 0\r\n @x = 0\r\n @y = 0\r\n @real_x = 0\r\n @real_y = 0\r\n @tile_id = 0\r\n @character_name = \"\"\r\n @character_index = 0\r\n @move_speed = 4\r\n @move_frequency = 6\r\n @walk_anime = true\r\n @step_anime = false\r\n @direction_fix = false\r\n @opacity = 255\r\n @blend_type = 0\r\n @direction = 2\r\n @pattern = 1\r\n @priority_type = 1\r\n @through = false\r\n @bush_depth = 0\r\n @animation_id = 0\r\n @balloon_id = 0\r\n @transparent = false\r\n end", "def import!\n import_binary_files\n member_ids = []\n source_metadata_adapter.query_service.find_members(resource: source_resource).each do |member|\n member = self.class.import(source_resource: member, source_metadata_adapter: source_metadata_adapter, change_set_persister: change_set_persister)\n # Set this property so derivatives will run, acts like a FileAppender.\n source_change_set.created_file_sets += [member] if member.is_a?(FileSet)\n member_ids << member.id\n end\n # Get rid of non-preserved members. If they're not preserved, it was\n # probably a bug - e.g. page 3 didn't make it into preservation.\n source_change_set.try(:member_ids=, member_ids)\n output = change_set_persister.save(change_set: source_change_set, external_resource: true)\n output\n end", "def add_member(opts)\n opts = check_params(opts,[:members])\n super(opts)\n end", "def index\n @members = Member.with_attached_avatar.all\n end", "def add_members(members)\n @members.merge!(members)\n end", "def reload\n new = search(:scope => :base, :limit => true)\n @original_attributes = new.instance_variable_get(:@original_attributes)\n @attributes = new.instance_variable_get(:@attributes)\n @dn = Ldaptic::DN(new.dn, self)\n @children = {}\n self\n end", "def toplevel_members; end", "def fetch(*_args, &_block)\n resource = super\n return resource if top_level_element?\n\n parent_hierarchy.each do |p|\n p.first.top_level_element = true\n p.first.fetch\n end\n resource\n end", "def publications\n @publications = Publication.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end", "def member_params\n params.require(:member).permit(\n :name, :load, :exit_cycle,\n member_positions_attributes: %i[id position_id _destroy],\n member_projects_attributes: %i[id project_id _destroy],\n manager_projects_attributes: %i[id project_id _destroy]\n )\n end", "def create\n if params[:date_validate] == \"false\"\n @flash = { status: :none }\n else\n @member = Member.new(as_params(params))\n @member.childrens_attributes = params[:member][:childrens_attributes]\n @member.status = true\n _charge_ids = []\n if [2,3,4,5].include?(params[:member][:membership_type].to_i)\n if params[:default_flat_2000].present? && params[:default_flat_2000] == \"DEFAULT_FLAT_2000\"\n _charge_ids = _charge_ids + Charge.where(\"freq_flag = 'DEFAULT_FLAT_2000'\").collect(&:id)\n end\n Charge.where(freq_flag: [\"MEMBER_3_PER_WEEK\",\"MEMBER_4_PER_WEEK\",\"MEMBER_5_PER_WEEK\"]).each_with_index do |charge, index|\n _charge_ids << params[\"member_#{charge.activity.id}_#{index}\"] if params.has_key?(\"member_#{charge.activity.id}_#{index}\")\n end\n Charge.where(freq_flag: [\"MEMBER_SUMMER_1_PER_WEEK\",\"MEMBER_SUMMER_2_PER_WEEK\",\"MEMBER_SUMMER_3_PER_WEEK\"]).each_with_index do |charge, index|\n _charge_ids << params[\"member_summer_#{charge.activity.id}_#{index}\"] if params.has_key?(\"member_summer_#{charge.activity.id}_#{index}\")\n end\n @member.charge_ids = _charge_ids\n end\n if @member.save\n UserMailer.invitation(@member).deliver\n @flash = { status: :success, message: 'Member is successfully created.' }\n else\n @flash = { status: :warning, message: @member.errors.full_messages.join(',') }\n end\n end\n rescue Exception => e\n @flash = { status: :danger, message: e.message }\n end", "def people_for_publication(publication_version_id:)\n p2ps = People2publication.where(publication_version_id: publication_version_id).order(position: :asc)\n people = p2ps.map do |p2p|\n # Use unscoped to ignore the default scope deleted_at: nil for person to avoid crash.\n # TODO: Remove default scope\n person = Person.unscoped.where(id: p2p.person_id).first.as_json\n\n departments = Department.includes(:departments2people2publications).where(\"departments2people2publications.people2publication_id = ?\", p2p.id).order(\"departments2people2publications.position asc\")\n person['departments'] = departments.as_json(skip_children: true)\n\n presentation_string = Person.where(id: p2p.person_id).first.presentation_string(departments.map{|d| I18n.locale == :en ? d.name_en : d.name_sv}.uniq[0..1])\n person['presentation_string'] = presentation_string\n\n person\n end\n\n return people\n end", "def show\n @referential = @publication.referential\n breadcrumb\n end", "def create_derivatives\n begin\n if datastreams.include? PDF_CONTENT_DS\n DERIVATIVES_LOGGER.info(DateTime.parse(Time.now.to_s).strftime('%A %B %-d, %Y %I:%M:%S %p'))\n\n derivative_settings = setup_derivative_environment\n\n create_page_turner_json(derivative_settings)\n create_readme(derivative_settings)\n create_pdf_page_images(derivative_settings)\n else\n DERIVATIVES_LOGGER.error(\"Can't create PDF derivatives for #{pid}. Object does not have an Archival.pdf datastream.\")\n end\n\n rescue Magick::ImageMagickError => ex\n DERIVATIVES_LOGGER.error(\"Can't create PDF derivatives for #{pid}. ImageMagick error: #{ex.message}\")\n raise(ex)\n rescue SystemCallError => ex\n DERIVATIVES_LOGGER.error(\"Can't create PDF derivatives for #{pid}. I/O error: #{ex.message}\")\n raise(ex)\n rescue StandardError => ex\n DERIVATIVES_LOGGER.error(\"Can't create PDF derivatives for #{pid}. error: #{ex.message}\")\n raise(ex)\n ensure\n DERIVATIVES_LOGGER.info(DateTime.parse(Time.now.to_s).strftime('%A %B %-d, %Y %I:%M:%S %p'))\n DERIVATIVES_LOGGER.info('') # blank line between events\n end\n\n end", "def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end", "def enable_for_public\n # TODO Create and write all the checks necessary for the listing to become active and public\n self.update_attribute(:active, true)\n end", "def index\n @members = Member.all\n @page = Page.find_by_id(8)\n\t@pdf_files = PdfFile.all\n\n @member = Member.new\n user = @member.build_user\n @roles = Role.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @members }\n end\n end", "def all_descendent_members\n raise TypeError.new(\"can only call on a persisted object\") unless persisted? && id.present?\n\n sql = <<~EOS\n id IN (WITH RECURSIVE tree AS (\n SELECT id, ARRAY[]::UUID[] AS ancestors\n FROM kithe_models WHERE id = '#{self.id}'\n\n UNION ALL\n\n SELECT kithe_models.id, tree.ancestors || kithe_models.parent_id\n FROM kithe_models, tree\n WHERE kithe_models.parent_id = tree.id\n ) SELECT id FROM tree WHERE id != '#{self.id}')\n EOS\n\n\n Kithe::Model.where(sql)\n end", "def generate_revision_page(payments)\n payments.to_xml(:skip_instruct => true, :root => 'slice')\n end", "def dl_and_update_medias_directly_from_root\n raise \"dl_and_update_medias_directly_from_root must be redefined in children classes\"\n end", "def members=(value)\n @members = value\n end", "def members=(value)\n @members = value\n end" ]
[ "0.60017693", "0.56515074", "0.51981527", "0.5187353", "0.5185061", "0.51598805", "0.5136127", "0.50696236", "0.49961883", "0.495845", "0.4948948", "0.49079594", "0.49011508", "0.48758703", "0.4830166", "0.4822564", "0.4743451", "0.47218892", "0.47218892", "0.47218892", "0.47218892", "0.47218892", "0.47218892", "0.47218892", "0.47032443", "0.4694968", "0.46892652", "0.46824992", "0.46810794", "0.46404836", "0.46310744", "0.46144342", "0.46117336", "0.45928922", "0.45770046", "0.455504", "0.45402858", "0.45402858", "0.45318878", "0.45251969", "0.45185584", "0.45144022", "0.45015904", "0.44991875", "0.4493654", "0.44932312", "0.44923383", "0.44766572", "0.4474968", "0.44722992", "0.44620177", "0.44332168", "0.44326115", "0.44314912", "0.44277117", "0.4427301", "0.44132", "0.44061014", "0.44021514", "0.44011876", "0.43983835", "0.4370663", "0.43636197", "0.4362567", "0.43616298", "0.43616298", "0.43485707", "0.43482992", "0.43458655", "0.4343967", "0.4341584", "0.4334381", "0.43260413", "0.43179527", "0.43014184", "0.42934525", "0.42905504", "0.4290496", "0.42809284", "0.4276925", "0.427425", "0.42728677", "0.42717072", "0.4264342", "0.4263684", "0.42561677", "0.42559108", "0.42555967", "0.42549866", "0.42531884", "0.42446718", "0.42386", "0.4233184", "0.42315686", "0.42314735", "0.42277837", "0.41996282", "0.41955447", "0.41941604", "0.41941604" ]
0.64027566
0
name | scenario | passed | failed | pending | result | | | | |
def scenarios @@scenarios ||= ( ss = [] feature = feature_build(feature_a) examples = run_feature(feature, '/path/to/test1.feature') ss << TurnipFormatter::Resource::Scenario::Pass.new(examples[0]) ss << TurnipFormatter::Resource::Scenario::Failure.new(examples[1]) feature = feature_build(feature_b) examples = run_feature(feature, '/path/to/test2.feature') ss << TurnipFormatter::Resource::Scenario::Pending.new(examples[0]) feature = feature_build(feature_c) examples = run_feature(feature, '/path/to/test3.feature') ss << TurnipFormatter::Resource::Scenario::Pass.new(examples[0]) ss << TurnipFormatter::Resource::Scenario::Pass.new(examples[1]) ss ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n if (!plan_results || plan_results == [])\n return 'no_tests'\n end\n if (plan_results['state'] == \"Successful\")\n return 'pass'\n end\n if (plan_results['state'] != \"Successful\")\n return 'fail'\n end\n return 'no_tests'\n end", "def step_result; end", "def report_test_result success, msg\n if(success)\n print_success msg\n else\n print_error msg\n end\nend", "def status\n return \"Passed\" if self.passed?\n return \"Failed\" if self.failed?\n return \"Not Run\"\n end", "def passed_tests\n self.tests.select do |test|\n test.status == 'passed'\n end\n end", "def after_test_step(test_step, result)\n #puts test_step.to_yaml\n puts \"after #{test_step.class} result is #{result}\"\n puts result.to_yaml\n #p result.kind_of? Cucumber::Core::Test::Result::Passed\n #p result.kind_of? Cucumber::Core::Test::Result::Skipped\n end", "def results_status()\n r = attr_get(\"status\")\n if(r.eql?(\"passed\"))\n \"passed\"\n else\n \"failed\"\n end\n end", "def test_checklist_status_values_not_started\n test = @product.product_tests.checklist_tests.first\n passing, failing, not_started, total = checklist_status_values(test)\n\n assert_equal 0, passing\n assert_equal 0, failing\n assert_equal 1, not_started\n assert_equal 1, total\n end", "def scenarios\n @runner.done_scenarios\n end", "def after_test_step(step,result)\n unless result.passed?\n # only the first non-passed step\n failed_step[:step] ||= step\n failed_step[:result] ||= result\n end\n end", "def test_steps; end", "def test_steps; end", "def passing_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :passed\n end\n end", "def running_test_case; end", "def current_state\n if !self.failure_message.nil?\n { message: self.failure_message, status: :forced_failure }\n elsif temporary\n { message: 'Running Visual Tests', status: :pending }\n else\n unapproved_count = self.unapproved_diffs.count\n approved_count = self.approved_diffs.count\n new_count = self.new_tests.count\n message_components = []\n message_components.push(\"#{new_count} new tests\") if new_count > 0\n\n if unapproved_count > 0\n message_components.push(\"#{unapproved_count} unapproved diffs\")\n end\n\n if approved_count > 0\n message_components.push(\"#{approved_count} approved diffs\")\n end\n\n message = message_components.count > 0 ? message_components.join(', ') : '0 diffs'\n status = unapproved_count > 0 ? :failure : :success\n { message: message, status: status }\n end\n end", "def test_step; end", "def test_cases; end", "def failures; end", "def failures; end", "def failures; end", "def running_test_step; end", "def succeeded?; state == 'succeeded'; end", "def succeeded?; state == 'succeeded'; end", "def example_passed(notification)\n add_row(test_information(notification).merge(pass: 1))\n end", "def strategies_for_success\n end", "def report_test_result(test_name, status, message)\n if status == true\n status_string = \"success\"\n else\n status_string = \"failure\"\n end\n\n if !message or message == \"\"\n message = \"No message\"\n end\n\n if (message.is_a?(Array))\n temp = \"\"\n for m in message\n temp += m.to_s + \"\\n\"\n end\n message = temp\n end\n\n if(!$test_report)\n $test_report = {\"success\" => [], \"failure\" => []}\n end\n\n $test_report[status_string].push({\"test_name\" => test_name, \"lead_state\" => @lead_state, \"message\" => message})\n puts \"[\" + status_string + \"] \" + @lead_state + \" > \"+ test_name + \": \" + message\nend", "def results_state results\n if results.respond_to?(:errored?) && results.errored?\n 'Errored'\n elsif results.failing?\n 'Failing'\n elsif results.pending? || results.empty?\n 'Pending'\n else\n 'Passing'\n end # if-elsif-else\n end", "def compare_result(test, result)\n if @per_test_insert\n expected = translate_column_names(test['expected'])\n else\n expected = test['expected']\n end\n expected.each do |key, value|\n if value == 'ignore'\n next\n end\n\n if !compare_values(value, result[key])\n @num_fails += 1\n @failed_tests.push(test['name'])\n\n puts \" Expected: \\\"#{key}\\\": #{value}\"\n puts \" Result: \\\"#{key}\\\": #{result[key]}\"\n puts \" Status: Failed\"\n return\n end\n end\n\n @num_successes += 1\n puts \" Status: Passed\"\n end", "def failed?; state == 'failed'; end", "def failed?; state == 'failed'; end", "def derive_results(resources)\n # Total resources \n total = resources.count\n # Count the passing resources\n passed_count = 0\n resources.map{|r| if r['status'] == 'passed' then passed_count += 1 end }\n # Set passing if all are passed\n status = 'failed'\n status = 'passed' if passed_count >= total\n # Return hash\n return {'status'=>status, 'passed'=>passed_count, 'total'=>total}\nend", "def passed_test?(event)\n event['event'] == 'test' && event['status'] == 'pass'\n end", "def print_results\n if [email protected]?\n @failures.each do |test|\n pout \"\\nFailed: #{test[:desc]}\"\n puts test[:result]\n # print a newline for easier reading\n puts \"\"\n end\n abort\n else\n puts \"All passed!\".green\n end\nend", "def failure_feature_with_two_scenarios\n feature = failure_feature_title + failure_scenario + success_scenario\n steps = failure_step + success_step + \"\\nend\"\n write_feature failure_filename, feature,\n failure_step_filename, steps\n end", "def spec(result, log = true)\n @run_count += 1\n if result.passing?\n @passes << result\n elsif result.pending?\n @pendings << result\n else\n @failures << result\n end\n log_spec(result) if log\n @stdout = \"\"\n end", "def example_failed(notification)\n add_row(test_information(notification).merge(pass: 0))\n end", "def runTest(browser)\n puts \"Step 2: At step description here\"\n #Do shit here\n #....\n puts \"Step 3: ....\"\n #Do more shit here\n #....\n\n puts \"Expected Result:\"\n puts \"Result that we expect to happen.\"\n\n if true #Test passed condition here\n self.passed = true\n puts \"TEST PASSED. Add some description/details here\"\n else #Test failed condition here\n self.passed = false\n puts \"TEST FAILED. Show what we have screwed up\"\n end\n end", "def send_result(test_case,result,id,testrun)\n testrail_status = case \n when result.passed?\n {id:1,comment: 'passed'}\n when result.failed?\n {id:5,comment: 'failed'}\n when result.undefined?\n {id:7,comment: 'undefined step'}\n when result.pending?\n {id:6,comment: 'pending step'}\n end\n unless result.passed?\n # the before step can fail. So we have to check\n if @failed_step[:step].source.last.is_a?(Cucumber::Hooks::BeforeHook)\n failed_step = 'failed in the before hook'\n location = 'before hook'\n elsif @failed_step[:step].source.last.is_a?(Cucumber::Hooks::AfterHook)\n failed_step = 'failed in the after hook'\n location = 'after hook'\n else\n failed_step = \"#{@failed_step[:step].source.last.keyword}#{@failed_step[:step].source.last.name}\"\n location=@failed_step[:step].source.last.file_colon_line\n end\n failure_message = <<-FAILURE\n Error message: #{testrail_status[:comment]} #{result.exception.message}\n Step: #{failed_step}\n Location: #{location}\n FAILURE\n else\n failure_message = nil\n end\n #only send defects if the test is not passed\n report_on_result = {status_id:testrail_status[:id],comment:failure_message,defects:testrail_status[:id]==1 ? '' : defects(test_case)}\n begin\n testrail_api_client.send_post(\"add_result_for_case/#{testrun}/#{id}\",report_on_result)\n rescue => e\n if e.message =~ /No \\(active\\) test found for the run\\/case combination/\n add_case_to_test_run(id,testrun)\n retry\n else\n puts \"#{e.message} testrun=#{testrun} test case id=#{id}\"\n end\n end\n end", "def evalscenarios(scenarios)\n data={} # = { pass: pass, fail: fail, error: error, datetime: datetime1, resultinfo1: result1}\n count=0\n runstopped = nil\n latestdate =nil\n\n scenarios.each do |test|\n begin\n count +=1\n pf = eeval(test['status']) if test.has_key?('status')\n dt = eeval(test['datetime']) if test.has_key?('datetime')\n sc = eeval(test['scenario']) if test.has_key?('scenario')\n ff = eeval(test['failstep']) if test.has_key?('failstep')\n if pf\n if pf == \"pass\"\n data[\"pass#{count}\"] = \"PASS\"\n elsif pf == \"fail\"\n data[\"fail#{count}\"] = \"FAIL\"\n elsif pf == \"error\"\n data[\"error#{count}\"] = \"ERROR\"\n end\n if dt\n #testdate = DateTime.parse(dt)\n #data[\"datetime#{count}\"] = testdate.strftime(\"%F %T\")\n starttime = Time.parse(dt).localtime\n dtlocal =starttime.strftime(\"%F %T\")\n data[\"datetime#{count}\"]=dtlocal\n end\n if sc\n data[\"scenario#{count}\"] = sc\n puts \"\\t#{pf}:#{dt}-#{sc}\"\n end\n if ff and pf != \"pass\"\n data[\"resultinfo#{count}\"] = ff\n else\n data[\"resultinfo#{count}\"] = \"\"\n end\n end\n rescue => e\n puts \"ERROR scenarios.each do |test| SCENARIO:#{count}\\n#{e}\"\n end\n end\n return runstopped, latestdate, data\nend", "def message(results)\n message = \"#{results[:tests]} tests\\n\"\n message << \"#{results[:assertions]} assertions\\n\"\n message << \"#{results[:failures]} failures\\n\"\n message << \"#{results[:errors]} errors\\n\"\n message\n end", "def context_return_value(desired_test_result)\n raise 'desired_test_result value must be either \"pass\" or \"fail\"' unless\n %w[pass fail].include?(desired_test_result)\n\n if desired_test_result == 'fail'\n 'returns offending logical resource id'\n else\n 'returns empty list'\n end\nend", "def test_it_can_get_outcome\n assert_equal :home_win, @game_1.outcome\n end", "def results\n ab_test_results.map { |result| [ result.ab_test.name, result.ab_test_option.name ] }.to_hash\n end", "def report_test_results(test_name, results)\n status = true\n message = \"\"\n for result in results\n # print (\"Status: \"+result[0].to_s+\"\\n\")\n status = (status && result[0])\n if (result[1].is_a?(Array))\n for m in result[1]\n message += m.to_s + \"\\n\\t\"\n end\n else\n message += result[1] + \"; \"\n end\n end\n\n report_test_result(test_name, status, message)\nend", "def tst_result\n passed? ? \"p\" : \"f\"\n end", "def test_both_players_exceed_defcon\n scenario us: 4, ussr: 5, defcon: 3\n assert_no_award\n end", "def test_should_create_test_results\n test_target_instance = get_new_test_target_instance(\"example2\", \"2012112802\")\n batch_edit_test_results(test_target_instance, members(:one), TestResult::TEST_TARGET_PASS, 'test_case_1', 'test_case_2')\n assert_response :success\n\n assert_test_result_valid(test_target_instance, members(:one), 'test_case_1', 1)\n assert_test_result_valid(test_target_instance, members(:one), 'test_case_2', 1)\n end", "def get_FailureDescription()\n \t return @outputs[\"FailureDescription\"]\n \tend", "def result\n state.try(:to_sym) == :passed ? 0 : 1\n end", "def success_count\n examples_total - examples_pending - examples_failed\n end", "def tagged_failure_feature_with_two_scenarios\n feature = \"@feature\\n\" +\n failure_feature_title +\n \" @failing\" +\n failure_scenario + \"\\n\" +\n \" @passing\\n\" +\n \" \" + success_scenario\n\n steps = failure_step +\n success_step + \"\\n\" +\n \"end\"\n\n write_feature(\n failure_filename, feature,\n failure_step_filename, steps\n )\n end", "def test_stats(example)\n file_path = example.metadata[:file_path].gsub('./qa/specs/features', '')\n api_fabrication = ((example.metadata[:api_fabrication] || 0) * 1000).round\n ui_fabrication = ((example.metadata[:browser_ui_fabrication] || 0) * 1000).round\n\n {\n name: 'test-stats',\n time: time,\n tags: {\n name: example.full_description,\n file_path: file_path,\n status: example.execution_result.status,\n smoke: example.metadata.key?(:smoke).to_s,\n reliable: example.metadata.key?(:reliable).to_s,\n quarantined: quarantined(example.metadata),\n retried: ((example.metadata[:retry_attempts] || 0) > 0).to_s,\n job_name: job_name,\n merge_request: merge_request,\n run_type: run_type,\n stage: devops_stage(file_path),\n testcase: example.metadata[:testcase]\n },\n fields: {\n id: example.id,\n run_time: (example.execution_result.run_time * 1000).round,\n api_fabrication: api_fabrication,\n ui_fabrication: ui_fabrication,\n total_fabrication: api_fabrication + ui_fabrication,\n retry_attempts: example.metadata[:retry_attempts] || 0,\n job_url: QA::Runtime::Env.ci_job_url,\n pipeline_url: env('CI_PIPELINE_URL'),\n pipeline_id: env('CI_PIPELINE_ID'),\n merge_request_iid: merge_request_iid\n }\n }\n rescue StandardError => e\n log(:error, \"Failed to transform example '#{example.id}', error: #{e}\")\n nil\n end", "def pending_feature_with_multiple_scenario\n feature_str = pending_feature_str + \"\\n\" + success_scenario\n steps = pending_step_class_str + pending_step + \"\\n\" + failure_step_definition + success_step + \"\\nend\"\n write_feature 'features/success_feature.feature', feature_str,\n 'features/steps/pending_feature_with_multiple_scenario.rb', steps\n end", "def test_should_create_test_result\n test_target_instance = get_new_test_target_instance(\"example1\", \"2012112801\")\n batch_edit_test_results(test_target_instance, members(:one), TestResult::TEST_TARGET_PASS, 'test_case_1')\n assert_response :success\n assert_test_result_valid(test_target_instance, members(:one), 'test_case_1', 1)\n end", "def post\n j :pass\nlabel :fail\n RVTEST_FAIL()\nlabel :pass\n RVTEST_PASS()\n RVTEST_CODE_END()\n end", "def test_both_players_level_and_exceed_defcon\n scenario us: 4, ussr: 4, defcon: 3\n assert_no_award\n end", "def run_completion_fields\n [\n { title: \"Result\", value: run[:result].humanize, short: true },\n {\n title: \"Tests Passed: #{run[:total_passed_tests]} - #{test_percentage(run[:total_passed_tests])}%\",\n value: \"<#{payload[:frontend_url]}?expandedGroups%5B%5D=passed | View all Passed tests>\",\n short: true\n },\n { title: \"Duration\", value: humanize_secs(run[:time_taken]), short: true },\n {\n title: \"Tests Failed: #{run[:total_failed_tests]} - #{test_percentage(run[:total_failed_tests])}%\",\n value: \"<#{payload[:frontend_url]}?expandedGroups%5B%5D=failed | View all Failed tests>\",\n short: true\n },\n { title: \"Environment\", value: run[:environment][:name], short: true },\n {\n title: \"Other Results: #{run[:total_no_result_tests]} - #{test_percentage(run[:total_no_result_tests])}%\",\n value: \"<#{payload[:frontend_url]}?expandedGroups%5B%5D=no_result | View all tests with no result>\",\n short: true\n }\n ]\n end", "def run_cmd_check_status_and_output(expected_status = \"succeed\", expected_result = nil)\n it do\n match_status(\"should #{expected_status}\")\n expect(cmd_output).to include(expected_result) if expected_result\n end\nend", "def test_completed(test)\n case test.status\n when 'passed'\n puts \"\\e[34mTest:\\e[0m \\e[37m#{test.name} Line: #{test.lineNumber}\\e[0m Status: \\e[92mPassed\\e[0m\"\n when 'failed'\n puts \"\\e[34mTest:\\e[0m \\e[37m#{test.name} Line: #{test.lineNumber}\\e[0m Status: \\e[31mFailed\\e[0m\"\n when 'undefined'\n puts \"\\e[34mTest:\\e[0m \\e[37m#{test.name} Line: #{test.lineNumber}\\e[0m Status: \\e[93mUndefined\\e[0m\"\n when 'pending'\n puts \"\\e[34mTest:\\e[0m \\e[37m#{test.name} Line: #{test.lineNumber}\\e[0m Status: \\e[96mPending\\e[0m\"\n end\n end", "def after_features(*args)\n @scenarios = failed_and_passed\n JiraInterface.new.report(formatted_scenarios)\n end", "def message\n \"Test has 'When' as the final step.\"\n end", "def failed_test?(event)\n event['event'] == 'test' && event['status'] == 'fail'\n end", "def pretty_result\n data['build']['result'] == 0 ? 'passes' : 'fails'\n end", "def create_test_case_by_name(project_name, plan_name, suite_name,\n test_case_name, login, summary, steps, expected_results)\n\n test_project_id = self.project_id(project_name)\n test_suite_id = self.suite_info(project_name, plan_name, suite_name)\n\n result = create_test_case(test_project_id, test_suite_id, test_case_name,\n summary, steps, expected_results, login)\n\n if result.any?\n result.each do |result_ptr|\n if result_ptr[:message].eql? \"Success!\"\n if result_ptr.has_key? \"additionalInfo\"\n result_info = result_ptr.fetch(\"additionalInfo\")\n if result_info[:msg].eql? \"ok\"\n test_case_id = result_info[:id]\n test_case_version = result_info[:version_number]\n return [test_case_id, test_case_version]\n else\n return -1\n end\n end\n end\n end\n end\n end", "def outcome\n status.first\n end", "def test_scenario2\n data = [[File.dirname(__FILE__)+'/data/iris_missing.csv', {\"fields\" => {\"000000\" => {\"optype\" => \"numeric\"}}}, {\"000000\" => 1}]]\n\n puts\n puts \"Scenario: Successfully obtaining parsing error counts\"\n\n data.each do |filename, params, missing_values|\n puts\n puts \"Given I create a data source uploading a %s file\" % filename \n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I update the source with params <%s>\" % JSON.generate(params)\n source = @api.update_source(source, params)\n assert_equal(BigML::HTTP_ACCEPTED, source[\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset with local source\"\n [email protected]_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"I ask for the error counts in the fields\"\n step_results = @api.error_counts(dataset)\n puts \"Then the error counts dict is <%s>\" % missing_values \n\n assert_equal(missing_values, step_results) \n \n end\n\n end", "def failed?\n (scenarios_results.include?\"failed\") || (steps_results.include?\"failed\")\n end", "def failing_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :failed\n end\n end", "def test_scenario2\n data = [{'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.98029',\n 'params' => {\"combiner\" => 0},\n 'tlp' => 1},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.95061',\n 'params' => {\"combiner\" => 1},\n 'tlp' => 1},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.98029',\n 'params' => {\"combiner\" => 2},\n 'tlp' => 1},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.98029',\n 'params' => {\"operating_kind\" => \"votes\"},\n 'tlp' => 1},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.97064',\n 'params' => {\"operating_kind\" => \"probability\"},\n 'tlp' => 1}, \n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.95061',\n 'params' => {\"operating_kind\" => \"confidence\"},\n 'tlp' => 1},\n ]\n \n puts\n puts \"Scenario: Successfully creating an evaluation for an ensemble\" \n\n data.each do |item|\n puts\n puts \"Given I create a data source uploading a \" + item[\"filename\"] + \" file\"\n source = @api.create_source(item[\"filename\"], {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset with local source\"\n [email protected]_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"And I create an ensemble of #{item['number_of_models']} models and #{item['tlp']} tlp\"\n \n ensemble = @api.create_ensemble(dataset, {\"number_of_models\"=> item[\"number_of_models\"], \n \"seed\" => 'BigML', \n 'ensemble_sample'=>{'rate' => 0.7, \n 'seed' => 'BigML'}, \n 'missing_splits' => false})\n \n\n puts \"And I wait until the ensemble is ready\"\n assert_equal(BigML::HTTP_CREATED, ensemble[\"code\"])\n assert_equal(@api.ok(ensemble), true)\n\n puts \"When I create an evaluation for the ensemble with the dataset\"\n evaluation = @api.create_evaluation(ensemble, dataset, item[\"params\"])\n\n puts \"And I wait until the evaluation is ready\"\n assert_equal(BigML::HTTP_CREATED, evaluation[\"code\"])\n assert_equal(@api.ok(evaluation), true)\n\n puts \"Then the measured #{item['measure']} is #{item['value']}\"\n evaluation = @api.get_evaluation(evaluation)\n assert_equal(item[\"value\"].to_f, evaluation[\"object\"][\"result\"][\"model\"][item[\"measure\"]].to_f) \n\n end\n\n end", "def result_case\n if @succeeded\n color_print(\"Success\", :green)\n else\n color_print(\"Error\", :red)\n end\n end", "def test_success_scenario\n assert last_response.ok?\n end", "def name\n name = self.TestResult\n end", "def report\n tests_executed_string = @executed_count == 1 ? \"test\" : \"tests\"\n tests_failed_string = @failed_count == 1 ? \"failure\" : \"failures\"\n tests_retried_string = @retried_count == 1 ? \"retry\" : \"retries\"\n\n if @failed_count > 0\n fail(\"Executed #{@executed_count}(#{@total_count}) #{tests_executed_string}, with **#{@failed_count}** #{tests_failed_string} 🚨\")\n @failures.each do |failure|\n fail(\"`[#{failure.content.split(\"/\").last}] [#{failure.parent['name']}] #{failure['message']}`\")\n end\n elsif @retried_count > 0\n message(\"Executed #{@executed_count}(#{@total_count}) #{tests_executed_string}, with #{@failed_count} #{tests_failed_string} and #{@retried_count} #{tests_retried_string} 🎉\")\n else\n message(\"Executed #{@executed_count}(#{@total_count}) #{tests_executed_string}, with #{@failed_count} #{tests_failed_string} 🎉\")\n end\n\n return @failed_count <= 0\n end", "def failure_feature\n feature = failure_feature_title + failure_scenario\n write_feature failure_filename, feature,\n failure_step_filename, failure_step + \"\\nend\"\n end", "def test_status_sym\n @job.status = nil\n assert ! @job.submitted?\n assert @job.not_submitted?\n\n @job.status = :Q\n\n assert @job.submitted?\n assert ! @job.completed?\n assert @job.active?\n assert_equal \"Queued\", @job.status.to_s\n\n @job.status = :R\n assert @job.active?\n assert_equal \"Running\", @job.status.to_s\n\n @job.status = :C\n assert @job.completed?, \"completed? should return true when status is C\"\n assert ! @job.failed?, \"failed? should return false when status is not F\"\n\n @job.status = :F\n assert @job.completed?, \"completed? should return true when status is F\"\n assert ! @job.passed?, \"passed? should return false when status is F\"\n assert @job.failed?, \"failed? should return true when status is F\"\n end", "def test_results_sad_one\r\n assert_output(\"Going home sad.\\n\") { @g.results(1) }\r\n end", "def run_vmth_test(scenario)\n @scenario=scenario\n service=scenario # legacy/lazy\n start_timer = Time.now()\n @results['tests'][service] = {}\n test_passed = true\n begin\n ssh_session do |session|\n @results['tests'][service]['apply'] =\n _recursor(@config['applying'],session)\n @results['tests'][service]['test'] =\n _recursor(@config['testing'],session)\n @results['tests'][service]['passed'] = @results['tests'][service]['apply']['passed'] \\\n and @results['tests'][service]['test']['passed']\n _recursor(@config['teardown'],session)\n @results['tests'][service]['teardown'] =\n _recursor(@config['teardown'],session)\n end\n rescue => e\n # If anything was raised here it is big problems yo.\n @results['tests'][service]['apply'] ||= {}\n @results['tests'][service]['apply']['passed'] = false\n @results['tests'][service]['test'] ||= {}\n @results['tests'][service]['test']['passed'] = false\n @results['tests'][service]['passed'] = false\n @results['tests'][service]['error'] = {\n 'class' => e.class.to_s, 'message' => e.message, 'backtrace' => e.backtrace\n }\n end\n @results['tests'][service]['elapsed_time'] = (Time.now() - start_timer)\n write_out_state()\n return @results['tests'][service]['passed']\n end", "def report\n\t\t\tputs \"Tests: #{@ok} ok, #{@fail} failures.\"\n\t\t\tif (@fail > 0)\n\t\t\t\tputs \"*** THERE WERE FAILURES *** \"\n\t\t\telse \n\t\t\t\tputs \"*** ALL TESTS PASSED ***\"\n\t\t\tend\n\t\tend", "def execution_state\n return :pending if self.test_executions.empty?\n\n self.test_executions.ordered_by_date.first.state\n end", "def test_result(run_id, case_id, result, error_message = '', options = {})\n unless !error_message.nil?\n error_message = 'PASSED'\n end\n options[:basic_auth] = @auth\n options[:body] = {\n executed_step: {\n actual_result: error_message,\n passed: result\n }\n }\n self.class.patch(\"/projects/id/runs/#{run_id}/executed_steps/#{case_id}.json\", options)\n end", "def make_step\n @result\n end", "def build_context_message(options)\n 'when ' + options.each_with_object([]) do |(attribute, value), msg|\n next msg if attribute == :outcome\n msg << \"'#{attribute}' is '#{value}'\"\n msg\n end.join(', ')\nend", "def message\n \"Test has 'Given' step after 'Then' step.\"\n end", "def run_succeeded; end", "def print_result_summary(result, time_taken=0)\n if result.failure_count == 0 && result.error_count == 0\n final_color = success_color\n elsif result.error_count > 0\n final_color = error_color\n else\n final_color = fail_color\n end\n\n out \"\\nTests: #{result.run_count}, Assertions: #{result.assertion_count}, Fails: #{result.failure_count}, Errors: #{result.error_count}, Time taken #{sprintf('%.2f', time_taken)}s\", final_color\n end", "def generate_default_result_and_time_columns(result, error_detail, passed)\n \"<td><pre>#{result.concat(\"\\n\").concat(error_detail) if !passed}</pre></td><td>0 seconds</td></tr>\"\n end", "def passes\n count - failures - errors - skips\n end", "def test(test=false, expecting=false, text=\"Unnamed Passing Test\")\n passed = test == expecting\n @tests += 1\n @passing += 1 if test == expecting\n result = passed ? PASS : FAIL\n symbol = passed ? SYM_PASS : SYM_FAIL\n status = \" #{result} (#{test.to_s[0]} #{symbol} #{expecting.to_s[0]})\"\n \n len_dot = WIDTH - text.length - status.length\n len_dot = 0 if len_dot < 0\n dots = (\".\"*len_dot).to_s\n flex_len = WIDTH - (status.length + dots.length)\n text = text[0..(flex_len-1)]\n result = \"#{text}#{dots}#{status}\"\n puts result\n result\n end", "def rspec(index)\n if not @succeeded\n puts \"\\n#{color_print(\"Error\", :red)} (#{index}) - \\\"#{@testcase.name}\\\"\"\n puts @error_message\n end\n end", "def call(*tests, env:)\n summary = execute_all(tests, env)\n List.new(\n List.new(Symbol.new(\"success\"), List.new(*summary[:success])),\n List.new(Symbol.new(\"failures\"), List.new(*summary[:failures]))\n )\n end", "def passed?\n !failed?\n end", "def compare_tests(test_a, test_b); end", "def compare_tests(test_a, test_b); end", "def test_scenario1\n data = [\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\", \n \"method\" => 0,\n \"prediction\" => \"a\",\n\t \"confidence\" => 0.450471270879},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\",\n \"method\" => 1,\n \"prediction\" => \"a\",\n \"confidence\" => 0.552021302649},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\",\n \"method\" => 2,\n \"prediction\" => \"a\",\n \"confidence\" => 0.403632421178},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 0,\n \"prediction\" => 1.55555556667, \n \"confidence\" => 0.400079152063},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 1,\n \"prediction\" => 1.59376845074,\n \"confidence\" => 0.248366474212},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 2,\n \"prediction\" => 1.55555556667,\n \"confidence\" => 0.400079152063}\n ]\n\n puts \"Scenario: Successfully computing predictions combinations\"\n data.each do |item|\n puts\n\n puts \"Given I create a MultiVote for the set of predictions in file <%s>\" % item[\"filename\"]\n multivote = BigML::MultiVote.new(JSON.parse(File.open(item[\"filename\"], \"rb\").read))\n\n puts \"When I compute the prediction with confidence using method <%s>\" % item[\"method\"]\n combined_results = multivote.combine(item[\"method\"], nil, true)\n\n puts \"And I compute the prediction without confidence using method <%s>\" % item[\"method\"] \n combined_results_no_confidence = multivote.combine(item[\"method\"])\n\n if multivote.is_regression() \n puts \"Then the combined prediction is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results[\"prediction\"].round(6), item[\"prediction\"].round(6))\n puts \"And the combined prediction without confidence is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results_no_confidence.round(6), item[\"prediction\"].round(6))\n else\n puts \"Then the combined prediction is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results[\"prediction\"], item[\"prediction\"])\n puts \"And the combined prediction without confidence is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results_no_confidence,item[\"prediction\"])\n end\n puts \"And the confidence for the combined prediction is %s \" % item[\"confidence\"]\n assert_equal(combined_results[\"confidence\"].round(5), item[\"confidence\"].round(5)) \n end\n\n end", "def unitTests\n\t\trender(json: {nrFailed: 0, output: \"return some output\", totalTests: 15})\n\tend", "def ab_get_outcome(_experiment)\n raise \"Not implemented\"\n end", "def smoke_test()\n return [\"case_aaaa\"]\n end", "def passed?\n return @test_passed\n end", "def all_pass_result_summary_msg\n if result_count < 1\n \"uhh...\"\n elsif result_count == 1\n \"pass\"\n else\n \"all pass\"\n end\n end" ]
[ "0.64807844", "0.643095", "0.6429154", "0.6415654", "0.6376603", "0.6359231", "0.63587785", "0.629693", "0.6261748", "0.6260855", "0.62587965", "0.62587965", "0.6207284", "0.61709565", "0.6134171", "0.61297894", "0.61281896", "0.61148816", "0.61148816", "0.61148816", "0.6109666", "0.6045804", "0.6045804", "0.5997594", "0.59939355", "0.59609526", "0.59510255", "0.5942467", "0.59349954", "0.59349954", "0.59300643", "0.5929252", "0.5927981", "0.5927084", "0.5908467", "0.5905615", "0.5901537", "0.58954525", "0.58869135", "0.58865213", "0.58841133", "0.5872508", "0.5868288", "0.585487", "0.5852412", "0.5833897", "0.58318186", "0.58276665", "0.5818871", "0.5811544", "0.5810037", "0.5807756", "0.58059835", "0.5764893", "0.5759832", "0.5753712", "0.575332", "0.5740854", "0.5733143", "0.5717931", "0.5708847", "0.5703829", "0.5699504", "0.5693517", "0.5693216", "0.56920844", "0.5685294", "0.5683467", "0.5668339", "0.5664465", "0.56604177", "0.5654956", "0.5646101", "0.5632106", "0.56171757", "0.5613754", "0.56086713", "0.5605512", "0.5605428", "0.55998653", "0.55933", "0.55897456", "0.5588167", "0.55831754", "0.5579821", "0.5579684", "0.5573424", "0.5568489", "0.55659676", "0.55541736", "0.55491567", "0.55478406", "0.55478406", "0.5547124", "0.554479", "0.5540074", "0.5539311", "0.553631", "0.5534073" ]
0.601309
24
add workflow triggered methods that run when corresponding event is triggered as necessary
def new_allocation allocate! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_custom_method\n # da implementare per eventuali estensioni\n end", "def workflow\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def define_event_helpers; end", "def run_actions; end", "def fire_events!(*events); end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def register_events\n EventReactor.sub(:trade_cleared, &method(:trade_cleared))\n EventReactor.sub(:round_change, &method(:change_round))\n EventReactor.sub(:ask_posted, &method(:ask_posted))\n EventReactor.sub(:bid_posted, &method(:bid_posted))\n end", "def events\n end", "def triggers\n\n end", "def def_hooks(*events)\r\n events.each { |event| def_hook(event) }\r\n end", "def on_investigation_end; end", "def on_investigation_end; end", "def before_workflow_launch(workflow, user)\n #raise \"Must implement in target model!\"\n end", "def send_events; end", "def add_actions; end", "def start_the_wf\n self.workflow_action = \"start\"\n trigger_workflow \n end", "def on_new_investigation; end", "def on_new_investigation; end", "def on_new_investigation; end", "def fire_workflow_event\n\n # Check that this is a valid event name for the state machines\n if @project.class.event_names.include? params[:event]\n event_name = params[:event]\n if @project.fire_state_event(event_name)\n event = WorkflowEvent.new\n event.creator = current_user\n event.accountable = @project\n event.event_type = event_name\n event.save\n notify_user(:notice, \"Capital Project #{@project.project_number} is now #{@project.state.humanize}.\")\n else\n notify_user(:alert, \"Could not #{event_name.humanize} capital project #{@project.project_number}\")\n end\n else\n notify_user(:alert, \"#{params[:event_name]} is not a valid event for a #{@project.class.name}\")\n end\n\n redirect_back(fallback_location: root_path)\n\n end", "def handle_child_workflow_execution_started(event)\n handle_event(event,\n {:id_methods => [:workflow_execution, :workflow_id],\n :consume_symbol => :handle_started_event,\n :decision_helper_scheduled => :scheduled_external_workflows,\n :handle_open_request => lambda do |event, open_request|\n open_request.run_id.set(event.attributes.workflow_execution.run_id)\n end\n })\n end", "def method_missing(sym,*args, &block)\n if sym.to_s.match(/^(on|before|after)_/)\n register_handler(sym.to_s,args.first,&block)\n else\n super\n end\n end", "def event_requirement; end", "def pre_hook_send(handler); end", "def action_hook; end", "def add_events(new_events); end", "def method_missing(sym,*args, &block)\n if sym.to_s.match(/^(on|before|after)_/)\n register_handler(sym.to_s,args.first,&block)\n else\n super\n end\n end", "def execute_callbacks(event)\n parent.execute_callbacks(event)\n fetch_or_create_callbacks.each do |callback|\n callback.call(event)\n end\n end", "def method_events events\n events - spec_events(events)\nend", "def run_on_additions(paths)\n @builder.notify\n end", "def prepare_for_execution(evt,config)\n # here for sub-classes to override.\n end", "def around_hooks; end", "def process_hooks(timing, args={})\n Rails.application.config.sparkle[:builder][:hooks][action_name][timing].each do |callback|\n callback.call(args)\n end\n end", "def trigger event, env\n triggered(event).each do |triggered_event|\n Nark.class_eval 'triggered_event.method_block.call env'\n end\n end", "def all_steps\n\t#make calls to step here...\nend", "def pre_task\n end", "def apply(raw_event); end", "def call\n return unless action.triggered_methods.any?\n success = action.triggered_methods.order(:weight).all? do |method|\n status = process_action(method.service_name)\n Hyrax.logger.debug(\"Result of #{method.service_name} is #{status}\")\n status\n end\n\n return save_target if success\n Hyrax.logger.error \"Not all workflow methods were successful, so not saving (#{target.id})\"\n false\n end", "def trigger(owner, event, *args); end", "def register_events(klass, state, other_params, &exec_block)\n @klass_being_defined = klass\n @state_being_defined = state\n\n # if an initial state has not been set, then set it. In practice, means the first state definition\n # gets the initial state.\n @cfsm_initial_state[ klass ] = state unless @cfsm_initial_state[ klass ]\n\n # Evaluate the transition definitions\n self.instance_eval( &exec_block ) if exec_block\n\n @klass_being_defined = nil\n @state_being_defined = nil\n @other_params = other_params\n end", "def added_events(events)\n\t\tsuper if defined? super\n\t\tPlanModificationHooks.added_objects(self, events) \n\t end", "def events=(_); end", "def before_create()\n end\n \n def before_update()\n end\n \n def before_destroy()\n end\n \n ##################################################################\n # execute the rule\n # this rule does nothing\n def process(process_id, plan, data)\n RulesEngine::Process.auditor.audit(process_id, \"Inside Rule #{title}\", RulesEngine::Process::AUDIT_INFO) \n # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_SUCCESS)\n # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_FAILURE)\n # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::START_WORKFLOW, 'next_workflow')\n RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::NEXT)\n end \n end", "def hooks\n # ???\n end", "def actions\n response = nil\n\n lambda do |_reason, data|\n puts \"[admin] Execute block code with reason : #{reason}\"\n case_events(data.to_hash)\n end\n\n response\n end", "def handle_workflow_execution_started(event)\n @workflow_async_scope = AsyncScope.new do\n FlowFiber.current[:decision_context] = @decision_context\n input = (event.attributes.keys.include? :input) ? event.attributes[:input] : nil\n @definition = @workflow_definition_factory.get_workflow_definition(@decision_context)\n @result = @definition.execute(input)\n end\n end", "def register_events\n EventReactor.sub(:trade_cleared, &method(:log_trade_cleared))\n EventReactor.sub(:round_change, &method(:log_round_change))\n end", "def define_action_hook; end", "def invoke!(state)\n ### TODO: encapsulate in PageUpdateQueue:\n Apotomo::EventProcessor.instance.processed_handlers << [name, invoke(:state)]\n end", "def create_events\n end", "def find_and_trigger_event(event_type, args = nil)\r\n \r\n case event_type\r\n when :before_change\r\n \r\n if respond_to?(:before_change)\r\n \r\n results = send(:before_change, args)\r\n return false if results == false\r\n \r\n end\r\n \r\n when :after_change\r\n \r\n if respond_to?(:after_change)\r\n \r\n results = send(:after_change, args)\r\n return false if results == false\r\n \r\n end\r\n \r\n when :before_change_field\r\n \r\n #CALL FOR A SPECIFIC FIELD THAT HAS CHANGED\r\n trigger_function_name = \"#{:before_change_field}_#{args.field_name}\"\r\n if respond_to?(trigger_function_name)\r\n \r\n results = send(trigger_function_name, args) \r\n return false if results == false\r\n \r\n end\r\n \r\n #CALL FOR ANY FIELD THAT CHANGES\r\n trigger_function_name = \"#{:before_change_field}\"\r\n if respond_to?(trigger_function_name)\r\n \r\n results = send(trigger_function_name, args) \r\n return false if results == false\r\n \r\n end\r\n \r\n when :after_change_field\r\n #looks in own class for :after_change_field for the field passed, requires the parameter of a Field object to be passed\r\n \r\n #SAPPHIRE UPDATE\r\n #SEARCH FOR ACTIVE MAP DEFINITION THAT INCLUDES THE CURRENT TABLE AND FIELD.\r\n #IF ANY ARE FOUND QUEUE THE PROCESS\r\n if args.table.field_order.include?(\"student_id\")\r\n \r\n if map_id = $tables.attach(\"SAPPHIRE_INTERFACE_MAP\").field_value(\r\n \"primary_id\",\r\n \"WHERE athena_table = '#{table_name }'\r\n AND athena_field = '#{args.field_name }'\r\n AND trigger_event = 'after_change_field'\"\r\n )\r\n \r\n sid = $tables.attach(args.table.table_name).field_value(\"student_id\", \"WHERE primary_id = '#{args.primary_id}'\")\r\n student = $students.get(sid)\r\n \r\n if student && student.active.is_true?\r\n \r\n queue_record = $tables.attach(\"SAPPHIRE_INTERFACE_QUEUE\").new_row\r\n queue_record.fields[\"map_id\" ].value = map_id\r\n queue_record.fields[\"athena_pid\" ].value = args.primary_id\r\n queue_record.save\r\n \r\n end\r\n \r\n end\r\n \r\n end\r\n \r\n #CALL FOR A SPECIFIC FIELD THAT HAS CHANGED\r\n trigger_function_name = \"#{:after_change_field}_#{args.field_name}\"\r\n if respond_to?(trigger_function_name)\r\n \r\n results = send(trigger_function_name, args) \r\n return false if results == false\r\n \r\n end\r\n \r\n #CALL FOR ANY FIELD THAT CHANGES\r\n trigger_function_name = \"#{:after_change_field}\"\r\n if respond_to?(trigger_function_name)\r\n \r\n results = send(trigger_function_name, args)\r\n return false if results == false\r\n \r\n end\r\n \r\n when :before_load #any table can have this event for self table\r\n \r\n continue_with_load = true\r\n \r\n this_trigger_event = \"before_load_#{table_name.downcase}\"\r\n \r\n tables_with_before_load_events = args ? args : event_array(this_trigger_event)\r\n \r\n tables_with_before_load_events.each{|file|\r\n this_table = $tables.attach(file)\r\n \r\n begin\r\n continue_with_load = this_table.send(this_trigger_event)\r\n \r\n rescue=> e\r\n #raise e #THIS SHOULD HAVE BEEN A SYSTEM NOTIFICATION - ADDING NOW BUT LEACING THIS NOTE HERE TO HELP IDENTIFY ANY ISSUES THAT MAY COME TO LIGHT WHICH WERE CONCEALED BY THIS BEFORE...\r\n $base.system_notification(\r\n subject = \"BEFORE LOAD FAILED - #{file}\",\r\n content = \"Don't just stand there and shout it; do something about it... Here's the error:\r\n #{e.message}\r\n <br>\r\n <br>\r\n #{e.backtrace}\"\r\n )\r\n \r\n end\r\n \r\n } if tables_with_before_load_events\r\n \r\n return continue_with_load\r\n \r\n when :after_load #any table can have this event for self table\r\n \r\n this_trigger_event = \"after_load_#{table_name.downcase}\"\r\n \r\n tables_with_after_load_events = args ? args.dup : event_array(this_trigger_event)\r\n \r\n db_config_record(\r\n field_name = \"phase_total\",\r\n new_value = tables_with_after_load_events.join(\",\")\r\n )\r\n db_config_record(\r\n field_name = \"phase_completed\",\r\n new_value = nil\r\n )\r\n \r\n if !args || args.include?(\"move_source_to_dest\")\r\n tables_with_after_load_events.delete(\"move_source_to_dest\")\r\n move_source_to_dest\r\n end\r\n \r\n tables_with_after_load_events.each{|file|\r\n this_table = $tables.attach(file)\r\n db_config_record(\r\n field_name = \"after_load_status\",\r\n new_value = \"Started #{file} - #{DateTime.now.strftime(\"%Y-%m-%d %H:%M:%S\")}\"\r\n )\r\n \r\n begin\r\n this_table.send(this_trigger_event)\r\n db_config_record = $tables.attach(\"Db_Config\").by_table_name(table_name)\r\n phase_completed = db_config_record.fields[\"phase_completed\"].value\r\n phase_completed = (phase_completed ? \"#{phase_completed},#{file}\" : file)\r\n db_config_record(\r\n field_name = \"phase_completed\",\r\n new_value = phase_completed\r\n )\r\n db_config_record(\r\n field_name = \"after_load_status\",\r\n new_value = \"Completed #{file} - #{DateTime.now.strftime(\"%Y-%m-%d %H:%M:%S\")}\"\r\n )\r\n \r\n rescue=> e\r\n after_load_failed(message = \"#{file} - #{e.message} <br><br> #{e.backtrace}\", e)\r\n raise e\r\n end\r\n \r\n } if tables_with_after_load_events\r\n \r\n when :after_insert\r\n send(:after_insert, args) if respond_to?(:after_insert)\r\n \r\n when :after_save\r\n send(:after_save, args) if respond_to?(:after_save)\r\n \r\n when :before_insert\r\n #Looks in own class for before_insert event, requires the parameter of a Row object to be passed\r\n if respond_to?(:before_insert)\r\n send(:before_insert, args)\r\n else\r\n return true\r\n end\r\n \r\n end\r\n \r\n return true\r\n \r\n end", "def events\n @execution.events if @execution\n end", "def event; end", "def event; end", "def event; end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def optimize_workflow\n end", "def event_change\n\t\n\tend", "def run_on_additions(paths)\n end", "def execute_callbacks(event)\n parent.execute_callbacks(event)\n callbacks.execute(event)\n end", "def add_custom_handlers\n # Set up hooks\n @irc.on_msg self.method(:_in_msg)\n @irc.on_act self.method(:_in_act)\n @irc.on_invite self.method(:_in_invited)\n @irc.on_kick self.method(:_in_kick)\n @irc.saying_join self.method(:_out_join)\n end", "def call_events\n model.call_events.map{|c| Event::CallDecorator.new(c) }\n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def runnable_methods; end", "def runnable_methods; end", "def handle_child_workflow_execution_completed(event)\n handle_event(event,\n {:id_methods => [:workflow_execution, :workflow_id],\n :consume_symbol => :handle_completion_event,\n :decision_helper_scheduled => :scheduled_external_workflows,\n :handle_open_request => method(:completion_function)\n })\n end", "def run_callbacks(index = 0)\n if index == 0\n # Clears any traces of the event attribute to prevent it from being\n # evaluated multiple times if actions are nested\n each do |transition|\n transition.machine.write(object, :event, nil)\n transition.machine.write(object, :event_transition, nil)\n end\n\n # Rollback only if exceptions occur during before callbacks\n begin\n super\n rescue\n rollback unless @before_run\n @success = nil # mimics ActiveRecord.save behavior on rollback\n raise\n end\n\n # Persists transitions on the object if partial transition was successful.\n # This allows us to reference them later to complete the transition with\n # after callbacks.\n each { |transition| transition.machine.write(object, :event_transition, transition) } if skip_after && success?\n else\n super\n end\n end", "def run_em_hooks type\n @example_group_instance.class.em_hooks[type].each do |hook|\n if @example_group_instance.respond_to? :instance_eval_without_event_loop\n @example_group_instance.instance_eval_without_event_loop(&hook)\n else\n @example_group_instance.instance_eval(&hook) #_with_rescue(&hook)\n end\n end\n end", "def add_method_hooks\n eigen_class = @target.singleton_class\n\n if @options[:class_methods]\n return unless @target.is_a?(Module)\n\n orig_singleton_method_added = @target.method(:singleton_method_added)\n\n eigen_class.send :define_method, :singleton_method_added do |method|\n aspector_singleton_method_added(method)\n orig_singleton_method_added.call(method)\n end\n else\n if @target.is_a? Module\n orig_method_added = @target.method(:method_added)\n else\n orig_method_added = eigen_class.method(:method_added)\n end\n\n eigen_class.send :define_method, :method_added do |method|\n aspector_instance_method_added(method)\n orig_method_added.call(method)\n end\n end\n end", "def before_running(*args); end", "def hook_run\n\trun_hook = {\n\t :return => :execute\n\t}\n\tmake_magic_hooks(run_hook)\n end", "def processEvent(eventName)\n\tend", "def before_execution(method_name)\n end", "def create_work_event\n\t\n end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\n return unless compile_time\n Array(action).each do |action|\n run_action(action)\n end\nend", "def after_created\n return unless compile_time\n Array(action).each do |action|\n run_action(action)\n end\nend", "def after_created\n return unless compile_time\n Array(action).each do |action|\n run_action(action)\n end\nend", "def apply_events(events)\n events.each do |event|\n method_name = event_handler(event)\n public_send(method_name, event.data) if respond_to?(method_name)\n end\n @revision = events.last&.revision.to_i if events.last.respond_to?(:revision)\n end", "def trigger_class_callback_actions(method, type)\n self.class.callback_actions_for(method, type).each do |callback|\n \n if callback.block\n self.instance_eval(&callback.block)\n else\n callback.proc.call\n end\n end\n \n #I'm not happy with this...\n if self.respond_to?(\"#{type}_#{method}\")\n self.send(\"#{type}_#{method}\")\n end\n end", "def configure_events(model, view)\n command_queue.each do |cmd|\n case\n when cmd.is_a?(EventCommand)\n view.add_command(cmd)\n when cmd.is_a?(TimedCommand)\n view.add_timer(cmd)\n view.proxy.start_timer(cmd)\n when cmd.is_a?(BehaviorCommand)\n model.add_command cmd\n end unless cmd.attached?\n end\n end", "def when_running(*args); end", "def callbacks; end", "def callbacks; end", "def trigger!\n end", "def on_start(_klass, _method); end", "def add_event(event_name, &block)\n # We don't want to randomly override things that we shouldn't\n raise \"Method already taken can_#{event_name}?\" if @class.methods.include?(:\"can_#{event_name}?\")\n raise \"Method already taken #{event_name}\" if @class.methods.include?(:\"#{event_name}\")\n raise 'Event #{event_name} already exists. Rename or combine the events' if events.include? event_name\n event = Event.new(event_name, &block)\n @events[event_name] = event\n\n # Add the states from the transition\n event.transitions.each_value do |transition|\n add_state transition.to\n add_state transition.from\n end\n\n # Creates the method can_event_name?\n @class.send(:define_method, :\"can_#{event_name}?\") do\n event.transitions.key? current_state.name\n end\n\n # Creates the method event_name\n @class.send(:define_method, :\"#{event_name}\") do\n if event.transitions.key? current_state.name\n\n # Makes sure the transition can happen\n transition = event.transitions[current_state.name]\n if transition.condition.nil? or self.instance_exec(&transition.condition)\n\n new_state = states[event.transitions[current_state.name].to]\n\n # Call all of the \"before event\" callbacks\n event.callbacks[:before].each do |callback|\n self.instance_eval &callback\n end\n\n # Call all of the before_all callbacks\n if callbacks[:before].key? :all\n callbacks[:before][:all].each do |callback|\n self.instance_eval &callback\n end\n end\n\n # Call the \"before state\" callbacks\n if callbacks[:before].key? new_state.name\n callbacks[:before][new_state.name].each do |callback|\n self.instance_eval &callback\n end\n end\n\n # Set the current state\n @current_state = new_state\n\n # call the \"after state\" callbacks\n if callbacks[:after].key? current_state.name\n callbacks[:after][current_state.name].each do |callback|\n self.instance_eval &callback\n end\n end\n\n # call the \"after all\" callbacks\n if callbacks[:after].key? :all\n callbacks[:after][:all].each do |callback|\n self.instance_eval &callback\n end\n end\n\n # Call the \"after event\" callbacks\n event.callbacks[:after].each do |callback|\n self.instance_eval &callback\n end\n self\n end\n end\n end\n end", "def perform_hooks!\n @perform_hooks = true\n end", "def update_global_common_events\n end", "def trigger hook, *args\n return unless self.class.hooks[hook]\n self.class.hooks[hook].each do |block|\n instance_exec(*args, &block)\n end\n end", "def event_bus; end", "def event_bus; end" ]
[ "0.6767924", "0.6590258", "0.6306053", "0.6273421", "0.6253403", "0.6125355", "0.61116534", "0.61116534", "0.61116534", "0.61116534", "0.61116534", "0.61116534", "0.61116534", "0.61116534", "0.60709643", "0.6016223", "0.596318", "0.5944855", "0.5931129", "0.5931129", "0.59297615", "0.5929023", "0.59171903", "0.58978075", "0.5875026", "0.5875026", "0.5875026", "0.58337224", "0.58179665", "0.5811896", "0.5772844", "0.5765827", "0.5752063", "0.57422644", "0.5734902", "0.56892455", "0.56873137", "0.56848884", "0.56759715", "0.5663711", "0.56501323", "0.56451386", "0.5639399", "0.5606653", "0.56049263", "0.5602109", "0.5600558", "0.55872595", "0.5586113", "0.55808306", "0.55783", "0.5569335", "0.5565903", "0.55656683", "0.5546446", "0.55435675", "0.5540647", "0.55401444", "0.55397785", "0.5535664", "0.5528529", "0.5528529", "0.5528529", "0.550951", "0.5506924", "0.55033344", "0.5492271", "0.5456917", "0.5443569", "0.5429815", "0.54264486", "0.5421845", "0.5421845", "0.54179233", "0.5416965", "0.5416892", "0.5411342", "0.540573", "0.5401648", "0.53959644", "0.53855944", "0.5382493", "0.5377438", "0.5377438", "0.5373735", "0.5373735", "0.5373735", "0.53686756", "0.5365998", "0.5351506", "0.5348066", "0.5346101", "0.5346101", "0.5342718", "0.5341106", "0.5339334", "0.53334653", "0.5330962", "0.53119254", "0.5311538", "0.5311538" ]
0.0
-1
These methods need an id parameter. Ruby Kernel__callee__ gets the method name being called. verb = :aget ver[1..1] => "get" aget(id, merge_params(id, params))
def amethod_with_id(id, params={}, &payload) verb = send(:__callee__)[1..-1] pio.async(payload) { self.send(verb, id, merge_params(id, params)) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n @get ||= Verb.new do |verb|\n verb.entity :air, :lodging, :car, :rail, :transport, \\\n :cruise, :restaurant, :activity, :note, :map, :directions, \\\n :points_program \\\n do |entity, id|\n do_request('get', entity, {:id=>id}, nil)\n end\n\n verb.entity :profile do |*args|\n entity = args[0]\n do_request('get', entity, nil, nil)\n end\n\n verb.entity :trip do |*args|\n entity, id, filter = args\n if filter.nil?\n filter = {}\n end\n filter[:id] = id\n do_request('get', entity, filter, nil)\n end\n end\n end", "def method_missing(method_id, params = {})\n request(method_id.id2name.gsub(/_/, '.'), params)\n end", "def method_missing(method_id, *params)\n _request(method_id.to_s.sub('_api', ''), *params)\n end", "def get\n end", "def get; end", "def _get\n http_method(:get)\n end", "def get\n end", "def get\n url = prefix + \"get\" + id_param\n return response(url)\n end", "def get!\n request! :get\n end", "def method_missing(method_name, box_id)\n # get_(bone / kibble / treat )_(info / tastiness) and pass 'box_id'\n raise \"Simple argument error\" unless box_id.is_a?(Integer)\n\n method_name = method_name.to_s\n\n if method_name.start_with?(\"get_\")\n attr_str = method_name[(\"get_\".length)..-1]\n attr_names = attr_str.split(\"_\")\n\n raise 'Second-level method name error' unless attr_names.length == 2\n\n food , data_request = attr_names\n\n return data[box_id][\"#{food}\"][\"#{data_request}\"]\n else\n raise 'Simple method name error'\n end\n end", "def method_missing(meth, *args, &blk) \n\t\traise NoMethodError if (meth.to_s == 'id')\n\t\t\t\n\t\tself.bien[0].send(meth, *args, &blk)\n\t\t\n\t\trescue NoMethodError\n\t\t\tsuper\n\tend", "def get(path, data={})\n http_verb :get, path, data\n end", "def get(*args, &block); end", "def GET; end", "def get(path, **args); end", "def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end", "def get(*args, &block)\n end", "def http_method\n :get\n end", "def get(data = {})\n call data, method: :get\n end", "def get\n end", "def method_missing(name, *args)\n options = args.first\n options = {} unless options.kind_of?(Hash)\n method_name = toCamel(name)\n get(options.merge(:method => method_name))\n end", "def method_missing(meth, *args, &block)\n retrieve(meth.to_s)\n end", "def detail(params={})\n self.request(__method__, params)\n end", "def get(params={})\n rpc_call :get, params\n end", "def get(params)\n request.method = :get\n execute(params)\n end", "def get\n execute(:get)\n end", "def get\n execute(:get)\n end", "def get(path, options={})\n http_verb :get, path, options\n end", "def method_missing(method, cache: true, **kwargs)\n uri = create_uri(method.id2name, kwargs)\n EOAT::Request.new(@host, uri, EOAT::Result::EveType::Result).get(cache)\n end", "def method_missing(id, *params, &b)\n @hash.send(id, *params, &b)\n end", "def get(path, options = {}, &block); add :get, path, options, &block end", "def get(*args)\n execute(:get, *args)\n end", "def method_missing(method_id, *arguments, &block)\n if %i[get post put delete].include? method_id\n send_to_connection method_id, arguments\n else\n super\n end\n end", "def api_get(action, data)\n api_request(action, data, 'GET')\n end", "def api_get(action, data)\n api_request(action, data, 'GET')\n end", "def get(path, id)\n path = \"#{API_PATH}#{path}\"\n return super(path, id, headers: admin_headers(path, '', 'GET', resource_id: id))\n end", "def operation_get(job_id, interaction_id, path, cgi_info)\n interactive_front(job_id, interaction_id).get(path, cgi_info)\n end", "def request_method\n {:filter => :post,\n :sample => :get,\n :firehose => :get,\n :retweet => :get\n }.fetch(@path, :get)\n end", "def get(options = nil)\n options ||= {}\n options[:method] = :get\n call options\n end", "def method_missing(methid, *rest)\n meth = methid.id2name\n\t\t\t #$stderr.print \"method_missing: #{meth}\\n\"\n\t\t\t\t#$stderr.print \"parameters: #{@parameters.keys.inspect}\\n\"\n if @parameters.has_key?(meth)\n\t\t\t\t #$stderr.print \"return parm obj\\n\"\n\t\t\t return @parameters[meth].value\n\t\t\t elsif mat = /^(.*?)\\=$/.match(meth)\n\t\t\t\t #$stderr.print \"return parm val\\n\"\n if @parameters.has_key?(mat[1])\n\t\t\t\t\t return @parameters[mat[1]].value = rest[0]\n\t\t\t\t else\n\t\t\t\t\t raise NoMethError\n end\n\t\t\t else\n\t\t\t raise NoMethodError\n\t\t\t end\n end", "def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def a_id_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemsApi.a_id_get ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling SystemsApi.a_id_get\"\n end\n if @api_client.config.client_side_validation && id.to_s.length > 19\n fail ArgumentError, 'invalid value for \"id\" when calling SystemsApi.a_id_get, the character length must be smaller than or equal to 19.'\n end\n\n if @api_client.config.client_side_validation && id.to_s.length < 17\n fail ArgumentError, 'invalid value for \"id\" when calling SystemsApi.a_id_get, the character length must be great than or equal to 17.'\n end\n\n pattern = Regexp.new(/^[0-9]{17,19}/)\n if @api_client.config.client_side_validation && id !~ pattern\n fail ArgumentError, \"invalid value for 'id' when calling SystemsApi.a_id_get, must conform to the pattern #{pattern}.\"\n end\n\n # resource path\n local_var_path = '/a/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'System'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"SystemsApi.a_id_get\",\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: SystemsApi#a_id_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n\n type = GET\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 126:7: 'get'\n match( \"get\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 5 )\n\n end", "def method\n options[:method] || :get\n end", "def get(path, params = {})\n\t\trequest(path, :get, params)\n\tend", "def one_bus_away(method, id=nil, params={})\n\t\t# optional id parameter. omit it and it will be ignored\n\t\tif id.class() == Hash \n\t\t\tparams = id\n\t\t\tid = nil\n\t\tend\n\n\t\t# prepare the query parameter string\n\t\t# params['includeReferences'] = false\n\t\t[:format, :controller, :action, :method, :id].each {|key| params.delete key }\n\t\t@query = params.map {|key, value| \"#{key}=#{value}\"}.join('&')\n\t\t\n\t\t# encode ID in URL if it exists\n\t\tmethod += \"/\" + ERB::Util.url_encode(id) unless id.nil?\n\n\t\tputs \"method: #{method}, query: #{@query}\"\n\t\tresult = get_json(\"http://api.onebusaway.org/api/where/#{method}.json?key=TEST&#{@query}\")['data']\n\t\t(result.is_a?(Hash) and result.has_key?('entry')) ? result['entry'] : result\n\tend", "def get endpoint\n do_request :get, endpoint\n end", "def method_missing(id, *args, &blk)\n if @resource.respond_to?(id, true)\n @resource.send(id, *args, &blk)\n else\n super\n end\n end", "def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end", "def http_verb(params)\n [:post, :put, :delete].detect { |method_name|\n params.key?(method_name)\n } || :get\n end", "def method_missing(method_name, *args)\n payload = Kauplus::Client.authenticate_payload(args.first)\n if method_name.match(/(get|post|multipart_post|put|delete|head)_(.*)/)\n Kauplus::Client.send($1, \"#{@resource}/#{$2}\", payload)\n else\n Kauplus::Client.get(\"#{@resource}/#{method_name}\", payload)\n end\n end", "def params_for_get\n \"params[:id]\"\n end", "def get(id)\n server.get(\"#{name}/#{CGI.escape(id)}\")\n end", "def get(file, flags); @actions << Action::GetAction.new(file, flags); end", "def get(resource, id)\n Api.new.get(resource, id)\n end", "def get_resource(id, type)\n\t\[email protected](type).call.get(id)\n\tend", "def k_get!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 62 )\n\n\n\n type = K_GET\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 501:3: 'get'\n match( \"get\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 62 )\n\n\n end", "def get(url, params={})\n @agent.get(url,params)\n end", "def http_get(path)\n http_methods(path, :get)\n end", "def get method, params={}\n Request.new(self, :get, method, params)\n end", "def get_action_name( txn, id=nil, *args )\n\t\thttp_method = txn.request_method\n\t\tself.log.debug \"Looking up service action for %s %s (%p)\" %\n\t\t\t[ http_method, txn.uri, args ]\n\n\t\ttuple = METHOD_MAPPING[ txn.request_method ] or return :not_allowed\n\t\tself.log.debug \"Method mapping for %s is %p\" % [ txn.request_method, tuple ]\n\n\t\tif args.empty?\n\t\t\tself.log.debug \" URI refers to top-level resource\"\n\t\t\tmsym = tuple[ id ? 1 : 0 ]\n\t\t\tself.log.debug \" picked the %p method (%s ID argument)\" %\n\t\t\t\t[ msym, id ? 'has an' : 'no' ]\n\n\t\telse\n\t\t\tself.log.debug \" URI refers to a sub-resource (args = %p)\" % [ args ]\n\t\t\tops = args.collect {|arg| arg[/^([a-z]\\w+)$/, 1].untaint }\n\n\t\t\tmname = \"%s_%s\" % [ tuple[1], ops.compact.join('_') ]\n\t\t\tmsym = mname.to_sym\n\t\t\tself.log.debug \" picked the %p method (args = %p)\" % [ msym, args ]\n\t\tend\n\n\t\treturn msym, id, *args\n\tend", "def get(path, rev = nil)\n invoke(Request.new(:path => path, :rev => rev, :verb => Request::Verb::GET))\n end", "def hit\n action = params[:req]\n name = params[:name] || params[:id]\n render api_not_supported action, name\n end", "def call_API_orig(endpoint,id=nil,url_params={:format=>:json},accept=nil)\n # calls are GET\n call_args={:operation=>'GET',:subpath=>endpoint}\n # specify id if necessary\n call_args[:subpath]=call_args[:subpath]+'/'+id unless id.nil?\n unless url_params.nil?\n if url_params.has_key?(:format)\n call_args[:headers]={'Accept'=>'application/'+url_params[:format].to_s}\n end\n call_args[:headers]={'Accept'=>accept} unless accept.nil?\n # add params if necessary\n call_args[:url_params]=url_params\n end\n return @api_orch.call(call_args)\n end", "def aget(index)\n end", "def get(*params); raise('Stub or mock required.') end", "def method_missing(meth, *args, **kwords)\n return missing_action(meth, *args, **kwords) if meth.to_s[-1] == '!'\n\n res = resource\n if res.respond_to?(meth)\n # The droplet_kit resource mapping crap is fairly shitty and doesn't\n # manage to handle kwords properly, pack it into a ruby <=2.0 style\n # array.\n argument_pack = []\n argument_pack += args unless args.empty?\n argument_pack << kwords unless kwords.empty?\n return res.send(meth, *argument_pack) if res.respond_to?(meth)\n end\n p meth, args, { id: id }.merge(kwords)\n client.droplets.send(meth, *args, **{ id: id }.merge(kwords))\n end", "def route_request\n env.logger.debug \"#{self.class} ROUTING - #{env[Goliath::Request::PATH_INFO]}\"\n if has_path = ( env[Goliath::Request::PATH_INFO] =~ /^\\/(\\w+)(\\/\\w+)*/ )\n env.logger.debug \"#{self.class} route_request:\\t pathinfo = #{$1} extended = #{$2}\"\n path_info = $1\n extended_path_info = $2\n has_path = true #it will be a number or nil - let's just make it a bool\n elsif params[:id]\n has_path = true\n end\n \n method = env[Goliath::Request::REQUEST_METHOD]\n action = case method\n when 'GET'\n has_path ? 'show' : 'index'\n when 'POST'\n has_path ? ( raise BadRequestError, \"can't post to this resource\" ) : 'create'\n when 'PUT'\n !has_path ? ( raise BadRequestError, \"no resource to PUT to\" ) : 'update'\n when 'DELETE'\n !has_path ? ( raise BadRequestError, \"no resource to DELETE\" ) : 'delete'\n else\n raise MethodNotAllowedError, \"unknown request method\"\n end\n env.logger.info \"#{self.class} route_request:\\t attempting to call #{action} action\"\n if self.respond_to?(action, true) #second param includes private methods\n env['params']['id'] = params[:id] || (path_info if has_path)\n self.send(action)\n else\n error_on MethodNotAllowedError, \"#{action} not supported for this resource\"\n end\n end", "def read(id)\n # do not respond with anything\n end", "def get(id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'id', id);\n\t\t\tclient.queue_service_action_call('accesscontrol', 'get', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def get_aos_version_box_by_id(args = {}) \n get(\"/aosversions.json/aosversionbox/#{args[:aosVersionBoxId]}\", args)\nend", "def method_missing(id, *args, &block)\n # Figure out what kind of resource we're trying to get.\n klass = Scrumy::Models.const_get(id.to_s.capitalize.singularize)\n # Special case for handling id=:current - this really only applies to Sprint resources\n # but if other resources specified the `current` sub-resources then it should still work.\n if klass.current_url and args.first==:current\n @url = format(klass.current_url, :current)\n else\n # TODO\n # Figure out a better way of determining if the resource is singular or plural\n \n # The only argument that resources ever take is an ID, so pass the first arg as the ID.\n @url = format((id.to_s =~ /s$/ ? klass.list_url : klass.show_url), args.first)\n end\n\n # Here we request the resource using the singular of the resource name as the root\n # to extract from the returned JSON hash.\n response = get(@url, id.to_s.singularize)\n \n # Responses are of two types, either arrays of hashes or a single hash\n if response.kind_of? Array\n # If it's array collect a new array by constructing objects based on the resource\n # name capitalized and singularized.\n response.collect do |obj| \n klass.new(obj, self)\n end\n else\n # Otherwise create a single new object of the correct type.\n klass.new(response, self)\n end\n end", "def [](id)\n begin\n @params[id]\n rescue NameError => e\n Utils_errors::critical_error(\"Params module #{@db_name}'s getter was called with a bad argument : '#{id}' ( there is no such id )\", e)\n end\n end", "def query_api_pattern(method_name, verb, path='', opts={}, &block)\n self.class.query_api_pattern(method_name, verb, path, opts, @query_api_patterns, &block)\n end", "def method_missing(method, *args)\n ## If not loaded, load and retry.\n unless loaded\n return self.get.send(method, *args)\n end\n\n\n ## Otherwise, try to match against attributes, then objects, then links.\n method = method.to_s\n if method[-1,1] == '='\n return attributes[method[0..-2]] = args.first if attributes && attributes.has_key?(method[0..-2])\n else\n return attributes[method] if attributes && attributes.has_key?(method.to_s)\n return objects[method] if objects && objects[method]\n if links && links[method]\n if args.count > 0\n return links[method].where(*args)\n else\n return links[method]\n end\n end\n end\n\n raise NoMethodError, \"undefined method `#{method}' for #{self.inspect}\"\n end", "def method_missing(m,params={})\n get url(m.to_s.camelize,params)\n end", "def method_missing(method, *args)\n method_name = translate_method_to_wire_command(method)\n element_identifier = args[0]\n value = args[1]\n command_string = \"|#{method_name}|#{element_identifier}|#{value}|\"\n #print \"command_string: \" + command_string\n if method_name =~ /^get/\n \treturn do_command(command_string)\n end\n if method_name =~ /^(verify|assert)/\n \treturn do_verify(command_string)\n end\n do_action(command_string)\n end", "def get(type, id)\n info = json_get(@target, \"#{type_info(type, :path)}/#{Addressable::URI.encode(id)}\",\n @key_style, headers)\n\n fake_client_id(info) if type == :client # hide client reply, not quite scim\n info\n end", "def get(object); end", "def api_method\n @_api_method ||= \"#{method_from_class_name}.get\"\n end", "def get(path_or_id, *args)\n if path_or_id.is_a?(String)\n get_by_path(path_or_id)\n else\n super\n end\n end", "def method_missing(api_method, *args) # :nodoc:\n raise ArgumentError.new('Please include method parameters.') unless args.size > 0\n params = ''\n args.each do |arg|\n params << arg.map {|k,v| \"#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}\"}.join(\"&\")\n params << '&' unless arg == args.last\n end\n api_url = \"http://#{@console_url}/frontend/#{camelize_api_method_name(api_method.to_s)}.aspx?#{params}\"\n response = HTTPI.get(api_url)\n rc, rb = response.code, response.body.gsub( /\\r\\n/m,'').to_i\n # Raise an error if the method was not found.\n super if rc == 404\n # Raise an error if the request did not succeed.\n raise APIError.new(rc) if rc != 200\n # Raise an error if the IP is not authorized.\n raise APIError.new(rb) if rb == -1011\n # Raise an error if there was an error returned.\n raise APIError.new(rb) if rb == 1\n rb\n end", "def get\n\t\t\tself.make_request!({uri: self.to_uri, method: :get})\n\t\tend", "def get path = \"\", payload = {}\n make_request(path, \"get\", payload)\n end", "def get_action_info action_detail\n get_one_of action_detail\nend", "def aget path, query={}, opts={}, &cb\n get(path, query, {:async => true}.merge(opts), &cb)\n end", "def aget path, query={}, opts={}, &cb\n get(path, query, {:async => true}.merge(opts), &cb)\n end", "def to_get_request\n 'get_%ss' % api_name\n end", "def get(action, params={}, options={})\n request(:get, action, params, options)\n end", "def http( *args )\n p http_get( *args )\n end", "def method_missing( id, *args )\n DBC.require id.class == Symbol\n\n id_string = \"#{id}\"\n if id_string =~ /=$/\n # C'est un appel de la forme \"os.champ = ...\"\n id = id_string.chop.to_sym\n definir_reader_et_writer( id )\n set_attribut id, args[0]\n else\n raise NoMethodError, \"Methode non-definie `#{id}' pour #{self}\", caller(1)\n end\n end", "def get(path, options={}, &b)\n event(:get, path, options, &b)\n end", "def get!\n clear and get\n end", "def get(id=nil)\n if id.class == String && block_given?\n return @j_del.java_method(:get, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(id,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWeb::Session) : nil) }))\n end\n raise ArgumentError, \"Invalid arguments when calling get(id)\"\n end", "def get\n request_object.get_query\n end", "def method_missing(method, *args)\n return super if args.length > 1 or block_given?\n if args.length == 0\n return super unless data.has_key?(method)\n get method\n else\n set method, args[0]\n end\n end", "def get(id, params={})\n response = Shippo.request(:get, \"#{url}/#{CGI.escape(id)}/\", params)\n self.construct_from(response)\n end", "def call(method, params={})\n # Build path\n params[:apikey] = @api_key\n params = params.map { |p| p.join('=') }.join('&').gsub(/\\s/, '%20')\n path = [@uri.path, API_VERSION, method].compact.join('/') << '?' << params\n # Send request\n get = Net::HTTP::Get.new(path)\n response = @http.request(get)\n handleResult response.body\n end", "def get key; call key; end", "def method name\n\t\t\"- (void) API_#{name}_get_success:(void (^)(RKMappingResult *))success fail:(void (^)(NSError *))failure\"\n\tend" ]
[ "0.695279", "0.65962714", "0.6335788", "0.6249612", "0.62225884", "0.6186497", "0.61675584", "0.61400354", "0.60772324", "0.6070931", "0.60554856", "0.6050929", "0.5976037", "0.5937177", "0.5927827", "0.5912216", "0.58981645", "0.58951724", "0.58734953", "0.5818319", "0.5810651", "0.57975", "0.5788235", "0.57831925", "0.5738168", "0.57230645", "0.57230645", "0.57170856", "0.5716946", "0.57156724", "0.57120264", "0.5706131", "0.5699886", "0.5660033", "0.5660033", "0.56507915", "0.56440157", "0.56411713", "0.563778", "0.56190497", "0.5615159", "0.56012267", "0.55909896", "0.5538388", "0.5532479", "0.55195886", "0.5512445", "0.55114937", "0.55085933", "0.54829794", "0.54802006", "0.54758924", "0.5475132", "0.5473156", "0.5471423", "0.54596865", "0.545345", "0.54509795", "0.54431736", "0.54418164", "0.54366815", "0.543572", "0.54285365", "0.54261726", "0.5423649", "0.54172355", "0.54141146", "0.54128873", "0.5412052", "0.5410244", "0.54077005", "0.53736866", "0.5368998", "0.53603244", "0.53572804", "0.5357125", "0.5351936", "0.5348257", "0.5342374", "0.53402364", "0.53338504", "0.53237194", "0.53225577", "0.5316106", "0.5310969", "0.5310308", "0.5310308", "0.5305219", "0.5303457", "0.5301437", "0.5296703", "0.5292544", "0.52913165", "0.52909625", "0.52786136", "0.52751803", "0.5267171", "0.5256777", "0.52503043", "0.5241643" ]
0.63229954
3
Each xmain will create many run_seq as many as steps and form_steps ]
def create_runseq(xmain) @xvars= xmain.xvars default_role= get_default_role xml= xmain.service.xml root = REXML::Document.new(xml).root i= 0; j= 0 # i= step, j= form_step root.elements.each('node') do |activity| text= activity.attributes['TEXT'] next if ma_comment?(text) next if text =~/^rule:\s*/ action= freemind2action(activity.elements['icon'].attributes['BUILTIN']) if activity.elements['icon'] return false unless action i= i + 1 output_ma_display= false if action== ('output'|| 'list' ||'folder') ma_display= get_option_xml("display", activity) if ma_display && !affirm(ma_display) output_ma_display= false else output_ma_display= true end end j= j + 1 if (action=='form' || output_ma_display) @xvars['referer'] = activity.attributes['TEXT'] if action=='redirect' if action!= 'if' && !text.blank? scode, name= text.split(':', 2) name ||= scode; name.strip! code= name2code(scode) else code= text name= text end role= get_option_xml("role", activity) || default_role rule= get_option_xml("rule", activity) || "true" runseq= Jinda::Runseq.create :xmain=>xmain.id, :name=> name, :action=> action, :code=> code, :role=>role.upcase, :rule=> rule, :rstep=> i, :form_step=> j, :status=>'I', :xml=>activity.to_s xmain.current_runseq= runseq.id if i==1 end @xvars['total_steps']= i @xvars['total_form_steps']= j end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_steps\n\t#make calls to step here...\nend", "def test_steps; end", "def test_steps; end", "def add_step(step,sample)\t\n\n\t\t\t\t# setting job working directory\n\t\t\t\tworking_dir = \"\"\t\n\t\t\t\tif self.local \n\t\t\t\t\tworking_dir = self.local+\"/\"+self.name\n\t\t\t\telse\n\t\t\t\t\tworking_dir = self.output\n\n\t\t\t\t\tif step.is_multi?\t\n\t\t\t\t\t\tfolder = (self.custom_output) ? self.custom_output : @shortname \n\t\t\t\t\t\tworking_dir += \"/#{folder}\"\n\t\t\t\t\telse\n\t\t\t\t\t\tfolder =\n\t\t\t\t\t\tif self.custom_output \n\t\t\t\t\t\t\tself.custom_output\n\t\t\t\t\t\telsif self.custom_name\n\t\t\t\t\t\t\tself.custom_name\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tstep.name\n\t\t\t\t\t\tend\n\t\t\t\t\t\tworking_dir += \"/#{sample.name}/#{folder}\"\n\t\t\t\t\tend\n\n\t\t\t\tend\n\n\t\t\t\t# set job cpus number to the higher step cpus (this in case of multiple steps)\n\t\t\t\tself.cpus = step.cpus if step.cpus > self.cpus\n\t\t\t\t\n\t\t\t\t# set number of nodes for job\n\t\t\t\tself.nodes = (step.nodes) ? step.nodes : @nodes\n\n\t\t\t\t# set the memory used\n\t\t\t\tself.mem = step.mem\n\n\t\t\t\t# adding job working directory\n\t\t\t\tunless step.name.start_with? \"_\"\n\t\t\t\t\tself.command_line << \"if [ ! -f #{working_dir}/checkpoint ]\"\n\t\t\t\t\tself.command_line << \"then\"\n\t\t\t\t\tself.command_line << logger(step, \"start\")\n\t\t\t\t\tself.command_line << \"\\nmkdir -p #{working_dir}\"\n\t\t\t\t\tself.command_line << \"cd #{working_dir}\"\n\t\t\t\tend\n\n\t\t\t\t# generate command lines for this step\n\t\t\t\tif step.run.kind_of? Array\n\t\t\t\t\tstep.run.each_with_index do |cmd, i|\n\t\t\t\t\t\tcommand = generate_cmd_line(cmd,sample,step)\n\t\t\t\t\t\t# TODO verify that logger works in this case\n\t\t\t\t\t\t# self.command_line << \"#{command} || { echo \\\"FAILED `date`: #{step.name}:#{i}\\\" ; exit 1; }\"\n\t\t\t\t\t\tself.command_line << \"#{command} || { #{logger(step, \"FAILED #{i}\" )}; exit 1; }\"\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcommand = generate_cmd_line(step.run,sample,step)\n\t\t\t\t\t# TODO verify that logger works in this case\n\t\t\t\t\t# self.command_line << \"#{command} || { echo \\\"FAILED `date`: #{step.name} \\\" ; exit 1; }\"\n\t\t\t\t\tself.command_line << \"#{command} || { #{logger(step, \"FAILED\" )}; exit 1; }\"\n\t\t\t\tend\n\t\t\t\tself.command_line << logger(step, \"finished\")\n self.command_line << \"touch #{working_dir}/checkpoint\"\n\t\t\t\tself.command_line << \"else\"\n\t\t\t\tself.command_line << logger(step, \"already executed, skipping this step\")\n\t\t\t\tself.command_line << \"fi\"\n\t\t\t\n\t\t\t\t# check if a temporary (i.e. different from 'output') directory is set\n\t\t\t\tif self.local\n\t\t\t\t\tfinal_output = \"\"\n\n\t\t\t\t\tif step.is_multi?\t\n\t\t\t\t\t\tfolder = (self.custom_output) ? self.custom_output : @shortname \n\t\t\t\t\t\tfinal_output = self.output+\"/#{folder}\"\t \n\t\t\t\t\telse\n\t\t\t\t\t\tfolder = (self.custom_output) ? self.custom_output : step.name\n\t\t\t\t\t\tfinal_output = self.output+\"/#{sample.name}/#{folder}\"\n\t\t\t\t\tend\n\n\t\t\t\t\tself.command_line << \"mkdir -p #{final_output}\"\n\t\t\t\t\tself.command_line << \"cp -r #{working_dir}/* #{final_output}\"\n\t\t\t\t\tself.command_line << \"rm -fr #{working_dir}\"\n\t\t\t\tend\n\n\t\t\tend", "def create_steps(stage_steps)\n sequence = 1\n stage_steps.map do |stage_step|\n step = Step.new\n step.sequence = sequence\n\n begin\n action_name = stage_step['action']\n plugin = Cyclid.plugins.find(action_name, Cyclid::API::Plugins::Action)\n\n step_action = plugin.new(stage_step)\n raise if step_action.nil?\n rescue StandardError => ex\n # XXX Rescue an internal exception\n halt_with_json_response(404, INVALID_ACTION, ex.message)\n end\n\n # Serialize the object into the Step and store it in the database.\n step.action = Oj.dump(step_action)\n step.save!\n\n sequence += 1\n\n step\n end\n end", "def exec_steps!\n Executor[result, @options, _self: self]\n end", "def step1\n\n end", "def steps(n)\nend", "def run inputs = {}\n inputs.merge!(self.options)\n output_inputs(inputs)\n run_step_names = run_steps inputs\n puts \"running steps: #{run_step_names.join(\", \")}\"\n missing = missing_step_inputs inputs\n unless missing.empty?\n output_missing(missing)\n return\n end\n results = []\n @steps.each do |step|\n puts \"step: #{step.name}\"\n step_output = step.outputs_given inputs\n if run_step_names.include? step.name\n results << step.call_run_block(inputs,step_output)\n inputs.merge! step_output\n else\n inputs.merge! step_output\n end\n end\n results\n end", "def reg_participants\n puts \"#{self.thread_name} engine particpant setup\"\n # SETUP MUST BE CALLED.\n # ANY exceptions or errors in the participants aborts the workflow and are hard to find. YOU HAVE BEEN WARNED\n self.wfe_engine.register_participant :setup do |workitem|\n puts \"------> setup got a workitem...\" if @debug\n target = ['[email protected]', '[email protected]']\n workitem.sms_source = \"992\"\n workitem.my_hostname = Socket.gethostname \n workitem.sms_message = \"no message\"\n workitem.email_target = target\n # workitem.email_from = \"[email protected]\"\n workitem.workflow_status = \"false\"\n workitem.process_result = \"false\"\n workitem.final_response=\"failure\"\n puts \"<------- end of setup\" if @debug\n end\n # self.wfe_engine.register_participant( \n # 'bal_transfer', \n # OpenWFE::Extras::ActiveStoreParticipant.new('bal_transfer\n#self.wfe_engine.register_participant :bal_transfer do |workitem|\n# puts \"bal_transfer got a workitem...\"\n# workitem.particpant = 'bal_transfer'\n# workitem.store = 'bal_transfer'\n# workitem.save\n#end\n#FIX LATER\n s=%w(bal_transfer pasaload dispense_pin dealer_load load process2 )\n s.each {|i|# self.wfe_engine.register_participant( \"#{i}_store\", ActiveTracker.new(\"#{i}\")) \n puts \"---REG PARticipant #{i}_store \"\n self.wfe_engine.register_participant \"#{i}_store\" do |workitem|\n puts \"#{i}_store got a workitem...\"\n #workitem.monkey_comment = \"this thing looks interesting\"\n end \n }\n \n self.wfe_engine.register_participant :credit do |workitem|\n puts \"----> credit action got a workitem...\" if @debug\n workitem.credit_result=false\n res= self.billing_action('credit',workitem.credit_msisdn,workitem.peso_value )\n puts \"action credit msisdn #{workitem.credit_msisdn} value #{workitem.peso_value} RES: #{res}\"\n puts \"<----credit action finished res #{res}...\" if @debug\n workitem.process_result=res\n end\n self.wfe_engine.register_participant :pasaload do |workitem|\n puts \"----> pasaload action got a workitem...\" if @debug\n workitem.process_result=false\n workitem.sms_source = \"992\"\n puts \"before action pasaload msisdn #{workitem.source_msisdn} value #{workitem.value} dest: #{workitem.dest_msisdn}\"\n res= self.billing_action('pasaload',workitem.source_msisdn,workitem.value, workitem.dest_msisdn)\n puts \"action pasaload msisdn #{workitem.source_msisdn} value #{workitem.value} dest: #{workitem.dest_msisdn} RES: #{res}\"\n puts \"<----pasaload action finished res #{res}...\" if @debug\n workitem.process_message=res.to_yaml\n workitem.final_response=\"all ok\" if res[0]=='true'\n \n end\n self.wfe_engine.register_participant :dealer_load do |workitem|\n puts \"----> dealer load action got a workitem...\" if @debug\n workitem.process_result=false\n workitem.sms_source = \"913\"\n puts \"before action dealer load msisdn #{workitem.source_msisdn} value #{workitem.value} dest: #{workitem.dest_msisdn}\"\n res= self.billing_action('dealer_load',workitem.source_msisdn,workitem.value, workitem.dest_msisdn)\n puts \"action dealer load msisdn #{workitem.source_msisdn} value #{workitem.value} dest: #{workitem.dest_msisdn} RES: #{res}\"\n puts \"<----dealer load action finished res #{res}...\" if @debug\n workitem.process_message=res.to_yaml\n workitem.final_response=\"all ok\" if res[0]=='true'\n end\n self.wfe_engine.register_participant :load do |workitem|\n puts \"----> load action got a workitem...\" if @debug\n workitem.process_result=false\n workitem.sms_source = \"990\"\n puts \"before action load msisdn #{workitem.source_msisdn} value #{workitem.value} dest: #{workitem.dest_msisdn}\"\n res= self.billing_action('load',workitem.source_msisdn,workitem.value, workitem.dest_msisdn)\n puts \"action load msisdn #{workitem.source_msisdn} value #{workitem.value} dest: #{workitem.dest_msisdn} RES: #{res}\"\n puts \"<----load action finished res #{res}...\" if @debug\n workitem.process_message=res.to_yaml\n workitem.final_response=\"all ok\" if res[0]=='true'\n workitem.loadvalue=res[1] if res[0]=='true'\n \n end\n self.wfe_engine.register_participant :dispense_pin do |workitem|\n puts \"----> dispense_pin action got a workitem...\" if @debug\n workitem.process_result=false\n puts \"before action dispense_pin msisdn #{workitem.source_msisdn} value #{workitem.value} dest: #{workitem.dest_msisdn}\"\n res= self.billing_action('dispense_pin', workitem.source_msisdn, workitem.value, workitem.dest_msisdn)\n puts \"action dispense_pin msisdn #{workitem.source_msisdn} value #{workitem.value} dest: #{workitem.dest_msisdn} RES: #{res.to_s}\"\n puts \"<----load action finished res #{res}...\" if @debug\n # result = YAML.load\n workitem.process_message=res.to_yaml\n workitem.final_response=\"all ok\" if res[0]=='true'\n workitem.pin=res[1] if res[0]=='true'\n \n end\n \n \n self.wfe_engine.register_participant :debit do |workitem|\n puts \"----> debit action got a workitem...\" if @debug\n workitem.debit_result=false \n # peso charge -- could be variable\n value=-1*workitem.peso_value.to_i-1\n res=self.billing_action('debit',workitem.debit_msisdn,value.to_s )\n puts \"action debit msisdn #{workitem.debit_msisdn} value #{workitem.peso_value} RES: #{res}\"\n workitem.process_result=res\n workitem.process_message=res\n puts \"<----debit action finsihed res #{res}...\" if @debug\n end\n self.wfe_engine.register_participant :monkey do |workitem|\n puts \"monkey got a workitem...\"\n workitem.monkey_comment = \"this thing looks interesting\"\n end\n self.wfe_engine.register_participant :intprocess2 do |workitem|\n puts \"process2 got a workitem...\"\n workitem.process2_comment = \"yeah process 2\"\n end\n self.wfe_engine.register_participant :bob do |workitem|\n puts \"bob got a workitem...\"\n workitem.bob_comment = \"not for me, I prefer VB\"\n workitem.bob_comment2 = \"Bob rules\"\n workitem.final_response = \"all ok\"\n self.final_response[workitem.fei.workflow_instance_id.to_s] = workitem.final_response\n end\n self.wfe_engine.register_participant :sms do |workitem|\n puts \"sms got a workitem...\"\n puts \"sms #{workitem.sms_destination} message: #{workitem.sms_message}\"\n res=send_sms(workitem.sms_message,workitem.sms_destination, workitem.sms_source)\n workitem.problem=!res \n end\n # needs workitem.email_target set\n mailp=OpenWFE::MailParticipant.new(\n :smtp_server => \"mail2.cure.com.ph\",\n :smtp_port => 25,\n :from_address => \"[email protected]\"\n ) do |workitem|\n puts \"----> mail got workitem\"\n s = \"\"\n duration=Time.now-self.start_time\n s << \"Subject: Workflow PROCESS [#{workitem.process_name}] [#{workitem.final_response}]\\n\\n\"\n s << \"result is #{workitem.final_response}\\n\"\n s << \"Processing Time so far: #{duration} \\n\"\n s << \"summary of process #{workitem.fei.workflow_instance_id}\\n\"\n workitem.attributes.each do |k, v|\n s << \" - #{k} : '#{v}'\\n\"\n end \n s << \"Time: #{Time.new.to_s}\\n\"\n puts \"----> leaving mail\"\n s\n end\n self.wfe_engine.register_participant( \n \"mail\", mailp)\n \n \n self.wfe_engine.register_participant :debug do |workitem|\n puts \"--->debug got a workitem...\"\n puts \"--status of process #{workitem.fei.workflow_instance_id}\"\n workitem.attributes.each do |k, v|\n puts \" - #{k} : '#{v}'\"\n end\n puts '<------end of debug'\n end\n # summarize must be called to set final_response\n self.wfe_engine.register_participant :summarize do |workitem|\n puts \"---->Summarize got a workitem...\"\n # workitem.final_response=\"all ok\" if workitem.attributes['process_result']=='true' \n puts \"result is #{workitem.final_response}\"\n self.final_response[workitem.fei.workflow_instance_id.to_s] = workitem.process_message\n puts \"summary of process #{workitem.fei.workflow_instance_id}\"\n workitem.attributes.each do |k, v|\n # next unless k.match \".*_comment$\"\n puts \" - #{k} : '#{v}'\"\n end\n puts '<-------end of summary'\n end\n self.wfe_engine.register_participant :reverse_charges do |workitem|\n puts \"-----> reverse got a workitem...\"\n res=false\n if workitem.attributes['debit_result']=='true'\n value=1*workitem.peso_value.to_i+1\n res=self.billing_action('credit',workitem.debit_msisdn,value.to_s )\n puts \"return from reversing debit: #{res}\"\n end\n if workitem.attributes['credit_result']=='true'\n res= self.billing_action('debit',workitem.credit_msisdn,workitem.peso_value )\n puts \"return from reversing credit: #{res}\"\n end\n puts 'end of reverse charges'\n end\n self.wfe_engine.register_participant :process_failure do |workitem|\n puts \"----> process_failure got a workitem...\"\n res=false\n # res=send_sms(\"There was a problem with your request (process id:'#{workitem.fei.workflow_instance_id})'. Call *999 if you require further information\", workitem.source_msisdn, workitem.sms_source)\n puts \"<------ out of process failure\"\n end\n self.wfe_engine.register_participant :inform_success_pasa do |workitem|\n puts \"---->Inform_success_pasa got a workitem...\"\n res=true\n if workitem.final_response==\"all ok\"\n # res=send_sms(\"You have sent #{workitem.value} pesos to #{workitem.dest_msisdn}: (process id:'#{workitem.fei.workflow_instance_id})'\", workitem.source_msisdn, workitem.sms_source)\n res=send_sms(\"You have received #{workitem.value} pesos from #{workitem.source_msisdn}: To check your balance, text BAL to 991\", workitem.dest_msisdn,workitem.sms_source) and res\n #(process id:#{workitem.fei.workflow_instance_id})\n end\n puts \"<---- end inform_sucess\"\n res\n end\n self.wfe_engine.register_participant :inform_success_dispense_pin do |workitem|\n puts \"---->Inform_success_dispense_pin got a workitem...\"\n res=false\n if workitem.final_response==\"all ok\"\n res=send_sms(\"Your pin is #{workitem.loadvalue} via tracking process id:'#{workitem.fei.workflow_instance_id}'\", workitem.source_msisdn, workitem.sms_source)\n \n end\n puts \"<---- end inform_success_dispense_pin\"\n res\n end\n self.wfe_engine.register_participant :inform_success_load do |workitem|\n puts \"---->Inform_success_load got a workitem...\"\n res=false\n if workitem.final_response==\"all ok\"\n # res=send_sms(\"You have loaded #{workitem.loadvalue} pesos (process id: #{workitem.fei.workflow_instance_id})\", workitem.source_msisdn, workitem.sms_source)\n \n end\n puts \"<---- end inform_sucess\"\n res\n end\n self.wfe_engine.register_participant :inform_success do |workitem|\n puts \"Inform_success got a workitem...\"\n res=false\n if workitem.final_response==\"all ok\"\n res=send_sms(\"You have sent #{workitem.peso_value} peso to #{workitem.credit_msisdn}: (process id:'#{workitem.fei.workflow_instance_id}')\", workitem.debit_msisdn, workitem.sms_source)\n res=send_sms(\"You have received #{workitem.peso_value} pesos from #{workitem.debit_msisdn}: tracking process id:'#{workitem.fei.workflow_instance_id}' \",workitem.credit_msisdn,workitem.sms_source) and res\n end\n end\n \nend", "def expand_loop\r\n raise \"no examples found for loop start on line #{@loop_start_ln}\" unless @loop_examples.size > 0\r\n loop_n = 0\r\n @loop_examples.each do |exa|\r\n loop_n += 1\r\n # treat each loop example as a yaml var definition for the template\r\n rslt = Erubis::Eruby.new(@loop_template).result(YAML.load(exa))\r\n li = 0\r\n rslt.split(\"\\n\").each do |line|\r\n li += 1\r\n self.process_line @loop_start_ln + li, line\r\n end\r\n end\r\n \r\n # clear up holders\r\n self.reset_loop\r\n end", "def set_steps\n invalid_steps = []\n unless @page && @page.content_type\n steps = {pages: %w[position title type],\n names: %w[Position Title Type]}\n self.steps = steps[:pages]\n self.steps_names = steps[:names]\n else\n invalid_steps << 'type' if params[:id] != 'type'\n steps = @page.form_steps\n self.steps = steps[:pages]\n self.steps_names = steps[:names]\n end\n\n invalid_steps << session[:invalid_steps][@page_id] if session[:invalid_steps][@page_id]\n invalid_steps.flatten!\n invalid_steps.uniq!\n set_invalid_steps invalid_steps\n end", "def steps\n %w[name time]\n end", "def step1\n \n end", "def steps\n %w[first last]\n end", "def run_list; end", "def run\n\t\t\t\tstart_flowcell\n\t\t\t\tdistributions = []\n\n\n\t\t\t\tunless @options[:no_distribute]\n\t\t\t\t\tdistributions = @flowcell.external_data.distributions_for @flowcell.id \n\t\t\t\tend\n\n\t\t\t\tsteps = @options[:steps]\n\t\t\t\tlogm \"running steps: #{steps.join(\", \")}\"\n\n\t\t\t\tif steps.include? \"setup\"\n\t\t\t\t\tcopy_sample_sheet\n\t\t\t\tend\n\n\t\t\t\tif steps.include? \"unaligned\"\n\t\t\t\t\t#process_unaligned_reads distributions\n\t\t\t\tend\n\n\t\t\t\tif steps.include?\n\n\n\t\t\tend\n\n\t\t\tdef logm message\n\t\t\t\tlog \"# #{message}\"\n\t\t\t\tSolexaLogger.log(@flowcell.paths.id, message) unless @options[:test]\n\t\t\tend\n\n\t\t\tdef copy_sample_sheet\n\t\t\t\tsource = File.join(@flowcell.paths.base_dir, \"SampleSheet.csv\")\n\t\t\t\tdestination = File.join(@flowcell.paths.unaligned_dir, \"SampleSheet.csv\")\n\t\t\t\tif !File.exists? source\n\t\t\t\t\tputs \"ERROR: cannot find SampleSheet at: #{source}\"\n\t\t\t\tend\n\n\t\t\t\texecute(\"cp #{source} #{destination}\")\n\t\t\tend\n\n\t\t\tdef process_unaligned_reads distributions\n\t\t\t\tstatus \"processing unaligned\"\n\t\t\t\tsteps = @options[:steps]\n\t\t\t\tfastq_groups = group_fastq_files(@flowcell.paths.unalinged_project_dir,\n\t\t\t\t\t @flowcell.paths.fastq_combine_dir)\n\t\t\t\t#unless @options[:only_distribute]\n\t\t\t\t#\tcat files fastq_groups\n\t\t\t\t#end\n\n\t\t\t\t###### LAST STOP\n\n\t\t\tend\n\n\n\t\t\t#\n # Helper method that executes a given string on the command line.\n # This should be used instead of calling system directly, as it also\n # deals with if we are in test mode or not.\n #\n def execute command\n log command\n system(command) unless @options[:test]\n end\n\n\n #\n # Gets grouping data for fastq.gz files\n #\n def group_fastq_files starting_path, output_path, options = {:prefix => \"L\", :suffix => \".fastq.gz\", :exclude_undetermined => true}\n execute \"mkdir -p #{output_path}\"\n fastq_groups = []\n \n fastq_files = Dir.glob(File.join(starting_path, fastq_search_path))\n if fastq_files.empty?\n log \"# ERROR: no fastq files found in #{starting_path}\" if fastq_files.empty?\n else\n log \"# #{fastq_files.size} fastq files found in #{starting_path}\"\n fastq_file_data = get_file_data fastq_files, \"\\.fastq\\.gz\"\n fastq_groups = group_files fastq_file_data, output_path, options\n end\n fastq_groups\n end\n\n #\n # Actually combines the related fastq files\n # using cat.\n #\n def cat_files file_groups\n file_groups.each do |group|\n check_exists(group[:paths])\n # this is the Illumina recommended approach to combining these fastq files.\n # See the Casava 1.8 Users Guide for proof\n files_list = group[:paths].join(\" \")\n command = \"cat #{files_list} > #{group[:path]}\"\n execute command\n end\n end\n\n\n\n #\n # Returns an array of hashes, one for each\n # new combined fastq file to be created\n # Each hash will have the name of the\n # combined fastq file and an Array of\n # paths that the group contains\n #\n def group_files file_data, output_path, options = {:prefix => \"L\", :suffix => \".fastq.gz\", :exclude_undetermined => true}\n\t\t\t\t# alternatively inherit the parent class and call super???? \n\t\t\t\t# super \n\t\t\t\t# \t\n groups = {}\n file_data.each do |data|\n if data[:barcode] == \"Undetermined\" and options[:exclude_undetermined]\n log \"# Undetermined sample lane: #{data[:lane]} - name: #{data[:sample_name]}. Skipping\"\n next\n end\n \n group_key = name_for_data data, options\n \n if groups.include? group_key\n if groups[group_key][:sample_name] != data[:sample_name]\n raise \"ERROR: sample names not matching #{group_key} - #{data[:path]}:#{data[:sample_name]}vs#{groups[group_key][:sample_name]}\"\n end\n if groups[group_key][:lane] != data[:lane]\n raise \"ERROR: lanes not matching #{group_key} - #{data[:path]}\"\n end\n groups[group_key][:files] << data\n else\n group_path = File.join(output_path, group_key)\n groups[group_key] = {:group_name => group_key,\n :path => group_path,\n :sample_name => data[:sample_name],\n :read => data[:read],\n :lane => data[:lane],\n :files => [data]\n }\n end\n end\n \n # sort based on read set\n groups.each do |key, group|\n group[:files] = group[:files].sort {|x,y| x[:set] <=> y[:set]}\n group[:paths] = group[:files].collect {|data| data[:path]}\n end\n groups.values\n end\n\n\n\n\tend", "def starten\n create_fox_components\n instance_final_activate\n activate\n end", "def create_steps(show_correct_answers_option)\n @@steps = []\n questions_tests.each do |variable|\n @@steps << 'question'\n @@steps << 'show_correct' if show_correct_answers_option\n end\n @@steps << 'evaluate'\n end", "def steps\n steps_keywords = %w(Given When Then And But)\n nsteps = 0\n @steps = []\n while true\n print \"Add step [Y/n]: \"\n choice = gets\n if choice.downcase.strip != \"n\"\n puts \"Step #{nsteps +1}:\"\n step = gets.capitalize\n init_step_word = step.split(' ').first\n if steps_keywords.include?(init_step_word)\n @steps << step\n nsteps = nsteps ++ 1\n else\n puts \"Error: #{init_step_word} unsupported initial value\"\n puts \"Use only #{steps_keywords} keywords\"\n end\n elsif choice.downcase.strip == \"n\"\n break\n else\n \"please enter a valid choice.\"\n end\n end\n write_feature\n end", "def steps\n Rails.cache.fetch([self, \"pill_sequence_steps\"]) { pill_sequence_steps }\n end", "def expand_loop\r\n raise \"no examples found for loop start on line #{@loop_start_ln}\" unless @loop_examples.size > 0\r\n loop_n = 0\r\n @loop_examples.each do |exa|\r\n loop_n += 1\r\n vars = YAML.load(exa)\r\n # erubie the template\r\n rslt = Erubis::Eruby.new(@loop_template).result(vars)\r\n li = 0\r\n rslt.split(\"\\n\").each do |line|\r\n li += 1\r\n self.process_line line, @loop_start_ln + li, loop_n\r\n end\r\n end\r\n \r\n # clear up holders\r\n self.reset_loop\r\n end", "def run\n create_log_folder\n \n in_tmp_dir do\n start_frame = tmp_path START_FRAME\n extract_start_transition_frame(start_frame) # 1.\n \n end_frame = tmp_path END_FRAME\n extract_end_transition_frame(end_frame) # 2.\n \n transitions = tmp_path TRANSITIONS\n Cmd::GenerateTransitionFrames.new(start_frame, end_frame, transitions, INNER_FRAMES_AMOUNT).run! *logs('3_generate_transition_frames') # 3.\n \n Queue.run *FORMATS.map{ |format| proc{ transition(format) } }, close_connection_before_execution: true # 4.\n end\n \n outputs\n end", "def start_workflow(name)\n puts \"schedule the next Activity/Step for #{name}!\"\n #number is an array of Futures object (http://docs.aws.amazon.com//amazonswf/latest/awsrbflowapi/AWS/Flow/Core/Future.html)\n numbers = []\n numbers << client_one.send_async(:set_number)\n numbers << client_two.send_async(:set_number)\n wait_for_all(numbers)\n #get the output of activites by futures element (map method)\n sum = numbers.map! { |x| x.get }.reduce(:+)\n client_one.print_finish\n client_two.print_finish\n resto = (sum % 2)\n case resto\n when 0\n # Use the activity client_three for print pari if rest is 0\n client_three.print_dispari(sum)\n when 1\n # Use the activity client_three for print dispari if rest is 0\n client_three.print_pari(sum)\n end\n end", "def upa_steps; end", "def steps\n @steps ||= []\n end", "def runs; end", "def step(steps, force = false)\n #This is a stub, used for indexing\n end", "def steps\n %w[\n household_member_demographics_step\n household_member_address_step\n household_member_address_search_results_step\n household_member_citizenship_step\n household_member_education_step\n household_member_employments_step\n household_member_assessment_employment_step\n household_member_incomes_step\n household_member_unearned_incomes_step\n household_member_expenses_step\n household_member_resources_step\n household_member_relations_step\n ]\n end", "def upa_steps=(_arg0); end", "def main\n \n # make is not needed, we have no new items \n # operations.retrieve # should be in loop!!!\n\n operations.each { |op|\n \n # message to user: run this operation on the browser on the flow cytometer \n show do\n title \"Flow cytometery - info\"\n warning \"The following should be run on a browser window on the #{CYTOMETER_TYPE} computer!\"\n end \n \n # Standard cleaning cycle for the flow cytometer\n cleanCytometer(CYTOMETER_TYPE)\n \n # run calibration beads - a new aquqrium sample bead_sample is created\n bead_item = beadCalibration(CYTOMETER_TYPE, op.input(BEAD_STOCK), op) \n \n # op.input(SAMPLE_TYPE).val seems to pick one of the parameters (E coli or Yeast) at random\n \n log_info CYTOMETER_TYPE, op.input(SAMPLE_TYPE).val, op.input(WELL_VOL).val, op.input(INPUT_NAME).collection, op\n # My Params - EL 01272018\n # log_info CYTOMETER_TYPE, \"Yeast\", 300, op.input(\"96 well plate\").collection, op\n \n take([op.input(INPUT_NAME).item], interactive: true)\n \n # run plate - uses collection to determine number of samples and their positions\n uploads_key=runSample96(CYTOMETER_TYPE, op.input(SAMPLE_TYPE).val, op.input(WELL_VOL).val, op.input(INPUT_NAME).collection, op)\n # uploads_key=runSample96(CYTOMETER_TYPE, \"Yeast\", 300, op.input(\"96 well plate\").collection, op)\n \n # add hash associations - will create new hash if none exists\n associatePlateFSCuploads(op.input(INPUT_NAME).collection, uploads_key)\n \n # run final clean\n cleanCytometer(CYTOMETER_TYPE)\n log_info 'end of main'\n } # operations.each\n \n # Add cleaning up of input plates\n input_collections = operations.map {|op| op.input(INPUT_NAME).item.id}\n show do \n title \"Cleaning Up After Experiment\"\n separator\n note \"Please clean up the following 96 Well plates by rinsing out with DI water and 70% EtOH\"\n check \"Clean up <b>#{input_collections}</b>\"\n end\n \n # dispose plates\n operations.each {|op| op.input(INPUT_NAME).item.mark_as_deleted}\n return {}\n \n end", "def build_steps(b)\n if !steps\n b.builders\n else\n b.builders do\n self.steps ||= default_steps(job_type)\n steps.each do |step|\n method, cmd = step\n send(method.to_sym, b, cmd) # e.g. build_shell_step(b, \"bundle install\")\n end\n if fingerprint\n b.tag! \"hudson.plugins.createfingerprint.CreateFingerprint\" do\n b.targets do\n b << fingerprint\n end\n end\n end\n end\n end\n end", "def steps\n %w[/14/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/educations\n /12/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /13/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/client_scores\n /41/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /42/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /15/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/work/characteristics/index\n /29/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/client_immunization/show\n /ASSESSMENT/disability/characteristics/index\n /ASSESSMENT/mental/characteristics/index\n /35/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/substance_abuse/characteristics/index\n /32/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/domestic/characteristics/index\n /38/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /39/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/clients/medical_pregnancy/show\n /19/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /21/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /22/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /23/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /24/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /25/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /26/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /2/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/employments\n /ASSESSMENT/legal/characteristics/index\n /7/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /assessment_careers/interest_profiler_questions/interest_profiler_question_wizard_initialize\n ]\n\n end", "def execute(step)\n end", "def create_steps(value, expected)\n temp = []\n st_count = 0\n\n value.each do |x|\n temp[st_count] = {}\n temp[st_count][:step_number] = \"#{st_count+1}\"\n temp[st_count][:actions] = \"<p>#{x.strip}</p>\"\n temp[st_count][:expected_results] = expected unless expected.nil?\n temp[st_count][:execution_type] = \"1\"\n temp[st_count][:active] = \"1\"\n st_count += 1\n end\n return temp\n end", "def step_result; end", "def run\n ngen_auth\n @validate = Validator.new\n stack = EcoSystem.new\n @instanceparameters = stack.yaml_reader(config[:yaml])\n stack.validate = @validate\n config[:action] = 'create'\n stack.options = config\n stack.supress_output ='1'\n stack.instanceparameters = @instanceparameters\n inst_result = stack.opt_parse\n ho_hum\n \n inst_result.each do |server|\n config[:inst] = server['server']['display_name']\n instance = {}\n # puts chef_attrs = server['server']['userdata'].at(0)['chef']\n chef_attrs = server['server']['userdata'].at(0)['chef'] if !server['server']['userdata'].at(0)['chef'].nil?\n chef_attrs.each do |attr, value|\n instance[attr] = value\n end\n chef_node_configuration(instance)\n config[:chef_node_name] = config[:inst]\n inst_details = AttrFinder.new(server)\n inst_details.options = config\n inst_details.validate = @validate\n inst_details.function = 'server' \n inst = InstanceClient.new\n inst.validate = @validate\n inst.options = config\n inst.supress_output ='1'\n inst.instanceparameters = @instanceparameters\n ssh_host = inst.list_instance_ip(inst_details.compartment, inst_details.instance).at(1)\n bootstrap_for_linux_node(ssh_host).run\n node_attributes(ssh_host, 'IaaS')\n end\n end", "def index\n @process_steps = ProcessStep.all\n end", "def import_all(options)\n import_docx_specific_steps(options)\n import_folio_xml_specific_steps(options)\n import_idml_specific_steps(options)\n import_shared_steps(options)\n end", "def initialize\n @steps = {}\n @notes = {}\n end", "def steps(steps)\n @step_lengths = steps.map {|keyword, name| (keyword+name).unpack(\"U*\").length}\n @max_step_length = @step_lengths.max\n @step_index = -1\n end", "def steps(steps)\n @step_lengths = steps.map {|keyword, name| (keyword+name).unpack(\"U*\").length}\n @max_step_length = @step_lengths.max\n @step_index = -1\n end", "def form_steps\n self.steps\n end", "def _spawn_runners(automation_config, set_name, instance_flags, repeats)\n file_pattern = @config[:output_file]\n repeats.times.each do |instance|\n unless file_pattern.nil? || file_pattern.empty?\n f_path = format(file_pattern, batch_name: @batch_name, set_name: set_name, instance: instance + 1)\n instance_flags[Ladon::Automator::Automation::OUTPUT_FILE.name] = File.expand_path(f_path)\n end\n\n @runners << LadonAutomationRunner.spawn(flags: _runner_flags(automation_config, instance_flags))\n end\n end", "def run\n start_flowcell\n distributions = []\n\n unless @options[:no_distribute]\n distributions = @flowcell.external_data.distributions_for @flowcell.id\n end\n\n steps = @options[:steps]\n status \"running steps: #{steps.join(\", \")}\"\n\n if steps.include? \"unaligned\"\n # unaligned dir\n process_unaligned_reads distributions\n Emailer.email \"UNALIGNED step finished for #{@flowcell.paths.id}\" unless @options[:test]\n end\n\n if steps.include? \"undetermined\"\n process_undetermined_reads distributions\n Emailer.email \"UNDETERMINED step finished for #{@flowcell.paths.id}\" unless @options[:test]\n end\n\n if steps.include? \"fastqc\"\n unless @options[:only_distribute]\n run_fastqc @flowcell.paths.fastq_combine_dir\n end\n distribute_to_unique distributions, @flowcell.paths.fastqc_dir\n Emailer.email \"FASTQC step finished for #{@flowcell.paths.id}\" unless @options[:test]\n end\n\n if steps.include? \"aligned\"\n run_aligned distributions\n Emailer.email \"ALIGNED step finished for #{@flowcell.paths.id}\" unless @options[:test]\n end\n\n if steps.include? \"stats\"\n create_custom_stats_files\n distribute_custom_stats_files distributions\n end\n\n if steps.include? \"report\"\n create_sample_report\n distribute_sample_report distributions\n end\n\n if steps.include? \"qcdata\"\n distribute_to_qcdata\n end\n\n if steps.include? \"lims\"\n notify_lims\n end\n\n stop_flowcell\n end", "def steps\n %i[upload setup order]\n end", "def driver\n\n @steps.each do |step|\n begin\n next if step['Run'].to_s.downcase != 'x'\n displayDescription(step)\n @skipCurrentStep = false\n @step = step\n @action = step['Action'].clone\n\n methodName = getMethodName(step['Action'])\n begin\n send(methodName, step)\n rescue Exception => e\n screenActions\n end\n rescue Exception => e\n @report << [step['Action'], step['Description'], e.message, 'False']\n end\n end\n\n generateReport\n system(\"start excel #{@reportFolder}/report.csv\")\n end", "def children\n steps\n end", "def request_launch_new_instances(num=1)\n out = []\n num.times {out << launch_new_instance!}\n out\n end", "def test_step; end", "def add_build_steps(content)\n unless build_config.setup_steps.nil?\n build_config.setup_steps.each do |step|\n content += \"RUN #{step}\\r\\n\"\n end\n end\n content\n end", "def initialize(path_steps = [])\n\t\t@sequence = path_steps\n\tend", "def steps\n step_flows.collect(&:current_step)\n end", "def start_generators\n threads = []\n 5.times do |idx|\n thread = Thread.new { contious_generation }\n thread[:id] = idx\n threads << thread\n end\n threads\n end", "def run_step_one\n puts \"Executing Step ONE\"\n end", "def sheets_steps= value ; @sheets_steps = value end", "def steps\n if template_steps_bound?\n @unbound_steps = nil\n @bound_steps ||= build_steps\n else\n @unbound_steps ||= build_steps\n end\n end", "def index\n @next_steps = NextStep.all\n end", "def start\n model_name = model.name\n # $stderr.write \"0 - #{model_name}\\n\"\n # $stderr.write \"A - current_uniq - #{Script.current_uniq ? 'true' : 'false'}\\n\"\n # $stderr.write \"B - #{Script.current_stack.join(',')}\\n\"\n if Script.current_uniq and Script.current_stack.include?(model_name)\n # we've already done this in the current stack, so skip it\n return\n end\n if not Script.current_uniq\n # since we're not trying to uniq, ignore the current contents of the stack\n Script.current_stack.clear\n end\n Script.current_stack << model_name\n unless Run.table_exists?\n Run.auto_upgrade!\n end\n run = Run.new\n run.model_name = model_name\n run.start do\n steps.each do |step|\n step.start\n model.reset_column_information\n end\n end\n end", "def children\n examples + steps + tags\n end", "def before_steps(steps)\n @current_feature_element[:steps] = []\n end", "def steps\n find_solution\n end", "def steps\n unless @steps_loaded\n step_file = File.expand_path(\"./steps/#{self.class.name.underscore}.rb\", @@current_dir)\n if File.exists?(step_file)\n self.instance_eval File.read(step_file), __FILE__, __LINE__ + 1\n else\n raise StepsFileNotFoundError.new(\"File #{step_file} not found\")\n end\n @steps_loaded = true\n end\n end", "def create\n @test_run = TestRun.new(test_run_params)\n @test_run.scenarios.map! do |s|\n s.test_run = @test_run\n s.config_template = @test_run.config\n s\n end\n\n if @test_run.save\n redirect_to @test_run, notice: 'Test run was successfully created.'\n else\n render action: 'new'\n end\n end", "def step(generations = 1)\n cells = Array.new(ROWS * COLUMNS, 0)\n generations.times do\n 0.upto(ROWS - 1) do |row|\n 0.upto(COLUMNS - 1) do |column|\n cells[row * ROWS + column] = next_state(column, row)\n end\n end\n @cell_state = cells\n @iteration += 1\n end\n upload_state\n end", "def generate_instances(supervisor, quantity = self.quantity)\n quantity.times.map { |i| create_instance(supervisor) }\n end", "def build_steps_script_arguments(steps, procedure_steps)\n steps.each_with_index do |step, i|\n Step.build_script_arguments_for(step, procedure_steps[i])\n end\n end", "def generate_example_osw_of_all_measures_in_order()\n\n require 'openstudio'\n require_relative 'resources/helper_methods'\n\n puts \"Updating example OSW...\"\n \n model = OpenStudio::Model::Model.new\n osw_path = \"workflows/create-model-example.osw\"\n \n if File.exist?(osw_path)\n File.delete(osw_path)\n end\n \n workflowJSON = OpenStudio::WorkflowJSON.new\n workflowJSON.setOswPath(osw_path)\n workflowJSON.addMeasurePath(\"../measures\")\n workflowJSON.setSeedFile(\"../seeds/EmptySeedModel.osm\")\n \n # Check that there is no missing/extra measures in the measure-info.json\n # and get all_measures name (folders) in the correct order\n data_hash = get_and_proof_measure_order_json()\n \n steps = OpenStudio::WorkflowStepVector.new\n \n data_hash.each do |group|\n group[\"group_steps\"].each do |group_step|\n \n measure = group_step[\"measures\"][0]\n measure_path = File.expand_path(File.join(\"../measures\", measure), workflowJSON.oswDir.to_s) \n\n measure_instance = get_measure_instance(\"#{measure_path}/measure.rb\")\n measure_args = measure_instance.arguments(model).sort_by {|arg| arg.name}\n \n step = OpenStudio::MeasureStep.new(measure)\n step.setName(measure_instance.name)\n step.setDescription(measure_instance.description)\n \n step.setModelerDescription(measure_instance.modeler_description)\n\n # Loop on each argument\n measure_args.each do |arg|\n if arg.hasDefaultValue\n step.setArgument(arg.name, arg.defaultValueAsString)\n elsif arg.required\n puts \"Error: No default value provied for #{measure} argument '#{arg.name}'.\"\n exit\n end\n end\n \n # Push step in Steps\n steps.push(step)\n end \n end\n\n workflowJSON.setWorkflowSteps(steps)\n workflowJSON.save\n \n # Update README.md as well\n update_readme(data_hash)\n \nend", "def step msg\n end", "def index\n @step_commands = StepCommand.all\n end", "def make_step\n @result\n end", "def run(runner, user_arguments)\n super(runner, user_arguments)\n \n #make the runner a class variable\n @runner = runner\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(), user_arguments)\n return false\n end\n\n runner.registerInitialCondition(\"Starting QAQC report generation\")\n\n # get the last model and sql file \n @model = runner.lastOpenStudioModel\n if @model.is_initialized\n @model = @model.get\n else\n runner.registerError(\"Cannot find last model.\")\n return false\n end\n \n @sql = runner.lastEnergyPlusSqlFile\n if @sql.is_initialized\n @sql = @sql.get\n else\n runner.registerError(\"Cannot find last sql file.\")\n return false\n end\n \n resource_path = \"#{File.dirname(__FILE__)}/resources/\"\n if not File.exists?(\"#{resource_path}/CreateResults.rb\")\n # support pre 1.2.0 OpenStudio\n resource_path = \"#{File.dirname(__FILE__)}/\"\n end\n\n\n \n #require the files that create results and qaqc checks\n # use different code for 2.0 and higher\n if @model.version < OpenStudio::VersionString.new('1.11')\n runner.registerInfo(\"Using the pre-2.0 code\")\n require \"#{resource_path}/CreateResults.rb\"\n require \"#{resource_path}/EndUseBreakdown\"\n require \"#{resource_path}/EUI\"\n require \"#{resource_path}/FuelSwap\"\n require \"#{resource_path}/PeakHeatCoolMonth\"\n require \"#{resource_path}/UnmetHrs\"\n\n #vector to store the results and checks\n report_elems = OpenStudio::AttributeVector.new\n report_elems << create_results\n \n #create an attribute vector to hold the checks\n check_elems = OpenStudio::AttributeVector.new\n\n #unmet hours check\n check_elems << unmet_hrs_check\n \n #energy use for cooling and heating as percentage of total energy check\n check_elems << enduse_pcts_check\n\n #peak heating and cooling months check\n check_elems << peak_heat_cool_mo_check\n\n #EUI check\n check_elems << eui_check\n \n #end checks\n report_elems << OpenStudio::Attribute.new(\"checks\", check_elems)\n \n #create an extra layer of report. the first level gets thrown away.\n top_level_elems = OpenStudio::AttributeVector.new\n top_level_elems << OpenStudio::Attribute.new(\"report\", report_elems) \n \n #create the report\n result = OpenStudio::Attribute.new(\"summary_report\", top_level_elems)\n result.saveToXml(OpenStudio::Path.new(\"report.xml\"))\n\n else\n runner.registerInfo(\"Using the post-2.0 code\")\n require \"#{resource_path}/CreateResults_2.rb\"\n require \"#{resource_path}/EndUseBreakdown_2\"\n require \"#{resource_path}/EUI_2\"\n require \"#{resource_path}/FuelSwap_2\"\n require \"#{resource_path}/PeakHeatCoolMonth_2\"\n require \"#{resource_path}/UnmetHrs_2\" \n \n # store the results\n create_results\n \n # QAQC checks\n runner.registerValue(\"test_reg_value\", 9989, \"ft^2\")\n \n \n end\n \n #closing the sql file\n @sql.close()\n\n #reporting final condition\n runner.registerFinalCondition(\"Finished generating report.xml.\")\n \n return true\n \n end", "def run_all\n end", "def run_all\n end", "def run_from(step, options =nil)\n if ALLOWED_STEP_NAMES.include?(step)\n logger.info \"[workflow_start] Starting deep seq data workflow on machine: #{self.class.name}, from step: '#{step}'\"\n logger.info self.to_yaml\n if options.nil?\n send(\"#{step}!\")\n else\n send(\"#{step}!\", options)\n end\n logger.info \"[workflow_end] End of deep seq data workflow.\"\n else\n # illegal step parameter specified: notify and exit\n logger.error \"Illegal step parameter specified: #{step}\"\n notify_admins('illegal_step')\n end\n end", "def create_test_instances\n model = Sketchup.active_model\n definition = model.definitions.add('TC_Sketchup_InputPoint')\n group1 = definition.entities.add_group\n group2 = group1.entities.add_group\n group2.transform!([10, 20, 30])\n group3 = group2.entities.add_group\n edge = group3.entities.add_line([10, 10, 10], [20, 20, 20])\n tr = Geom::Transformation.new([20, 30, 40])\n instance = model.entities.add_instance(definition, tr)\n [instance, group1, group2, group3, edge]\n end", "def build_unit_test_contexts\n create_stores\n create_employees\n create_assignments\n create_jobs\n create_shifts\n create_shift_jobs\n create_flavors\n create_store_flavors\n end", "def action_step(*action_name, &block)\n\n # Instantiate a ViewStep object if symbol or string received\n action_name.each do |name|\n \n step = WebFlow::ActionStep.new(name.to_s)\n \n # Register this step in the flow repository\n register name.to_s, step\n \n # Execute the config block\n step.instance_eval(&block) if block_given?\n \n end\n\n end", "def setup\n Wizard.new do |config|\n yield config\n end\n end", "def run_all\n run_suite(@suite)\n end", "def running_test_step; end", "def taxes\n wizard_step(STEPS)\n end", "def index\n @steps = Step.all\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make an argument for the simulation timesteps per hour\n arg = OpenStudio::Measure::OSArgument::makeIntegerArgument(\"timesteps_per_hr\", true)\n arg.setDisplayName(\"Simulation Timesteps Per Hour\")\n arg.setDefaultValue(6)\n args << arg\n\n # make an argument for the run period begin month\n arg = OpenStudio::Measure::OSArgument::makeIntegerArgument(\"begin_month\", true)\n arg.setDisplayName(\"Run Period Begin Month\")\n arg.setDefaultValue(1)\n args << arg\n\n # make an argument for the run period begin day of month\n arg = OpenStudio::Measure::OSArgument::makeIntegerArgument(\"begin_day_of_month\", true)\n arg.setDisplayName(\"Run Period Begin Day of Month\")\n arg.setDefaultValue(1)\n args << arg\n\n # make an argument for the run period end month\n arg = OpenStudio::Measure::OSArgument::makeIntegerArgument(\"end_month\", true)\n arg.setDisplayName(\"Run Period End Month\")\n arg.setDefaultValue(12)\n args << arg\n\n # make an argument for the run period end day of month\n arg = OpenStudio::Measure::OSArgument::makeIntegerArgument(\"end_day_of_month\", true)\n arg.setDisplayName(\"Run Period End Day of Month\")\n arg.setDefaultValue(31)\n args << arg\n\n return args\n end", "def generate_input_file\n @run_name += \"_t\"\n if @restart_id\n @runner.run_list[@restart_id].restart(self)\n else\n make_initial_profiles if self.respond_to?(:make_initial_profiles) \n end\n if uses_ecom?\n setup_ecom\n elsif uses_chease?\n setup_chease\n end\n #eputs \"nwrite 6 is \", new_run.flux_runs[0].nwrite\n @avail_cpu_time = (@wall_mins-1.0) * 60 if @wall_mins\n if flux_gs2? or flux_gryfx?\n @avail_cpu_time = (@wall_mins-6.0) * 60 if @wall_mins\n end\n check_parameters\n write_input_file\n #eputs \"nwrite 7 is \", new_run.flux_runs[0].nwrite\n generate_flux_input_files if flux_gs2? or flux_gryfx?\n #eputs \"nwrite 8 is \", new_run.flux_runs[0].nwrite\n end", "def build_rake_step\n @rake_task << self.global_config # Open the rake Stek and get General Configuration information\n @rake_task << (self.render self.get_config_template) # get Specific Configuration. Defined in the [tool].rb module file (erb)\n @opt_parser.check_error # stop here if errors found in the configuration\n @rake_task << self.test_validation # step is already done ? Defined in the tool_template.rb file\n @rake_task << (self.render self.tool_template) # get specific Task Code. Defined in the [tool].rb module file (erb)\n @rake_task << self.write_validation # write the check file Defined in the tool_template.rb file\n @rake_task << self.close_step # To close the rake Step Defined in the tool_template.rb file\n end", "def arguments(model)\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n \r\n #make an argument for location of G Function .idf file\r\n g_function_path = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"g_function_path\",true)\r\n g_function_path.setDisplayName(\"G Function File Path (C:/g_function.idf)\")\r\n args << g_function_path\r\n\r\n # Find the names of all plant loops in the model that contain both a \r\n # district heating and district cooling object\r\n loop_names = OpenStudio::StringVector.new\r\n loop_handles = OpenStudio::StringVector.new\r\n model.getPlantLoops.each do |loop|\r\n dist_htg_name = nil\r\n dist_clg_name = nil\r\n loop.supplyComponents.each do |sc|\r\n if sc.to_DistrictHeating.is_initialized\r\n dist_htg_name = sc.name.get\r\n elsif sc.to_DistrictCooling.is_initialized\r\n dist_clg_name = sc.name.get\r\n end \r\n end # Next supply component\r\n\r\n if dist_htg_name and dist_clg_name\r\n loop_names << loop.name.get\r\n loop_handles << loop.handle.to_s\r\n end\r\n \r\n end # Next loop \r\n \r\n #make an argument for plant loops\r\n object = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"object\", loop_handles, loop_names,true)\r\n object.setDisplayName(\"Select plant loop to add GLHX to\")\r\n args << object\r\n \r\n return args\r\n end", "def step(number = 1)\n number.times do\n @already_done.clear\n @parameters.each_value do |parameter|\n process(parameter)\n end\n end\n end", "def run\n while @running\n step\n end\n end", "def run\n number = options[\"number\"].to_i\n\n threads = options[\"max_threads\"].to_i\n\n factories = if options[:approved] || options[:rejected] || options[:pending] || options[:incomplete]\n build_factory_list\n else\n options[\"factory\"]\n end\n\n puts \"Starting load of #{number} enrollments per factory(s) #{factories.inspect}\"\n\n t1 = Time.zone.now\n\n if threads.zero?\n 1.upto(number) do |n|\n print \".\" if (n % 10).zero?\n factories.each { |f| FactoryGirl.create(f) }\n end\n else\n puts \"Running using #{threads} threads\"\n\n cycles = (number / threads).to_i\n\n # the remainder\n 1.upto(number - (cycles * threads)).each { factories.each { |f| FactoryGirl.create(f) } }\n\n 1.upto(cycles).map do\n 1.upto(threads).map do\n Thread.new do\n factories.each { |f| FactoryGirl.create(f) }\n ActiveRecord::Base.connection.close\n end\n end.each(&:join)\n end\n end\n\n t2 = Time.zone.now\n\n puts(\"\\nBulk load of [#{options['number'] * factories.size}] Enrollments took [#{t2 - t1}] seconds\")\n end", "def xsteps(steps)\n len = @dataxy.first[1].length\n steps = len if(steps >= len)\n labels = {}\n every = (len.to_f / steps).floor\n for i in 0..steps do\n index = i == 0 ? 0 : (i * every) - 1\n labels_val = i == 0 ? 1 : i * every\n # labels[labels_val] = @dataxy.first[1][index].round(2)\n labels[@dataxy.first[1][index]] = @dataxy.first[1][index].round(2)\n end\n @methods[:labels] = labels\n end", "def new\n @test = @subject.tests.new\n 3.times do\n question = @test.questions.build\n 4.times { question.answers.build }\n end\n end", "def setup_test_1(test_name, epw_path)\n\n co = OpenStudio::Runmanager::ConfigOptions.new(true)\n co.findTools(false, true, false, true)\n\n if !File.exist?(sql_path(test_name))\n puts \"Running EnergyPlus\"\n\n wf = OpenStudio::Runmanager::Workflow.new(\"modeltoidf->energypluspreprocess->energyplus\")\n wf.add(co.getTools())\n job = wf.create(OpenStudio::Path.new(run_dir(test_name)), OpenStudio::Path.new(model_out_path(test_name)), OpenStudio::Path.new(epw_path))\n\n rm = OpenStudio::Runmanager::RunManager.new\n rm.enqueue(job, true)\n rm.waitForFinished\n end\n end", "def execute_sequence\n case @acts[0]\n when SEQUENCE_POSE; setup_pose\n when SEQUENCE_MOVE; setup_move\n when SEQUENCE_SLIDE; setup_slide\n when SEQUENCE_RESET; setup_reset\n when SEQUENCE_MOVE_TO_TARGET; setup_move_to_target\n when SEQUENCE_SCRIPT; setup_eval_script\n when SEQUENCE_WAIT; @acts[1].times { method_wait }\n when SEQUENCE_DAMAGE; setup_damage\n when SEQUENCE_CAST; setup_cast\n when SEQUENCE_VISIBLE; @visible = @acts[1]\n when SEQUENCE_SHOW_ANIMATION; setup_anim\n when SEQUENCE_AFTERIMAGE; @afterimage = @acts[1]\n when SEQUENCE_FLIP; setup_flip\n when SEQUENCE_ACTION; setup_action\n when SEQUENCE_PROJECTILE_SETUP; setup_projectile\n when SEQUENCE_PROJECTILE; show_projectile\n when SEQUENCE_LOCK_Z; @lock_z = @acts[1]\n when SEQUENCE_ICON; setup_icon\n when SEQUENCE_SOUND; setup_sound\n when SEQUENCE_IF; setup_branch\n when SEQUENCE_TIMED_HIT; setup_timed_hit\n when SEQUENCE_SCREEN; setup_screen\n when SEQUENCE_ADD_STATE; setup_add_state\n when SEQUENCE_REM_STATE; setup_rem_state \n when SEQUENCE_CHANGE_TARGET; setup_change_target\n when SEQUENCE_TARGET_MOVE; setup_target_move\n when SEQUENCE_TARGET_SLIDE; setup_target_slide\n when SEQUENCE_TARGET_RESET; setup_target_reset\n when SEQUENCE_BLEND; @blend = @acts[1]\n when SEQUENCE_FOCUS; setup_focus\n when SEQUENCE_UNFOCUS; setup_unfocus\n when SEQUENCE_TARGET_LOCK_Z; setup_target_z\n # New update list v1.1\n when SEQUENCE_ANIMTOP; setup_anim_top\n when SEQUENCE_FREEZE; $game_temp.global_freeze = @acts[1]\n when SEQUENCE_CSTART; setup_cutin\n when SEQUENCE_CFADE; setup_cutin_fade\n when SEQUENCE_CMOVE; setup_cutin_slide\n when SEQUENCE_TARGET_FLIP; setup_targets_flip\n when SEQUENCE_PLANE_ADD; setup_add_plane\n when SEQUENCE_PLANE_DEL; setup_del_plane\n when SEQUENCE_BOOMERANG; @proj_setup[PROJ_BOOMERANG] = true\n when SEQUENCE_PROJ_AFTERIMAGE; @proj_setup[PROJ_AFTERIMAGE] = true\n when SEQUENCE_BALLOON; setup_balloon_icon\n # New update list v1.2\n when SEQUENCE_LOGWINDOW; setup_log_message\n when SEQUENCE_LOGCLEAR; get_scene.log_window.clear\n when SEQUENCE_AFTINFO; setup_aftinfo\n when SEQUENCE_SMMOVE; setup_smooth_move\n when SEQUENCE_SMSLIDE; setup_smooth_slide\n when SEQUENCE_SMTARGET; setup_smooth_move_target\n when SEQUENCE_SMRETURN; setup_smooth_return\n # New update list v1.3 + v1.3b + v1.3c\n when SEQUENCE_LOOP; setup_loop\n when SEQUENCE_WHILE; setup_while\n when SEQUENCE_COLLAPSE; tsbs_perform_collapse_effect\n when SEQUENCE_FORCED; setup_force_act\n when SEQUENCE_ANIMBOTTOM; setup_anim_bottom\n when SEQUENCE_CASE; setup_switch_case\n when SEQUENCE_INSTANT_RESET; setup_instant_reset\n when SEQUENCE_ANIMFOLLOW; setup_anim_follow\n when SEQUENCE_CHANGE_SKILL; setup_change_skill\n when SEQUENCE_CHECKCOLLAPSE; setup_check_collapse\n when SEQUENCE_RESETCOUNTER; get_scene.damage.reset_value\n when SEQUENCE_FORCEHIT; @force_hit = default_true\n when SEQUENCE_SLOWMOTION; setup_slow_motion\n when SEQUENCE_TIMESTOP; setup_timestop\n when SEQUENCE_ONEANIM; $game_temp.one_animation_flag = true\n when SEQUENCE_PROJ_SCALE; setup_proj_scale\n when SEQUENCE_COMMON_EVENT; setup_tsbs_common_event\n when SEQUENCE_GRAPHICS_FREEZE; Graphics.freeze\n when SEQUENCE_GRAPHICS_TRANS; setup_transition\n # New update list v1.4\n when SEQUENCE_FORCEDODGE; @force_evade = default_true\n when SEQUENCE_FORCEREFLECT; @force_reflect = default_true\n when SEQUENCE_FORCECOUNTER; @force_counter = default_true\n when SEQUENCE_FORCECRITICAL; @force_critical = default_true\n when SEQUENCE_FORCEMISS; @force_miss = default_true\n when SEQUENCE_BACKDROP; setup_backdrop\n when SEQUENCE_BACKTRANS; setup_backdrop_transition\n when SEQUENCE_REVERT_BACKDROP; $game_temp.backdrop.revert;Fiber.yield\n when SEQUENCE_TARGET_FOCUS; @focus_target = @acts[1]\n when SEQUENCE_SCREEN_FADEOUT; setup_screen_fadeout\n when SEQUENCE_SCREEN_FADEIN; setup_screen_fadein\n when SEQUENCE_CHECK_COVER; setup_check_cover\n when SEQUENCE_STOP_MOVEMENT; stop_all_movements\n when SEQUENCE_ROTATION; setup_rotation\n when SEQUENCE_FADEIN; setup_fadein\n when SEQUENCE_FADEOUT; setup_fadeout\n when SEQUENCE_IMMORTALING; setup_immortaling\n when SEQUENCE_END_ACTION; setup_end_action\n when SEQUENCE_SHADOW_VISIBLE; $game_temp.shadow_visible = default_true\n when SEQUENCE_AUTOPOSE; setup_autopose\n when SEQUENCE_ICONFILE; @icon_file = @acts[1] || ''\n when SEQUENCE_IGNOREFLIP; @ignore_flip_point = default_true\n # Interesting on addons?\n else; custom_sequence_handler\n end\n end", "def iterate\n fill_first_task\n step until status.finished?\n save_tree if @printing\n end", "def start\n start_thread\n wait(20) # This so that you wait until either the step is done or 20 seconds is up.\n # It doesn't have to wait the whole 20 seconds if the step finishes quickly.\n end", "def create\n\n # ensure that the submitted parent_id actually exists\n if !Step.exists?(params[:step][:parent_id].to_i)\n logger.debug \"Step doesn't exist!\"\n if @project.steps.last\n params[:step][:parent_id] = @project.steps.last.id\n else\n params[:step][:parent_id] = nil\n end\n end\n\n if params[:step][:pin] && params[:step][:pin].empty?\n params[:step][:pin] = nil\n end\n\n @step = @project.steps.build(params[:step])\n authorize! :create, @step \n\n if params[:step][:position]\n @step.position = params[:step][:position]\n else\n @step.position = @numSteps\n end\n \n respond_to do |format|\n if @step.save\n\n # update corresponding collections\n @step.project.collections.each do |collection|\n collection.touch\n end\n \n # create an edit entry\n Edit.create(:user_id => current_user.id, :step_id => @step.id, :project_id => @project.id)\n\n # check whether project is published\n if @project.public? || @project.privacy.blank?\n @project.set_published(current_user.id, @project.id, @step.id)\n end\n\n @project.set_built\n\n # update the project updated_at date\n @project.touch\n\n # update the user last_updated_at date\n current_user.touch\n\n @step.update_attributes(:published_on => @step.created_at)\n\n # create a public activity for any added question\n if @step.question\n Rails.logger.debug(\"created new question\")\n @step.question.create_activity :create, owner: current_user, primary: true\n end\n\n # log the creation of a new step\n @project.delay.log\n\n format.html { \n\n # update all images with new step id\n new_step_images = @project.images.where(\"step_id = -1\")\n new_step_images.each do |image|\n image.update_attributes(:saved => true)\n image.update_attributes(:step_id => @step.id)\n end\n\n # update all videos with new step id\n new_step_videos = @project.videos.where(\"step_id = -1\")\n new_step_videos.each do |video|\n video.update_attributes(:saved=>true)\n video.update_attributes(:step_id=> @step.id)\n end\n\n # push project to village if it doesn't already exist\n if @project.village_id.blank? && current_user.from_village? && @project.public? && !access_token.blank?\n create_village_project\n elsif [email protected]_id.blank? && !access_token.blank?\n update_village_project\n end\n \n redirect_to project_steps_path(@project), :flash=>{:createdStep => @step.id}\n \n }\n \n format.json { render :json => @step }\n else\n Rails.logger.debug(@step.errors.inspect)\n format.html { render :action => \"new\" }\n format.json { render :json => @step.errors, :status => :unprocessable_entity }\n end\n end\n end", "def each_exon_seq\n each_exon do | id, reclist, component |\n if component\n sequence = @sequencelist[component.seqname]\n if sequence\n seq = assemble(sequence,component.start,reclist)\n yield description(id,component,reclist), seq\n else \n warn \"No sequence information for\",id\n end\n end\n end\n end", "def setup(step_name, &block)\n if block_given?\n Step.new.tap do |step|\n step.define_singleton_method :run, &block\n step.step_title = step_name.to_s.titleize\n end.run!\n else\n klass = \"Stairs::Steps::#{step_name.to_s.camelize}\".constantize\n klass.new.run!\n end\n end", "def process_and_build_components \n end" ]
[ "0.6226016", "0.57974505", "0.57974505", "0.5615313", "0.55760384", "0.5518346", "0.5513413", "0.5485281", "0.54351246", "0.5385154", "0.53595537", "0.5353766", "0.53498465", "0.53372645", "0.53364813", "0.5308568", "0.53064734", "0.53033334", "0.5302176", "0.52902144", "0.52896595", "0.52872103", "0.52786875", "0.5273911", "0.5256855", "0.52512074", "0.5245998", "0.52367246", "0.5230645", "0.5226282", "0.5226256", "0.51910377", "0.5188854", "0.51641154", "0.51406276", "0.5122313", "0.5114348", "0.5106399", "0.5105635", "0.5105406", "0.51016736", "0.51016736", "0.50973976", "0.5096262", "0.50903964", "0.50865084", "0.50758165", "0.5060042", "0.50543797", "0.5051557", "0.5047335", "0.5041024", "0.5037775", "0.50324494", "0.50157857", "0.50107616", "0.5008505", "0.49990857", "0.4995102", "0.499132", "0.49877772", "0.49791867", "0.49790877", "0.49736887", "0.49694723", "0.49693283", "0.49663275", "0.49644974", "0.49638626", "0.49567443", "0.49553394", "0.49444228", "0.49442828", "0.49442828", "0.49402687", "0.49389654", "0.49359655", "0.49340844", "0.49325436", "0.4932453", "0.49305123", "0.4923098", "0.4908274", "0.49073675", "0.4898543", "0.48954725", "0.48897433", "0.48896092", "0.4880247", "0.48799628", "0.48793918", "0.4879014", "0.48758996", "0.48734206", "0.4872162", "0.48642096", "0.4862455", "0.4860714", "0.48595688", "0.4850794" ]
0.736912
0
returns false. Stop searching the first time the block returns false. Write a method called all? that behaves similarly for Arrays. Should return true if the array is empty.
def all?(collection) collection.each { |item| return false if !yield(item) } true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all?(&block)\n n = 0\n lim = size\n if block_given?\n while n < lim\n unless yield(self.__at(n)) ; return false ; end\n n = n + 1\n end\n else\n while n < lim\n unless self.__at(n) ; return false ; end\n n = n + 1\n end\n end\n true\n end", "def all?(arr)\n arr.each { |el| return false if yield(el) == false}\n true\nend", "def my_all?\n\t\t#if any element is false return false\n\t\tmy_each do | element |\n\t\t\tif yield( element )\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\t# returns true when all iterations pass\n\t\treturn true\n\n\tend", "def my_all?\n all = true\n self.my_each do |x|\n if !block_given?\n if !x || x.nil?\n all = false\n end\n elsif !yield x\n all = false\n end\n break if all == false\n end\n all\n end", "def my_all?\n return unless block_given?\n self.my_each do |ele|\n if not yield ele then return false\n end\n end\n return true\n end", "def my_all?(collection)\n i = 0 \n block_return_values = []\n while i < collection.length\n \n # declare our array & yield each element in the collection\n \n block_return_values << yield(collection[i])\n i = i + 1 \n end\n \n # add an ' #include? ' method to determine the return value of the my_all? method.\n \n if block_return_values.include?(false)\n false \n else \n true \n end\nend", "def my_any?\n if block_given?\n self.my_each {|n| return true if yield(n) == true}\n return false\n else\n return false if self.size == 0\n self.my_each {|n| return true if n == true}\n return false\n end\n end", "def my_all? \n\ti = true\n\tself.my_each do |a|\n\t\tunless yield (a)\n\t\t\ti = false\n\t\t\tbreak\n\t\tend\n\tend\n\ti\nend", "def my_all?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == true\n end\n return true if counter == size\n\n false\n end", "def my_all?(collection)\n i = 0\n block_return_values = []\n while i < collection.length\n block_return_values.push(yield(collection[i]))\n #Three steps\n #First we add yield keyword to yield each element of the block\n #Second we, save the the return values to an array which we declare\n #before the while loop\n i = i + 1\n end\n #Third, we want the final to be true or false for each element in\n #our block_return_values as that is what all? returns\n if block_return_values.include?(false)\n false\n else\n true\n end\nend", "def my_all?\n my_each do |i|\n if (!yield(i))\n return false\n end\n end\n true\n end", "def my_all?(&block)\n return true unless block_given?\n\n # Return false as early as possible\n my_each { |*args| return false unless block.call(*args) }\n\n true\n end", "def my_all?\n if block_given?\n self.my_each{|item| return false if yield(item) == false }\n # return true unless one is false\n true\n else\n # if no block given return true\n true\n end\n end", "def my_all?\n return self unless block_given?\n for a in self\n if !yield(a)\n return false\n end\n end\n return true\n end", "def my_all?\n\t\tvalue = true\n\t\tself.my_each do |element|\n\t\t\tif yield(element) != true\n\t\t\t\tvalue = false\n\t\t\tend\n\t\tend\n\t\treturn value\n\tend", "def my_all?\n self.my_each {|x| return false if yield(x) != true}\n true\n end", "def none?(array)\n array.each do |item|\n return false if yield(item)\n end\n true\nend", "def every?(arr, &blck)\n # arr.all? { |el| blck.call(el) }\n arr.each do |el|\n if !blck.call(el)\n return false\n end\n end\n return true\nend", "def my_all?(collection)\n #our counter\n i = 0\n block_return_values = [ ]\n while i < collection.length\n block_return_values << yield(collection[i])\n # yield(collection[i]) go throughe each element in the index.\n i = i + 1\n #i += 1 does the same thing. Use this if it's easier for you.\n\n end\n\n if block_return_values.include?(false)\n false\n else\n true\n end\nend", "def my_any?\n all = false\n self.my_each do |x|\n if !block_given?\n if x || !x.nil?\n all = true\n end\n elsif yield x\n all = true\n end\n break if all == true\n end\n all\n end", "def my_all?\n return my_all? { |n| n } unless block_given?\n array = []\n to_a.my_each { |n| array << n if yield(n) }\n array.size == size\n end", "def my_all?(arr, &prc)\n arr.each do |ele|\n return false if !prc.call(ele)\n end\n true\nend", "def my_all?(&prc)\n self.my_each do |el|\n return false if !prc.call(el)\n end\n\n true\n end", "def any?(array)\n return false if array.empty?\n result = nil\n\n array.each do |element|\n result = yield(element)\n return result if result == true\n end\n\n result\nend", "def my_all?(&prc)\n self.my_each { |el| return false if !prc.call(el) }\n true\n end", "def my_all?(main_param = nil)\n result = true\n my_each do |element|\n condition = my_all_any_none_helper(main_param, element) { |i| block_given? ? yield(i) : i }\n result &&= condition\n break if result == false\n end\n result\n end", "def any?(array)\n array.each do |element|\n return true if yield(element)\n end\n \n false\nend", "def my_all?(collection)\n i = 0\n return_value = []\n while i < collection.length\n return_value << yield(collection[i])\n i += 1\n end\n\n # check to see if the return values from yielding contains a false\n if return_value.include?(false)\n false\n else\n true\n end\n\nend", "def my_all?(collection)\n i = 0\n block_return_values = []\n while i < collection.length\n block_return_values << yield(collection[i]) #or .push, in this case shove is being used.\n i = i + 1 #i += does the same thing. Use this if it's easier for you.\n end\n\n if block_return_values.include?(false)\n false\n else\n true\n end\nend", "def none?(array)\n array.each { |el| return false if yield(el) }\n true\n end", "def my_all?(collection)\n i = 0\n block_return_values = []\n #the array will store multiple data values\n while i < collection.length\n block_return_values << yield(collection[i])\n #When this code is run and it hits the yield line,\n #it is going to send whatever is passed in as the argument to the block.\n\n #shovel the return value of the block into the array\n i = i + 1\n end\n\n #Now have access to an array of return values block_return_values.\n #We have to determine whether the array contains any false elements.\n if block_return_values.include?(false)\n false\n else\n true\n end\nend", "def my_any?(&prc)\n i = 0\n while i < self.length\n if prc.call(self[i]) == true\n return true\n end\n i += 1\n end\n return false\n end", "def any?\n ! empty?\n end", "def my_none?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == false\n end\n return true if counter == size\n\n false\n end", "def none?(arr)\n arr.each { |el| return false if yield(el) }\n true\nend", "def empty?\n all.empty?\n end", "def every?(arr, &prc)\n\n arr.each do |ele|\n return false if !(prc.call(ele))\n end\n\n true\nend", "def empty?(&block)\n block ? !any?(&block) : !any?\n end", "def my_all?\n status = true\n self.my_each do |item|\n if (yield item) != true\n status = false\n end\n end\n status\n end", "def my_none?\n if block_given?\n self.my_each {|n| return false if yield(n) == true}\n return true\n else\n return true if self.size == 0\n self.my_each {|n| return false if n == true}\n return true\n end\n end", "def my_all? looking_for\n output = true\n self.my_each {|item| output = false if item != looking_for}\n output\n end", "def any?(array)\n array.each do |el|\n return true if yield(el)\n end\n\n false\nend", "def my_none?\n all = true\n self.my_each do |x|\n if !block_given?\n if x\n all = false\n end\n elsif yield x\n all = false\n end\n break if all == false\n end\n all\n end", "def empty?\n return true unless @all\n @all.empty?\n end", "def all?(array)\n i = 0\n score = 0\n\n while i < array.length\n if yield(array[i])\n score += 1\n end\n i += 1\n end\n\n score == array.length\nend", "def my_all?(proc=nil)\n self.my_each do |item|\n if block_given?\n return false if !yield(item)\n else\n return false if !proc.call(item)\n end\n end\n true\n end", "def my_all?(proc=nil)\n self.my_each do |item|\n if block_given?\n return false if !yield(item)\n else\n return false if !proc.call(item)\n end\n end\n true\n end", "def array_fast_empty?(arr)\n return true if arr.size.zero?\n\n arr.each do |a|\n if a.is_a?(Array)\n return false if !array_fast_empty?(a)\n\n next\n end\n return false\n end\n\n true\n end", "def all?(&block)\n if block\n self.each{|*val| return false unless block.call(*val)}\n else\n self.each{|*val| return false unless val.__svalue}\n end\n true\n end", "def any?\n !empty?\n end", "def any?\n !empty?\n end", "def my_all?\n self.my_each do |word|\n return false if !yield(word)\n end\n return true\n end", "def my_any?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == true\n end\n return true if counter.positive?\n\n false\n end", "def any?(array)\n array.each do |item|\n check = yield(item) if block_given?\n if check == true\n return true\n else\n next\n end\n end\n false\nend", "def __empty?\n all?(&:__empty?)\n end", "def my_any?\n return unless block_given?\n self.my_each do |ele|\n if yield ele then return true\n end\n end\n return false\n end", "def my_any?\n self.my_each {|x| return true if yield(x) == true}\n false\n end", "def my_all?( proc_argument = nil )\n result = []\n\n my_each do |element|\n if block_given? \n result << element if yield(element)\n else\n result << element if proc_argument.call(element)\n end\n end\n\n # If the new array has the same number of true elements as the original array, we know that all elements satisfied the condition\n self.size == result.size ? true : false\n end", "def any?(arr)\n arr.each { |el| return true if yield(el) }\n false\nend", "def any?(arr)\n arr.each { |el| return true if yield(el) }\n false\nend", "def my_all?\n if self.class == Array\n my_each do |value|\n # stop if item is flagged\n return false unless yield(value)\n end\n elsif self.class == Hash\n my_each do |key, value|\n return false unless yield(key, value)\n end\n end\n true\n end", "def my_any?(&block)\n return false unless block_given?\n\n # Return true on first instance\n my_each { |*args| return true if block.call(*args) }\n\n false\n end", "def my_all? (pattern = false)\n if block_given?\n self.my_each{|item| return false if !!(yield item) == false}\n elsif !!pattern == true\n self.my_each{|item| return false if (pattern === item) == false}\n else\n self.my_each{|item| return false if !!item == false}\n end\n true\n end", "def any?\n if block_given?\n to_a.any? { |*block_args| yield(*block_args) }\n else\n !empty?\n end\n end", "def my_any?\n return self unless block_given?\n for a in self\n if yield(a)\n return true\n end\n end\n return false\n end", "def my_any?\n if block_given?\n self.my_each{|item| return true if yield(item)}\n # return false unless one is true\n false\n else\n # if no block given return true\n true\n end\n end", "def any?\n if block_given?\n to_a.any? { |*block_args| yield(*block_args) }\n else\n !empty?\n end\n end", "def my_none?(arr, &prc)\n arr.each do |ele|\n return false if prc.call(ele)\n end\n true\nend", "def all?(collection)\n collection.each_with_object(true) { |el| return false unless yield(el) }\nend", "def any?\n false\n end", "def my_any?(&prc)\n\t\tself.my_each do |ele|\n\t\t\treturn true if prc.call(ele)\n\t\tend\n\t\tfalse\n\tend", "def include_all?(*items)\n items = items.first if items.length == 1 && items.first.kind_of?(Array)\n (items - self).empty?\n end", "def my_any?\n status = false\n self.my_each do |item|\n if (yield item) == true\n status = true\n end\n end\n status\n end", "def none?(collection)\n collection.each { |element| return false if yield(element) }\n true\nend", "def my_all?(*args)\n arr = self\n is_all = true\n if !args[0].nil?\n arr.my_each do |x|\n if args[0].is_a?(Class)\n is_all = false unless x.is_a?(args[0])\n elsif args[0].is_a?(Regexp)\n is_all = false unless args[0].match?(x)\n else\n is_all = false unless args[0] == x\n end\n end\n elsif block_given?\n arr.my_each do |x|\n is_all = false unless yield(x)\n end\n else\n arr.my_each do |x|\n is_all = false unless x\n end\n end\n is_all\n end", "def match_all?\n self.class.array_matching == :all\n end", "def empty?\r\n @arr.empty?\r\n end", "def any1?(arr, &block)\n return false if arr.empty?\n block.call(arr.first) ? true : any?(arr.drop(1), &block)\nend", "def any?(collection)\n collection.each do |element|\n return true if yield(element)\n end\n false\nend", "def my_any?(&prc)\n self.my_each { |el| return true if prc.call(el) }\n false\n end", "def my_none?\n return unless block_given?\n self.my_each do |ele|\n if yield ele then return false\n end\n end\n return true\n end", "def my_none?\n if self.class == Array\n my_each do |value|\n # stop if any item is true\n return false if yield(value)\n end\n elsif self.class == Hash\n my_each do |key, value|\n # stop if any item is true\n return false if yield(key, value)\n end\n end\n\n true\n end", "def my_all?(args = nil)\n result = true\n my_each do |value|\n if block_given?\n result = false unless yield(value)\n elsif args.nil?\n result = false unless value\n else\n result = false unless args === value\n end\n end\n result\n end", "def my_none?\n self.my_each {|x| return false if yield(x) == true}\n true\n end", "def my_none?\n return self unless block_given?\n for n in self\n if yield(n)\n return false\n end\n end\n return true\n end", "def reduce_to_all_true(source_array)\n i = 0\n while i < source_array.length do\n return false if !source_array[i]\n i += 1\n end\n return true\nend", "def my_any?(arr, &prc)\n arr.each do |ele|\n return true if prc.call(ele)\n end\n false\nend", "def full?\n each_cell do |cell|\n return false unless cell\n end\n true\n end", "def empty?\n peek\n false\n rescue StopIteration\n true\n end", "def any?(&block)\n if block\n self.each{|*val| return true if block.call(*val)}\n else\n self.each{|*val| return true if val.__svalue}\n end\n false\n end", "def empty?\n iterator.nil?\n end", "def my_any? looking_for\n output = false\n self.my_each {|item| output = true if item == looking_for}\n output\n end", "def reduce_to_all_true(array)\n counter = 0;\n while counter < array.length do\n return false if !array[counter];\n counter += 1;\n end\n return(true);\nend", "def my_all?(var = nil)\n result = true\n my_each do |item|\n if block_given?\n result = false unless yield(item)\n elsif var.nil?\n result = false unless item\n else\n result = false unless var === item\n end\n end\n result\n end", "def any?(collection)\n return false if collection.empty?\n collection.each { |args| return true if yield(args) }\n false\nend", "def full?\n grid.each do |row|\n row.each do |location|\n return false if location.nil?\n end\n end\n true\n end", "def my_all?(arg = nil)\n all_matched = true\n my_each do |val|\n if block_given?\n all_matched = false unless yield(val)\n elsif arg.nil?\n all_matched = false unless val\n else\n all_matched = false unless arg === val\n end\n end\n all_matched\n end", "def all?\n only_with('all?', 'Boolean')\n items.compact.all?\n end", "def my_any? (pattern = false)\n if block_given?\n self.my_each{|item| return true if yield item}\n elsif !!pattern == true\n self.my_each{|item| return true if pattern === item}\n else\n self.my_each{|item| return true if !!item}\n end\n false\n end", "def every?(arr, &prc)\n count = 0\n arr.each do |ele| \n if prc.call(ele)\n count += 1\n end\n end\n count == arr.length\nend" ]
[ "0.8125602", "0.7620637", "0.75627947", "0.7521884", "0.751895", "0.75036246", "0.7461377", "0.744715", "0.74178237", "0.7372185", "0.73671174", "0.7350128", "0.73386264", "0.7287544", "0.72684443", "0.726438", "0.7262817", "0.72156686", "0.71917385", "0.7177755", "0.7172164", "0.7162382", "0.7137896", "0.7132923", "0.7098455", "0.7095888", "0.70508635", "0.70390624", "0.7028679", "0.7025262", "0.70169204", "0.70114577", "0.6988641", "0.6976256", "0.6967134", "0.6962111", "0.6948683", "0.69405425", "0.69389164", "0.6927697", "0.692622", "0.6914363", "0.6910875", "0.69105387", "0.6904989", "0.68963367", "0.68963367", "0.68850374", "0.6864704", "0.68492454", "0.68492454", "0.682312", "0.681088", "0.6803992", "0.6794715", "0.6790914", "0.678868", "0.678556", "0.676679", "0.676679", "0.67665285", "0.6736653", "0.67229277", "0.6685916", "0.66345984", "0.6629051", "0.6628761", "0.6624713", "0.66239744", "0.66209036", "0.6609166", "0.6576307", "0.65745455", "0.656749", "0.6556828", "0.6556459", "0.6550668", "0.6517657", "0.65011376", "0.64961743", "0.64932775", "0.64650935", "0.64294475", "0.6427621", "0.642499", "0.6411527", "0.64102995", "0.64035285", "0.6401989", "0.6400781", "0.63975686", "0.6386708", "0.6373398", "0.63678104", "0.6366328", "0.6360075", "0.63573647", "0.6355269", "0.63513017", "0.6347333" ]
0.6858307
49
TODO: default eligible_item_service from 4033
def initialize(resource_id:, eligible_item_service:, change_set_persister:) @resource_id = resource_id @eligible_item_service = eligible_item_service @change_set_persister = change_set_persister resource_charge_list.clear_expired_charges! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_request(service); end", "def eligible_inventory_item_ids\n where_hash = {\n vendor: promotion.vendor_ids,\n service_id: preferred_service_id,\n item_id: preferred_item_id,\n item_type_id: preferences[:item_type_id]\n }\n @eligible_inventory_item_ids ||= InventoryItem.where(where_hash).ids\n end", "def delivery_service\n super || available_delivery_services.first\n end", "def source_item_choices\n choices = source.items_by_product(product)\n amount > 0 ? choices.online : choices\n end", "def bi_service\n end", "def is_aus_post_service_allowed(allowed_methods, service_code, item_weight, has_satchel)\n\n Rails.logger.debug(\"checking code #{service_code} weight #{item_weight}\")\n Rails.logger.debug(\"allowed_methods[service_code] is #{allowed_methods[service_code].class} and #{allowed_methods[service_code].to_s}\")\n if (allowed_methods[service_code].to_s == \"1\")\n \n Rails.logger.debug(\" #{service_code} is allowed by user\") \n \n return true if item_weight.to_f > 5.0\n #will fit in prepad satchel]\n if (item_weight.to_f > 3.0) # 3 to 5\n Rails.logger.debug(\" 3 to 5\")\n if has_satchel\n return service_code.include? (\"SATCHEL\")\n else\n return true\n end\n \n elsif (item_weight.to_f > 0.5) #0.5 to 3\n Rails.logger.debug(\" 0.5 to 3\") \n if has_satchel\n return service_code.include? (\"SATCHEL\")\n else\n return true\n end\n else\n Rails.logger.debug(\" 0.5\") \n if has_satchel \n Rails.logger.debug(\" service_code.include? ('SATCHEL_500G') #{ service_code.include? ('SATCHEL_500G')}\") \n \n return service_code.include? (\"SATCHEL\") \n else\n Rails.logger.debug(\"return true\")\n return true\n end \n end \n else\n return false\n #Rails.logger.debug(\"not an allowed shipping method\")\n #Rails.logger.debug \"Preference.AusPostParcelServiceListInt[service_code] is\" + Preference.AusPostParcelServiceListInt[service_code.to_sym].blank?.to_s\n #Rails.logger.debug \"Preference.AusPostParcelServiceListDom[service_code] is\" + Preference.AusPostParcelServiceListDom[service_code.to_sym].blank?.to_s\n \n #see if this is a recognized service, if not, allow this to be displayed to the user\n #value = Preference.AusPostParcelServiceListInt[service_code.to_sym].blank? && Preference.AusPostParcelServiceListDom[service_code.to_sym].blank?\n #Rails.logger.debug \"value is #{value.to_s}\"\n #return value\n end\n \n return false\n \n end", "def pending_offers_as_seller\n self.offers_as_seller.pending\n end", "def eligible_items\n @eligible_items ||= ::InventoryItem.where(vendor: promotion.vendors)\n end", "def set_service_item\n @service_item = ServiceItem.find(params[:id])\n end", "def set_service_item\n @service_item = ServiceItem.find(params[:id])\n end", "def refine_item_outlook(item)\n the_item = {}\n if Status.find(item.status_id).value.include? \"Banned\"\n the_item = {id: item.id, title: item.title, description: item.description, category: Category.find(item.category_id).value, \n price: \"%.2f\" % item.price, seller_longitude: Seller.find(item.seller_id).longitude,\n seller_latitude: Seller.find(item.seller_id).latitude, status: Status.find(item.status_id).value}\n else \n the_item = {id: item.id, title: item.title, description: item.description, category: Category.find(item.category_id).value, \n price: \"%.2f\" % item.price, seller_name: Seller.find(item.seller_id).name, seller_longitude: Seller.find(item.seller_id).longitude,\n seller_latitude: Seller.find(item.seller_id).latitude, status: Status.find(item.status_id).value, published_date: item.published_date}\n end\n return the_item\n end", "def with_pricing\n # CCS::FM::Rate.non_zero_rate\n services_with_pricing = CCS::FM::Rate.non_zero_rate.map(&:code)\n\n services_selected = user_buildings.collect { |b| b.building_json['services'] }.flatten # s.collect { |s| s['code'].gsub('-', '.') }\n services_selected = services_selected.map { |s| s['code'] }\n services_selected.uniq!\n\n FacilitiesManagement::Service.all.select do |service|\n # (@posted_services.include? service.code) && (services_with_pricing.include? service.code)\n (services_selected.include? service.code) && (services_with_pricing.include? service.code)\n end\n end", "def service_contract_of(buyer)\n service_contracts.find_by(user_account_id: buyer.id)\n end", "def is_service_fee?\n sku_type.to_s == Product::SKU_TYPE_SERVICE_FEE && self.internal?\n end", "def pending_offers_as_buyer\n self.offers_as_buyer.pending\n end", "def get_item_availability(holding, item)\n # is_offsite = LOCATIONS['offsite_locations'].include? holding[:location_code]\n # if is_offsite\n if is_offsite_location_code?(holding[:location_code])\n self.fetch_scsb_availabilty unless @scsb_availability\n return @scsb_availability[ item[:barcode] ] if @scsb_availability.has_key?(item[:barcode])\n else\n # If we didn't find an offsite availability for this item, check Voyager availability\n self.fetch_voyager_availability unless @voyager_availability\n return @voyager_availability[ item[:item_id] ]\n end \n end", "def update_current_discount_to_service\n service = self.service\n if service\n #get spots already taken\n availabilities = service.availabilities\n spots_taken = service.reservations.get_unarchived.not_cancelled.count\n\n #get percentage availabilites\n number_of_ten_available = service.nb_10\n number_of_fifteen_available = service.nb_15\n number_of_twenty_available = service.nb_20\n number_of_twenty_five_available = service.nb_25\n\n #get new current discount\n #return 0 if no spots left\n if spots_taken >= availabilities \n discount = 0\n #start highest to lowest percentages \n #to see which percentage is still available \n elsif spots_taken < number_of_twenty_five_available\n discount = 0.25\n elsif spots_taken < number_of_twenty_available\n discount = 0.20\n elsif spots_taken < number_of_fifteen_available\n discount = 0.15\n else\n discount = 0.10\n end\n \n service.update(current_discount: discount)\n end\n end", "def service_provider_line_items(service_provider, items)\n service_provider_items = []\n items.map(&:sub_service_request_id).each do |ssr|\n if service_provider.identity.is_service_provider?(SubServiceRequest.find(ssr))\n service_provider_items << SubServiceRequest.find(ssr).line_items\n end\n end\n service_provider_items.flatten.uniq\n end", "def active_services_responsible_for\n # Old Rails 2 style\n #Service.all( :joins => [ :service_responsibles ],\n # :conditions => [ \"service_responsibles.user_id = ? AND service_responsibles.status = 'active'\", self.id ])\n Service.joins(:service_responsibles).where([\"service_responsibles.user_id = ? AND service_responsibles.status = 'active'\", self.id ])\n end", "def true_cost\n # convert to array so it doesn't try to do sum on database directly\n #items.to_a.reject{|item|item.itemable_type == \"ServiceGroup\"}.sum(&:cost)\n items.collect.sum(&:cost)\n end", "def offenses_to_check; end", "def overdue_service(service)\n notification = Notification.find_by_name(\"Overdue service\")\n vehicle = service.fleet\n setting = vehicle.truck_fleet.setting.email_notifications.find_by_notification_id(notification.id)\n emails = self.find_emails(user, vehicle, setting)\n if emails.present?\n mail :to => emails,\n :subject => \"Service overdue. For #{vehicle.fleet_number}\"\n end\n end", "def assignable_services\n\t\t(Service.predefined + services).sort_by(&:lower_case_name).uniq\n\tend", "def current_item_enabled?\n true\n end", "def show\n # params[:q] = {} if params[:q].blank?\n @title = \"#{@service.name} - JC Auto Restoration, Inc.\"\n \t@service_applications = []\n \t@price_lists = @service.service_price_lists\n \t@price_lists.each do |price_list|\n \t\tprice_list.service_items.order(\"position ASC\").each do |item|\n \t\t\tif item.service_application && (!@service_applications.include? item.service_application)\n \t\t\t\t@service_applications << item.service_application\n \t\t\tend\n \t\tend\n \tend\n\n # @search = @service_applications.ransack(params[:q])\n # @activities = @search.result.order('created_at desc').page(params[:page]).per(Spree::Config[:admin_products_per_page])\n\n \tif params[:my_service_application]\n if params[:my_service_application][:my_service_application_id]\n \t\t @service_app_id = params[:my_service_application][:my_service_application_id].to_i\n end\n if params[:my_service_application][:my_service_price_list_id]\n @service_price_list_id = params[:my_service_application][:my_service_price_list_id].to_i\n end\n \tend\n end", "def price_to_be_announced?\n unless self.product_supplies.empty? || self.product_supplies.first.supply_details.empty?\n unpriced_item_type = self.product_supplies.first.supply_details.first.unpriced_item_type\n end\n unpriced_item_type ? unpriced_item_type.human==\"PriceToBeAnnounced\" : false\n end", "def needs_item_set\n\t\treturn false\n\tend", "def cash_services \n services.select{|i| i[:btype] && i[:btype] == CASH_BILLING} rescue []\n end", "def service\n self.original_service or Service.find_by_name(\"FieldStatus\")\n end", "def total_insured_fees\n services.select{|i| i[:btype] && i[:btype] < CASH_BILLING}.sum{|s| s[:fee]} rescue 0\n end", "def getHttpService()\r\n @currentlyDisplayedItem.getHttpService\r\n end", "def service_params\n atts = params.require(:service).permit(:title, {:items => []},:cover, :content, :external_link, :status, {:article_attributes => [ :content ]}, :id )\n atts['items'] = atts['items'].reject { | i | i.length <= 0 } if !atts['items'].nil?\n \n atts\n \n end", "def service_company\n self.well_info.service_company\n end", "def populate_from_enquiry_items\n if enquiry_items.present? # not present\n self.food_partner = enquiry_items.first.packageable_item.food_partner # cleanlol\n enquiry_price.populate_price_from_cart\n end\n end", "def service_name; end", "def search_for_item\n search_service.fetch(params[:id], { fl: ['visibility_ssi'] })\n end", "def item_status!(item)\n item['status'] = item_status(item.fetch('loc_current', ''), item['loc_n'])\n if item['status'] == 'Available'\n if offsite?(item)\n item['status'] = 'Available upon request'\n elsif reserve?(item)\n item['status'] = 'Available - On Reserve'\n elsif kindle?(item)\n item['status'] = 'Available - Libraries Kindle only'\n end\n end\n item['status'] = item['status'] + ' (Library use only)' if library_use_only?(item)\n end", "def has_this_item?(item_id)\n item_id.blank? ? true : self.delivered_items.map(&:item_id).include?(item_id)\n end", "def has_this_item?(item_id)\n item_id.blank? ? true : self.delivered_items.map(&:item_id).include?(item_id)\n end", "def current_item_enabled?() target end", "def ill_item?(instance)\n instance['source'] == 'FOLIO' &&\n instance['discoverySuppress'] == true &&\n instance['staffSuppress'] == false\n end", "def get_eligible_shipping_services(shipment_request_details)\n operation('GetEligibleShippingServices')\n .add('ShipmentRequestDetails' => shipment_request_details)\n .structure!('ItemList', 'Item')\n\n run\n end", "def available_service_providers\n ServiceProvider.includes(:provision_services).\n where(:provision_services => {:product_category_id => self.service_request.product_category_id,\n :product_brand_id => self.service_request.product_brand_id }\n ) if self.service_request\n end", "def offer_an_item(item)\r\n item.status = true\r\n end", "def service; services.first; end", "def sell_pending\n end", "def collect_eligible(items)\n items.select{|item| eligible?(item) }\n end", "def enable?(item)\n item && item.price > 0\n end", "def set_considered_item\n @considered_item = ConsideredItem.find(params[:id])\n end", "def total_insured_services\n services.select{|i| i[:btype] && i[:btype] < CASH_BILLING}.count rescue 0\n end", "def refine_item_outlook(item)\n the_item = {id: item.id, title: item.title, description: item.description, category: Category.find(item.category_id).value, \n price: \"%.2f\" % item.price, seller_name: Seller.find(item.seller_id).name, seller_longitude: Seller.find(item.seller_id).longitude,\n seller_latitude: Seller.find(item.seller_id).latitude, status: Status.find(item.status_id).value, published_date: item.published_date}\n end", "def other_party(company)\n (company == service_provider) ? service_buyer : service_provider\n end", "def keyword_based_service?; end", "def business_decision_support \n end", "def across_service_state\n super\n end", "def service?(service)\n taxes.include?(service.to_s.upcase)\n end", "def within_limit_of?(item, user)\r\n @member_limits.fetch(user.email).has_resources_for?(item.price)\r\n end", "def current_item_enabled?\n return true\n end", "def enable?(item)\n return false if item.nil?\n return false unless has_recipebook?\n return false if item.tocrafting_gold_fee > $game_party.gold\n return false if $game_party.item_max?(item)\n return false unless have_tools?(item)\n return false unless have_actors?(item)\n return true if item.ingredient_list.empty?\n return have_ingredients?(item)\n end", "def service(nickname, reserved, distribution, type)\n end", "def other_services_responsible(page=1, per_page=PAGE_ITEMS_SIZE)\n Service.paginate(:page => page,\n :per_page => per_page,\n :joins => [ :service_responsibles ],\n :conditions => [ \"service_responsibles.user_id = ? AND service_responsibles.status = 'active'\", \n self.id ])\n end", "def extra_item?\n false\n end", "def available_delivery_services\n delivery_service_prices.map(&:delivery_service).uniq\n end", "def risks_by_service(limit=10)\n\t\t\t\t\tselect(\"items.*\").select(\"count(*) as count_all\").where(\"svc_name != 'unknown' and svc_name != 'general'\").group(:svc_name).order(\"count_all DESC\").limit(limit)\n\t\t\t\tend", "def create_line_items_for_service(args)\n service = args[:service]\n requester = args[:requester]\n optional = args[:optional].nil? ? true : args[:optional]\n allow_duplicates = args[:allow_duplicates].nil? ? false : args[:allow_duplicates]\n recursive_call = args[:recursive_call].nil? ? false : args[:recursive_call]\n\n # If this service has already been added, then do nothing\n return if !allow_duplicates && self.line_items.incomplete.where(service: service).any?\n\n line_items = []\n\n ssr = find_or_create_ssr(service.process_ssrs_organization, requester)\n\n # add service to line items\n line_items << create_line_item(service: service, sub_service_request: ssr, optional: optional, quantity: service.displayed_pricing_map.quantity_minimum)\n\n self.reload\n\n # add required services to line items\n service.required_services.each do |rs|\n next unless rs.parents_available?\n rs_line_items = create_line_items_for_service(service: rs, optional: false, recursive_call: true)\n line_items += rs_line_items if rs_line_items\n end\n\n # add optional services to line items\n # if were in a recursive call, we don't want to add optional services\n unless recursive_call\n service.optional_services.each do |os|\n next unless os.parents_available?\n os_line_items = create_line_items_for_service(service: os, optional: true, recursive_call: true)\n line_items += os_line_items if os_line_items\n end\n end\n\n return line_items\n end", "def service_code\n \"#{shipment_mode_code}#{service_type_code}#{services_code}\"\n end", "def review_assigned_stock\n\n automatic_assignation = SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation', 'false').to_bool\n\n # Search availability\n product_search = ::Yito::Model::Booking::BookingCategory.search(self.rental_location_code,\n self.date_from,\n self.time_from,\n self.date_to,\n self.time_to,\n self.days,\n {\n locale: self.customer_language,\n full_information: true,\n product_code: nil,\n web_public: false,\n sales_channel_code: self.sales_channel_code,\n apply_promotion_code: self.promotion_code.nil? ? false : true,\n promotion_code: self.promotion_code,\n include_stock: true,\n ignore_urge: {origin: 'booking', id: self.id}\n })\n free_resources = product_search.inject([]) do |result, item|\n result.concat(item.resources)\n end\n\n p \"free_resources: #{free_resources}\"\n\n self.booking_line_resources.each do |booking_line_resource|\n\n if !booking_line_resource.booking_item_reference.nil? # Assigned resource\n if free_resources.index(booking_line_resource.booking_item_reference).nil? # Not found\n if product = product_search.select { |item| item.code == booking_line_resource.booking_line.item_id }.first\n if product.availability and product.resources.size > 0\n if automatic_assignation\n p \"booking : #{self.id} reassigned #{product.resources.first} instead of #{booking_line_resource.booking_item_reference}\"\n booking_line_resource.assign_resource(product.resources.first)\n product.resources.delete_at(0)\n end\n else\n booking_line_resource.clear_assignation\n p \"booking : #{self.id} clear assignation #{booking_line_resource.booking_item_reference} -- not free resources\"\n end\n else\n p \"booking : #{self.id} #{booking_line_resource.booking_item_reference} product #{booking_line_resource.booking_line.item_id} not found\"\n end\n else\n p \"booking: #{self.id} kept: #{booking_line_resource.booking_item_reference}\"\n end\n else # Not assigned resource\n if automatic_assignation\n if product = product_search.select { |item| item.code == booking_line_resource.booking_line.item_id }.first\n if product.availability and product.resources.size > 0\n p \"booking : #{self.id} assigned #{product.resources.first}\"\n booking_line_resource.assign_resource(product.resources.first)\n product.resources.delete_at(0)\n end\n end\n end\n end\n end\n end", "def service_item_params\n params.require(:service_item).permit(:description, :service_id)\n end", "def inventory_item_is_available\n \tif self.inventory_item.present? && self.inventory_item.is_available?(project.rental_delivery, project.rental_pickup) == false\n \t\terrors.add(:inventory_item, \"is not available within this project's duration\")\n \telsif self.inventory_item.blank?\n \t\tself.inventory_item = inventory_style.find_available(project.rental_delivery, project.rental_pickup)\n \t\terrors.add(:inventory_style, \"has no available items within this project's duration\") if self.inventory_item.blank?\n \tend\n end", "def manage_items\n @pending_items = Item.find_all_by_item_status_id(1)\n @for_sale_items = Item.find_all_by_item_status_id(2)\n @free_items = Item.find_all_by_item_status_id(3)\n @claimed_items = Item.find_all_by_item_status_id(4)\n @sold_items = Item.find_all_by_item_status_id(5)\n end", "def item_schema\n {\n 'personnelCategoryTypeCode' => {},\n 'serviceEpisodeStartDate' => { rename: 'begin_date' },\n 'serviceEpisodeEndDate' => { rename: 'end_date' },\n 'serviceEpisodeTerminationReason' => { rename: 'termination_reason' },\n 'branchOfServiceCode' => {},\n 'retirementTypeCode' => {},\n 'personnelProjectedEndDate' => {},\n 'personnelProjectedEndDateCertaintyCode' => {},\n 'dischargeCharacterOfServiceCode' => {},\n 'honorableDischargeForVaPurposeCode' => {},\n 'personnelStatusChangeTransactionTypeCode' => {},\n 'narrativeReasonForSeparationCode' => {},\n 'post911GIBillLossCategoryCode' => {},\n 'mgadLossCategoryCode' => {},\n 'activeDutyServiceAgreementQuantity' => {},\n 'initialEntryTrainingEndDate' => {},\n 'uniformServiceInitialEntryDate' => {},\n 'militaryAccessionSourceCode' => {},\n 'personnelBeginDateSource' => {},\n 'personnelTerminationDateSourceCode' => {},\n 'activeFederalMilitaryServiceBaseDate' => {},\n 'mgsrServiceAgreementDurationYearQuantityCode' => {},\n 'dodBeneficiaryTypeCode' => {},\n 'reserveUnderAge60Code' => {}\n }\n end", "def enable?(item); true; end", "def match_services_indicator\n return {} if @all\n @service ? { 'services_indicator' => 'Y' } : { 'services_indicator' => 'N' }\n end", "def works_with\n self.class.use_with_class_names.include? item_type\n end", "def enable?(item)\n CookingManager.quantity(item) > 0\n end", "def get_availability(item, numeric_version, reldev)\n\n img = platform_availability(item)\n availabilityBadge(item['Package'], img, numeric_version, reldev)\n\nend", "def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end", "def chosen_service\n real = Service.where(\n id: store[:chosen_service_id] || store[:chosen_service_selection_id],\n business_id: business.id).first\n\n # Explicit return for debug hook\n real\n end", "def create\n if params[:item].present?\n # TODO - see impact\n @item = Item.new(params[:item])\n @item.user_id = current_user.id if current_user.present?\n\n # TODO Commented shipping information because of REQUIREMENT CHANGE (https://www.pivotaltracker.com/story/show/62299176)\n \n # @item.bring_it_to_you = params[:item][:bring_it_to_you] if params[:item][:bring_it_to_you].present?\n # @item.come_and_get_it = params[:item][:come_and_get_it] if params[:item][:come_and_get_it].present?\n # @item.lets_meet_up = params[:item][:lets_meet_up] if params[:item][:lets_meet_up].present?\n # @item.come_to_you = params[:item][:come_to_you] if params[:item][:come_to_you].present?\n # @item.come_to_me = params[:item][:come_to_me] if params[:item][:come_to_me].present?\n # @item.done_remotely = params[:item][:done_remotely] if params[:item][:done_remotely].present?\n # @item.ship_it = params[:item][:ship_it] if params[:item][:ship_it].present?\n # @item.lets_meet_service = params[:item][:lets_meet_service] if params[:item][:lets_meet_service]\n\n if @item.user.nil? and params[:user_id] and params[:user_id] != ''\n @item.user_id = params[:user_id]\n end\n if not @item.user_id.present? and session[:guest_user_id].to_i > 0\n @item.user_id = session[:guest_user_id].to_i\n end\n # if params[:multi_trade] and params[:multi_trade] == \"on\"\n # @item.is_single_tradeya = false\n # end\n if params[:item][:tod_id].blank?\n @item.exp_date = Item.get_expiry_date_for_tod\n @item.status = \"LIVE\"\n else\n @item.tod = false\n @item.status = \"ACTIVE\"\n end\n respond_to do |format|\n if ((params[:captcha] and params[:item][:tod_id]) or params[:item][:tod_id].nil?) and not @item.user_id.blank?\n if @item.desc == \"Add more details about your good or service here...\" then @item.desc = \"\" end\n if @item.save\n\n # sbx tracking pixel fire\n if current_user.tracking_infos.where(affiliate:'sbx').present?\n Resque.enqueue(FireTrackingPixelJob, current_user.id, 'post')\n end\n\n chk = false\n # Case 1 - Old Offer - edit\n\n # Case 2 - New Tradeya/Offer but item selected from dropdown\n if params[:item][:selected_item_id].to_i > 0 or params[:item][:have].to_i > 0\n create_new = true\n # Create new record for item photos\n end\n # Case 3 - New Tradeya/Offer\n if params[:item_photos].present?\n photos = JSON.parse(params[:item_photos])\n if photos and photos.count > 0\n photos.each_with_index do |photo,index|\n existing_ph = ItemPhoto.find(photo[\"id\"])\n if create_new and existing_ph.item_id.present?\n ph = ItemPhoto.new\n ph.photo = existing_ph.photo\n ph.width = existing_ph.width; ph.height = existing_ph.height;\n ph.crop_x = existing_ph.crop_x; ph.crop_y = existing_ph.crop_y;\n ph.crop_w = existing_ph.crop_w; ph.crop_h = existing_ph.crop_h;\n else\n ph = existing_ph\n end\n if ph.present?\n ph.item_id = @item.id\n if index == 0\n ph.main_photo = true\n end\n ph.save\n chk = true\n end\n end\n end\n end\n if params[:item_videos].present?\n videos = JSON.parse(params[:item_videos])\n if videos and videos.count > 0\n videos.each do |video|\n existing_vi = ItemVideo.find(video[\"id\"])\n if create_new and existing_vi.item_id.present?\n vi = ItemVideo.new\n vi.video = existing_vi.vi\n else\n vi = existing_vi\n end\n if vi.present?\n vi.item_id = @item.id\n vi.save\n chk = true\n end\n end\n end\n end\n # TODO - read below and make it like below\n\n # if params[:file_type] == \"photo\"\n # if params[:item][:item_photo] and params[:item][:item_photo][:id] and params[:item][:item_photo][:id].to_i > 0\n # ip = ItemPhoto.find(params[:item][:item_photo][:id])\n # ip.item_id = @item.id\n # ip.save\n # chk = true\n # elsif params[:item][:item_photo]\n # if params[:item][:item_photo][:photo]\n # o = ItemPhoto.new(params[:item][:item_photo])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # end\n # end\n # elsif params[:file_type] == \"video\"\n # if params[:item][:item_video] and params[:item][:item_video][:id] and params[:item][:item_video][:id].to_i > 0\n # o = ItemVideo.find(params[:item][:item_video][:id])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # elsif params[:item][:item_video]\n # if params[:item][:item_video][:video]\n # o = ItemVideo.new(params[:item][:item_video])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # end\n # end\n # end\n\n if not chk and params[:item][:selected_item_id].to_i > 0\n itm = Item.find(params[:item][:selected_item_id])\n if itm.item_videos and itm.item_videos.count > 0\n o = ItemVideo.new\n if File.exist?(itm.item_videos[0].video.path)\n o.video = File.open(itm.item_videos[0].video.path)\n else\n o.video_from_url(itm.item_videos[0].video.url)\n end\n o.item_id = @item.id\n o.save\n elsif itm.item_photos and itm.item_photos.count > 0\n o = ItemPhoto.new\n if File.exist?(itm.item_photos[0].photo.path)\n o.photo = File.open(itm.item_photos[0].photo.path)\n else\n o.photo_from_url(itm.item_photos[0].photo.url)\n end\n o.item_id = @item.id\n o.save\n end\n end\n\n # if params[:item_wants] and params[:item_wants].present?\n # os = JSON.parse(params[:item_wants])\n # os.each do |iwa|\n # o = ItemWant.new\n # o.title = iwa[0]\n # o.category_id = iwa[1]\n # o.desc = iwa[2]\n # o.item = @item\n # o.user = current_user\n # o.save\n # end\n # end\n if params[:item][:have].present?\n Have.create(:item_id => params[:item][:have].to_i,:user_id => current_user.id )\n end\n\n flash[:notice] = \"item created\"\n # Send mail when item created\n if (InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins)\n if (@item.user.items.count == 1)\n ItemMailer.item_added_first(@item.id,@item.user.id).deliver\n elsif (@item.user.items.count < 6)\n ItemMailer.item_added(@item.id,@item.user.id).deliver\n end\n # Activity Feed\n @item.create_activity key: @item.id, owner: @item.user, recipient: @item.user\n end\n\n\n if params[:item][:tod_id] # check if the request is coming from an offer or just item\n trade = Trade.new(:item_id => params[:item][:tod_id].to_i, :offer_id => @item.id, :status => 'ACTIVE')\n trade.save!\n if params[:item][:tod] and params[:item][:tod] == \"1\"\n offer_as_tod = Item.new\n offer_as_tod.title = @item.title\n offer_as_tod.desc = @item.desc\n offer_as_tod.tod = true\n offer_as_tod.exp_date = Item.get_expiry_date_for_tod\n offer_as_tod.category_id = @item.category_id\n offer_as_tod.user_id = @item.user_id\n offer_as_tod.status = 'INCOMPLETE'\n offer_as_tod.is_single_tradeya = @item.is_single_tradeya\n if offer_as_tod.save\n session[:offer_as_tod] = offer_as_tod.id\n chk = false\n if params[:file_type] == \"photo\"\n if params[:item][:item_photo]\n if params[:item][:item_photo] and params[:item][:item_photo][:id] and params[:item][:item_photo][:id].to_i > 0\n ip = ItemPhoto.find(params[:item][:item_photo][:id])\n o = ItemPhoto.new\n if File.exist?(ip.photo.path)\n o.photo = File.open(ip.photo.path)\n else\n o.photo_from_url(ip.photo.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n elsif params[:item][:item_photo]\n if params[:item][:item_photo][:photo]\n o = ItemPhoto.new(params[:item][:item_photo])\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n end\n end\n elsif params[:file_type] == \"video\"\n if params[:item][:item_video] and params[:item][:item_video][:id] and params[:item][:item_video][:id].to_i > 0\n iv = ItemVideo.find(params[:item][:item_video][:id])\n o = ItemVideo.new\n if File.exist?(iv.video.path)\n o.video = File.open(iv.video.path)\n else\n o.video_from_url(iv.video.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n elsif params[:item][:item_video]\n if params[:item][:item_video][:video]\n o = ItemVideo.new(params[:item][:item_video])\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n end\n end\n\n if not chk and params[:archive_id].present?\n o = ItemVideo.new\n o.video_from_url(@url)\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n\n if not chk and params[:item][:selected_item_id].to_i > 0\n itm = Item.find(params[:item][:selected_item_id])\n if itm.item_videos and itm.item_videos.count > 0\n o = ItemVideo.new\n if File.exist?(itm.item_videos[0].video.path)\n o.video = File.open(itm.item_videos[0].video.path)\n else\n o.video_from_url(itm.item_videos[0].video.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n else\n o = ItemPhoto.new\n if File.exist?(itm.item_photos[0].photo.path)\n o.photo = File.open(itm.item_photos[0].photo.path)\n else\n o.photo_from_url(itm.item_photos[0].photo.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n end\n end\n if session[:guest_user_id].to_i > 0\n session[:guest_offer_as_tod] = true\n end\n end\n else\n session[:guest_user_id] = nil\n session[:is_guest_user] = nil\n end\n\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, NEW_OFFER_ON_TRADEYA, trade.item.user.id, nil, trade.id)\n\n # if InfoAndSetting.sm_on_o_made then EventNotificationMailer.offer_is_made(trade).deliver end\n if InfoAndSetting.sm_on_o_made and trade.item.user.notify_received_offer then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_OFFER_MADE, trade.item.user.id, {:trade_id => trade.id}) end\n # if InfoAndSetting.sm_on_trd_live and params[:item][:tod] == '1' then EventNotificationMailer.tradeya_is_live(@item).deliver end\n # if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins?(MAIL) and params[:item][:tod] == '1' then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n #if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins and params[:item][:tod] == '1' then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n\n # if offer is submitted from new offer flow, id and title of offer is needed\n if params[:new_offer_flow].present? and params[:item][:is_tod].present? and (params[:item][:is_tod] == 'false') and current_user\n session[:new_offer_title] = @item.title\n session[:new_offer_id] = @item.id\n else\n session[:item_saved_offer] = true\n end\n finished(\"make_offer_form\")\n # if current_user and !current_user.showed_onboarding\n # format.html { redirect_to profile_url }\n # else\n format.html { redirect_to item_path(Item.find(params[:item][:tod_id])) }\n # end\n else\n session[:guest_user_id] = nil\n session[:is_guest_user] = nil\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, TRADEYA_LIVE, @item.user.id, @item.id)\n\n # if InfoAndSetting.sm_on_trd_live then EventNotificationMailer.tradeya_is_live(@item).deliver end\n # if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins?(MAIL) then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n #if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n\n # if not session[:ipad_mini_contest].nil? and session[:ipad_mini_contest] = 5\n # format.html{ redirect_to contest_url}\n # else\n\n if params[:item][:offer_for]\n if params[:item][:offer_for].include? \"?\"\n format.html { redirect_to my_offers_item_path(Item.find(params[:item][:offer_for]))+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html { redirect_to my_offers_item_path(Item.find(params[:item][:offer_for]))+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:referer_page]\n session[:have_saved] = params[:item][:referer_page]\n if params[:item][:referer_page].include? \"?\"\n format.html {redirect_to params[:item][:referer_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:referer_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:have_add_page]\n if params[:item][:have_add_page].include? \"?\"\n format.html {redirect_to params[:item][:have_add_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:have_add_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:referer_browse_page]\n if params[:item][:referer_browse_page].include? \"?\"\n format.html {redirect_to params[:item][:referer_browse_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:referer_browse_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n else\n # session[:item_saved] = {:title => @item.title, :url => item_path(@item)}\n format.html { redirect_to new_item_path + \"?item_saved=\" + @item.id.to_s }\n end\n # format.html { redirect_to @item.item_url }\n # end\n end\n else\n format.html { redirect_to new_item_path }\n end\n else\n if params[:item][:tod_id]\n format.html { redirect_to item_path(Item.find(params[:item][:tod_id])) }\n else\n format.html { redirect_to new_item_path }\n end\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to new_item_path }\n end\n end\n end", "def enable?(item)\n return (item.price > 0)\n end", "def valid_delivery_service?\n self.delivery_service ? self.available_delivery_services.include?(self.delivery_service) : !self.delivery_required?\n end", "def delivery_service_price\n self.delivery_service && self.delivery_service.delivery_service_prices.for_weight(self.total_weight).first\n end", "def examine(item)\r\n \r\n end", "def discounted_conference_items\n @discounted_items ||= ConferenceItem.discounted_items(discount_key).not_registered(line_items)\n end", "def compute_shipment_or_line_item(item)\n rate.included_in_price ? raise('TaxCloud cannot calculate inclusive sales taxes.') : round_to_two_places(tax_for_item item)\n end", "def featured_item(items)\n\n end", "def eval_service_provider_id\n service_provider_id = \"-\"\n if eob && eob.provider_npi.present?\n service_provider_id = eob.provider_npi\n elsif eob && eob.provider_tin.present?\n service_provider_id = eob.provider_tin\n elsif (!eob.blank? && !eob.claim_information.blank? && eob.claim_information.provider_npi.present?)\n service_provider_id = eob.claim_information.provider_npi\n elsif (!eob.blank? && !eob.claim_information.blank? && eob.claim_information.provider_ein.present?)\n service_provider_id = eob.claim_information.provider_ein\n elsif facility.facilities_npi_and_tins.present?\n service_provider_id = get_facility_npi_and_tin\n end\n service_provider_id\n end", "def getHttpService()\n return @currentlyDisplayedItem.getHttpService()\n end", "def provided_services\n\t\t\t\tdescription.provided_services\n\t\t\tend", "def find_match_and_decrement_available(line_item)\n gs = Orders::LineItemPresenter.new(line_item).global_sku\n if rii = ReturnInventoryItem.where([\"upc= ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n elsif gs\n #do this check since global skus are jacked up and can't be trusted\n gs = GlobalSku.where(\n style_number: gs.style_number,\n product_name: gs.product_name,\n size: gs.size,\n color_id: gs.color_id,\n customisation_id: gs.customisation_id,\n height_value: gs.height_value,\n product_id: gs.product_id,\n ).first\n\n if rii = ReturnInventoryItem.where([\"upc = ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n end\n end\n rii\n end", "def item_params\n\n params.require(:item).permit(:company_id, :pharmacy_id, :cdb_monograph_id, :price_based_pricing_schedule, :quantity_based_pricing_schedule, :legacy_item_id_number, :item_name, :mfg_description, :ndc_number, :scanned_ndc_number, :clinical_ndc_number, :synonym, :ddid_number, :kdc_code, :generic_product_identifier, :active, :dea_schedule, :awp_unit_price, :mac_unit_price, :act_unit_price, :wac_unit_price, :govt_340b_unit_price, :contract_unit_price, :nadac_unit_price, :custom_unit_price, :awp_automatic_update, :mac_automatic_update, :act_automatic_update, :wac_automatic_update, :govt_340b_automatic_update, :contract_automatic_update, :nadac_automatic_update, :custom_automatic_update, :last_awp_update_date, :last_mac_update_date, :last_act_update_date, :last_wac_update_date, :last_340b_update_date, :last_contract_update_date, :last_nadac_update_date, :last_custom_update_date, :route_of_administration_code, :dosage_form, :inventory, :quantity_on_hand, :strength, :package_size, :package_size_unit_measure, :mfg_name, :drug_class, :item_taxable, :dispensing_unit, :state_billing_code, :alternate_product_code, :alternate_product_qualifier, :memo, :notes, :counseling_notes, :brand_generic_compound, :brand_generic_xref, :fed_tax, :unit_of_measure, :dosage_form_code, :strength_unit_measure_code, :potency_code, :maintenance_code, :doc_u_dose, :discard_age_days, :remote_dispensing, :image_file_name, :imprint_side1, :imprint_side2, :clarity, :coating, :color, :flavor, :scored, :shape, :appearance_text, :monitoring_program, :monitoring_file_name, :monograph_file_name, :medication_guide_file_name, :black_box_file_name, :contains_acetaminophen, :contains_pseudoephedrine, :label_warnings, :active_ingredient, :wellness_tracking, :retest_date, :limited_distribution, :hsa_fsa_eligible, :on_contract, :gpo_drug, :pos_item, :upc_product_number, :upc_category)\n end", "def best_offer_auto_accept_price\n return nil unless best_offer?\n item_hash.deep_find([:listing_details, :best_offer_auto_accept_price])\n end", "def set_status_to_available_if_nil\n self.status_constant = SupplyItem::AVAILABLE if self.status_constant == nil\n end", "def supports_shipment_auto_booking?\n return false\n end", "def service; end", "def buyable_items(_entity)\n []\n end", "def restricted_service_point_options(request)\n request.restricted_pickup_service_points.map do |item|\n [item['discoveryDisplayName'], item['id']]\n end\n end", "def partner_service_request\n @service_requests = @user.get_partner_service_requests(@page)\n end", "def has_service_relation\n # Get the relations for this line item and others to this line item\n service_relations = ServiceRelation.find_all_by_service_id(self.service_id)\n related_service_relations = ServiceRelation.find_all_by_related_service_id(self.service_id)\n\n # Narrow the list to those with linked quantities\n service_relations = service_relations.reject { |sr| sr.linked_quantity == false }\n related_service_relations = related_service_relations.reject { |sr| sr.linked_quantity == false }\n\n # Check to see if this line item even has a relation\n return (service_relations.empty? && related_service_relations.empty?) ? false : true\n end", "def show_service_providers?\n\n # Get the specific Setting for the key Setting::USER_SELECTION,\n # specific to this business.\n setting = Setting.business(business).key(Setting::USER_SELECTION).first\n\n # Return the result of checking if the setting\n # value == Setting::USER_SELECTION_EXPRESS_I\n setting.is? Setting::USER_SELECTION_EXPRESS_I\n end" ]
[ "0.58373576", "0.5758303", "0.5719049", "0.5702834", "0.56762964", "0.5660141", "0.55610645", "0.5552717", "0.5551457", "0.5551457", "0.5532734", "0.5521943", "0.5496442", "0.54834175", "0.54799235", "0.54724634", "0.5470479", "0.5444505", "0.5443673", "0.54296976", "0.54032624", "0.5395262", "0.53791577", "0.5373079", "0.53713226", "0.53687125", "0.536594", "0.5364659", "0.5362268", "0.5356822", "0.534361", "0.53402716", "0.5313434", "0.5305447", "0.5304817", "0.52972406", "0.52884936", "0.52773184", "0.52773184", "0.5274807", "0.5270045", "0.52657205", "0.52650434", "0.5254967", "0.52498025", "0.52490526", "0.5241192", "0.52398074", "0.52363706", "0.5226201", "0.5205823", "0.5204257", "0.52028936", "0.5201079", "0.51977366", "0.51777333", "0.5176657", "0.5172937", "0.5170405", "0.51607144", "0.5149002", "0.5145952", "0.51424", "0.5135411", "0.51308876", "0.51274157", "0.5123299", "0.5106011", "0.51055944", "0.50982773", "0.50966364", "0.50944984", "0.5088782", "0.5087509", "0.5085384", "0.50847584", "0.50830775", "0.50824654", "0.5082412", "0.5082144", "0.5079005", "0.5071757", "0.5067079", "0.50661635", "0.50642383", "0.50625205", "0.5059175", "0.5055718", "0.50536597", "0.5053513", "0.50526875", "0.50510174", "0.5049418", "0.5044938", "0.5039868", "0.5039279", "0.50392103", "0.5039184", "0.50382984", "0.5034319" ]
0.5034547
99
GET /admin/solutions or admin_solutions_path
def index @solutions = Solution.all.paginate(:page => params[:page]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path(*args)\n render_path(:admin, args)\n end", "def index\n @solutions = Solution.all\n end", "def index\n @solutions = Solution.all\n end", "def index\n @solutions = Solution.all\n end", "def admin_routes\n if admin?\n [\n [ new_help_path, 'New Help' , 'helps' ],\n [ new_credit_path, 'New Credit' , 'credits' ]\n ]\n else\n []\n end\n end", "def index\n @solutions = @idea.solutions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solutions }\n end\n end", "def index\n # @solutions = Solution.all\n @solutions = @goal.solutions\n end", "def show\n @home_page = true\n @solutions = Solution.company_solutions(@solution.company_id)\n @clients = @solution.clients\n end", "def show\n @solution = @idea.solutions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solution }\n end\n end", "def admin_conditional_path(user, options = {})\n (current_user && current_user.has_role?('admin', 'staff')) ? admin_to_client_path(user, options) : client_account_path(options)\n end", "def index\n if params[:problem_id]\n @problem = Problem.find_by_shortname(params[:problem_id])\n @solutions = @problem.solutions.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n add_breadcrumb(@problem.name, problem_path(@problem))\n else\n @solutions = Solution.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n end\n add_breadcrumb \"Solutions\", problem_solutions_path(@problem)\n respond_to :html, :json, :js\n end", "def get_admin()\n erb :\"#{here}/views/admin\"\n end", "def show\n @solutions = @achievement.solutions.paginate(page: params[:page], per_page: 10).order('created_at DESC')\n add_breadcrumb @achievement.name, achievement_path(@achievement)\n respond_with @achievement\n end", "def default_path\n admin_posts_path\n end", "def admin\n #TODO\n end", "def routes\n ['Agriculture, environmental and animal care', 'Business administration', 'Catering and hospitality' \\\n 'Construction',\n 'Creative and design', 'Digital', 'Engineering and manufacturing', 'Hair and beauty', 'Health and science',\n 'Legal, finance and accounting', 'Protective services', 'Sales, marketing and procurement', 'Transport']\n end", "def index\n @solutions = Solution.all\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @solutions }\n end\n end", "def show_solr_document_url doc, options\n if options[:controller]\n case options[:controller]\n when 'collections'\n collection_url doc\n when 'institutions'\n institution_url doc\n end\n else\n solr_document_url doc, options\n end\n\n end", "def index_portal\n index\n end", "def index\n @code_solutions = CodeSolution.all\n end", "def admin_url( path = '', scheme = 'admin' )\n get_admin_url( nil, path, scheme)\n end", "def company_management_it_solutions_get(opts = {})\n data, _status_code, _headers = company_management_it_solutions_get_with_http_info(opts)\n return data\n end", "def solutions\n @products = website.products\n end", "def solution_paiement\n\n #add_breadcrumb \"solutions menu\", :access_sols_paiement\n #render layout: 'fylo'\n render layout: 'views/index'\n end", "def show_solutions\n\t\t@normal_solutions = current_problem.solutions.where(reported: false)\n\t\t@reported_solutions = current_problem.solutions.where(reported: true)\n\tend", "def solutions()\n return MicrosoftGraph::Solutions::SolutionsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def index_path\n return templates_path\n end", "def search_path; end", "def search_path; end", "def index\n if params[:admin]==\"1\"\n @ideas = Idea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end\n end", "def show_solr_document_url(doc, options)\n if options[:controller]\n case options[:controller]\n when 'collections'\n collection_url doc\n when 'institutions'\n institution_url doc\n end\n else\n solr_document_url doc, options\n end\n end", "def admin_permalink\n admin_expediente_path(self)\n end", "def path_for_index(ps = {})\n home_path\n end", "def context_url\n if params[:context_type] == 'countries'\n admin_country_url(@country)\n else\n admin_province_url(@province)\n end\n end", "def show\n solution = Solution.find(params[:id])\n if solution.team\n if (@current_user == solution.user) || (SolutionPartnering.where(solution_id: solution.id, user_id: @current_user.id).any?)\n redirect_to team_crossword_path(solution.crossword.id, solution.key)\n else\n render :nothing\n end\n else\n redirect_to solution.crossword\n end\n end", "def show_admin\n screen_name(\"Inicial-Admin\")\n\n distribute_ots\n\n respond_to do |format|\n format.html { render action: \"show_admin\" }\n format.json { head :ok }\n end\n end", "def suggest_handler_path\n @autocomplete_config[\"solr_endpoint\"]\n end", "def admin_basicas_path(o)\n n = self.nombreobj_admin(o, true) + \"_path\"\n send(n.to_sym)\n end", "def show\n @solution = Solution.find(params[:id])\n end", "def show\n\t@solution = @examquestion.question.solutions.build.tap { |sol| sol.user_id = current_user.id } if user_signed_in?\n end", "def show\n @problem = Problem.find_by_shortname(params[:id])\n @solutions = @problem.solutions.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n add_breadcrumb @problem.name, problem_path(@problem)\n respond_with @problem\n end", "def homepage_path_for_role(educator)\n if educator.districtwide_access?\n educators_districtwide_url\n elsif educator.schoolwide_access? || educator.has_access_to_grade_levels?\n school_url(educator.school)\n else\n default_homeroom_path(educator)\n end\n end", "def set_solution\n # @solution = Solution.find(params[:id])\n @solution = @goal.solutions.find(params[:id])\n end", "def index\n @admin_problems = Problem.all\n end", "def admin_use\n redirect_to(root_url) unless current_use.admin?\n end", "def admin_report_path\n session[:dm_admin_path] == :reports ? settings.dm_reports_location : settings.dm_grid_queries_location\n end", "def show\n @solutions = @profile.solutions.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n respond_with @profile\n end", "def edit_admin_tax_cloud_settings_path\n spree.edit_admin_tax_cloud_settings_path\n end", "def view_portfolios_path\n end", "def admin_index\n return unless (user_is_allowed_to 'view', 'rets_properties') \n render :layout => 'caboose/admin' \n end", "def main_path\n \"#{params._component || 'main'}/\n #{params._controller || 'main'}/\n #{params._action || 'index'}\"\n end", "def set_path\n @comment = Comment.find(params[:comment_id]) if !params[:comment_id].nil?\n @solution = Solution.find(params[:solution_id]) if !params[:solution_id].nil?\n @problem = Problem.find_by_shortname(params[:problem_id])\n if @solution.nil?\n @path = problem_path(@problem)\n else\n @path = problem_solution_path(@problem, @solution)\n end\n end", "def index\n redirect_to admin_voices_path\n end", "def index\n @languages = Language.all.order(:name)\n @path_langu = request.path.starts_with? '/langu'\n end", "def admin_link\n admin_app_url(:host => CONSTANTS[:base_url_host], :offering => offering, :id => self)\n end", "def show\n @solution = Solution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solution }\n end\n end", "def find_solution\n @solution = Solution.find(params[:id])\n end", "def admin\n end", "def admin\n end", "def admin\n end", "def admin\n end", "def company_management_it_solutions_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ManagementItSolutionsApi.company_management_it_solutions_get ...\"\n end\n # resource path\n local_var_path = \"/company/managementItSolutions\"\n\n # query parameters\n query_params = {}\n query_params[:'conditions'] = opts[:'conditions'] if !opts[:'conditions'].nil?\n query_params[:'orderBy'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'childconditions'] = opts[:'childconditions'] if !opts[:'childconditions'].nil?\n query_params[:'customfieldconditions'] = opts[:'customfieldconditions'] if !opts[:'customfieldconditions'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<ManagementItSolution>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementItSolutionsApi#company_management_it_solutions_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n redirect_to '/admin/posts'\n end", "def objective_path\n \"objectives/#{params[:user][:quests_attributes][:objective_id]}\"\n end", "def admin\n\n end", "def new_or_edit_survey_path(study)\n study.survey_id ? edit_survey_path(study.survey_id) : new_survey_path(study_id: study.id)\n end", "def index\n params[:problem_id] ?\n @problem_solutions = ProblemSolution.paginate(page: params[:page], per_page: 5).order('updated_at ASC').find_all_by_problem_id(params[:problem_id]) :\n @problem_solutions = ProblemSolution.accessible_by(current_ability).paginate(page: params[:page], per_page: 5).order('updated_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def main_path\n \"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}\"\n end", "def url_for_document(doc, _options = {})\n return [hyrax, doc] if doc.collection?\n [main_app, doc]\n end", "def url_for_index; end", "def url_for_index; end", "def resources\n end", "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to([:admin, @solution], notice: 'Solution was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated solution #{@solution.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def admin_basica_path(o)\n n = self.nombreobj_admin(o, !o.id) + \"_path\"\n return send(n.to_sym, o)\n end", "def edit_path\n \"/answers/#{object.id}/edit\"\n end", "def locations\n get('locations')\n end", "def things_path(object = nil)\n object ||= @route_name || controller_name\n send(:\"admin_#{underpluralize(object)}_path\")\n end", "def collections_path; end", "def advanced_search\n raise ActionController::RoutingError.new('Not Found')\n end", "def index\n redirect_to(controller: \"portal\", action: \"experimentlist\")\n end", "def index\n #Nested resources only displayed in the context of its parent patient\n redirect_to(root_url)\n end", "def resource\n @current_page ||= Page.find_by_identifier(Page::Identifiers::ADMIN_HELP)\n end", "def index\n\t\tif current_admin.full_access? || current_admin.partial_access?\n\t\t\t@equipaments = Equipament.all\n\t\telse\n\t\t\tredirect_to \"/404.html\"# configurar pagina 403\n\t\tend\n\tend", "def problems_index\n \"#{edit_course_assessment_path(@course, @assessment)}/#tab_problems\"\n end", "def is_in_admin_view\n !request.path.match(\"/admin\").nil?\n end", "def is_in_admin_view\n !request.path.match(\"/admin\").nil?\n end" ]
[ "0.5869873", "0.5787353", "0.5787353", "0.5787353", "0.57679534", "0.56829405", "0.5676829", "0.56346035", "0.56345123", "0.5622203", "0.53823394", "0.5372288", "0.53691924", "0.5360022", "0.5341985", "0.5325785", "0.53091323", "0.530597", "0.5285104", "0.52795", "0.5262125", "0.5220002", "0.5215074", "0.5187672", "0.518114", "0.51662487", "0.51636297", "0.5160775", "0.5160775", "0.5160139", "0.5153864", "0.5141506", "0.5129715", "0.5127038", "0.5112316", "0.50903267", "0.5081962", "0.5079055", "0.5054458", "0.50528973", "0.5047291", "0.5030745", "0.5028211", "0.5021122", "0.50203145", "0.5010106", "0.50081706", "0.5000778", "0.499593", "0.49953082", "0.49916545", "0.49864197", "0.4986103", "0.49813253", "0.49784997", "0.4978062", "0.49725863", "0.49712986", "0.49712986", "0.49712986", "0.49712986", "0.49661303", "0.49562076", "0.49553952", "0.49524307", "0.49494693", "0.49413818", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.49401996", "0.4936161", "0.49348155", "0.49348155", "0.49291268", "0.49291202", "0.49287692", "0.49234045", "0.4923014", "0.4919334", "0.49191183", "0.49160177", "0.4915059", "0.49131915", "0.49024802", "0.49018502", "0.48976225", "0.4897609", "0.4897609" ]
0.55134374
10
GET /admin/solutions/:id/edit or edit_admin_solution_path
def edit end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit_path\n \"/answers/#{object.id}/edit\"\n end", "def edit\n @problem = @solution.problem\n @languages = Language.all\n breadcrumbs\n add_breadcrumb \"Edit Solution\"\n end", "def edit\n find_admin_by_id\n end", "def edit\n @resource = Admin.find(params[:id])\n end", "def edit_path(path)\n url('/e/' + path)\n end", "def edit\n respond_to do |format|\n format.html { render :action => resource_template(\"edit\") }\n end\n end", "def edit_thing_path(model, object)\n id = object['ID'] || object['id']\n send(:\"edit_admin_#{undersingularize(model)}_path\", id: id)\n end", "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to([:admin, @solution], notice: 'Solution was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated solution #{@solution.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_resources\n @unit_planner = UnitPlanner.find params[:id]\n end", "def edit\n @exercise = current_user.exercises.find_by_id(params[:id])\n unless @exercise\n flash[:error] = \"You can't edit exercises that don't belong to you\"\n redirect_to :action => 'index'\n end\n @title = 'Edit Exercise'\n end", "def edit\n # TODO: ensure is admin\n operation = params[:oper]\n if operation == 'edit'\n update\n elsif operation == 'del'\n destroy\n elsif operation == 'add'\n create\n end \n end", "def edit\n if current_admin.present?\n @client = Client.friendly.find(params[:id])\n else\n redirect_to new_admin_session_path and return\n end\n end", "def edit\n @admin = Admin.find(params[:id])\n end", "def edit\n @admin = Admin.find(params[:id])\n end", "def edit\n @admin = Admin.find(params[:id])\n end", "def edit\n @data = SlidesHlp.getSlide(params[:id])\n if @data['slide_vi'] == nil\n @mode = 'I'\n else\n @slide = @data['slide_vi']\n @slide_ja = @data['slide_ja']\n @lang = @data['lang']\n @mode = 'U'\n end\n render 'admin/slides/slide'\n end", "def update\n #refactor w/ edit to separate method\n unless current_user.id == Thing.find(params[:id]).user_id\n flash[:alert] = \"You can only edit your own things!\"\n redirect_to(:back) and return \n end \n if params[:add_solution]\n @thing = Thing.find(params[:id])\n @thing.update(thing_params)\n @thing.solutions.build\n render :edit\n return\n end\n respond_to do |format|\n if @thing.update(thing_params)\n format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing }\n else\n format.html { render :edit }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n\n end\n end", "def edit_resource_path(*args)\n options = args.extract_options!\n options.merge! :action => :edit\n\n super_path(with_chain(args.first || resource), options)\n end", "def edit\n respond_with(@exercise)\n end", "def edit(options = { only: [], except: [:id, :created_at, :updated_at], required: [] })\n @required_keys = options[:required]\n @attrs = CEO::Iterator.filter(@thing.attributes.keys, options)\n @model = @thing.model_name.name.constantize\n @route_name ||= @controller_name ||= controller_name\n @index_route = send(:\"admin_#{@route_name}_path\")\n\n render 'admin/edit'\n end", "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to @solution, notice: '¡ Has editado la solución !' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_project\n if current_admin.present? || current_client.present?\n @project = Project.find(params[:id])\n else\n redirect_to new_admin_session_path and return\n end \n end", "def edit\n\t\t# must have admin access or be in the course\n\tend", "def edit\n template = Template.includes(:org, :phases).find(params[:id])\n authorize template\n # Load the info needed for the overview section if the authorization check passes!\n phases = template.phases.includes(sections: { questions: :question_options })\n .order('phases.number',\n 'sections.number',\n 'questions.number',\n 'question_options.number')\n .select('phases.title',\n 'phases.description',\n 'phases.modifiable',\n 'sections.title',\n 'questions.text',\n 'question_options.text')\n if template.latest?\n render 'container', locals: {\n partial_path: 'edit',\n template: template,\n phases: phases,\n referrer: get_referrer(template, request.referer)\n }\n else\n redirect_to org_admin_template_path(id: template.id)\n end\n end", "def edit\n @site = Site.find_by_name(params[:site])\n if @site.nil?\n return render_404\n end\n @menu = @site.menus.by_menu_type(params[:menu_type]).first\n if @menu.nil?\n return render_404\n end\n @menu_item = @menu.menu_items.by_id(params[:id]).first\n if @menu_item.nil?\n return render_404\n end\n \n if params[:parent_id]\n parent = @menu.menu_items.by_id(params[:parent_id]).first\n if parent.nil?\n return render_404\n end\n @menu_item.parent = parent\n end\n \n generate_selections!(@menu_item)\n respond_to do |format|\n format.html \n end\n end", "def edit\n Log.add_info(request, params.inspect)\n\n @equipment = Equipment.find(params[:id])\n\n render(:layout => (!request.xhr?))\n end", "def update\n @solution = Solution.find(params[:id])\n\n respond_to do |format|\n if @solution.update_attributes(params[:solution])\n format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n @official = Official.find(params[:id])\n if params[:user_id]\n @user = User.find(params[:user_id])\n # if the users don't match we shouldn't be here\n record_not_found and return if @user != current_user and !admin? and !official_admin?\n else\n # if we aren't an admin we shouldn't be here\n record_not_found and return if !admin? and !official_admin?\n end\n\n if ([email protected]?)\n @districts = District.find(:all, :order => \"name\")\n @divisions = Division.find(:all)\n end\n\n respond_to do |format|\n format.html {\n render \"officials/admin/edit\" if admin? and !params[:user_id]\n }\n end\n end", "def edit\n respond_with(resource)\n end", "def edit\r\n render :edit\r\n end", "def edit\n @employee = Employee.find(params[:id])\n @url = { controller: '/employees', action: :update }\n render :form\n end", "def edit\r\n end", "def edit\n @project = @task.project\n respond_to do |format|\n format.html # edit.html.erb\n end\n end", "def edit\n @idea = Idea.find(params[:id])\n\t\t@categories = Category.find(:all)\n\n\t\t@path = [link_to_ideas, link_to_edit_idea(@idea)]\n\t\t@subnavigation = [active_link_to_edit_idea(@idea), link_to_destroy_idea(@idea)]\n\n end", "def edit\n @step = Step.find(params[:id])\n @tc = TestCase.find(params[:test_case_id])\n @project = Project.find(params[:project_id])\n end", "def edit\n\t\t\n\tend", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n phase = Phase.includes(:template).find(params[:id])\n authorize phase\n # User cannot edit a phase if its a customization so redirect to show\n if phase.template.customization_of.present? || !phase.template.latest?\n redirect_to org_admin_template_phase_path(\n template_id: phase.template,\n id: phase.id,\n section: params[:section]\n )\n else\n render('container',\n locals: {\n partial_path: 'edit',\n template: phase.template,\n phase: phase,\n prefix_section: phase.prefix_section,\n sections: phase.sections.order(:number)\n .select(:id, :title, :modifiable, :phase_id),\n suffix_sections: phase.suffix_sections.order(:number),\n current_section: Section.find_by(id: params[:section], phase_id: phase.id)\n })\n end\n end", "def edit\n @option = Vger::Resources::Mrf::Option.find(params[:id], :item_id => params[:item_id])\n respond_to do |format|\n format.html\n end\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n @project = current_user.projects.find(params[:id])\n end", "def update\n @problem_solution = ProblemSolution.find(params[:id])\n\n respond_to do |format|\n if @problem_solution.update_attributes(params[:problem_solution])\n format.html { redirect_to @problem_solution.problem ? solutions_by_problem_path(@problem_solution.problem) : :problem_solutions, notice: 'Решение проблемы успешно обновлено.' }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def edit \n @project = Project.find(params[:id])\n end", "def edit\n @test = Project.find(params[:id])\n end", "def edit\r\n \r\n end", "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }\n format.json { render :show, status: :ok, location: @solution }\n else\n format.html { render :edit }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n # Renders the edit form\n end", "def edit\n respond_with(@sicoss_location)\n end" ]
[ "0.7136057", "0.7039822", "0.681941", "0.6751952", "0.66999936", "0.6554603", "0.6407349", "0.63712865", "0.63529664", "0.6334892", "0.633301", "0.6327482", "0.6319841", "0.6319841", "0.6319841", "0.6315453", "0.63057196", "0.6305072", "0.6287706", "0.6280186", "0.62761766", "0.62711406", "0.6268567", "0.6265149", "0.62623435", "0.624646", "0.62337434", "0.6226469", "0.62086546", "0.62007385", "0.61949503", "0.6193825", "0.61718506", "0.61604613", "0.6158894", "0.6152013", "0.61472976", "0.614627", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.6143671", "0.61412126", "0.6138116", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.61373585", "0.6136808", "0.612465", "0.6123969", "0.6122254", "0.6116093", "0.611291", "0.611169", "0.61099494" ]
0.0
-1
PATCH/PUT /admin/solutions/:id or admin_solution_path AJAX
def update if @solution.update_attributes(update_solution_params) alert_js('SUCCESS solution updated.') else alert_js('!!!ERROR updating solution!!!') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }\n format.json { render :show, status: :ok, location: @solution }\n format.js \n else\n format.html { render :edit }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n @solution = @idea.solutions.find(params[:id])\n\n if @solution.update_attributes(params[:solution])\n render json: { text: \"success\" }\n else\n render json: { text: \"fail\"}\n end\n end", "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to @solution, notice: '¡ Has editado la solución !' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @solution = Solution.find(params[:id])\n\n respond_to do |format|\n if @solution.update_attributes(params[:solution])\n format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #refactor w/ edit to separate method\n unless current_user.id == Thing.find(params[:id]).user_id\n flash[:alert] = \"You can only edit your own things!\"\n redirect_to(:back) and return \n end \n if params[:add_solution]\n @thing = Thing.find(params[:id])\n @thing.update(thing_params)\n @thing.solutions.build\n render :edit\n return\n end\n respond_to do |format|\n if @thing.update(thing_params)\n format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing }\n else\n format.html { render :edit }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n\n end\n end", "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to([:admin, @solution], notice: 'Solution was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated solution #{@solution.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }\n format.json { render :show, status: :ok, location: @solution }\n else\n format.html { render :edit }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admin_project = Admin::Project.find(params[:id])\n if request.xhr?\n @admin_project.update_attributes(params[:admin_project])\n render :partial => 'show', :locals => { :admin_project => @admin_project }\n else\n respond_to do |format|\n if @admin_project.update_attributes(params[:admin_project])\n flash[:notice] = 'Admin::Project was successfully updated.'\n format.html { redirect_to(@admin_project) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @admin_project.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def update\n @problem = @solution.problem\n respond_to do |format|\n if @solution.update_attributes(solution_params)\n format.html { redirect_to problem_solution_path(@problem, @solution), notice: 'Solution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\" }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to project_goal_path(@project, @goal), notice: 'Solution was successfully updated.' }\n format.json { render :show, status: :ok, location: @solution }\n else\n format.html { render :edit }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n if request.xhr?\n @resource = Resource.find(params[:id])\n add_dependent_entities\n render partial: 'edit_form', locals: { action: :edit }\n else\n render status: 406, plain: 'Not Acceptable'\n end\n end", "def update\n @problem_solution = ProblemSolution.find(params[:id])\n\n respond_to do |format|\n if @problem_solution.update_attributes(params[:problem_solution])\n format.html { redirect_to @problem_solution.problem ? solutions_by_problem_path(@problem_solution.problem) : :problem_solutions, notice: 'Решение проблемы успешно обновлено.' }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def edit\n @plate_edition = PlateEdition.find(params[:id])\n @partial = params.fetch(:partial, 'plate_editions/remote_edit_form')\n\n respond_to do |format|\n format.html { redirect_to plate_url(@plate_edition.plate_id) }\n format.js\n end\n end", "def update\n respond_to do |format|\n if @code_solution.update(code_solution_params)\n format.html { redirect_to @code_solution, notice: 'Code solution was successfully updated.' }\n format.json { render :show, status: :ok, location: @code_solution }\n else\n format.html { render :edit }\n format.json { render json: @code_solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey.update(survey_params)\n respond_with( [ :admin, @survey] )\n end", "def update\n respond_to do |format|\n if @feature.update_attributes(params[:feature])\n flash[:notice] = 'Feature was successfully updated.'\n @changed << @feature.id\n\n format.html { redirect_to features_path }\n format.js { render 'shared/index'; flash.discard }\n format.json { head :no_content }\n else\n @edited << @feature.id\n @expanded << @feature.id\n\n format.html { render action: 'edit', template: 'shared/edit' }\n format.js { render 'feature' }\n format.json { render json: @feature.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @page_title = \"Edit Recipe Ingredient\"\n @recipe_ingredient = current_recipe.recipe_ingredients.find(params[:id])\n @btnText = \"Update Ingredient\"\n @obj = @recipe_ingredient\n respond_to do |f|\n f.html {render 'shared/form'}\n f.js\n end\n end", "def edit\n @object = params[:id].blank?? Project.new : Project.find(params[:id])\n respond_with @object do |format|\n \tformat.js \t{render :template=> 'shared/edit', :layout => 'layouts/edit', :formats=>[:html]}\n end\n end", "def update\n @form_path = admin_study_path(@study)\n respond_to do |format|\n if @study.update(study_params)\n @study.active? ? @study.update(published: true) : @study.update(published: false)\n format.html { redirect_to edit_admin_study_path(@study), notice: 'Study was successfully updated.' }\n format.json { render :show, status: :ok, location: admin_dashboard_index_path }\n else\n add_notification_if_needed\n format.html { render :edit }\n format.js { render :edit }\n format.json { render json: @study.errors, status: :unprocessable_entity }\n end\n rescue Exception => e\n format.html { render :edit }\n flash[:error] = I18n.t('failure.something_went_wrong')\n Rollbar.error(e.message,\n object_info: @study)\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n set_tasks\n format.js { render_index }\n format.json { render :show, status: :ok, location: @task }\n else\n format.js { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @how_to = HowTo.find(params[:id])\n\n respond_to do |format|\n if @how_to.update_attributes(allowed_params)\n @status = admin_how_to_steps_url(@how_to, course_id: @course)\n flash[:notice] = 'HowTo was successfully updated.'\n format.html { redirect_to(admin_how_to_steps_url(@how_to, course_id: @course)) }\n format.xml { head :ok }\n else\n @status = \"failed\"\n format.html { render action: \"edit\" }\n format.xml { render xml: @how_to.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def update\n authorize! :manage, @lop_mon_hoc\n @lop_mon_hoc_sinh_vien = @lop_mon_hoc.lop_mon_hoc_sinh_viens.find(params[:id])\n\n respond_to do |format|\n if @lop_mon_hoc_sinh_vien.update_attributes(params[:lop_mon_hoc_sinh_vien])\n format.js\n format.html { redirect_to [@lop_mon_hoc,@lop_mon_hoc_sinh_vien], notice: 'Lop mon hoc sinh vien was successfully updated.' }\n format.json { head :no_content }\n else\n format.js\n format.html { render action: \"edit\" }\n format.json { render json: @lop_mon_hoc_sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize(@extraction)\n redirect_path = params[:redirect_to]\n\n respond_to do |format|\n if @extraction.update(extraction_params)\n format.html do\n redirect_to(\n redirect_path || work_extraction_path(@extraction,\n 'panel-tab': params[:extraction][:extraction_forms_projects_section_id]),\n notice: t('success')\n )\n end\n format.json { render :show, status: :ok, location: @extraction }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @extraction.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def edit\n Log.add_info(request, params.inspect)\n\n @equipment = Equipment.find(params[:id])\n\n render(:layout => (!request.xhr?))\n end", "def update\n respond_to do |format|\n if @exercise_execution.update(exercise_execution_params)\n @exercise = @exercise_execution.exercise\n @session = @exercise_execution.session\n format.html { redirect_to @exercise_execution, notice: 'Exercise execution was successfully updated.' }\n format.js\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @exercise_execution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exercise_modification.update(exercise_modification_params)\n format.js { render \"timetable_modifications/reload_timetable_modification\", locals: {timetable_modification: @exercise_modification.timetable_modification, beginning_date: @exercise_modification.date} }\n else\n format.js { render plain: @exercise_modification.errors.full_messages, status: :error }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to projects_path }\n format.json { head :no_content }\n format.js { redirect_to projects_path }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @operation.update(operation_params)\n @show_modal = 'hide'\n format.html { redirect_to @operation, notice: 'Operation was successfully updated.' }\n format.json { head :no_content }\n set_operations\n format.js\n else\n @show_modal = 'show'\n format.html { render action: 'edit' }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n @assignment = Assignment.find(params[:assignment_id])\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }\n format.json { render :show, status: :ok, location: @solution }\n else\n format.html { render :edit }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize(@extractions_extraction_forms_projects_section)\n respond_to do |format|\n if @extractions_extraction_forms_projects_section.update(extractions_extraction_forms_projects_section_params)\n format.html do\n if params[:extractions_extraction_forms_projects_section].has_key? :extraction_ids\n redirect_to consolidate_project_extractions_path(@extractions_extraction_forms_projects_section.project,\n extraction_ids: params[:extractions_extraction_forms_projects_section][:extraction_ids],\n 'panel-tab': @extractions_extraction_forms_projects_section.extraction_forms_projects_section.id.to_s),\n notice: t('success')\n else\n redirect_to work_extraction_path(\n @extractions_extraction_forms_projects_section.extraction,\n \"panel-tab\": @extractions_extraction_forms_projects_section.extraction_forms_projects_section.id.to_s\n ),\n notice: t('success')\n end\n end\n format.json do\n type1_params = extractions_extraction_forms_projects_section_params[:extractions_extraction_forms_projects_sections_type1s_attributes]\n type1_params = type1_params['0']['type1_attributes']\n type1 = Type1.find_by(name: type1_params['name'], description: type1_params['description'])\n eefpst1 = ExtractionsExtractionFormsProjectsSectionsType1\n .find_by(\n extractions_extraction_forms_projects_section: @extractions_extraction_forms_projects_section,\n type1:\n )\n render json: { extractions_extraction_forms_projects_sections_type1_id: eefpst1.id }\n end\n format.js do\n if params[:extractions_extraction_forms_projects_section][:action] == 'work'\n @consolidated_extraction = @extractions_extraction_forms_projects_section.extraction\n render '/extractions_extraction_forms_projects_sections/work_update'\n else\n @action = params[:extractions_extraction_forms_projects_section][:action]\n @extraction = @extractions_extraction_forms_projects_section.extraction\n @linked_type2_sections = @extractions_extraction_forms_projects_section.link_to_type2s\n @results_eefps = @extraction.find_eefps_by_section_type('Results')\n end\n end\n else\n format.html do\n redirect_to work_extraction_path(\n @extractions_extraction_forms_projects_section.extraction,\n \"panel-tab\": @extractions_extraction_forms_projects_section.extraction_forms_projects_section.id.to_s\n ),\n alert: t('failure')\n end\n format.json do\n render json: @extractions_extraction_forms_projects_section.errors, status: :unprocessable_entity\n end\n format.js do\n end\n end\n end\n end", "def execute_update_api\n\t\t@task = Task.find(params[:id])\n\t\t@demo = Demo.find(@task.demo_id)\n\t\tif params[:all]\n\t \[email protected] do |task|\n\t\t\t\ttask.update_attribute(:cloud_id, params[:id_selected].to_i) if(params[:type] == \"Cloud API\" && params[:id_selected] != \"\")\n\t\t\t\ttask.update_attribute(:platform_id, params[:id_selected].to_i) if(params[:type] == \"Platform Management\" && params[:id_selected] != \"\")\n\t\t\tend\n\t\telse\n\t\t\[email protected]_attribute(:cloud_id, params[:id_selected].to_i) if(params[:type] == \"Cloud API\" && params[:id_selected] != \"\")\n\t\t\[email protected]_attribute(:platform_id, params[:id_selected].to_i) if(params[:type] == \"Platform Management\" && params[:id_selected] != \"\")\n\t\tend\n\n respond_to do |format|\n format.js { render 'demo/execute_update_api' }\n end\n end", "def update\n @navigation_solution = NavigationSolution.find(params[:id])\n\n respond_to do |format|\n if @navigation_solution.update_attributes(params[:navigation_solution])\n format.html { redirect_to @navigation_solution, notice: 'Navigation solution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @navigation_solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update_attributes(task_param)\n format.json { head :no_content }\n format.js { render }\n else\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n respond_with(@exercise)\n end", "def update\n set_experiments\n respond_to do |format|\n if @experiment.update(experiment_params)\n @show_modal = 'hide'\n format.js \n format.html { redirect_to @experiment, notice: 'Experiment was successfully updated.' }\n format.json { head :no_content }\n else\n @show_modal = 'show'\n format.js\n format.html { render action: 'edit' }\n format.json { render json: @experiment.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_admin\n user = User.find(params[:id])\n if user.is_admin?\n user.is_admin = false\n else\n user.is_admin = true\n end\n user.save!\n respond_to do |format|\n format.js {\n render :update do |page|\n page[\"user_#{user.id}\"].replace_html :partial => 'user', :locals => { :user => user }\n page[\"user_#{user.id}\"].visual_effect :highlight\n end\n }\n end\n end", "def update\n respond_to do |format|\n format.js {update_js}\n end\n end", "def update\n @analisis = Analisis.find(params[:id])\n\n respond_to do |format|\n if @analisis.update_attributes(params[:analisis])\n format.js\n else\n format.js { render :form }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n @consultant.department_id = consultant_params[:department_attributes][:id]\r\n if @consultant.update(consultant_params.except(:department_attributes))\r\n set_consultants_grid\r\n format.html { redirect_to @consultant, notice: t('activerecord.success.messages.updated', model: Consultant.model_name.human) }\r\n format.js\r\n else\r\n format.html { render :edit }\r\n format.js { render :edit }\r\n end\r\n end\r\n end", "def update\n #formats as js since it's getting parsed on the front end\n respond_to do |format|\n format.js\n end\n end", "def update\n authorize! :update, @response_survey\n respond_to do |format|\n if @response_survey.update(response_survey_params)\n format.html { redirect_to :back }\n format.js\n else\n format.html\n format.js\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n get_tasks\n format.js\n format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.js\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @step.update(step_params)\n format.js\n format.html { redirect_to home_path, notice: 'Step was successfully updated.' }\n format.json { render :show, status: :ok, location: @step }\n else\n format.html { render :edit }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_solution\n @solution = Solution.find(params[:id])\n end", "def set_solution\n @solution = Solution.find(params[:id])\n end", "def set_solution\n @solution = Solution.find(params[:id])\n end", "def set_solution\n @solution = Solution.find(params[:id])\n end", "def set_solution\n @solution = Solution.find(params[:id])\n end", "def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to [@project, @resource], notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def set_solution\n #@solution = Solution.find(params[:id])\n end", "def update\n @admin = Admin.find(params[:id])\n\n if @admin.update(admin_params)\n head :no_content\n else\n render json: @admin.errors, status: :unprocessable_entity\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.js {\n @projects = Project.order( :name ).all\n }\n format.html { redirect_from_session_or(@project, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.js\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n render_json_auto @survey.update_logic_control_rule(params[:id].to_i, params[:logic]) and return\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.js { \n if params[:render_nothing]\n render :nothing => true\n else\n @tasks = @project.tasks\n end\n }\n format.html { redirect_from_session_or([@project, @task], :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.js\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recurso_orden.update(recurso_orden_params)\n format.js\n else\n format.js{ render :new}\n end\n end\n end", "def view_sub_admin\n @sub_admin=Admin.find(params[:sub_admin_id])\n session[:searched_addmin_id]=params[:sub_admin_id]\n session[:updating_using_ajax]=1\n respond_to do |format|\n format.html\n format.js\n format.json\n end\n end", "def update\n @interview = Interview.find_by_slug(params[:id])\n\n respond_to do |format|\n if @interview.update_attributes(params[:interview])\n format.html { redirect_to admin_interviews_path, notice: 'Interview was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_solution\n @solution = Solution.find(params[:solution_id])\n end", "def update\n @contest = Contest.find(params[:contest_id])\n\n respond_to do |format|\n if @editorial.update(editorial_params)\n format.html { redirect_to admin_contest_path(@contest), notice: 'Editorial was successfully updated.' }\n format.json { render :show, status: :ok, location: admin_contest_path(@contest) }\n else\n format.html { render :edit }\n format.json { render json: @editorial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repairing_layer.update(repairing_layer_params)\n format.js\n format.json { head :no_content }\n else\n format.js\n format.json { head :no_content }\n end\n end\n end", "def edit\n @problem = @solution.problem\n @languages = Language.all\n breadcrumbs\n add_breadcrumb \"Edit Solution\"\n end", "def edit\n @dept = Department.find(params[:id])\n @form_id = 'edit-form'\n \n respond_to do |fmt|\n fmt.html { render :partial => 'form' }\n fmt.json { render :json => @dept }\n end\n end", "def update\n respond_to do |format|\n if @admin_survey.update(admin_survey_params)\n format.html { redirect_to @admin_survey, notice: 'Survey was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_survey }\n else\n format.html { render :edit }\n format.json { render json: @admin_survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @extractions_extraction_forms_projects_section.update(extractions_extraction_forms_projects_section_params)\n format.html { redirect_to work_extraction_path(@extractions_extraction_forms_projects_section.extraction,\n anchor: \"panel-tab-#{ @extractions_extraction_forms_projects_section.id.to_s }\"),\n notice: t('success') }\n format.json { render :show, status: :ok, location: @extractions_extraction_forms_projects_section }\n else\n format.html { redirect_to work_extraction_path(@extractions_extraction_forms_projects_section.extraction,\n anchor: \"panel-tab-#{ @extractions_extraction_forms_projects_section.id.to_s }\"),\n alert: t('failure') }\n format.json { render json: @extractions_extraction_forms_projects_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n\n respond_to do |format|\n format.js\n end\n end", "def update\n @workspaces = current_user.workspaces\n @project = Project.find(params[:id])\n @workspace = Workspace.find(params[:workspace_id])\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to workspace_project_tasks_path(@workspace , @project), notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n respond_with @project\n end", "def update\n @useradmin = Useradmin.find(params[:id])\n #\n respond_to do |format|\n if @useradmin.update_attributes(params[:useradmin])\n format.html { redirect_to @useradmin, notice: 'Useradmin was successfully updated.' }\n format.js\n else\n format.html { render action: \"edit\" }\n format.js { render action: \"edit\" }\n end\n end\n end", "def update\n @estudio = Estudio.find(params[:id])\n\n respond_to do |format|\n if @estudio.update_attributes(params[:estudio])\n format.js\n else\n format.js { render :form }\n end\n end\n end", "def update\n respond_to do |format|\n if @solucao.update(solucao_params)\n format.html { redirect_to @solucao, notice: 'Solucao was successfully updated.' }\n format.json { render :show, status: :ok, location: @solucao }\n else\n format.html { render :edit }\n format.json { render json: @solucao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @survey.update(survey_params)\n format.html { redirect_to admin_survey_path @survey, notice: 'Survey was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey }\n else\n format.html { render :edit }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @scenario.update(scenario_params.merge(labels: Scenario.parse_labels(scenario_params[:labels_text], @scenario.project_id)))\r\n set_scenarios_grid(issue_id: @scenario.issue_id)\r\n format.html { redirect_to redirect_url, notice: t('activerecord.success.messages.updated', model: Scenario.model_name.human) }\r\n format.js\r\n else\r\n format.html { render :edit }\r\n format.js { render :edit }\r\n end\r\n end\r\n end", "def update\n @syllabus_part = SyllabusPart.find(params[:id])\n\n respond_to do |format|\n if @syllabus_part.update_attributes(allowed_params)\n @status = admin_course_policies_url(@course)\n flash[:notice] = 'SyllabusPart was successfully updated.'\n format.html {redirect_to(admin_course_policies_url(@course))}\n format.xml { head :ok }\n else\n @status = \"failed\"\n format.html { render action: \"edit\" }\n format.xml { render xml: @syllabus_part.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def update\n respond_to do |format|\n if @site_editorial.update(site_editorial_params)\n format.html { redirect_to @site_editorial, notice: 'Site editorial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site_editorial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dependencia = Dependencia.find(params[:id])\n\n respond_to do |format|\n if @dependencia.update_attributes(dependencia_params)\n format.html { redirect_to @dependencia, notice: 'Dependencia se actualizo correctamente.' }\n format.json { head :no_content }\n format.js{}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dependencia.errors, status: :unprocessable_entity }\n format.js{}\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def update\n @assessment = @department.assessments.find(params[:id])\n respond_to do |format|\n if @assessment.update(assessment_params)\n flash[:notice] = \"Aspek Penilaian berhasil diubah, #{undo_link(@assessments)}\"\n format.js\n else\n format.js { render action: 'edit' }\n end\n end\n end", "def update_feature\n if request.xhr?\n existed_feature = Feature.find_by_id(params[\"hidden_feature_id\"])\n return render :json =>{\"success\" =>false} if existed_feature.blank?\n updated = existed_feature.update_attributes(:description => params[\"description\"], :status =>params[\"status\"])\n return render :js =>\"success_update(true)\" if updated ==true\n return render :js =>\"success_update(false)\"\n else\n return render :js =>\"success_update(false)\"\n end\n end", "def update\r\n respond_to do |format|\r\n if @milestone.update(milestone_params)\r\n set_milestones_grid\r\n format.html { redirect_to @milestone, notice: t('activerecord.success.messages.updated', model: Milestone.model_name.human) }\r\n format.js\r\n else\r\n format.html { render :edit }\r\n format.js { render :edit }\r\n end\r\n end\r\n end", "def update\n @form_section.update(form_section_params)\n respond_with( [ :admin, @form_section] )\n end", "def set_solution\n @solution = Solution.find(params[:id])\n end", "def update\n if @physician.update(survey_params)\n head :no_content\n else\n render json: @physician.errors, status: :unprocessable_entity\n end\n end", "def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end", "def show\n @solution = @idea.solutions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solution }\n end\n end", "def set_solution\n # @solution = Solution.find(params[:id])\n @solution = @goal.solutions.find(params[:id])\n end", "def edit\n @object = referenced_object\n @attribute = params[:attribute]\n @form_element = params[:form_element]\n @sub_id = params[:sub_id]\n @update_span = params[:update]\n respond_to do |format|\n format.html { } unless @Klass.not_accessible_through_html?\n format.js { }\n end\n end", "def update\n @admin_interview = Interview.find(params[:id])\n\n respond_to do |format|\n if @admin_interview.update_attributes(params[:interview])\n format.html { redirect_to [:admin, @admin_interview], notice: 'Entrevista atualizada com sucesso' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: [:admin, @admin_interview.erros], status: :unprocessable_entity }\n end\n end\n end", "def update_by_ajax\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n cat_h = {:desktop => User::AUTH_DESKTOP, :user => User::AUTH_USER, :log => User::AUTH_LOG}\n\n yaml = ApplicationHelper.get_config_yaml\n\n cat_h.keys.each do |cat|\n\n next if params[cat].blank?\n\n unless @login_user.admin?(cat_h[cat])\n render(:text => t('msg.need_to_be_admin'))\n return\n end\n\n yaml[cat] ||= {}\n\n params[cat].each do |key, val|\n yaml[cat][key] = val\n end\n end\n\n ApplicationHelper.save_config_yaml(yaml)\n\n render(:text => '')\n end", "def update\n respond_to do |format|\n if @ajax.update(ajax_params)\n format.html { redirect_to @ajax, notice: 'Ajax was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ajax.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @species = Species.find(params[:id])\n @species.update_attributes(params[:species])\n \n respond_with(@species, :location => admin_species_path(@species))\n end", "def edit\n @plate = Plate.find(params[:id])\n respond_to do |format|\n format.html do\n render :template => 'plates/edit'\n end\n format.js\n end\n end", "def variables_for_edit\r\n @path = administration.article_cluster_category_path\r\n @method = :patch\r\n end", "def update\n @task = Task.find(params[:id])\n @task.update_attributes!(task_params)\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @project, notice: 'Task was successfully updated.' }\n format.js\n else\n format.html { render :edit }\n format.js\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @department.update(department_params)\r\n set_departments_grid\r\n format.html { redirect_to @department, notice: t('activerecord.success.messages.updated', model: Department.model_name.human) }\r\n format.js\r\n else\r\n format.html { render :edit }\r\n format.js { render :edit }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @resource.update(catalogs_level_params)\n index\n flash[:success] = t('notices.updated_successfully')\n format.html { redirect_to @resource, notice: 'Level was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @answer.post.update(embedded_post_params)\n format.js { head :no_content }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @site = Site.find_by_name(params[:site])\n if @site.nil?\n return render_404\n end\n @menu = @site.menus.by_menu_type(params[:menu_type]).first\n if @menu.nil?\n return render_404\n end\n @menu_item = @menu.menu_items.by_id(params[:id]).first\n if @menu_item.nil?\n return render_404\n end\n \n if params[:parent_id]\n parent = @menu.menu_items.by_id(params[:parent_id]).first\n if parent.nil?\n return render_404\n end\n @menu_item.parent = parent\n end\n \n generate_selections!(@menu_item)\n respond_to do |format|\n format.html \n end\n end", "def update\n respond_to do |format|\n if @endpoint.update(endpoint_params)\n format.html { redirect_to [@project,@endpoint], notice: 'Endpoint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @endpoint.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def update\n @survey = Survey.find(params[:id])\n success = @survey.update_attributes(params[:survey])\n \n puts \"UPDATE: Survey:#{@survey.id} - #{@survey.name}\"\n # Load the JSON Survey form data.\n survey_questions = ActiveSupport::JSON.decode(@survey.survey_data)\n #y survey_questions\n \n update_questions(@survey, survey_questions)\n \n # Render a response.\n respond_to do |format|\n if success\n format.html { redirect_to(@survey, :notice => 'Survey was successfully updated.') }\n format.xml { head :ok }\n format.js { head :ok}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @survey.errors, :status => :unprocessable_entity }\n format.js { render :json => @survey.errors, :status => :error }\n end\n end\n end" ]
[ "0.7323371", "0.7013389", "0.6855448", "0.6778403", "0.66757756", "0.6632259", "0.6627208", "0.6416595", "0.6363618", "0.6300785", "0.6259604", "0.6244589", "0.6212094", "0.6190753", "0.6149305", "0.6129834", "0.61275864", "0.6119496", "0.61144036", "0.6109143", "0.6084728", "0.60613716", "0.6042001", "0.60027486", "0.5995083", "0.59876525", "0.5987154", "0.5967684", "0.5946627", "0.59459966", "0.59417313", "0.5933822", "0.5932357", "0.5930421", "0.59255844", "0.59163487", "0.59139836", "0.5913583", "0.5906255", "0.5898202", "0.5888326", "0.58871144", "0.588423", "0.58762604", "0.58762604", "0.58762604", "0.58762604", "0.58762604", "0.5870881", "0.58676666", "0.58675265", "0.58651793", "0.5859001", "0.5854092", "0.58523446", "0.58508146", "0.58496195", "0.5839135", "0.58355063", "0.5834203", "0.58295053", "0.58289534", "0.5828594", "0.5827013", "0.582592", "0.5818654", "0.581672", "0.5815719", "0.5811357", "0.58091223", "0.5802254", "0.57999825", "0.57843214", "0.57836527", "0.5782479", "0.5781849", "0.57807356", "0.5778638", "0.5773246", "0.5769188", "0.5768933", "0.57611716", "0.57601887", "0.575879", "0.57584536", "0.5756372", "0.5756188", "0.5754856", "0.57528245", "0.57459915", "0.57421106", "0.5736477", "0.57345265", "0.5727271", "0.5725824", "0.5724511", "0.5723528", "0.57207525", "0.5720101", "0.5713653" ]
0.6805077
3
DELETE /admin/solutions/:id or admin_solution_path AJAX
def destroy if @solution.destroy alert_js('SUCCESS solution deleted.') else alert_js('!!!ERROR deleting solution!!!') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @solution = Solution.find(params[:id])\n @solution.destroy\n\n render json: { text: \"success\" }\n end", "def destroy\n @solution.destroy\n respond_to do |format|\n format.html { redirect_to(admin_solutions_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted solution #{@solution.name}\")\n end", "def destroy\n @solution = Solution.find(params[:id])\n @solution.destroy\n\n respond_to do |format|\n format.html { redirect_to solutions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @solution.destroy\n render json: {solutions: @solution}, status: 200\n end", "def destroy\n @solution.destroy\n respond_to do |format|\n format.html { redirect_to solutions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @solution.destroy\n respond_to do |format|\n format.html { redirect_to solutions_url, notice: 'Solution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @solution.destroy\n respond_to do |format|\n format.html { redirect_to solutions_url, notice: 'Solution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @solution.destroy\n respond_to do |format|\n format.html { redirect_to assignment_solutions_path(@solution.assignment_id), notice: 'Solution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @navigation_solution = NavigationSolution.find(params[:id])\n @navigation_solution.destroy\n\n respond_to do |format|\n format.html { redirect_to navigation_solutions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n event_id = params[:id]\n authorize @solution\n\n @solution.destroy\n respond_to do |format|\n flash[:success] = 'Solution was successfully destroyed.'\n format.html { redirect_to event_solutions_path(event_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @brand_solution_featured_product.destroy\n respond_to do |format|\n format.html { redirect_to([:admin, @solution]) }\n format.xml { head :ok }\n format.js\n end\n end", "def destroy\n @problem = @solution.problem\n @solution.destroy\n\n respond_to do |format|\n format.html { redirect_to problem_solutions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @goal = Goal.find(params[:goal_id])\n # @solution = @goal.solutions.find(params[:id])\n @project = Project.find(params[:project_id])\n @goal = @project.goals.find(params[:goal_id])\n @solution = @goal.solutions.find(params[:id])\n @solution.destroy\n respond_to do |format|\n format.html { redirect_to project_goal_path(@project, @goal), notice: 'Solution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url(:project_id =>@questionnaire.project_id) }\n format.json { head :no_content }\n format.js {}\n end\n end", "def destroy\n @code_solution.destroy\n respond_to do |format|\n format.html { redirect_to code_solutions_url, notice: 'Code solution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @problem_solution = ProblemSolution.find(params[:id])\n @problem = @problem_solution.problem\n\n @problem_solution.destroy\n\n respond_to do |format|\n format.html { redirect_to (@problem ? solutions_by_problem_path(@problem) : :problem_solutions), notice: 'Решение проблемы успешно удалено.' }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.js #-> loads destroy.js.erb\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_interview = Interview.find(params[:id])\n @admin_interview.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_interviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @discipline_section.destroy\n respond_to do |format|\n #format.html { redirect_to discipline_sections_url, notice: 'Раздел дисциплины был успешно удален' }\n #format.json { head :no_content }\n format.js { render ('discipline_sections/delete')}\n end\n end", "def advising_ajax_delete\n\t\t@user = @current_user\n\t\t@course = Course.find(params[:id])\n\n\t\t# check prerequisites error upon the remove\n\t\terror_messages = check_prerequisites_on_change(@plan, @course, 'remove')\n\n\t\t# if there is no prerequisite error then delete the course\n\t\tif error_messages.length == 0\n\t\t\[email protected](@course)\n\t\t\t@json_response = get_plans_courses_completion_json(@plan)\n\t\t\trespond_to do |format|\n\t\t\t\tformat.json { render json: @json_response }\n\t\t\tend\n\t\t# if there is a prerequisite error then send json error and the error messages back\n\t\telse\n\t\t\trespond_to do |format|\n\t\t\t\tformat.json { render json: { :error => true, :error_messages => error_messages } }\n\t\t\tend\n\t\tend\n\tend", "def destroy\n @solution = PeerReviewSolution.find(params[:id])\n @solution.destroy\n\n respond_to do |format|\n format.html { redirect_to(solutions_url) }\n format.xml { head :ok }\n end\n end", "def delete\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @vertical = Vertical.destroy(params[:id])\n respond_to do |format|\n format.html { redirect_to tasks_url }\n format.js\n end\n end", "def destroy\n @admin_survey.destroy\n respond_to do |format|\n format.html { redirect_to admin_surveys_url, notice: 'Survey was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dynamic_project_page.destroy\n respond_to do |format|\n format.html { redirect_to '/administrator/dynamic_project_pages', notice: 'Информация обновлена' }\n format.json { head :no_content }\n end\n end", "def destroy\n @kolegij = Kolegij.find(params[:id])\n @kolegij.destroy\n\n respond_to do |format|\n format.html { redirect_to kolegijs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @crossword_puzzle = CrosswordPuzzle.find(params[:id])\n @crossword_puzzle.destroy\n\n respond_to do |format|\n \tif current_user.admin\n format.html { redirect_to crossword_puzzles_url, notice: 'Puzzle successfully deleted.' }\n else\n\t\t\tformat.html { redirect_to root_url, notice: 'Crossword puzzle successfully deleted.' }\n end\n\t\t\tformat.json { head :no_content }\n format.js\n end\n end", "def destroy\n permission_denied and return if current_user.cannot 'destroy_inversion'\n @inversion.destroy\n respond_to do |format|\n format.html { redirect_to inversions_url, success: 'Inversion fue eliminado satisfactoriamente.' }\n format.json { head :no_content }\n format.js { render 'layouts/destroy' }\n end\n end", "def destroy\n @do_exercise = DoExercise.find(params[:id])\n @do_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to do_exercises_url }\n format.json { head :no_content }\n end\n end", "def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end", "def destroy\n @research.destroy\n respond_to do |format|\n format.html { redirect_to menu_investigacion_3_path, notice: 'La actividad se elimino con exito.' }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @assessment = Content.find(params[:id])\n @assessment.destroy\n\n respond_to do |format|\n format.js {render :nothing => true}\n format.html { redirect_to assessments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @admin_side_menu = Admin::SideMenu.find(params[:id])\n @admin_side_menu.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_side_menus_url }\n format.json { head :ok }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @requirement = Requirement.find(params[:id])\n @instance = @requirement.instance\n @requirement.destroy\n respond_to do |format|\n format.html { redirect_to instance_path(@instance) }\n format.js\n format.xml { head :ok }\n end\n end", "def destroy \n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to selection_path(params[:selection_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @interview = Interview.find_by_slug(params[:id])\n @interview.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_interviews_path, notice: 'Interview was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @casestudy = Casestudy.find(params[:id])\n @casestudy.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_casestudies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ajax.destroy\n respond_to do |format|\n format.html { redirect_to ajaxes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n render_json_auto @survey.delete_filter(params[:id].to_i) and return\n end", "def destroy\n @survey_choice = Survey::Choice.find(params[:id])\n \n if @survey_choice.answers.count>0\n redirect_to action: :show\nelse\n @divid = divid_for(@survey_choice) \n @survey_choice.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_choices_url }\n format.json { head :no_content }\n format.js\nend \nend\n end", "def destroy\n @survey.destroy\n respond_with( [ :admin, @survey] )\n end", "def destroy\n @admin.destroy!\n \n respond_to do |format|\n format.json { respond_to_destroy(:ajax) }\n format.xml { head :ok }\n format.html { respond_to_destroy(:html) } \n end\n \n rescue ActiveRecord::RecordNotFound\n respond_to_not_found(:json, :xml, :html)\n end", "def delete\n if request.xhr?\n existed_feature = Feature.find_by_id(params[\"id\"])\n existed_feature.destroy\n return render :js =>\"success_delete(true)\"\n else\n return render :js =>\"success_delete(false)\"\n end\n end", "def delete_task\n \t@task = Task.find(params[:id])\n \[email protected]\n \t@demo = Demo.find(@task.demo_id)\n\n respond_to do |format|\n format.js { render 'demo/delete_task' }\n end\n end", "def destroy\n render_json_auto @survey.delete_logic_control_rule(params[:id].to_i) and return\n end", "def destroy\n set_trigger\n @operation.destroy\n set_operations\n respond_to do |format|\n format.html { redirect_to operations_url }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @content = @content_admin.content\n @content_admin.destroy\n respond_to do |format|\n format.js\n end\n end", "def destroy\n @exam = Exam.find(params[:id])\n @exam.destroy\n\n respond_to do |format|\n format.js\n end\n end", "def destroy\n @danswer = Danswer.find(params[:id])\n @danswer.destroy\n\n respond_to do |format|\n format.html { redirect_to danswers_url }\n format.js\n # format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:project_id])\n @task = @project.tasks.find(params[:id])\n @task.destroy\n \n respond_to do |f|\n f.html { redirect_to @project, :notice => \"Task Deleted\" }\n f.js\n end \n end", "def destroy\n @quest_tree = QuestTree.find(params[:id])\n @quest_tree.destroy\n\n respond_to do |format|\n format.html { redirect_to quest_trees_url }\n format.json { head :ok }\n end\n end", "def remove\n @site = Site.find(params[:id])\n @study.sites.delete(@site)\n\n respond_to do |format|\n format.xml { head :ok }\n format.js\n end\n end", "def delete\n supprimer = QuestionOuverteService.instance.supprimerQuestion(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end", "def destroy\n @admin_section.destroy\n respond_to do |format|\n format.html { redirect_to admin_sections_url, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_option = QuestionOption.find(params[:id])\n check_forged_path\n @question_option.destroy\n\n respond_to do |format|\n format.json { head :ok }\n format.xml { head :ok }\n end\n end", "def destroy\n @experiment.destroy\n\n respond_to do |format|\n format.html { redirect_to(experiments_url) }\n format.xml { head :ok }\n format.js\t { head :ok }\n end\n\n end", "def destroy\n @extractions_extraction_forms_projects_sections_type1.destroy\n respond_to do |format|\n format.html { redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section\n .extraction,\n anchor: \"panel-tab-#{ @extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section.id }\"),\n notice: t('removed') }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to clclass_exercises_path(@clclass) }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_plan = ExercisePlan.find(params[:id])\n @exercise_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin.destroy\n\n head :no_content\n end", "def destroy\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path, notice: \"Project was successfully deleted.\" }\n format.js\n end\n end", "def destroy\n @home = Home.first\n @about = About.first\n \n @section = Section.find(params[:id])\n \n @section.destroy\n respond_to do |format|\n format.html { redirect_to admin_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @extractions_extraction_forms_projects_sections_type1.destroy\n respond_to do |format|\n format.html do\n redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section\n .extraction,\n 'panel-tab': @extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section\n .extraction_forms_projects_section\n .id),\n notice: t('removed')\n end\n format.json { head :no_content }\n end\n end", "def delete\n @interview = Interview.find(params[:id])\n @interview.destroy\n return if request.xhr?\n render :nothing => true\n end", "def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @optin_contestant = OptinContestant.find(params[:id])\n @optin_contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to optin_contestants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @solution_partnering\n @solution_partnering.destroy\n else\n @solution.destroy\n end\n redirect_to :root\n end", "def delete\n supprimer = AdministrateurService.instance.supprimerAdmin(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end", "def destroy\n @current_admin_user = current_admin_user\n @menu = Menu.find(params[:id])\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to menus_url }\n format.json { head :no_content }\n format.js\n end\n end", "def delete\r\n\t\t\trender json: Project.delete_by_id(params[:id])\r\n\t\tend", "def destroy\n @diagnosis = Diagnosis.find(params[:id])\n @id = @diagnosis.id\n @diagnosis.destroy\n\n respond_to do |format|\n format.html { redirect_to client_prof_inspections_path(@prof_inspection.client)}\n format.json { head :ok }\n format.js \n end\n end", "def destroy\n @check.destroy\n respond_to do |format|\n format.html { redirect_to editor_project_checks_path(@project), notice: \"Check was successfully deleted.\" }\n format.js\n end\n end", "def destroy\n @admin_template_software = TemplateSoftware.find(params[:id])\n @admin_template_software.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_template_software_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sivic_discipulo.destroy\n respond_to do |format|\n format.html { redirect_to sivic_discipulos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercice = Exercice.find(params[:id])\n @exercice.destroy\n\n respond_to do |format|\n format.html { redirect_to exercices_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @admin_heuristic.destroy\r\n respond_to do |format|\r\n format.html { redirect_to admin_heuristics_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey.destroy\n respond_to do |format|\n format.html { redirect_to admin_surveys_url, notice: 'Survey was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n Break.end\n respond_to do |format|\n format.html { redirect_to admin_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @oncourse_exercise.destroy\n respond_to do |format|\n format.html { redirect_to oncourse_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin.destroy\n\n render json: { operation: 'OK' }, status: :ok\n end", "def destroy\n @food_slider = FoodSlider.find(params[:id])\n @food_slider.destroy\n\n respond_to do |format|\n format.html { redirect_to food_sliders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @id = params[:id]\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.js { }\n format.json { head :no_content }\n end\n end", "def destroy\n contest = @editorial.contest\n @editorial.destroy\n respond_to do |format|\n format.html { redirect_to admin_contest_url(contest), notice: 'Editorial was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n render json: {:ok => true}\n end", "def destroy\n @task = Task.find(params[:id])\n @task.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_path }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @subdivision = Subdivision.find(params[:id])\n @subdivision.destroy\n\n respond_to do |format|\n format.html { redirect_to(subdivisions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dynamique = Dynamique.find(params[:id])\n @dynamique.destroy\n\n respond_to do |format|\n format.html { redirect_to dynamiques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sproject = current_user.sprojects.find(params[:id])\n @sproject.destroy\n\n respond_to do |format|\n format.html { redirect_to sprojects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @equipe = Equipe.find(params[:equipe_id])\n @adversaire = Adversaire.find(params[:id])\n @adversaire.destroy\n\n respond_to do |format|\n format.html { redirect_to @equipe }\n format.json { head :no_content }\n end\n end" ]
[ "0.7611594", "0.75602776", "0.75415486", "0.7489248", "0.7486619", "0.7264953", "0.7264953", "0.71954066", "0.7139925", "0.7117763", "0.7073571", "0.700038", "0.6998077", "0.69672996", "0.68717396", "0.68514323", "0.68483055", "0.68396723", "0.68216014", "0.6775228", "0.6759461", "0.675537", "0.6714074", "0.67078763", "0.66831535", "0.66814965", "0.66765267", "0.6671827", "0.66662824", "0.6663252", "0.665935", "0.66540813", "0.665102", "0.6649974", "0.6649974", "0.664693", "0.6646342", "0.66438717", "0.6642985", "0.6642534", "0.66412246", "0.6635432", "0.6628599", "0.66257894", "0.66185856", "0.6617773", "0.66135275", "0.66112876", "0.66103137", "0.66093814", "0.6608492", "0.6607789", "0.66069484", "0.6603865", "0.66024506", "0.65946335", "0.65894973", "0.65894973", "0.65894973", "0.65894973", "0.6589009", "0.6588063", "0.6586005", "0.658086", "0.6578344", "0.6577495", "0.6574967", "0.6573689", "0.6559225", "0.6555627", "0.65508205", "0.655036", "0.6546705", "0.65434724", "0.65418684", "0.6541351", "0.65397453", "0.6539665", "0.6537896", "0.6534472", "0.6531762", "0.652782", "0.65271014", "0.65262115", "0.6521974", "0.65187895", "0.65187895", "0.65182877", "0.6517559", "0.6514515", "0.65142965", "0.65129733", "0.6507163", "0.65068644", "0.65052325", "0.65017676", "0.6495113", "0.64949447", "0.64941365", "0.6493219" ]
0.7221511
7
will raise an exception on failed decryption
def load(password=nil) reset(password) if password data = @yzb.load(@dumpfile) # Sanity check... load will raise CipherError on decription error. raise CONFIG[:CipherError] unless data.class == Hash @data = data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decrypt; end", "def decrypt\n self\n end", "def decrypt(alg, password, cipher)\n \n begin\n case alg\n when \"3DES\" then key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'des3')\n when \"AES\" then key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'aes256')\n when \"Blowfish\" then key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'blowfish')\n when \"Plaintext\" then return cipher\n else key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'aes256')\n end\n decrypted_text = key.decrypt64(cipher)\n rescue => e\n p e.message\n end\n return decrypted_text\n \n end", "def encryption_decryption_exception( _order, _message = \"\")\n recipients \"[email protected]\"\n from \"[email protected]\"\n subject \"[\" + ServerInstance.current_host_short_string + \"] Order:#{_order.id} \" + \"Encrypting or Decrypting sensitive data has error\"\n body :order => _order, :message => _message\n end", "def decrypt\n self\n end", "def can_decrypt?\n false\n end", "def decrypt_files\n not_implemented(__method__)\n end", "def decrypt_message ciphertext\n key_pair.decrypt ciphertext\n end", "def decrypt(message)\n xcrypt(:decrypt, message)\n rescue OpenSSL::Cipher::CipherError\n raise CipherError, 'invalid password'\n end", "def decode(data)\n @encryptor.decrypt_and_verify(data)\n rescue ActiveSupport::MessageVerifier::InvalidSignature, ActiveSupport::MessageEncryptor::InvalidMessage\n 'Wrong password'\n end", "def decrypt(data)\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-256-cbc\")\n cipher.decrypt\n cipher.key = @passphrase\n cipher.iv = @iv\n decrypted = cipher.update(data)\n decrypted << cipher.final\n json = JSON.parse(decrypted)\n self.identifier = json['identifier']\n @expiry = Time.parse(json['expiry'])\n rescue OpenSSL::Cipher::CipherError => e\n raise Kennedy::BadTicketException, \"Given data was not decryptable\"\n end", "def decrypt(value)\n encryptor.decrypt_and_verify(value)\n end", "def cipher_failed(e='<no message>')\n warn (<<-XXX.gsub(/^\\s*/, ''))\n SECURITY WARNING: Session cipher failed: #{e}\n XXX\n return nil\n end", "def decrypt(encrypted)\n return nil unless encrypted =~ /Validation: (.*?)\\n(.*)\\n\\*\\*\\*/m\n begin\n decipher = OpenSSL::Cipher.new(\"AES-128-CBC\")\n decipher.decrypt\n # puts \"**** $1=#{$1}, $2=#{$2}\"\n decipher.key = EMAIL_KEY\n decipher.iv = Base64.decode64($1)\n encrypted_data = Base64.decode64($2)\n # puts \"**** decipher.iv=#{Base64.encode64 iv}\"\n # puts \"**** encrypted=#{Base64.encode64 encrypted}\"\n return decipher.update(encrypted_data) + decipher.final \n rescue\n return nil\n end \n end", "def unlock(str)\n str = str.unpack('m0').first\n aes = cipher.decrypt\n aes.key = @key.size > 32 ? @key[0..31] : @key\n iv = str[0, aes.iv_len]\n aes.iv = iv\n crypted_text = str[aes.iv_len..-1]\n return nil if crypted_text.nil? || iv.nil?\n aes.update(crypted_text) << aes.final\n rescue\n nil\n end", "def decrypt(ciphertext_blob)\n begin\n plaintext = client.decrypt_and_verify(ciphertext_blob)\n\n success_with_data(\n plaintext: plaintext\n )\n rescue Exception => e\n error_with_data('lc_2',\n \"LocalCipher could not decrypt cipher with message => #{e.message}\",\n 'Something Went Wrong.',\n GlobalConstant::ErrorAction.default,\n {})\n end\n end", "def decrypt phrase, key\n decrypt = encrypt phrase, key\n return decrypt\nend", "def decrypt()\n \t@private_key = AES.decrypt(self.encrypted_private_key, ENV[\"DECRYPTION_KEY\"])\n end", "def decrypt(txt)\n x = -1\n return txt.unpack('U*').pack('S*').unpack(\"U*\").collect do |i| \n x += 1\n x %= CRYPT.size\n i - CRYPT[x].unpack('U').first > 0 ? i - CRYPT[x].unpack('U').first : i\n end.pack('U*')\n end", "def maybe_decrypt(context)\n # TODO determine if we should be decrypting data coming from pre-4.2\n # servers, potentially using legacy wire protocols. If so we need\n # to implement decryption for those wire protocols as our current\n # encryption/decryption code is OP_MSG-specific.\n self\n end", "def decrypt_ciphertext(ciphertext)\n aes = OpenSSL::Cipher.new(@cipher).decrypt\n aes.key = @encryption_key\n iv = ciphertext[0, aes.iv_len]\n aes.iv = iv\n crypted_text = ciphertext[aes.iv_len..-1]\n return nil if crypted_text.nil? || iv.nil?\n aes.update(crypted_text) << aes.final\n rescue\n nil\n end", "def validate\n encrypt\n end", "def decrypt(ciphertext, options = {})\n # TODO\n end", "def decrypt(ciphertext)\n @cipher.decrypt(@secret_key, ciphertext)\n end", "def decrypt(*args, &block)\n crypt :decrypt, *args, &block\n end", "def private_decrypt(ciphertext)\n @private_key.private_decrypt(ciphertext)\n end", "def decrypt\n self.class.decrypt(@encrypted_name, @id)\n end", "def decrypt_and_verify(value)\n ::JSON.parse(\n @box.decrypt(\n Base64.urlsafe_decode64(value)),\n symbolize_names: true)\n rescue RbNaCl::CryptoError\n raise InvalidMessage\n end", "def decrypt_letter alphabet, cipherbet, letter\ndecrypt_letter = encrypt_letter cipherbet, alphabet, letter\nreturn decrypt_letter\nend", "def decipher\r\n aes = OpenSSL::Cipher::AES.new(128, :CBC)\r\n aes.decrypt\r\n aes.key = key\r\n aes.iv = iv\r\n return aes\r\n end", "def decrypt\n unless @encrypted_data.blank?\n plaintext_data\n end\n end", "def decrypt(str)\n str = str.unpack('m0').first\n aes = OpenSSL::Cipher::Cipher.new('aes-128-cbc').decrypt\n aes.key = @secret\n iv = str[0, aes.iv_len]\n aes.iv = iv\n crypted_text = str[aes.iv_len..-1]\n return nil if crypted_text.nil? || iv.nil?\n aes.update(crypted_text) << aes.final\n rescue\n nil\n end", "def decrypt(x)\n @aes_key.decrypt(x)\n end", "def decrypt(encrypted_string)\n CRYPTO.decrypt_string(encrypted_string.decode64)\nend", "def decrypt\r\n\t \r\n\t \tif @IV.empty?\r\n\t\t\t_iv = OpenSSL::Cipher::Cipher.new(\"aes-#{ @cipher }-#{ @mode }\").random_iv\r\n\t\telse\r\n\t\t\t_iv= @IV\r\n\t\tend\r\n\t\t\r\n\t\tEncryptor.default_options.merge!(:algorithm => \"aes-#{ @cipher }-#{ @mode }\", :key => @key, :iv => _iv)\t\t\r\n\t\t_rt = Encryptor.decrypt(Base64.decode64(@data))\r\n\t\t\t\r\n\t\treturn _rt\r\n\t\t\t\r\n\t end", "def decrypt encrypted_data, key, iv, cipher_type\n aes = OpenSSL::Cipher::Cipher.new cipher_type\n aes.decrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final \n end", "def decrypt(ciphertext_blob)\n begin\n\n d_resp = client.decrypt({\n ciphertext_blob: ciphertext_blob\n }).to_h\n\n plaintext = d_resp[:plaintext]\n\n return success_with_data(\n plaintext: plaintext\n )\n\n rescue => e\n return exception_with_data(\n e,\n 'a_k_1',\n GlobalConstant::ErrorAction.default,\n {\n purpose: @purpose,\n role: @role,\n ciphertext_blob: ciphertext_blob\n }\n )\n end\n end", "def decrypt(text)\n @private_key.private_decrypt(Base64.decode64(text)) if text\n end", "def decrypt(text)\n @private_key.private_decrypt(Base64.decode64(text)) if text\n end", "def handle_sync_key enc_key\n PRIVATE_KEY.private_decrypt enc_key\n end", "def ez_decrypt(worker = :default)\n _ez_decrypt(self, worker)\n end", "def vigenere_cipher(string, key_sequence)\n\nend", "def decrypt(encrypted_password)\nindex = 0\n# List the entire alphabet in order to match the letters of the decrypted password to their correct index\nalphabet = \"abcdefghijklmnopqrstuvwxyz\"\n# Prepare an empty string to store results\ndecrypted_string = \"\"\n# Create a loop to iterate over the encrypted password\nwhile index < encrypted_password.length do\n decrypted_index = alphabet.index(encrypted_password[index])\n decrypted_string+= alphabet[decrypted_index -1]\n index += 1\nend\n#return the implicit empty response at the end\n decrypted_string\nend", "def textDecryptor(encodedText, cryptoKey)\n decryptedText = \"\"\n\n #algorithm that uses key to un-shift letters in encoded word to return to human readable form (original word)\n encodedText.each_char do |value|\n \n formerPosition = $alphabet.find_index(value)\n newPosition = (formerPosition - cryptoKey) % $alphabet.count\n decryptedText += $alphabet[newPosition]\n \n end\n puts \"The cipher text decrypted is: #{decryptedText}\"\n\nend", "def decrypt(value,key,context)\n plaintext = @vault.logical.write(\"transit/decrypt/#{key}\", ciphertext: value, context: Base64.encode64(context).gsub('\\n',''))\n return Base64.decode64(plaintext.data[:plaintext]).gsub('\\n','')\n end", "def decrypt_string(encrypted_string) \n enc = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC')\n enc.decrypt(RAM_SALT)\n text = enc.update(Base64.decode64(encrypted_string))\n decrypted_string = (text << enc.final)\n rescue\n nil\n end", "def decrypt(provider)\n raise Yasst::Error::AlreadyDecrypted,\n 'File is already decrypted' unless encrypted?\n @encrypted = false\n replace(provider.decrypt(to_s))\n end", "def decryptHex\r\n\t \r\n\t \tif @IV.empty?\r\n\t\t\t_iv = OpenSSL::Cipher::Cipher.new(\"aes-#{ @cipher }-#{ @mode }\").random_iv\r\n\t\telse\r\n\t\t\t_iv= @IV\r\n\t\tend\r\n\t\t\r\n\t\tEncryptor.default_options.merge!(:algorithm => \"aes-#{ @cipher }-#{ @mode }\", :key => @key, :iv => _iv)\r\n\t\t_ret = \"\"\r\n\t\t([email protected]()/2).each{|index| _ret += [@data[index*2, 2]].pack(\"H2\")}\t\t\r\n\t\t_rt = Encryptor.decrypt(_ret)\r\n\t\t\t\r\n\t\treturn _rt\r\n\t\t\r\n\t end", "def encrypt; end", "def decryptor(io, password, &b)\n Decrypt.open(io, &b)\n end", "def decrypt(enc)\n\n des = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC')\n des.decrypt\n des.key = \"7304912f3d62b5efcd837373bf6b7ff4f1f438b6b67008ef\".unhex\n des.iv = \"0a0a0a0a0a0a0a0a\".unhex\n des.padding = 0\n\n # libCARSReposMgr.so 3DES padding handling is wrong...\n # we try to mimick the behavior here.\n enc += \"00\" * ( 8 - ( (enc.length / 2) & 7 ) )\n\n decrypted_passwd = des.update(enc.unhex) + des.final\n decrypted_passwd.gsub(/\\x00.*/, '')\n\n end", "def lookup(encrypted_string)\n crypted_iv, crypted_value = encrypted_string.split('|')\n fail ArgumentError, 'invalid value for decryption' unless crypted_iv && crypted_value\n iv = Base64.decode64(crypted_iv)\n value = Base64.decode64(crypted_value)\n @cipher.iv = iv\n @cipher.update(value) + @cipher.final\n end", "def authenticated_decrypter(context, cipher)\n if RUBY_VERSION.match(/1.9/)\n raise \"authenticated decryption not supported by OpeenSSL in Ruby version ~> 1.9\"\n raise Aws::Errors::NonSupportedRubyVersionError, msg\n end\n http_resp = context.http_response\n content_length = http_resp.headers['content-length'].to_i\n auth_tag_length = http_resp.headers['x-amz-meta-x-amz-tag-len']\n auth_tag_length = auth_tag_length.to_i / 8\n\n auth_tag = context.client.get_object(\n bucket: context.params[:bucket],\n key: context.params[:key],\n range: \"bytes=-#{auth_tag_length}\"\n ).body.read\n\n cipher.auth_tag = auth_tag\n cipher.auth_data = ''\n\n # The encrypted object contains both the cipher text\n # plus a trailing auth tag. This decrypter will the body\n # expect for the trailing auth tag.\n IOAuthDecrypter.new(\n io: http_resp.body,\n encrypted_content_length: content_length - auth_tag_length,\n cipher: cipher)\n end", "def encrypt(alg, password, string)\n \n begin\n case alg\n when \"3DES\" then key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'des3')\n when \"AES\" then key = EzCrypto::Key.with_password(password, $system_salt, :algoritmh => 'aes256')\n when \"Blowfish\" then key =EzCrypto::Key.with_password(password, $system_salt, :algoritmh => 'blowfish')\n when 'Plaintext' then return string\n else key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'aes256') \n end\n encrypted_text = key.encrypt64(string)\n rescue => e\n p e.message\n end\n return encrypted_text\n \n end", "def decrypt(value)\n result = Crypt::ExplicitDecryptionContext.new(\n @crypt_handle,\n @encryption_io,\n { 'v': value },\n ).run_state_machine['v']\n end", "def decrypt(string)\n require_key\n\n @private_key.private_decrypt(Base64.decode64(string))\n end", "def read_encrypted_secrets=(_arg0); end", "def read_encrypted_secrets=(_arg0); end", "def decrypt\n rotations_one = rotation_gen\n rotations = rotations_one.map do |rotation|\n rotation * (-1)\n end\n message.each_with_index do |char, i|\n letter = decrypt_letter(char, rotations[(i % 4)])\n decrypted_message << letter\n end\n decrypted_message.join(\"\")\n end", "def cipher; end", "def test_seal\n seal = Themis::ScellSeal.new(@master_key)\n\n encrypted = seal.encrypt(@message, @context)\n decrypted = seal.decrypt(encrypted, @context)\n\n assert(encrypted.length > @message.length)\n assert_equal(@message, decrypted)\n end", "def decryptor(io, password, &b)\n Decrypt.open(io, password, mtime, &b)\n end", "def decrypt_data(encrypted, &decrypted)\n injected = @engine.inject encrypted\n\n unless injected\n exit -1\n end\n\n read_data = []\n\n begin\n while(read_chunk = @engine.read)\n read_data << read_chunk\n end\n rescue Exception => e\n unless @engine.state == 'SSLOK '\n raise e\n end\n end\n\n if block_given? then\n read_data.each do |data|\n decrypted.call data\n end\n else\n read_data.join\n end\n end", "def decrypt(base64_encrypted_data,key,base64_init_vector,ciper='aes-128-cbc')\n SymmetricEncryption.cipher = SymmetricEncryption::Cipher.new(:key => key,:iv => Base64.urlsafe_decode64(base64_init_vector), :cipher => ciper )\n SymmetricEncryption.decrypt(Base64.urlsafe_decode64(base64_encrypted_data))\n end", "def test_token_protect\n token_protect = Themis::ScellTokenProtect.new(@master_key)\n\n encrypted, token = token_protect.encrypt(@message, @context)\n decrypted = token_protect.decrypt(encrypted, token, @context)\n\n assert_equal(@message.length, encrypted.length)\n assert_equal(@message, decrypted)\n end", "def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end", "def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end", "def decrypt(data)\n\t\tbegin\n\t\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/victim.pem'\n\t\t\treturn key.private_decrypt(data)\n\t\trescue\n\t\t\treturn false\n\t\tend\n\tend", "def decrypt(encrypted_text)\n len = encrypted_text.length\n if (len == 0) || (len % BlockLengthInBytes > 0) then\n puts \"(encrypted_text.length == 0) || (encrypted_text.length % BlockLengthInBytes > 0)\"\n return nil\n end\n blocks = encrypted_text.scan(/.{8}/m)\n decrypted_blocks = []\n blocks.each do |block|\n decryptedBlock = self.class.decryptBlock(block, @keys)\n decrypted_blocks << decryptedBlock\n end\n output = decrypted_blocks.join\n return output\n end", "def decrypt_and_encrypt(data)\n ## ** Decrypt\n keys = @keys\n begin\n #@@window.puts(\"Attempting to decrypt with primary key\")\n data = _decrypt_packet_internal(keys, data)\n #@@window.puts(\"Successfully decrypted with primary key\")\n\n # If it was successfully decrypted, make sure the @old_keys will no longer work\n @old_keys = nil\n rescue Encryptor::Error => e\n # Attempt to fall back to old keys\n if(@old_keys.nil?)\n @@window.puts(\"No secondary key to fallback to\")\n raise(e)\n end\n\n @@window.puts(\"Attempting to decrypt with secondary key\")\n keys = @old_keys\n data = _decrypt_packet_internal(@old_keys, data)\n @@window.puts(\"Successfully decrypted with secondary key\")\n end\n\n # Send the decrypted data up and get the encrypted data back\n data = yield(data, ready?(keys))\n\n # If there was an error of some sort, return nothing\n if(data.nil? || data == '')\n return ''\n end\n\n # If encryption is turned off, return unencrypted data\n if(!ready?(keys))\n @@window.puts(\"Returning an unencrypted response\")\n return data\n end\n\n ## ** Encrypt\n #@@window.puts(\"Encrypting the response\")\n\n # Split the packet into a header and a body\n header, body = data.unpack(\"a5a*\")\n\n # Encode the nonce properly\n nonce = [keys[:my_nonce]].pack(\"n\")\n\n # Encrypt the body\n encrypted_body = Salsa20.new(keys[:my_write_key], nonce.rjust(8, \"\\0\")).encrypt(body)\n\n # Sign it\n signature = SHA3::Digest::SHA256.digest(keys[:my_mac_key] + header + nonce + encrypted_body)\n\n # Arrange things appropriately\n return [header, signature[0,6], nonce, encrypted_body].pack(\"a5a6a2a*\")\n end", "def decrypt_jwt\n begin\n decoded_token_data = JWT.decode(\n params[:token],\n GlobalConstant::PublicOpsApi.secret_key,\n true,\n {:algorithm => 'HS256'}\n )[0][\"data\"]\n\n params[:decoded_token_data] = HashWithIndifferentAccess.new(decoded_token_data)\n rescue => e\n # decoding failed\n ApplicationMailer.notify(\n body: {exception: {message: e.message, backtrace: e.backtrace}},\n data: {\n 'decoded_token_data' => params[:decoded_token_data],\n 'token' => params[:token]\n },\n subject: 'Exception in decrypt_jwt'\n ).deliver\n\n render_api_response(\n Result::Base.error({\n error: 'c_oc_1',\n error_message: 'Token Invalid or Expired.',\n http_code: GlobalConstant::ErrorCode.not_found\n })\n )\n end\n end", "def decrypt_and_verify(message, **options)\n catch_and_raise :invalid_message_format, as: InvalidMessage do\n catch_and_raise :invalid_message_serialization, as: InvalidMessage do\n catch_and_ignore :invalid_message_content do\n read_message(message, **options)\n end\n end\n end\n end", "def decrypt(keys, cypher)\n keys.each do |key|\n verifier = ::Fernet.verifier(key, cypher, enforce_ttl: false)\n next unless verifier.valid?\n return verifier.message\n end\n cypher # Return cypher has it's probably just plain text\n end", "def decrypt(value)\n Crypt::ExplicitDecryptionContext.new(\n @crypt_handle,\n @encryption_io,\n { v: value }\n ).run_state_machine['v']\n end", "def decrypt(sentence, combination)\n encrypt(sentence, combination)\nend", "def decipher(key, user_iv, text)\n ssl_decipher = OpenSSL::Cipher.new('AES-256-CBC')\n ssl_decipher.decrypt\n ssl_decipher.key = key\n ssl_decipher.iv = user_iv\n ssl_decipher.update(text) + ssl_decipher.final\n end", "def aes_decrypt(key, crypt_string)\n cipher = OpenSSL::Cipher.new(ssl_cipher)\n\n cipher.decrypt\n cipher.key = key\n cipher.pkcs5_keyivgen(key)\n cipher.update(crypt_string) + cipher.final\n end", "def decrypt(value)\n escape_and_execute_sql(\n [\"SELECT AES_DECRYPT(?, ?)\", Base64.decode64(value), key]).first\n end", "def decrypt(value)\n if @private_key.present? && encrypted?(value)\n escape_and_execute_sql([\"SELECT pgp_pub_decrypt(?, dearmor(?), ?)\",\n value, @private_key, @key])['pgp_pub_decrypt']\n else\n value\n end\n end", "def with_reusable_cipher\n cipher = get_or_init_reusable_cipher\n\n result = yield(cipher)\n\n cleanup_reusable_cipher\n\n return result\n rescue => e\n # when an error is encountered, we cannot trust the state of the cipher object.\n @logger.debug(\"shared cipher: removing because an exception was raised in #{Thread.current}\", :exception => e.message)\n destroy_reusable_cipher\n raise\n end", "def aes_decrypt(key, crypt_string)\n cipher = OpenSSL::Cipher::Cipher.new(ssl_cipher)\n\n cipher.decrypt\n cipher.key = key\n cipher.pkcs5_keyivgen(key)\n decrypted_data = cipher.update(crypt_string) + cipher.final\n end", "def read_encrypted_secrets; end", "def read_encrypted_secrets; end", "def decrypt(ciphertext, key)\n plaintext = []\n i = 0\n ciphertext.each_byte do |c|\n p = c ^ key[i % 3][0]\n i += 1\n plaintext << p.chr\n end\n return plaintext.join\nend", "def base_decrypt(ciphertext)\n RbNaCl::SimpleBox\n .from_secret_key(key)\n .decrypt(ciphertext)\n .force_encoding(Encoding::UTF_8)\n end", "def decipher_base64(value_base64, key)\n if blank(value_base64)\n return nil\n else\n cipher_text = Base64.decode64(value_base64)\n return decipher(cipher_text, key)\n end\nend", "def decrypt_or_encrypt(operation,password)\n\tif operation == 'encrypt'\n\t\tencrypt(password) # the secret agent would like to encrypt so we call the encryption method \n\t\t\telsif operation == 'decrypt'\n\t\t\t\tdecrypt(password) # the secret agent would like to decrypt so we call the decryption method \n\t\t\telse \n\tend\nend", "def decrypt(data)\n crypto_key.decrypt64(data)\n end", "def decypt_and_verify(passphrase)\n decrypted_message = decrypt(passphrase)\n\n expected = Digest::SHA256.digest(decrypted_message)\n raise SlyErrors::StateError, \"Failed SHA-256 checksum\" unless expected == Base64.decode64(message_hash)\n\n decrypted_message\n end", "def decrypt(value)\n return unless value\n fail ArgumentError, 'Value is not encrypted' unless value.match(REGEXP)\n @key.private_decrypt(Base64.strict_decode64(Regexp.last_match(:value)))\n end", "def vigenere_cipher(string, key_sequence, alphabet)\n #\n # your code goes here\n #\nend", "def base_decrypt(ciphertext)\n simple_box = RbNaCl::SimpleBox.from_secret_key(key)\n simple_box.decrypt(ciphertext).force_encoding('UTF-8')\n # For an unknown reason, the decrypted result is default\n # to be of 'ASCII-8BIT', so we have to transform it into\n # UTF-8 by ourself!!\n end", "def decrypt(msg, private_key)\n # 1\n rsa_encrypted_aes_key = msg[0..255] # 256 bits\n rsa_encrypted_aes_iv = msg[256..511] # next 256 bits\n aes_encrypted_message = msg[512..msg.length]\n\n # 2\n rsa_decryptor = OpenSSL::PKey::RSA.new private_key\n aes_key = rsa_decryptor.private_decrypt rsa_encrypted_aes_key\n aes_iv = rsa_decryptor.private_decrypt rsa_encrypted_aes_iv\n\n # 3\n decipher = OpenSSL::Cipher::AES256.new(AES_MODE)\n decipher.decrypt\n decipher.key = aes_key\n decipher.iv = aes_iv\n\n decipher.update(aes_encrypted_message) + decipher.final\n end", "def decrypted_secret_key\n @decrypted_secret_key ||= get_decrypted_secret_key_from_memcache.data[:plaintext]\n end", "def decrypt(string)\n\tindex = 0\n\tsecret_password = string\n\twhile index < secret_password.length\n\tsecret_password[index] = (secret_password[index].ord - 1).chr\n\tindex += 1\nend\n\tp secret_password\nend", "def decrypt(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end", "def _decode_aes256 cipher, iv, data\n aes = OpenSSL::Cipher::Cipher.new \"aes-256-#{cipher}\"\n aes.decrypt\n aes.key = @encryption_key\n aes.iv = iv\n aes.update(data) + aes.final\n end", "def verify_key; end", "def verify_key; end", "def xor_decrypt(bytes, password)\r\n decrypt = \"\"\r\n pw_index = 0 #keeps track of index to cycle password\r\n\r\n bytes.each do |i|\r\n decrypt += (i ^ password[pw_index]).to_s + \",\" #run xor operation\r\n pw_index += 1\r\n #loop over the password if it reaches its limit\r\n if pw_index > password.length - 1\r\n pw_index = 0\r\n end\r\n end\r\n #returns as a string of ascii values\r\n decrypt\r\nend", "def decrypt( encrypt)\n @shift = @shift * -1\n encrypt( encrypt)\n end" ]
[ "0.7536875", "0.67451257", "0.6645803", "0.66172016", "0.6562857", "0.6429574", "0.63824034", "0.63176477", "0.63117486", "0.6257261", "0.62366974", "0.6212731", "0.6196867", "0.619491", "0.6146825", "0.61222184", "0.60974205", "0.6076279", "0.6036688", "0.6028061", "0.6001703", "0.59987247", "0.5996112", "0.59824485", "0.596221", "0.5944123", "0.59368193", "0.59250087", "0.591584", "0.59006965", "0.5894831", "0.587872", "0.5851407", "0.58466554", "0.58446693", "0.58426607", "0.5837241", "0.58154017", "0.58154017", "0.5814921", "0.580065", "0.57692266", "0.5768277", "0.5764914", "0.5735347", "0.5731788", "0.5730292", "0.57273227", "0.57228804", "0.57086", "0.5696044", "0.56848097", "0.56805474", "0.56757545", "0.5668711", "0.5662936", "0.56619835", "0.56619835", "0.56424046", "0.5637479", "0.56309545", "0.5615087", "0.5599553", "0.5592134", "0.55900264", "0.5584917", "0.5584917", "0.55842894", "0.5583707", "0.5568947", "0.5564825", "0.5562258", "0.55618536", "0.5561166", "0.5551261", "0.5546986", "0.5544684", "0.5540877", "0.55373955", "0.55352503", "0.55309206", "0.55183756", "0.55183756", "0.5509535", "0.55071783", "0.5502061", "0.549218", "0.549026", "0.54823565", "0.547713", "0.5475667", "0.5474041", "0.5471969", "0.54706746", "0.54689866", "0.54407287", "0.5429147", "0.5428608", "0.5428608", "0.5427915", "0.5427139" ]
0.0
-1
Return the cluster status
def clusterstatus(as_json: false) # don't cache it status = Utils.solr_request(connection, 'CLUSTERSTATUS') if as_json status.to_json else status end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cluster_status\n report_metric 'Cluster Status/Partitioned', 'nodes', rmq_manager.nodes.count { |n| Array(n['partitions']).any? }\n report_metric 'Cluster Status/Stopped', 'nodes', rmq_manager.nodes.count { |n| !n['running'] }\n end", "def read_cluster_status(opts = {})\n data, _status_code, _headers = read_cluster_status_with_http_info(opts)\n return data\n end", "def find_status\n health = get_es_resource('/_cluster/health')\n health['status'].downcase\n end", "def cluster_status\n # Default formatting changed to \"table\" in 3.8, need to explicity specify\n # \"erlang\" to parse output properly.\n installed_version = Gem::Version.new(installed_rabbitmq_version)\n version_requiring_formatter = Gem::Version.new('3.8.0')\n cmd = +'rabbitmqctl -q cluster_status'\n cmd << ' --formatter erlang' if installed_version >= version_requiring_formatter\n # execute > rabbitmqctl cluster_status\"\n # This removes an optional \"... Done\" linee that older version used to output\n Chef::Log.debug(\"[rabbitmq_cluster] Executing #{cmd}\")\n cmd = get_shellout(cmd)\n cmd.run_command\n cmd.error!\n result = cmd.stdout.squeeze(' ').gsub(/\\n */, '').gsub('...done.', '')\n Chef::Log.debug(\"[rabbitmq_cluster] #{cmd} : #{result}\")\n result\n end", "def run # rubocop:disable MethodLength\n if master?\n case find_status\n when 'green'\n ok 'Cluster is green'\n when 'yellow'\n warning 'Cluster is yellow'\n when 'red'\n critical 'Cluster is red'\n end\n else\n ok 'Not the master'\n end\n end", "def status\n debug \"Call: 'status' for Pacemaker service '#{name}' on node '#{hostname}'\"\n disable_basic_service_on_action :status\n\n cib_reset 'service_status'\n wait_for_online 'service_status'\n\n if primitive_is_multistate? name\n out = service_status_mode pacemaker_options[:status_mode_multistate]\n elsif primitive_is_clone? name\n out = service_status_mode pacemaker_options[:status_mode_clone]\n else\n out = service_status_mode pacemaker_options[:status_mode_simple]\n end\n\n if pacemaker_options[:add_location_constraint]\n if out == :running and not service_location_exists? full_name, hostname\n debug 'Location constraint is missing. Service status set to \"stopped\".'\n out = :stopped\n end\n end\n\n if pacemaker_options[:cleanup_on_status]\n if out == :running and primitive_has_failures? name, hostname\n debug \"Primitive: '#{name}' has failures on the node: '#{hostname}' Service status set to 'stopped'.\"\n out = :stopped\n end\n end\n\n debug \"Return: '#{out}' (#{out.class})\"\n debug cluster_debug_report \"#{@resource} status\"\n out\n end", "def measure_cluster_status cluster_name, private_ip\n begin\n connection = Net::HTTP.new(private_ip, 8080) # FIXME port\n request = Net::HTTP::Get.new('/status/cluster', 'Accept' => 'text/xml')\n response = connection.request(request)\n return false unless response.code.to_i == 200\n \n data = Crack::XML.parse(response.body)\n cluster_status = data['ClusterStatus']\n dead_nodes = cluster_status['DeadNodes'] ? cluster_status['DeadNodes']['Node'] : []\n live_nodes = cluster_status['LiveNodes']['Node']\n rescue NoMethodError, SocketError, REXML::ParseException, Errno::ECONNREFUSED => e\n # puts \"#{e.class} -- #{e.message}\"\n # puts e.backtrace\n return false\n end\n\n write({\n :hostname => \"#{cluster_name}-hbase\",\n :hostgroup => self.class::CLUSTER_HOSTGROUPS,\n :application => self.class::CLUSTER_APPLICATIONS,\n :templates => self.class::CLUSTER_TEMPLATES\n }) do |d|\n d << ['requests', cluster_status['requests']]\n d << ['regions', cluster_status['regions']]\n d << ['load', cluster_status['averageLoad']]\n d << ['nodes.dead', dead_nodes.size]\n d << ['nodes.alive', live_nodes.size]\n end\n measure_cluster_tables(cluster_name, data)\n measure_cluster_nodes(cluster_name, live_nodes)\n true\n end", "def report_clusterstatus(as: :table, using_persisted: false)\n rows = using_persisted ? restore_solr_status : check_cluster\n\n case as\n when :table\n # order first by STATUS then by COLLECTION (name)\n rows = sort_rows(rows)\n\n table = Terminal::Table.new(\n headings: [\n 'Collection',\n 'Replica Factor',\n 'Shards',\n 'Shard Active',\n 'Shard Down',\n 'Shard Good',\n 'Shard Bad',\n 'Replica UP',\n 'Replica DOWN',\n 'Status',\n 'Recoverable'\n ],\n rows: rows.map do |row|\n [\n row[:collection],\n row[:num_replicas],\n row[:num_shards],\n row[:shard_active],\n row[:shard_non_active],\n row[:shard_good],\n row[:shard_bad],\n row[:replicas_up],\n row[:replicas_down],\n row[:gstatus] ? 'OK' : 'BAD',\n row[:recoverable] ? 'YES' : 'NO'\n ]\n end\n )\n puts table\n when :native\n status = rows.each_with_object({}) do |row, acc|\n name = row[:collection]\n row.delete(:collection)\n acc[name] = row\n end\n status\n when :json\n status = rows.each_with_object({}) do |row, acc|\n name = row[:collection]\n row.delete(:collection)\n acc[name] = row\n end\n status.to_json\n when :simple\n status = 'green'\n bad_collections = []\n\n rows.each do |row|\n if row[:status] == :bad && row[:recoverable] == false\n status = 'red'\n bad_collections << {\n collection: row[:collection],\n base_url: row[:bad_urls],\n recoverable: false\n }\n elsif row[:status] == :bad && row[:recoverable] == true\n status = 'orange' unless status == 'red'\n bad_collections << {\n collection: row[:collection],\n base_url: row[:bad_urls],\n recoverable: true\n }\n elsif row[:bad_urls].count > 0\n bad_collections << {\n collection: row[:collection],\n base_url: row[:bad_urls],\n recoverable: true\n }\n end\n end\n { status: status, bad_collections: bad_collections }\n end\n end", "def get_cluster_state(host, port, timeout_sec)\n params = {\n :action => \"CLUSTERSTATUS\"\n }\n cluster_state = nil\n sleep_time_sec = 10\n attempts = timeout_sec/sleep_time_sec\n success = false\n while attempts >= 0 do\n begin\n Chef::Log.info(\"Getting cluster status. Remaining attempts : #{attempts}\")\n attempts = attempts - 1\n cluster_status_resp = solr_collection_api(host, port, params)\n cluster_state = cluster_status_resp[\"cluster\"]\n success = true\n break\n rescue => e\n Chef::Log.info(\"Error while getting cluster status : #{e.message}\")\n Chef::Log.info(\"Retry getting cluster status after #{sleep_time_sec} seconds\")\n sleep sleep_time_sec\n end\n end\n if !success\n error = \"Could not fetch the cluster state in #{timeout_sec} seconds\"\n puts \"***FAULT:FATAL=#{error}\"\n raise error\n end\n return cluster_state\n end", "def __get_cluster_health(status=nil)\n uri = URI(\"#{__cluster_url}/_cluster/health\")\n uri.query = \"wait_for_status=#{status}\" if status\n\n begin\n response = Net::HTTP.get(uri)\n rescue Exception => e\n STDERR.puts e.inspect if ENV['DEBUG']\n return nil\n end\n\n JSON.parse(response)\n end", "def secondary_status\n session.cluster.with_secondary do |secondary|\n secondary.command(:admin, replSetGetStatus: 1)\n end\n rescue => e\n raise ConnectionFailed, e\n end", "def __cluster_info\n health = JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_cluster/health\")))\n nodes = if version == '0.90'\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/?process&http\")))\n else\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/process,http\")))\n end\n master = JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_cluster/state\")))['master_node']\n\n result = [\"\\n\",\n ('-'*80).ansi(:faint),\n 'Cluster: '.ljust(20).ansi(:faint) + health['cluster_name'].to_s.ansi(:faint),\n 'Status: '.ljust(20).ansi(:faint) + health['status'].to_s.ansi(:faint),\n 'Nodes: '.ljust(20).ansi(:faint) + health['number_of_nodes'].to_s.ansi(:faint)].join(\"\\n\")\n\n nodes['nodes'].each do |id, info|\n m = id == master ? '*' : '-'\n result << \"\\n\" +\n ''.ljust(20) +\n \"#{m} \".ansi(:faint) +\n \"#{info['name'].ansi(:bold)} \".ansi(:faint) +\n \"| version: #{info['version'] rescue 'N/A'}, \".ansi(:faint) +\n \"pid: #{info['process']['id'] rescue 'N/A'}, \".ansi(:faint) +\n \"address: #{info['http']['bound_address'] rescue 'N/A'}\".ansi(:faint)\n end\n\n result\n end", "def clusterStatusV6(host_name,port,collection_name,path=\"/solr/admin/zookeeper\",params=\"detail=true&path=/collections/\")\n path = \"#{path}?#{params}\"+\"#{collection_name}/state.json&wt=json\"\n Chef::Log.info(\" HostName = \" + host_name + \", Port = \" + port + \", Path = \" + path)\n http = Net::HTTP.new(host_name, port)\n req = Net::HTTP::Get.new(path)\n unless !SolrAuth::AuthUtils.auth_enabled?\n admin_creds = SolrAuth::AuthUtils.get_solr_admin_credentials\n req.basic_auth(admin_creds['username'], admin_creds['password'])\n end\n response = http.request(req)\n if response != nil then\n return JSON.parse(response.body())\n end\n raise StandardError, \"empty response\"\n end", "def primary_status\n session.cluster.with_primary do |primary|\n primary.command(:admin, replSetGetStatus: 1)\n end\n rescue => e\n raise ConnectionFailed, e\n end", "def status\n result = {\n 'uid' => Time.now.to_i,\n 'links' => [\n {\n 'rel' => 'self',\n 'href' => uri_to(status_site_cluster_path(params[:site_id], params[:id])),\n 'type' => api_media_type(:g5kitemjson)\n },\n {\n 'rel' => 'parent',\n 'href' => uri_to(site_cluster_path(params[:site_id], params[:id])),\n 'type' => api_media_type(:g5kitemjson)\n }\n ]\n }\n\n expected_rtypes = ['node']\n expected_rtypes.push('disk') if params[:disks] != 'no'\n result.merge!(OAR::Resource.status(clusters: params[:id], network_address: params[:network_address], job_details: params[:job_details], waiting: params[:waiting], types: expected_rtypes))\n\n render_result(result)\n end", "def read_cluster_status_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_cluster_status ...\"\n end\n if @api_client.config.client_side_validation && opts[:'source'] && !['realtime', 'cached'].include?(opts[:'source'])\n fail ArgumentError, 'invalid value for \"source\", must be one of realtime, cached'\n end\n # resource path\n local_var_path = \"/cluster/status\"\n\n # query parameters\n query_params = {}\n query_params[:'source'] = opts[:'source'] if !opts[:'source'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\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 => 'ClusterStatus')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_cluster_status\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def __get_cluster_health(port=9250)\n uri = URI(\"http://localhost:#{port}/_cluster/health\")\n if response = Net::HTTP.get(uri) rescue nil\n return JSON.parse(response)\n end\n end", "def nodetool_status()\n out = `/opt/cassandra/bin/nodetool status`\n raise 'nodetool status failed' if $? != 0\n rows = out.split(\"\\n\")\n hash = {}\n dc_exp = /Datacenter: (.*)/\n #vnode\n #-- Address Load Tokens Owns Host ID Rack\n #non-vnode\n #-- Address Load Owns Host ID Token Rack\n #node_ex = /^(?<status>[UD\\?][NLJM]) +(?<address>(?:[0-9]{1,3}\\.){3}[0-9]{1,3}) +(?<load>(\\d+\\.?\\d* (TB|GB|MB|KB|bytes))|\\?) +(?<tokens>\\d+) +(?<owns>(\\d+\\.?\\d*%|\\?)) +(?<hostid>[a-z0-9\\-]+) +(?<rack>.*)$/\n node_ex = /^([UD\\?][NLJM]) +((?:[0-9]{1,3}\\.){3}[0-9]{1,3}) +((?:\\d+\\.?\\d* (?:TB|GB|MB|KB|bytes))|\\?) +(\\d+) +(\\d+\\.?\\d*%|\\?) +([a-z0-9\\-]+) +(.*)$/\n datacenter = nil\n rows.each do |row|\n m = dc_exp.match(row)\n if m\n datacenter = m[1]\n next\n end\n m = node_ex.match(row)\n next if m == nil\n node = {'datacenter' => datacenter}\n hash[m[2]] = node\n i = 0\n %w(status address load tokens owns hostid rack).each do |name|\n node[name] = m[i += 1]\n end\n # m.names.each do |name|\n # node[name] = m[name]\n # end\n end\n return hash\n end", "def status\n cmd = \"#{@vzctl} status #{@ctid}\"\n status = execute(cmd).split(/\\s/)\n Log.debug(\"Container (#{@ctid}) status requested: #{status}\")\n status.drop(2)\n end", "def status\n dist_service( service_name, 'status' )\n end", "def status\n @status\n end", "def status\n @status\n end", "def __wait_for_status(status='green', timeout=30)\n begin\n Timeout::timeout(timeout) do\n loop do\n response = __get_cluster_health(status)\n __log response if ENV['DEBUG']\n\n if response && response['status'] == status && ( arguments[:number_of_nodes].nil? || arguments[:number_of_nodes].to_i == response['number_of_nodes'].to_i )\n break\n end\n\n __log '.'.ansi(:faint), :print\n sleep 1\n end\n end\n rescue Timeout::Error => e\n message = \"\\nTimeout while waiting for cluster status [#{status}]\"\n message += \" and [#{arguments[:number_of_nodes]}] nodes\" if arguments[:number_of_nodes]\n __log message.ansi(:red, :bold)\n raise e\n end\n\n return true\n end", "def measure_cluster_health cluster_name, private_ip\n begin\n cluster_health = JSON.parse(open(es_url(private_ip, '_cluster', 'health')).read)\n rescue SocketError, OpenURI::HTTPError, JSON::ParserError, Errno::ECONNREFUSED => e\n # This node may not be running a webnode...\n return false\n end\n write({\n :hostname => \"#{cluster_name}-elasticsearch\",\n :hostgroup => self.class::CLUSTER_HOSTGROUPS,\n :templates => self.class::CLUSTER_TEMPLATES,\n :application => self.class::CLUSTER_APPLICATIONS\n }) do |d|\n d << ['status', cluster_health['status'] ]\n d << ['nodes.total', cluster_health['number_of_nodes'] ]\n d << ['nodes.data', cluster_health['number_of_data_nodes'] ]\n d << ['shards.active', cluster_health['active_shards'] ]\n d << ['shards.relocating', cluster_health['relocating_shards'] ]\n d << ['shards.unassigned', cluster_health['unassigned_shards'] ]\n d << ['shards.initializing', cluster_health['initializing_shards'] ]\n end\n true\n end", "def set_status_cluster\n @status_cluster = StatusCluster.find(params[:id])\n end", "def getClusterInfo\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view the clusters in this project\" }, :unauthorized)\n return\n end\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/swarm'\n\n # Create request for Service Manager\n stack = {\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, 200)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end", "def status\n s = []\n Node.transaction do\n node_roles.each { |nr| s[nr.id] = nr.status if nr.error? }\n end\n end", "def get_Status()\n \t return @outputs[\"Status\"]\n \tend", "def getStatus\n @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def get_status\n\t\tstatus\n\tend", "def get_status\n @connection.get(\"/\").body\n end", "def status\n case @result.retval\n when 0 ; \"ok\"\n when 1 ; \"warning\"\n when 2 ; \"critical\"\n end\n end", "def __print_cluster_info(port)\n health = JSON.parse(Net::HTTP.get(URI(\"http://localhost:#{port}/_cluster/health\")))\n nodes = JSON.parse(Net::HTTP.get(URI(\"http://localhost:#{port}/_nodes/process,http\")))\n master = JSON.parse(Net::HTTP.get(URI(\"http://localhost:#{port}/_cluster/state\")))['master_node']\n\n puts \"\\n\",\n ('-'*80).ansi(:faint),\n 'Cluster: '.ljust(20).ansi(:faint) + health['cluster_name'].to_s.ansi(:faint),\n 'Status: '.ljust(20).ansi(:faint) + health['status'].to_s.ansi(:faint),\n 'Nodes: '.ljust(20).ansi(:faint) + health['number_of_nodes'].to_s.ansi(:faint)\n\n nodes['nodes'].each do |id, info|\n m = id == master ? '+' : '-'\n puts ''.ljust(20) +\n \"#{m} #{info['name'].ansi(:bold)} | version: #{info['version']}, pid: #{info['process']['id']}, address: #{info['http']['bound_address']}\".ansi(:faint)\n end\n end", "def read_cluster_node_status(node_id, opts = {})\n data, _status_code, _headers = read_cluster_node_status_with_http_info(node_id, opts)\n return data\n end", "def status\n check_exists\n SideJob.redis.get \"#{redis_key}:status\"\n end", "def status\n output = riak_admin 'status'\n if $?.success?\n result = {}\n Hash[output.scan(TS_STATS_REGEXP)]\n end\n end", "def output_success\n puts \"status Cman node status for #{@hostname}\"\n @metrics.each do |name,v|\n puts \"metric #{name} #{v[:type]} #{v[:value]}\"\n end\nend", "def joined_cluster?(node_name, cluster_status)\n (running_nodes(cluster_status) || '').include?(node_name)\n end", "def cluster_enabled_state\n super\n end", "def status\n data.status\n end", "def status\n instance_get(:status)\n end", "def getStatus\r\n\t\t\t\t\treturn @status\r\n\t\t\t\tend", "def get_cluster_debug_report\n report = \"\\n\"\n primitives_status_by_node.each do |primitive, data|\n primitive_name = primitive\n primitive_name = primitives[primitive]['name'] if primitives[primitive]['name']\n primitive_type = 'Simple'\n primitive_type = 'Cloned' if primitive_is_clone? primitive\n primitive_type = 'Multistate' if primitive_is_multistate? primitive\n primitive_status = primitive_status primitive\n\n report += \"-> #{primitive_type} primitive '#{primitive_name}' global status: #{primitive_status}\"\n report += ' (UNMANAGE)' unless primitive_is_managed? primitive\n report += \"\\n\"\n report += ' ' if data.any?\n nodes = []\n data.keys.sort.each do |node_name|\n node_status = data.fetch node_name\n node_block = \"#{node_name}: #{node_status}\"\n node_block += ' (FAIL)' if primitive_has_failures? primitive, node_name\n nodes << node_block\n end\n report += nodes.join ' | '\n report += \"\\n\"\n end\n report\n end", "def status\n # We must provide a string version here: https://github.com/sul-dlss/dor-workflow-client/issues/169\n @status ||= WorkflowClientFactory.build.status(druid: cocina.externalIdentifier, version: cocina.version.to_s).status_code\n end", "def status\n @status ||= STATUS[mapping_for(:status)]\n end", "def status\n @status ||= STATUS[mapping_for(:status)]\n end", "def active_on_cluster_count\n (waiting_count + running_count)\n end", "def health_status\n data.health_status\n end", "def check_cluster\n hostname = \"botha1.cs.ualberta.ca\"\n username = \"prion\"\n keys = ['/apps/phaster/.ssh/botha', '~/.ssh/id_rsa'] # private keys to test (not all the files need to exist)\n\n # Can we connect?\n begin\n ssh = Net::SSH.start(hostname, username, :keys => keys, :auth_methods => ['publickey']) # Only try public key authentication.\n rescue\n #puts \"Unable to connect to #{hostname} using #{username}\"\n return('Unable to connect to the computing cluster! Please contact PHASTER support so the issue can be addressed.')\n end\n\n # Can qsub command be found?\n res = ssh.exec!('which qsub')\n if res =~ /no qsub in/\n return('A problem was detected on the computing cluster! Please contact PHASTER support so the issue can be addressed.')\n end\n\n # Are there any cluster child nodes that are alive?\n res = ssh.exec!('alive')\n c = 0\n res.split(\"\\n\").each { |line|\n c += 1\n }\n #puts \"#{c} child nodes available\"\n if c == 0\n return('A problem was detected on the computing cluster! Please contact PHASTER support so the issue can be addressed.')\n end\n\n ssh.close\n return('')\n end", "def status\n @group.status\n end", "def status\n\t\treturn @status\n\tend", "def status\n raise Timeout::Error unless @time_observer.enough_time?\n\n last_run = puppet_status\n status = node_status(last_run)\n Astute.logger.debug \"Node #{@node['uid']}(#{@node['role']}) status: #{status}\"\n\n result = case status\n when 'succeed'\n processing_succeed_node\n when 'running'\n processing_running_node\n when 'error'\n processing_error_node(last_run)\n end\n\n #TODO(vsharshov): Should we move it to control module?\n @ctx.report_and_update_status('nodes' => [result]) if result\n\n # ready, error or deploying\n result.fetch('status', 'deploying')\n rescue MClientTimeout, Timeout::Error\n Astute.logger.warn \"Puppet agent #{@node['uid']} \" \\\n \"didn't respond within the allotted time\"\n 'error'\n end", "def getserverstatus()\n if not checkRequirements([\"thezone\",\"theserver\"])\n return false\n end\n checkToken(@thezone)\n data = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@theserver.azone.name}/instances/#{@theserver.serial}', :method => 'get', :options => '', :access_token => @thezone.token )\n data ? data[\"status\"] : false\n end", "def read_cluster_boot_manager_service_status_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_cluster_boot_manager_service_status ...\"\n end\n # resource path\n local_var_path = \"/node/services/cluster_manager/status\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\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 => 'NodeServiceStatusProperties')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_cluster_boot_manager_service_status\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def status\n log('Fetching status')\n\n return not_enabled unless Vedeu::Configuration.drb?\n\n if drb_running?\n log('Running')\n\n :running\n\n else\n log('Stopped')\n\n :stopped\n\n end\n end", "def status\n info[\"Status\"]\n end", "def read_cluster_nodes_aggregate_status(opts = {})\n data, _status_code, _headers = read_cluster_nodes_aggregate_status_with_http_info(opts)\n return data\n end", "def status\n fixity_graph.query({ predicate: premis_status_predicate }).map(&:object) +\n fixity_graph.query({ predicate: fedora_status_predicate }).map(&:object)\n end", "def status\n info['status']\n end", "def status\n log('Fetching status')\n\n return not_enabled unless Vedeu.config.drb?\n\n if drb_running?\n log('Running')\n\n :running\n\n else\n log('Stopped')\n\n :stopped\n\n end\n end", "def status()\n puts @status\n end", "def summary\n \"#<Client cluster=#{cluster.summary}>\"\n end", "def getClusterMetrics\n @admin.getClusterMetrics\n end", "def get_status\n return @m_status\n end", "def status\n debug { \"status\" }\n verify_response { Remote.get('/status', :api_key => api_key ) }\n end", "def status\n data[:status]\n end", "def status\n inspect\n end", "def running?\n if cluster_health = Timeout::timeout(0.25) { __get_cluster_health } rescue nil\n return cluster_health['cluster_name'] == arguments[:cluster_name] && \\\n cluster_health['number_of_nodes'] == arguments[:number_of_nodes]\n end\n return false\n end", "def cluster() node[:cluster_name] ; end", "def query_cluster_restore_status_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.query_cluster_restore_status ...\"\n end\n # resource path\n local_var_path = \"/cluster/restore/status\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\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 => 'ClusterRestoreStatus')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#query_cluster_restore_status\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def status\n @status\n end", "def status\n @status\n end", "def health(params = {})\n response = client.get \"/_cluster/health{/index}\", params.merge(action: \"cluster.health\", rest_api: \"cluster.health\")\n response.body\n end", "def current_cluster_name(cluster_status)\n pattern = '({cluster_name,<<\")(.*?)(\">>})'\n result = match_pattern_cluster_status(cluster_status, pattern)\n Chef::Log.debug(\"[rabbitmq_cluster] current_cluster_name : #{result}\")\n result\n end", "def status\n s = {}\n # any node that's error or unknown will cause the whole state to be in the other state \n my_nodes.each { |n| s[n.id] = n.status unless n.state == 0 }\n return s\n end", "def getNodeStatus(node_id) \n cm_url = APP_CONFIG['cm_ip'] + ':' + APP_CONFIG['cm_port'].to_s\n res = HTTParty.get(cm_url+\"/resources/node/\"+ node_id)\n # puts \"status \"+node_id\n # puts res\n return res\n\n end" ]
[ "0.83505356", "0.7620132", "0.7598819", "0.73326105", "0.726689", "0.71325547", "0.70868975", "0.7084241", "0.70763725", "0.707241", "0.69856614", "0.6963993", "0.68929404", "0.68446666", "0.67671984", "0.67463964", "0.65773004", "0.65694827", "0.6547558", "0.64864856", "0.64698714", "0.64698714", "0.6448816", "0.6429489", "0.64283025", "0.6419973", "0.64020073", "0.6387543", "0.6383659", "0.6382956", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63820267", "0.63660955", "0.63468236", "0.6341137", "0.6325809", "0.6321572", "0.63199097", "0.63169956", "0.63113046", "0.63060194", "0.6288169", "0.6283054", "0.6282943", "0.62779284", "0.6269078", "0.6267852", "0.62669474", "0.62669474", "0.62628275", "0.62519723", "0.6240449", "0.6239965", "0.62382704", "0.6232685", "0.62303114", "0.62217534", "0.6214369", "0.62126976", "0.6211776", "0.6195388", "0.61912864", "0.6184819", "0.61802006", "0.61800015", "0.6179492", "0.6178751", "0.6177869", "0.6173379", "0.6173066", "0.61719227", "0.6167909", "0.615643", "0.6144276", "0.6144276", "0.6128058", "0.6124682", "0.6113507", "0.61119944" ]
0.83396685
1
Generate a report of the current collection/shards status as: type of rapresentation :native :table (default) :json :simple using_persisted: if true doesn't make a request to SOLR but use the persisted state
def report_clusterstatus(as: :table, using_persisted: false) rows = using_persisted ? restore_solr_status : check_cluster case as when :table # order first by STATUS then by COLLECTION (name) rows = sort_rows(rows) table = Terminal::Table.new( headings: [ 'Collection', 'Replica Factor', 'Shards', 'Shard Active', 'Shard Down', 'Shard Good', 'Shard Bad', 'Replica UP', 'Replica DOWN', 'Status', 'Recoverable' ], rows: rows.map do |row| [ row[:collection], row[:num_replicas], row[:num_shards], row[:shard_active], row[:shard_non_active], row[:shard_good], row[:shard_bad], row[:replicas_up], row[:replicas_down], row[:gstatus] ? 'OK' : 'BAD', row[:recoverable] ? 'YES' : 'NO' ] end ) puts table when :native status = rows.each_with_object({}) do |row, acc| name = row[:collection] row.delete(:collection) acc[name] = row end status when :json status = rows.each_with_object({}) do |row, acc| name = row[:collection] row.delete(:collection) acc[name] = row end status.to_json when :simple status = 'green' bad_collections = [] rows.each do |row| if row[:status] == :bad && row[:recoverable] == false status = 'red' bad_collections << { collection: row[:collection], base_url: row[:bad_urls], recoverable: false } elsif row[:status] == :bad && row[:recoverable] == true status = 'orange' unless status == 'red' bad_collections << { collection: row[:collection], base_url: row[:bad_urls], recoverable: true } elsif row[:bad_urls].count > 0 bad_collections << { collection: row[:collection], base_url: row[:bad_urls], recoverable: true } end end { status: status, bad_collections: bad_collections } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status(memoize = true)\n if @status[:updated].nil? or not memoize or (memoize and not @status[:updated].nil? and \n ((Time.now - @status[:updated]) >= self.class.status_update_threshold))\n response = Crocodoc.connection.get 'document/status', :uuids => @uuid\n response = response.body.first\n @status[:updated] = Time.now\n @status[:status] = STATUSES[response['status']]\n @status[:viewable] = response['viewable']\n @status[:error] = response['error'] if response.member?('error')\n end\n return @status\n end", "def statuses; end", "def index\n @status = OpenStruct.new({ articles_count: Article.count,\n articles_recent_count: Article.last_x_days(30).count,\n sources_disabled_count: Source.where(:state => 1).count,\n alerts_last_day_count: Alert.total_errors(1).count,\n delayed_jobs_active_count: DelayedJob.count,\n responses_count: ApiResponse.total(1).count,\n events_count: RetrievalStatus.joins(:source).where(\"state > ?\",0).where(\"name != ?\", \"relativemetric\").sum(:event_count), #where(\"state > 0 AND name != 'relativemetric'\").sum(:event_count),\n requests_count: ApiRequest.where(\"created_at > ?\", Time.now - 1.day).count, #where(\"created_at > NOW() - INTERVAL 1 DAY\").count,\n users_count: User.count,\n version: VERSION,\n couchdb_size: RetrievalStatus.new.get_alm_database[\"disk_size\"] || 0,\n mysql_size: RetrievalHistory.table_status[\"data_length\"],\n update_date: Status.update_date,\n cache_key: Status.update_date })\n end", "def clusterstatus(as_json: false)\n # don't cache it\n status = Utils.solr_request(connection, 'CLUSTERSTATUS')\n if as_json\n status.to_json\n else\n status\n end\n end", "def all_status\n\t status = Status.all\n\t return render_json_response(status, :ok)\n end", "def statuses\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Available\", \"2\" => \"On Hold\", \"3\" => \"Borrowed\", \"4\" => \"Unavailable\"}}, :status => 200\n\t\treturn\n\tend", "def index_status()\n\n read_index_alias = to_read_index_alias_name()\n write_index_alias = to_write_index_alias_name()\n parsed = @http.get(\"http://#{@host}:#{@port}/#{write_index_alias}/_status\")\n @logger.error(\"+++++ write index_status\", :write_index_alias => write_index_alias, :parsed => parsed)\n\n if parsed.key?(\"ok\")\n\n @logger.error(\"***** index_status ok\")\n\n indices = parsed[\"indices\"]\n index_name = indices.keys.first\n index = indices[index_name]\n docs = index[\"docs\"]\n num_docs = docs[\"num_docs\"]\n\n return index_name, num_docs, write_index_alias, read_index_alias\n\n else\n\n error = parsed[\"error\"]\n @logger.error(\"***** index_status error\", :error => error)\n\n index_name = to_index_name(0, @application, @domain)\n return index_name, 0, write_index_alias, read_index_alias\n\n end\n\n end", "def fetch_statistics\n user = AdminUser.find(get_logged_in_user_id)\n if user.designation == \"supervisor\"\n new_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"pending\").count\n pending_complaints = 0\n completed_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"completed\").count\n elsif user.designation == \"ward officer\"\n ward = WardOffice.find(user.municipal_id)\n new_complaints = ComplaintStatus.where(admin_user_id: user.id).count\n pending_complaints = ComplaintStatus.where(district_office_id: ward.district_office_id, ward_office_id: user.municipal_id,\n category: user.designation, status: \"pending\").count\n completed_complaints = ComplaintStatus.where(district_office_id: ward.district_office_id, ward_office_id: user.municipal_id,\n category: user.designation, status: \"completed\").count\n elsif user.designation == \"district officer\"\n new_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"new\").count\n pending_complaints = ComplaintStatus.where(district_office_id: user.municipal_id, status: \"pending\").count\n completed_complaints = ComplaintStatus.where(district_office_id: user.municipal_id, status: \"completed\").count\n end\n render json: {new_complaint: new_complaints, pending_complaint: pending_complaints, completed_complaint: completed_complaints}\n end", "def status_infos\n @dbi.status_infos\n end", "def status_infos\n @dbi.status_infos\n end", "def status\n inspect\n end", "def status\n result = {\n 'uid' => Time.now.to_i,\n 'links' => [\n {\n 'rel' => 'self',\n 'href' => uri_to(status_site_cluster_path(params[:site_id], params[:id])),\n 'type' => api_media_type(:g5kitemjson)\n },\n {\n 'rel' => 'parent',\n 'href' => uri_to(site_cluster_path(params[:site_id], params[:id])),\n 'type' => api_media_type(:g5kitemjson)\n }\n ]\n }\n\n expected_rtypes = ['node']\n expected_rtypes.push('disk') if params[:disks] != 'no'\n result.merge!(OAR::Resource.status(clusters: params[:id], network_address: params[:network_address], job_details: params[:job_details], waiting: params[:waiting], types: expected_rtypes))\n\n render_result(result)\n end", "def to_status\n time = Time.now.to_i\n last = @db.execute(\"SELECT value from #{@settings} where key = 'LAST_SYNC'\").flatten[0].to_i\n\n sync_state = last == 0 || time > (last + @conf[:sync].to_i)\n\n status_str = ''\n monitor_ids = []\n\n if sync_state then\n status_str = \"SYNC_STATE=yes\\nMISSING_STATE=#{@conf[:missing_state]}\\n\"\n \n @db.execute(\"REPLACE INTO #{@settings} VALUES ('LAST_SYNC', #{time.to_s})\")\n end\n\n vms = DomainList.state_info(@host, @host_id)\n\n # ----------------------------------------------------------------------\n # report state changes in vms\n # ----------------------------------------------------------------------\n vms.each do |uuid, vm|\n next if vm[:ignore] == true\n\n if vm[:id] == -1\n filter = \"WHERE uuid = '#{uuid}'\"\n else\n # in ec2 id could first be -1 but later added, check also uuid\n filter = \"WHERE id = '#{vm[:id]}' OR uuid = '#{uuid}'\"\n end\n\n vm_db = @db.execute(\"SELECT * FROM #{@dataset} #{filter}\").first\n\n monitor_ids << uuid\n\n if vm_db.nil?\n @db.execute(\n \"INSERT INTO #{@dataset} VALUES (?, ?, ?, ?, ?, ?, ?, ?)\",\n [uuid,\n vm[:id].to_i,\n vm[:name],\n vm[:deploy_id],\n time,\n 0,\n vm[:state],\n @conf[:hyperv]]\n )\n\n status_str << vm_to_status(vm)\n \n next\n end\n\n # Updates timestamp and uuid/deploy_id (e.g. VM recreated in KVM)\n @db.execute(\n \"UPDATE #{@dataset} SET \" \\\n \"state = '#{vm[:state]}', \" \\\n 'missing = 0, ' \\\n \"timestamp = #{time}, \" \\\n \"uuid = '#{uuid}', \" \\\n \"deploy_id = '#{vm[:deploy_id]}' \"\\\n \"#{filter}\"\n )\n\n if sync_state || vm_db[col_name_to_idx('state')] != vm[:state]\n status_str << vm_to_status(vm)\n end\n end\n\n # ----------------------------------------------------------------------\n # check missing VMs\n # ----------------------------------------------------------------------\n uuids = @db.execute(\"SELECT uuid FROM #{@dataset}\").flatten!\n uuids ||= []\n\n (uuids - monitor_ids).each do |uuid|\n vm_db = @db.execute(\n \"SELECT * FROM #{@dataset} WHERE uuid = '#{uuid}'\"\n ).first\n\n next if vm_db.nil?\n\n miss = vm_db[col_name_to_idx('missing')]\n\n if miss >= @conf[:times_missing]\n status_str << vm_db_to_status(vm_db, @conf[:missing_state])\n\n @db.execute(\"DELETE FROM #{@dataset} WHERE uuid = \\\"#{uuid}\\\"\")\n else\n status_str << vm_db_to_status(vm_db) if sync_state\n \n @db.execute(\n \"UPDATE #{@dataset} SET \" \\\n \"timestamp = #{time}, \" \\\n \"missing = #{miss + 1} \" \\\n \"WHERE uuid = '#{uuid}'\"\n )\n end\n end\n\n status_str\n end", "def status\n output = riak_admin 'status'\n if $?.success?\n result = {}\n Hash[output.scan(TS_STATS_REGEXP)]\n end\n end", "def index\n @document_statuses = DocumentStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @document_statuses }\n end\n end", "def status\n fixity_graph.query({ predicate: premis_status_predicate }).map(&:object) +\n fixity_graph.query({ predicate: fedora_status_predicate }).map(&:object)\n end", "def update_status\n return nil unless @on_status\n rows_count = Knj::Locales.number_out(@rows_count, 0)\n rows_count_total = Knj::Locales.number_out(@rows_count_total, 0)\n percent = (@rows_count.to_f / @rows_count_total.to_f) * 100\n percent_text = Knj::Locales.number_out(percent, 1)\n @on_status.call(text: \"Dumping table: '#{@table_obj.name}' (#{rows_count}/#{rows_count_total} - #{percent_text}%).\")\n end", "def index\n @entity_statuses = EntityStatus.all\n end", "def index\n @status_catalogs = StatusCatalog.all\n end", "def index\n @service_statuses = ServiceStatus.all\n end", "def index\n @health_statuses = HealthStatus.all\n end", "def status\n @status ||= STATUS[mapping_for(:status)]\n end", "def status\n @status ||= STATUS[mapping_for(:status)]\n end", "def index\n @deployment_statuses = DeploymentStatus.all\n end", "def index\n @reporting = Reporting.without_status(:deleted).all\n @category = Reporting::CATEGORY_REPORTS\n\n puts @reporting.inspect\n puts @category.inspect\n\n respond_to do |format|\n format.html\n format.json { render json: @reporting }\n end\n end", "def do_status\n return pretty_status(current_status)\n end", "def index\n @status = Status.last || Status.new(available: \"unavailable\", created_at: DateTime.now)\n end", "def render_status\n status.each do |st|\n puts \"#{st[:name]} (#{st[:id]})\"\n st[:nodes].each { |n| puts \" #{n[:name]} #{n[:condition]} #{n[:id]} #{n[:ip]}\" }\n puts '---'\n end\n\n nil\n end", "def status\n result_statuses = {}\n results.each{|result| result_statuses[result.status] ||= 0; result_statuses[result.status]+=1;}\n result_statuses\n end", "def status\n result_statuses = {}\n results.each{|result| result_statuses[result.status] ||= 0; result_statuses[result.status]+=1;}\n result_statuses\n end", "def summary\n res = description\n\n {\n in_service: res.instances.all?{ |e| e[:lifecycle_state] == 'InService' },\n healthy: res.instances.all?{ |e| e[:health_status] == 'Healthy' },\n size: res.instances.select { |e| e[:lifecycle_state] == 'InService' }.length\n }\n end", "def get_progress()\n doc = get_vre_status()\n result = {\n \"updating\" => false,\n \"ready\" => false\n }\n if doc\n doc.each {|key, value|\n if key.to_s().start_with?(\"collection_count_\")\n outputkey = key[\"collection_count_\".length..-1]\n subkey = \"count\"\n elsif key.to_s().start_with?(\"collection_finished_\")\n outputkey = key[\"collection_finished_\".length..-1]\n subkey = \"finished\"\n end\n if outputkey\n if !result.key?(outputkey)\n result[outputkey] = {}\n end\n result[outputkey][subkey] = value[0] if value\n end\n }\n if doc[:updating]\n result[\"updating\"] = !!doc[:updating][0]\n else\n result[\"updating\"] = false\n end\n if doc[:ready]\n result[\"ready\"] = !!doc[:ready][0]\n else\n result[\"ready\"] = false\n end\n end\n result\n end", "def retrieve_status\n \n end", "def custom_status\n {}\n end", "def index\n @nvs_mig_statuses = NvsMigStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nvs_mig_statuses }\n end\n end", "def status\n fetch(@config[:sales_path], 'Sales.getStatus')\n end", "def index\n @client_statuses = ClientStatus.all\n end", "def write_report\n @manager.atomic_file(report_file) do |file|\n file.write(JSON.pretty_generate(get_status))\n end\n end", "def status\n request :get, \"_status\"\n end", "def status\n \"#{@description} #{@status}\"\n end", "def status_info\n current_path = '/api/v1/status'\n @conn.get(current_path)\n end", "def clusterStatusV6(host_name,port,collection_name,path=\"/solr/admin/zookeeper\",params=\"detail=true&path=/collections/\")\n path = \"#{path}?#{params}\"+\"#{collection_name}/state.json&wt=json\"\n Chef::Log.info(\" HostName = \" + host_name + \", Port = \" + port + \", Path = \" + path)\n http = Net::HTTP.new(host_name, port)\n req = Net::HTTP::Get.new(path)\n unless !SolrAuth::AuthUtils.auth_enabled?\n admin_creds = SolrAuth::AuthUtils.get_solr_admin_credentials\n req.basic_auth(admin_creds['username'], admin_creds['password'])\n end\n response = http.request(req)\n if response != nil then\n return JSON.parse(response.body())\n end\n raise StandardError, \"empty response\"\n end", "def get_cluster_debug_report\n report = \"\\n\"\n primitives_status_by_node.each do |primitive, data|\n primitive_name = primitive\n primitive_name = primitives[primitive]['name'] if primitives[primitive]['name']\n primitive_type = 'Simple'\n primitive_type = 'Cloned' if primitive_is_clone? primitive\n primitive_type = 'Multistate' if primitive_is_multistate? primitive\n primitive_status = primitive_status primitive\n\n report += \"-> #{primitive_type} primitive '#{primitive_name}' global status: #{primitive_status}\"\n report += ' (UNMANAGE)' unless primitive_is_managed? primitive\n report += \"\\n\"\n report += ' ' if data.any?\n nodes = []\n data.keys.sort.each do |node_name|\n node_status = data.fetch node_name\n node_block = \"#{node_name}: #{node_status}\"\n node_block += ' (FAIL)' if primitive_has_failures? primitive, node_name\n nodes << node_block\n end\n report += nodes.join ' | '\n report += \"\\n\"\n end\n report\n end", "def status\n get_json('status.json')\n end", "def report_status\n f = File.open(File.expand_path('daemon/status.json', project.path), 'w')\n f.print JSON.pretty_generate(\n jobs_running: @jobs_running, jobs_to_run: @jobs_to_run)\n f.close\n end", "def index\n @sa_request_statuses = SaRequestStatus.all\n end", "def get_status\n result = {}\n result['registration'] = !!registration_start_date && !!registration_end_date\n result['cfp'] = !!call_for_papers\n result['venue'] = !!venue && !!venue.name && !!venue.address && !!venue.website\n result['rooms'] = rooms.count > 0\n result['tracks'] = tracks.count > 0\n result['event_types'] = event_types.count > 0\n result['difficulty_levels'] = difficulty_levels.count > 0\n result['process'] = (result.select { |k, v| v }.length / result.length.to_f * 100).round(0).to_s\n result['short_title'] = short_title\n result\n end", "def ingest_status(...)\n IngestService.active_status\n end", "def update_status\n return nil if !@on_status\n rows_count = Knj::Locales.number_out(@rows_count, 0)\n rows_count_total = Knj::Locales.number_out(@rows_count_total, 0)\n percent = (@rows_count.to_f / @rows_count_total.to_f) * 100\n percent_text = Knj::Locales.number_out(percent, 1)\n @on_status.call(:text => \"Dumping table: '#{@table_obj.name}' (#{rows_count}/#{rows_count_total} - #{percent_text}%).\")\n end", "def statuses\n aux = WorkOrderStatus.all\n render json: serialized_work_order_statuses(aux)\n end", "def index\n @statuses = Status.all\n end", "def index\n @statuses = Status.all\n end", "def index\n @inventory_statuses = InventoryStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventory_statuses }\n end\n end", "def statuses\n lifecycle.statuses\n end", "def index\n @site_rec_status_wrappers = SiteRecStatusWrapper.all\n end", "def index\n @store_statuses = StoreStatus.all\n end", "def query\n resp = {:records => []}\n status_key = STATUS[rand(STATUS.length)]\n ss = Spooge.find_on_redis(:status,status_key)\n resp[:record_count] = ss.length\n ss.each do |s|\n resp[:records] << s\n end \n render :json => resp\n end", "def status\n @status\n end", "def status\n @status\n end", "def get_sensor_statuses\n response = @db_client.query( \"SELECT name,status,updated_time,enabled,type,dismiss,verbose FROM #{SENSOR_STATUS}\" )\n return response.entries\n end", "def status\n @status\n end", "def status\n @status\n end", "def status_object\n @status\n end", "def status\n end", "def status\n end", "def status\n end", "def status\n end", "def status\n status = {\n \"num_questions\" => 0,\n \"num_answers\" => 0,\n \"sections\" => {},\n \"questions\" => {},\n \"space_used\" => 0 # percentage of available space in pdf used\n }\n\n space_used = height_of_text(self.title, 2, 2)\n\n section_ids = sections.map {|s| s.id}\n\n # we retrieve this is 2 joins:\n # 1. sections and questions\n # 2. questions and answers\n # why? because Rails 4 doesn't have any sensible left outer join.\n # when we change to RAILS 5 it is meant to have so this can be fixed then\n\n records = Section.joins(questions: :question_format)\n .select('sections.id as sectionid,\n sections.title as stitle,\n questions.id as questionid,\n questions.text as questiontext,\n question_formats.title as qformat')\n .where(\"sections.id in (?) \", section_ids)\n .to_a\n\n # extract question ids to get answers\n question_ids = records.map {|r| r.questionid}.uniq\n status[\"num_questions\"] = question_ids.count\n\n arecords = Question.joins(answers: :user)\n .select('questions.id as questionid,\n answers.id as answerid,\n answers.plan_id as plan_id,\n answers.text as answertext,\n answers.updated_at as updated,\n users.email as username')\n .where(\"questions.id in (?) and answers.plan_id = ?\",question_ids, self.id)\n .to_a\n\n # we want answerids to extract options later\n answer_ids = arecords.map {|r| r.answerid}.uniq\n status[\"num_answers\"] = answer_ids.count\n\n # create map from questionid to answer structure\n qa_map = {}\n arecords.each do |rec|\n qa_map[rec.questionid] = {\n plan: rec.plan_id,\n id: rec.answerid,\n text: rec.answertext,\n updated: rec.updated,\n user: rec.username\n }\n end\n\n\n # build main status structure\n records.each do |rec|\n sid = rec.sectionid\n stitle = rec.stitle\n qid = rec.questionid\n qtext = rec.questiontext\n format = rec.qformat\n\n answer = nil\n if qa_map.has_key?(qid)\n answer = qa_map[qid]\n end\n\n aid = answer.nil? ? nil : answer[:id]\n atext = answer.nil? ? nil : answer[:text]\n updated = answer.nil? ? nil : answer[:updated]\n uname = answer.nil? ? nil : answer[:user]\n\n space_used += height_of_text(stitle, 1, 1)\n\n shash = status[\"sections\"]\n if !shash.has_key?(sid)\n shash[sid] = {}\n shash[sid][\"num_questions\"] = 0\n shash[sid][\"num_answers\"] = 0\n shash[sid][\"questions\"] = Array.new\n end\n\n shash[sid][\"questions\"] << qid\n shash[sid][\"num_questions\"] += 1\n\n space_used += height_of_text(qtext) unless qtext == stitle\n if atext.present?\n space_used += height_of_text(atext)\n else\n space_used += height_of_text(_('Question not answered.'))\n end\n\n if answer.present? then\n shash[sid][\"num_answers\"] += 1\n end\n\n status[\"questions\"][qid] = {\n \"format\" => format,\n \"answer_id\" => aid,\n \"answer_updated_at\" => updated.to_i,\n \"answer_text\" => atext,\n \"answered_by\" => uname\n }\n\n end\n\n records = Answer.joins(:question_options).select('answers.id as answerid, question_options.id as optid').where(id: answer_ids).to_a\n opt_hash = {}\n records.each do |rec|\n aid = rec.answerid\n optid = rec.optid\n if !opt_hash.has_key?(aid)\n opt_hash[aid] = Array.new\n end\n opt_hash[aid] << optid\n end\n\n status[\"questions\"].each_key do |questionid|\n answerid = status[\"questions\"][questionid][\"answer_id\"]\n status[\"questions\"][questionid][\"answer_option_ids\"] = opt_hash[answerid]\n end\n\n status['space_used'] = estimate_space_used(space_used)\n\n return status\n end", "def discovery\n assigned_minions = assigned_with_status\n unassigned_minions = Minion.unassigned_role\n pending_minions = ::Velum::Salt.pending_minions\n retryable_bootstrap_orchestration = Orchestration.retryable? kind: :bootstrap\n retryable_upgrade_orchestration = Orchestration.retryable? kind: :upgrade\n\n respond_to do |format|\n format.html\n format.json do\n hsh = {\n assigned_minions: assigned_minions,\n unassigned_minions: unassigned_minions,\n pending_minions: pending_minions,\n admin: admin_status,\n retryable_bootstrap_orchestration: retryable_bootstrap_orchestration,\n retryable_upgrade_orchestration: retryable_upgrade_orchestration\n }\n render json: hsh, methods: [:update_status]\n end\n end\n end", "def to_unified_status\n status = nil\n statues = []\n\n units.each{|u| statues << u.status }\n\n if statues.any? {|s| s == \"Current\"}\n status = \"resident_current\"\n\n elsif statues.any? {|s| s == \"Future\"}\n status = \"resident_future\"\n\n elsif statues.any? {|s| s == \"Past\"}\n status = \"resident_past\"\n\n elsif statues.any? {|s| s == \"Notice\"}\n status = \"resident_notice\"\n\n end\n \n status\n end", "def statuses\n api.get('status')\n end", "def health_status\n data.health_status\n end", "def index\n @request_statuses = RequestStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @request_statuses }\n end\n end", "def info\n [@db_table, @filters, @sorts, @columns, @extra_fields, @operations, @macro.actions].to_json\n end", "def to_h\n {status: overall_status, checks: individual_statuses}\n end", "def status; end", "def status; end", "def status; end", "def status; end", "def status; end", "def status; end", "def status; end", "def status; end", "def status; end", "def index\n @listing_statuses = ListingStatus.find(:all, :select => 'id, description, position, is_final', :order => 'description')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @listing_statuses }\n end\n end", "def stats\n @db.command({:collstats => @name})\n end", "def index\n @catalogs_statuses = Catalogs::Status.search(params[:search]).order(\"#{sort_column}\").paginate(per_page: 15, page: params[:page])\n end", "def info\n result = []\n Server.all.each do |server|\n result << server.short_result\n end\n\n status_key = makeStatusKey(result)\n render :json => {servers:result}.merge(status_key)\n\n end", "def status\n @_sh ||= Sunra::Recording::StatusHash.new(self, @recorder_manager)\n end", "def display_results\n print_header\n print_detailed_report\n write_csv_report\n display_status\n end", "def statuses\n request(:get, \"applicant_tracking/statuses\")\n end", "def communication_status_for_solr\n return status\n end", "def index\n @statuses = Status.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @statuses }\n end\n end", "def status(packages: true)\n # When changing signature, don't forget to change samely of Master#status too\n {}.tap do |s|\n s[:name] = serf.name\n s[:version] = Mamiya::VERSION\n s[:labels] = labels\n\n s[:queues] = task_queue.status\n\n if packages\n s[:packages] = self.existing_packages\n s[:prereleases] = self.existing_prereleases\n s[:releases] = self.releases\n s[:currents] = self.currents\n end\n end\n end", "def status\n {\n name: name,\n state: state,\n grouped: false,\n prioritized: prioritized,\n pairwise: pairwise,\n subjects: subjects.size,\n users: users.length\n }\n end", "def getStatus\n fetch(@config[:sales_path], 'Sales.getStatus')\n end", "def index\n @project_statuses = Project::Status.all\n end", "def index\n @application_statuses = ApplicationStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @application_statuses }\n end\n end", "def getStatus\n @status\n end", "def status\n @object.status\n end" ]
[ "0.63049984", "0.6267864", "0.6119953", "0.61172706", "0.60531193", "0.5971388", "0.59207785", "0.58810276", "0.5837148", "0.5837148", "0.57742393", "0.57229936", "0.5695624", "0.56769913", "0.56360763", "0.563186", "0.56289184", "0.5622324", "0.56064737", "0.55927396", "0.5581089", "0.5579169", "0.5579169", "0.55758154", "0.55669487", "0.55588335", "0.55569565", "0.5551072", "0.55464506", "0.55464506", "0.5544223", "0.5530088", "0.55216676", "0.55144936", "0.55081165", "0.5499376", "0.5486145", "0.5483513", "0.548301", "0.5482569", "0.5473442", "0.5460682", "0.54606277", "0.54564077", "0.5449484", "0.54488194", "0.543791", "0.5432651", "0.54250234", "0.54246694", "0.54182005", "0.54182005", "0.5416685", "0.5415495", "0.5408693", "0.5408499", "0.5403775", "0.53985536", "0.53985536", "0.53950286", "0.5389208", "0.5389208", "0.53889936", "0.53793347", "0.53793347", "0.53793347", "0.53793347", "0.537855", "0.5376361", "0.53598374", "0.535105", "0.5343554", "0.5342", "0.53400785", "0.5334782", "0.532699", "0.532699", "0.532699", "0.532699", "0.532699", "0.532699", "0.532699", "0.532699", "0.532699", "0.531644", "0.531603", "0.53120565", "0.53074765", "0.5301332", "0.5300846", "0.5294121", "0.52864295", "0.5284907", "0.52705634", "0.5266368", "0.5264542", "0.5260215", "0.52551806", "0.52508485", "0.5248646" ]
0.7405822
0
Persist SOLR status to file (using pstore)
def persist_solr_status cluster = clusterstatus rows = check_cluster(status: cluster) # store to disk the current status store = PStore.new('cluster_stauts.pstore') store.transaction do # only for debug store['solr_cluster_status'] = cluster # save rows store['solr_cluster_status_rows'] = rows store['replicas_not_active'] = @replicas_not_active end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_status(file_path)\n begin\n Pathname.new(file_path).open('wb') do |f|\n @saved_at = Fluent::Engine.now\n @saved_duration = @saved_at - @last_checked\n Marshal.dump({\n :counts => @counts,\n :saved_at => @saved_at,\n :saved_duration => @saved_duration,\n :aggregate => @aggregate,\n :count_key => @count_key,\n :patterns => @patterns,\n }, f)\n end\n rescue => e\n log.warn \"out_datacounter: Can't write store_file #{e.class} #{e.message}\"\n end\n end", "def save_status(file_path)\n begin\n Pathname.new(file_path).open('wb') do |f|\n @saved_at = Fluent::Engine.now\n @saved_duration = @saved_at - @last_checked\n Marshal.dump({\n :counts => @counts,\n :matches => @matches,\n :saved_at => @saved_at,\n :saved_duration => @saved_duration,\n :regexp => @regexp,\n :exclude => @exclude,\n :input_key => @input_key,\n }, f)\n end\n rescue => e\n log.warn \"out_grepcounter: Can't write store_file #{e.class} #{e.message}\"\n end\n end", "def persist_statuses\n File.write(@status_path, @statuses.to_json)\n end", "def store_wffile\n # verify if there is actually a file to be saved\n if @file_data\n # create the WORKFLOW_STORE Folder if it does not exist\n FileUtils.mkdir_p File.join WORKFLOW_STORE, \"#{id}\"\n # create the file and write the data to the file system\n File.open(workflow_filename, 'wb') do |f|\n f.write(@file_data.read)\n end\n # ensure that the data is only save once by clearing the cache after savig\n @file_data = nil\n end\n end", "def nmap_save()\n print_status \"Nmap: saving nmap log file\"\n fh = self.nmap_log[0]\n nmap_data = fh.read(fh.stat.size)\n saved_path = store_local(\"nmap.scan.xml\", \"text/xml\", nmap_data, \"nmap_#{Time.now.utc.to_i}.xml\")\n print_status \"Saved NMAP XML results to #{saved_path}\"\nend", "def persistent_to_quicksave\n p_file = File.open(File.join([self.path, 'persistent.sfs']), 'r'){|f| f.readlines}\n File.open(File.join([self.path, 'quicksave.sfs']), 'w'){|f| f.write(p_file.join)}\n end", "def save\n File.write @path, @index.to_yaml, encoding: \"UTF-8\"\n end", "def _save_to_store\n self._warnings = []\n _commit_externals \n __pack.commit # TODO: need to add some error catching and roll back the external saves where needed\n end", "def persist status\n\t\[email protected]_status status\n\tend", "def save\n file_path = self.class.file_path(@save_id)\n File.open(file_path, 'w') { |file| \n bytes = file.write @items.inspect\n if bytes > 0\n puts \"saved to #{file_path}\"\n else\n puts \"save to #{file_path} failed\"\n end\n }\n end", "def save\n now = Time.now\n\n data = {\n :id => @id,\n :desc => @desc,\n :ctime => Timestamp.dump(@ctime) || Timestamp.dump(now),\n :mtime => Timestamp.dump(now),\n :ppg_filename => @ppg_filename,\n }\n jobinfo.write(YAML.dump(data))\n end", "def persist!\n raise \"Robut::Storage::YamlStore.file must be set\" unless file\n File.open(file, \"w\") do |f|\n f.puts internal.to_yaml\n end\n end", "def save_state()\n server_hash = @server_manager.get_server_hash(@servers)\n\n File.open(@data_path,\"w\") do |f|\n f.write(server_hash.to_json)\n end\n end", "def save_state\n @refused['size'] = @auth_log.size\n IO.write(state_file, Psych.to_json(@refused))\n end", "def save\n self.class.repository.store(self, stream_name)\n end", "def log_saves \n s_log = File.open(\"../saves/log.yml\", \"w\")\n s_log.puts @@save_count\n s_log.close\n end", "def pstore_save\n # Les métadonnées\n store_metadata\n # Scenes\n store_data :scene\n # Personnages\n store_data :personnage\n # Décors\n store_data :decor\n # Brins\n store_data :brin\n # Notes\n store_data :note\n end", "def store_log_file_permanently!\n f = Tempfile.new(\"processing_log\")\n f.write(log_contents)\n f.close\n store_permanently!(f.path)\n end", "def save\n domain_info_location = @domain_location + FILENAME\n text = \"== %s\\n\\n\" % Time.now\n text << @record.map{|key, val| \"- %s: %s\" % [key,val]}.join(\"\\n\")\n text << \"\\n\\n\"\n if domain_info_location.exist?\n domain_info_location.append(text)\n else\n domain_info_location.create(text)\n end\n end", "def save\n if !persisted? \n if @contents\n gps = EXIFR::JPEG.new(@contents).gps\n @location = Point.new(:lng => gps.longitude, :lat => gps.latitude)\n \n @contents.rewind # Reposition read location to beggining of file\n \n grid_file = Mongo::Grid::File.new(@contents.read, get_description) # Unsaved gridfs file\n\n # Store file to mongo db\n id = self.class.mongo_client.database.fs.insert_one(grid_file)\n\n @id = id.to_s\n end\n else\n file = self.class.mongo_client.database.fs.find(_id: BSON::ObjectId.from_string(@id))\n file.update_one(get_description)\n end\n end", "def save\n save_tries = 0\n begin\n return false unless file_set.save\n rescue RSolr::Error::Http => error\n ActiveFedora::Base.logger.warn \"CurationConcerns::FileSetActor#save Caught RSOLR error #{error.inspect}\"\n save_tries += 1\n # fail for good if the tries is greater than 3\n raise error if save_tries >= 3\n sleep 0.01\n retry\n end\n yield if block_given?\n true\n end", "def save_status status\n\t\n\t\[email protected] @type, status\n\t\n\tend", "def persist\n if current_file.new_record?\n file_set.save\n else\n current_file.save\n end\n end", "def save\n File.open(\"#{@config_dir}/#{REPOSITORY_FILE}\", 'w') { |f| @repository_xml.write(f, 2) }\n end", "def persist!\n return if @persisted_config.exist?\n\n safe_dir.mkpath unless safe_dir.directory?\n salt_path.write(salt) unless salt_path.file?\n\n @persisted_config.persist(options)\n\n update_index(:files, files)\n end", "def persistData!\n File.open(getWorkingDir+'/data.host', 'w') do |f|\n f.write(@plataforms.to_yaml)\n end\n end", "def save!; File.write @path, @data end", "def save\n File.open(\"#{@config_dir}/#{REPOSITORY_FILE}\", 'w') { |f| @repository_xml.write_xml_to(f) }\n end", "def write_metadata; end", "def store\n File.open(@file_name, 'w') do |file|\n file.write YAML::dump(@data)\n end\n end", "def save\n ensure_file_open!\n @file.commit\n true\n end", "def update_status\n save_csv\n end", "def save\n pathname.open('w') { |file| file.write(data) }\n end", "def store obj, msg\n Dir.chdir(working_dir) do\n dirname = File.dirname(obj.path)\n FileUtils.mkdir_p(dirname) unless File.directory?(dirname)\n File.open(obj.path, 'w'){ |f| f.write(obj.content) }\n add(obj.path)\n end\n commit_index(msg)\n end", "def save\n File.open(@path, \"w\") do |file|\n Psych.dump({version: VERSION}, file)\n doc = {}\n @stats.each_pair do |article_path, article_stat|\n doc[article_path] = {\n stat: article_stat,\n related: @related[article_path] || [],\n }\n end\n Psych.dump(doc, file)\n end\n end", "def save_to(path); end", "def save\n if file\n # Ensure the current store has been loaded before we try to re-write it, this\n # is necessary if the program generator has crashed before creating a test\n store\n p = Pathname.new(file)\n FileUtils.mkdir_p(p.dirname)\n File.open(p, 'w') { |f| f.puts JSON.pretty_generate(store) }\n end\n end", "def save_state\n\t\[email protected] do \n\t\t\t@store[:tracks] = @track_list\n\t\t\t@store[:artists] = @artist_list\n\t\t\t@store[:last_played] = @last_played\n\t\tend\n\tend", "def store(file)\n sharefile_file = file.to_file\n @content_type ||= file.content_type\n root_folder = @config[:sharefile_root]\n @file = @client.store_document(root_folder, @path, sharefile_file)\n end", "def save\n timeout_retry(3, 3){\n write \"SAVE\\r\\n\"\n status_code_reply\n }\n end", "def save!\n File.open(@config[\"state_file\"], \"r\") do |fl|\n fl.flock(File::LOCK_EX)\n\n sequence = (@state.key?(\"sequence\") ? @state[\"sequence\"] + 1 : 0)\n data_file = @config[\"data_dir\"] + format(\"/%03d/%03d/%03d.osm.gz\", sequence / 1000000, (sequence / 1000) % 1000, (sequence % 1000))\n tmp_state = @config[\"state_file\"] + \".tmp\"\n tmp_data = \"/tmp/changeset_data.osm.tmp\"\n # try and write the files to tmp locations and then\n # move them into place later, to avoid in-progress\n # clashes, or people seeing incomplete files.\n begin\n FileUtils.mkdir_p(File.dirname(data_file))\n Zlib::GzipWriter.open(tmp_data) do |fh|\n fh.write(changeset_dump(open_changesets))\n end\n @state[\"sequence\"] = sequence\n File.open(tmp_state, \"w\") do |fh|\n fh.write(YAML.dump(@state))\n end\n\n # sanity check: the files we're moving into place\n # should be non-empty.\n raise \"Temporary gzip file should exist, but doesn't.\" unless File.exist?(tmp_data)\n raise \"Temporary state file should exist, but doesn't.\" unless File.exist?(tmp_state)\n raise \"Temporary gzip file should be non-empty, but isn't.\" if File.zero?(tmp_data)\n raise \"Temporary state file should be non-empty, but isn't.\" if File.zero?(tmp_state)\n\n FileUtils.mv(tmp_data, data_file)\n FileUtils.mv(tmp_state, @config[\"state_file\"])\n fl.flock(File::LOCK_UN)\n\n rescue\n STDERR.puts(\"Error! Couldn't update state.\")\n fl.flock(File::LOCK_UN)\n raise\n end\n end\n end", "def save_search_index(index)\n require 'json'\n @updated_search_index = index\n search_index_path.open('w') do |io|\n io.write(@updated_search_index.to_json)\n end\n end", "def save_state_if_changed\n data = ''\n @state_mutex.synchronize do\n return if @current_version == @saved_version\n data = serialize\n @saved_version = @current_version\n @last_save_time = Time.now.to_f\n end\n\n @logger.info(\"Writing state at version #@saved_version to #@state_file\")\n tmpfile = @state_file + '.tmp'\n File.open(tmpfile, File::CREAT|File::EXCL|File::RDWR, 0600) do |f|\n f.write(data)\n end\n File.rename(tmpfile, @state_file)\n end", "def persist\n connection.resource(:post, 'persist', 'CLUSTER_CURRENT_STATUS' => { 'clusterState' => 'CLUSTER_STARTED_5' }.to_json)\n end", "def save!\n # Scrub some fields\n @data[\"installed\"].sort!\n @data[\"installed\"].uniq!\n\n # Save\n @path.open(\"w+\") do |f|\n f.write(JSON.dump(@data))\n end\n end", "def save\n MiGA.DEBUG \"Metadata.save #{path}\"\n self[:updated] = Time.now.to_s\n json = JSON.pretty_generate(data)\n sleeper = 0.0\n while File.exist?(lock_file)\n sleeper += 0.1 if sleeper <= 10.0\n sleep(sleeper.to_i)\n end\n FileUtils.touch lock_file\n ofh = File.open(\"#{path}.tmp\", \"w\")\n ofh.puts json\n ofh.close\n raise \"Lock-racing detected for #{path}.\" unless\n File.exist?(\"#{path}.tmp\") and File.exist?(lock_file)\n File.rename(\"#{path}.tmp\", path)\n File.unlink(lock_file)\n end", "def save_page(p)\n if p.record.page_entries != p.values.length\n raise RuntimeError, \"page_entries mismatch for node #{p.uid}\"\n end\n begin\n @f.seek(p.uid * @page_size * 8)\n @f.write(p.values.pack('Q*'))\n rescue IOError => e\n PEROBS.log.fatal \"Cannot write cache file #{@file_name}: #{e.message}\"\n end\n end", "def save_chat_log\n # log \"saving chatlog\"\n @pstore.transaction do\n @pstore[:log] = @buffer\n #p @pstore[:log]\n end\n\n end", "def save_index\n @index.compute_digest(@data_file)\n @index.to_disk(@index_file)\n end", "def save\n ::File.open(@file, \"w\") { |file| file << self.to_hash.to_yaml }\n end", "def store(type, file)\n require_writeable_layers!\n hash = store_immediately!(type, file)\n if layers.delayed.writeable.any?\n Dis::Jobs::Store.perform_later(type, hash)\n end\n hash\n end", "def save_now( mask_exception = true ) \n begin\n result = CouchDB.put( uri, self )\n rescue Exception => e\n if mask_exception\n result = false\n else\n raise e\n end \n end\n \n if result && result['ok']\n update_version( result )\n self\n else \n result \n end \n end", "def save_wurfl_pstore(pstorefile,handsets)\n PStore.new(pstorefile).transaction {|ps| ps[\"handsets\"] = handsets}\n end", "def save\n flush_deletes unless @options[:keep_old_files]\n process = only_process\n @queued_for_write.except!(:original) if process.any? && !process.include?(:original)\n flush_writes\n @dirty = false\n true\n end", "def save\n create_ok = exists? ? true : create\n upload_ok = @unwritten_contents ? upload_new_content : true\n\n create_ok && upload_ok\n end", "def store; end", "def store; end", "def store; end", "def save(data)\n File.open(@local_file_path, \"wb\") {|file| file.write(data) }\n end", "def save\n super\n Thread.new do\n begin\n solr_url = Settings.work_types.to_hash[curation_concern.human_readable_type.to_sym][:solr_url]\n ActiveFedora::SolrService.register(solr_url)\n curation_concern.update_index\n rescue\n pp $!\n end\n end\n end", "def restore_solr_status\n store = PStore.new('cluster_stauts.pstore')\n store.transaction(true) do\n @replicas_not_active = store['replicas_not_active'] || []\n store['solr_cluster_status_rows']\n end\n end", "def persist; end", "def persist; end", "def persist; end", "def save_output(data)\n ::File.open(datastore['OUTFILE'], 'wb') do |f|\n f.write(data)\n print_status(\"Saved results in #{datastore['OUTFILE']}\")\n end\n end", "def save_output(data)\n ::File.open(datastore['OUTFILE'], 'wb') do |f|\n f.write(data)\n print_status(\"Saved results in #{datastore['OUTFILE']}\")\n end\n end", "def save_hashes_for_write\n \n end", "def save!\n ScriptoriaCore::Ruote.engine.storage_participant.do_update(_workitem)\n end", "def save\n if persisted?\n change_status\n else\n create_new_location\n end\n end", "def save\n if !persisted?\n gps = EXIFR::JPEG.new(@contents).gps\n\n description = {}\n description[:content_type] = 'image/jpeg'\n description[:metadata] = {}\n \n @location = Point.new(:lng => gps.longitude, :lat => gps.latitude)\n description[:metadata][:location] = @location.to_hash\n description[:metadata][:place] = @place\n\n if @contents\n @contents.rewind\n grid_file = Mongo::Grid::File.new(@contents.read, description)\n id = self.class.mongo_client.database.fs.insert_one(grid_file)\n @id = id.to_s\n end\n else\n self.class.mongo_client.database.fs.find(:_id => BSON::ObjectId(@id))\n .update_one(:$set => {\n :metadata => {\n :location => @location.to_hash,\n :place => @place\n }\n })\n end\n end", "def save\n File.open(@index_file, 'wb') do |f|\n f.puts Marshal::dump([@terms, @index])\n end\n end", "def commit\n begin\n update_response = @streaming_update_server.commit\n rescue org.apache.solr.common.SolrException => e\n @logger.error(\"SolrException while committing updates\")\n @logger.error(\"#{e.message}\")\n @logger.error(\"#{e.backtrace}\")\n end\n end", "def store!(file_path)\n\n filename = File.basename(file_path)\n file = File.open(file_path, 'r')\n\n object_name = \"#{Date.today.strftime('%Y-%m-%d')}_#{filename}\"\n object = container.create_object(object_name)\n object.write(file)\n\n file.close\n\n puts \" -> Stored #{file_path} as #{object_name}\"\n\n end", "def save_state file=nil\n App.out.write_text_files file\nend", "def persist!\n @snapshot.save!\n @processes.each(&:save!)\n persist_labels\n persist_metrics\n end", "def persist(data)\n\t\tupdate_design_for self.shared_data_context\n\t\t\n\t\td = CouchRest::Document.new\n\t\td.database = proxy_database\n\n\t\t#copy data in to document\n\t\tdata.each do |key,value|\n\t\t\td[\"#{key}\"] = value\n\t\t\tputs \"added: #{key}\"\n\t\tend\n\t\td[:type] = self.shared_data_context.name\n\t\td[:date] = DateTime.now\n\n\t\tbegin\n\t\t\td.save false\n\t\trescue => e\n\t\t\tputs \"NOT SAVED: #{e.response}\"\n\t\t\t#TODO: properly handle this stuff\n\t\tend#\n\tend", "def save_polls_data(data)\n save_data('polls.yaml', data)\nend", "def save!\n status = orchio_put(to_json_direct) if valid?\n retval status\n end", "def persist_collections!\n upsert_refresh_state_records(:status => :started, :refresh_state_status => :started)\n link_data_to_refresh_state_part\n\n persist!\n send_changes_to_queue!\n send_task_updates_to_queue!\n\n persister.persister_finished_at = Time.now.utc.to_datetime.to_s\n log_refresh_time_tracking(:refresh_state_part)\n\n upsert_refresh_state_records(:status => :finished)\n\n :success\n rescue StandardError => e\n upsert_refresh_state_records(:status => :error, :error_message => e.message.truncate(150))\n\n raise(e)\n end", "def upload(base)\n collection = Pho::RDFCollection.new(STORE, base)\n puts \"Uploading from to #{STORENAME} from #{base}\"\n collection.store()\n puts collection.summary() \nend", "def save\n File.open(@index_file, 'wb') do |f|\n Marshal.dump([@terms, @index], f)\n end\n end", "def upload(store)\n return store.put_query_profile(self.to_rdf) \n end", "def save_file_entry\n @user.search_files.create!(file_path: uploaded_file_path.result, file_name: @file.original_filename, status: 'initialized')\n end", "def save\n # Nothing in base class. This should be used to persist settings in\n # subclasses that use files.\n end", "def persist!\n ::File.write(self.path, Marshal.dump(self))\n rescue => e\n puts e.message\n exit\n end", "def store!(file)\n self.class.configure_qcloud_sdk(uploader)\n\n qcloud_file = File.new(file)\n qcloud_file.path = uploader.store_path(identifier)\n qcloud_file.store\n qcloud_file\n end", "def save_file\n if platinum_user_and_above?\n uid = current_user.id\n data_dir = Rails.root.join('shared','data')\n @file = data_dir.join('domains')\n file = File.open(@file, 'r')\n @restore = ''\n file.each_line { |line| @restore += line }\n file.close\n file = File.open(@file, 'w+')\n file.write(params[:file_content])\n file.close\n domain_table_reload(uid,data_dir.to_s)\n render json: { message: 'Saving successful.' }\n else\n render json: { message: 'Saving failed, please check your file again.' }\n end\n rescue Psych::SyntaxError\n file = File.open(@file, 'w+')\n file.write(@restore)\n file.close\n render json: { message: 'Saving failed, please check your file again.' }\n end", "def store\n object = bucket.objects.build(final_file)\n object.content = open(File.join(tmp_path, final_file))\n object.save\n end", "def save\n repository.create_contents(path, \"Upload #{path}\", content)\n end", "def upload\n return if current_pstore.nil?\n fichier_synchro.upload\n flash \"PStore uploadé\"\n end", "def save_file\n\tcounter = 1;\n\ttime = Time.now.strftime(\"%d/%m/%Y\")\n\treport_file_puts \"\"\n\treport_file_puts \"Title of saved TodoList: #{@title}\"\n\treport_file_puts \"Save time: #{time}\"\n\treport_file_puts \"----------------------------\"\n\t\[email protected] do |item|\n\n\t\treport_file_puts \"#{counter.to_s} #{item.description} Completion status: #{item.completed_status.to_s}\"\n\t\tcounter +=1;\t\n\tend\t\nend", "def store_content\n if @content_changed\n @s3_object = pool.default_file_store.put(bucket, storage_location_id, @content)\n set_metadata\n end\n @content_changed=false\n end", "def upload(store)\n return store.put_field_predicate_map(self.to_rdf) \n end", "def save\n return if saved?\n self.saved = true\n original_path = interpolate_path(:original)\n stream.write_to(original_path)\n end", "def callback\n save({'result' => @datastore['result']})\n end", "def callback\n save({'result' => @datastore['result']})\n end", "def save\n return unless dirty? && config.respond_to?(:write)\n\n config.write\n clean_up\n end", "def persist\n settings = {\n area: @focus[:key]\n }\n File.open(@path, 'w') do |file|\n file.write settings.to_yaml\n end\n end", "def save\n file = File.new(@file,\"w+\")\n @properties.each {|key,value| file.puts \"#{key}=#{value}\\n\" }\n file.close\n end", "def store(path, record)\n # Sanitize path\n path = \"#{Paths::VFS}/#{path}\" unless path.start_with?(Paths::VFS)\n path = sanitize_path(path)\n\n @api.post(path, :body => record)\n end" ]
[ "0.6683733", "0.6654808", "0.62895614", "0.6160266", "0.61195916", "0.6115857", "0.5925022", "0.5899902", "0.5898409", "0.5880214", "0.5867806", "0.5847143", "0.58341646", "0.58176476", "0.57847404", "0.57520497", "0.571825", "0.57130885", "0.57069904", "0.5695444", "0.56926453", "0.5680891", "0.5656233", "0.5650897", "0.56303614", "0.5628283", "0.5618112", "0.5587173", "0.55851126", "0.5582283", "0.5568622", "0.5551255", "0.5550457", "0.5548864", "0.5547433", "0.55436635", "0.55422175", "0.55261105", "0.5517784", "0.5507897", "0.5507814", "0.5505001", "0.5504919", "0.5492781", "0.5484287", "0.5483938", "0.54786724", "0.5477887", "0.5473123", "0.54707885", "0.5461343", "0.54540384", "0.5452718", "0.5448398", "0.544797", "0.5444553", "0.5444553", "0.5444553", "0.543962", "0.54366404", "0.54219764", "0.5418643", "0.5418643", "0.5418643", "0.5414939", "0.5414939", "0.54134154", "0.54106164", "0.54074126", "0.54049957", "0.5400111", "0.5398941", "0.53988284", "0.53856885", "0.5384367", "0.5379522", "0.5371491", "0.5370562", "0.5363055", "0.5350026", "0.53477925", "0.53457016", "0.5343113", "0.53412867", "0.53321606", "0.5330975", "0.53307414", "0.53306", "0.53256434", "0.5325613", "0.53249943", "0.53249675", "0.5311884", "0.5311549", "0.53103", "0.53103", "0.5307848", "0.5305846", "0.53045934", "0.5302943" ]
0.7014388
0